|
@@ -849,19 +849,32 @@ class CourseManager {
|
|
|
* Return user info array of all users registered in the specified real or virtual course
|
|
|
* This only returns the users that are registered in this actual course, not linked courses.
|
|
|
*
|
|
|
- * @param string $course_code
|
|
|
- * @return array with user info
|
|
|
+ * @param string $course_code the code of the course
|
|
|
+ * @param boolean $with_session determines if the course is used in a session or not
|
|
|
+ * @param integer $session_id the id of the session
|
|
|
+ * @param string $limit the LIMIT statement of the sql statement
|
|
|
+ * @param string $order_by the field to order the users by. Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement that starts with ORDER BY ...
|
|
|
+ * @return array
|
|
|
*/
|
|
|
public static function get_user_list_from_course_code($course_code, $with_session = true, $session_id = 0, $limit = '', $order_by = '') {
|
|
|
|
|
|
- $session_id = intval($session_id);
|
|
|
- $course_code = Database::escape_string($course_code);
|
|
|
+ // variable initialisation
|
|
|
+ $session_id = intval($session_id);
|
|
|
+ $users = array();
|
|
|
+ $course_code = Database::escape_string($course_code);
|
|
|
+ $where = array();
|
|
|
+ // if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
|
|
|
+ if (!strstr($order_by,'ORDER BY')){
|
|
|
+ if (!empty($order_by) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))){
|
|
|
+ $order_by = 'ORDER BY user.'.$order_by;
|
|
|
+ } else {
|
|
|
+ $order_by = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- $users = array();
|
|
|
- $where = array();
|
|
|
$sql = $session_id == 0
|
|
|
- ? 'SELECT DISTINCT course_rel_user.status, user.user_id, course_rel_user.role, course_rel_user.tutor_id '
|
|
|
- : 'SELECT DISTINCT user.user_id, user.status ';
|
|
|
+ ? 'SELECT DISTINCT course_rel_user.status, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* '
|
|
|
+ : 'SELECT DISTINCT user.user_id, user.status, user.* ';
|
|
|
|
|
|
$sql .= ' FROM '.Database::get_main_table(TABLE_MAIN_USER).' as user ';
|
|
|
|
|
@@ -889,7 +902,8 @@ class CourseManager {
|
|
|
$rs = Database::query($sql, __FILE__, __LINE__);
|
|
|
|
|
|
while ($user = Database::fetch_array($rs)) {
|
|
|
- $user_info = Database::get_user_info_from_id($user['user_id']);
|
|
|
+ //$user_info = Database::get_user_info_from_id($user['user_id']);
|
|
|
+ $user_info = $user;
|
|
|
$user_info['status'] = $user['status'];
|
|
|
if (isset($user['role'])) {
|
|
|
$user_info['role'] = $user['role'];
|