source-function-F_select_modules_sql

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
Overview

Classes

Interfaces

Exceptions

Functions

  1: <?php
  2: //============================================================+
  3: // File name   : tce_functions_auth_sql.php
  4: // Begin       : 2006-03-11
  5: // Last Update : 2012-12-19
  6: //
  7: // Description : Functions to select topics.
  8: //
  9: // Author: Nicola Asuni
 10: //
 11: // (c) Copyright:
 12: //               Nicola Asuni
 13: //               Tecnick.com LTD
 14: //               www.tecnick.com
 15: //               info@tecnick.com
 16: //
 17: // License:
 18: //    Copyright (C) 2004-2012  Nicola Asuni - Tecnick.com LTD
 19: //    See LICENSE.TXT file for more information.
 20: //============================================================+
 21: 
 22: /**
 23:  * @file
 24:  * Functions to select topics.
 25:  * @package com.tecnick.tcexam.admin
 26:  * @author Nicola Asuni
 27:  * @since 2006-03-11
 28:  */
 29: 
 30: /**
 31:  * Returns a SQL string to select modules accounting for user authorizations.
 32:  * @author Nicola Asuni
 33:  * @since 2010-06-16
 34:  * @param $andwhere (string) additional WHERE statements (e.g.: "module_enabled='1'")
 35:  * @return string sql statement
 36:  */
 37: function F_select_modules_sql($andwhere = '')
 38: {
 39:     global $l;
 40:     require_once('../config/tce_config.php');
 41:     $sql = 'SELECT * FROM '.K_TABLE_MODULES.'';
 42:     if ($_SESSION['session_user_level'] >= K_AUTH_ADMINISTRATOR) {
 43:         if (!empty($andwhere)) {
 44:             $sql .= ' WHERE '.$andwhere;
 45:         }
 46:     } else {
 47:         $sql .= ' WHERE module_user_id IN ('.F_getAuthorizedUsers($_SESSION['session_user_id']).')';
 48:         if (!empty($andwhere)) {
 49:             $sql .= ' AND '.$andwhere;
 50:         }
 51:     }
 52:     $sql .= ' ORDER BY module_name';
 53:     return $sql;
 54: }
 55: 
 56: /**
 57:  * Returns a SQL string to select subjects accounting for user authorizations.
 58:  * @author Nicola Asuni
 59:  * @since 2006-03-12
 60:  * @param $andwhere (string) additional WHERE statements (e.g.: "subject_enabled='1'")
 61:  * @return string sql statement
 62:  */
 63: function F_select_subjects_sql($andwhere = '')
 64: {
 65:     return F_select_module_subjects_sql($andwhere);
 66: }
 67: 
 68: /**
 69:  * Returns a SQL string to select modules and subjects accounting for user authorizations.
 70:  * @author Nicola Asuni
 71:  * @since 2008-11-28
 72:  * @param $andwhere (string) additional WHERE statements (e.g.: "subject_enabled='1'")
 73:  * @return string sql statement
 74:  */
 75: function F_select_module_subjects_sql($andwhere = '')
 76: {
 77:     global $l;
 78:     require_once('../config/tce_config.php');
 79:     $sql = 'SELECT * FROM '.K_TABLE_MODULES.','.K_TABLE_SUBJECTS.'';
 80:     $sql .= ' WHERE module_id=subject_module_id';
 81:     if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
 82:         $authorized_users = F_getAuthorizedUsers($_SESSION['session_user_id']);
 83:         $sql .= ' AND (module_user_id IN ('.$authorized_users.') OR subject_user_id IN ('.$authorized_users.'))';
 84:     }
 85:     if (!empty($andwhere)) {
 86:         $sql .= ' AND '.$andwhere;
 87:     }
 88:     $sql .= ' ORDER BY module_name,subject_name';
 89:     return $sql;
 90: }
 91: 
 92: /**
 93:  * Returns a SQL string to select tests accounting for user authorizations.
 94:  * @author Nicola Asuni
 95:  * @since 2006-03-12
 96:  * @return string sql statement
 97:  */
 98: function F_select_tests_sql()
 99: {
100:     global $l;
101:     require_once('../config/tce_config.php');
102:     $sql = 'SELECT * FROM '.K_TABLE_TESTS.'';
103:     if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
104:         $sql .= ' WHERE test_user_id IN ('.F_getAuthorizedUsers($_SESSION['session_user_id']).')';
105:     }
106:     $sql .= ' ORDER BY test_begin_time DESC, test_name';
107:     return $sql;
108: }
109: 
110: /**
111:  * Returns a SQL string to select executed tests accounting for user authorizations.
112:  * @author Nicola Asuni
113:  * @since 2006-06-26
114:  * @return string sql statement
115:  */
116: function F_select_executed_tests_sql()
117: {
118:     global $l;
119:     require_once('../config/tce_config.php');
120:     $sql = 'SELECT *
121:         FROM '.K_TABLE_TESTS.'
122:         WHERE test_id IN (
123:             SELECT testuser_test_id
124:             FROM '.K_TABLE_TEST_USER.'
125:             WHERE testuser_status>0
126:         )';
127:     if ($_SESSION['session_user_level'] < K_AUTH_ADMINISTRATOR) {
128:         $sql .= ' AND test_user_id IN ('.F_getAuthorizedUsers($_SESSION['session_user_id']).')';
129:     }
130:     $sql .= ' ORDER BY test_begin_time DESC, test_name';
131:     return $sql;
132: }
133: 
134: //============================================================+
135: // END OF FILE
136: //============================================================+
137: 
 

© 2004-2018 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy