From 07ed204af70cd02e7565e83b67f200470df2926e Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Mon, 21 Jul 2008 20:57:25 +0200 Subject: [PATCH] [svn r15833] In User's tool is possible to change the status of a user into coach. (see FS#2701) --- main/inc/lib/course.lib.php | 32 +++++++++++++++++-------- main/user/user.php | 8 +++---- main/user/userInfo.php | 48 ++++++++++++++++++------------------- main/user/userInfoLib.php | 11 +++++---- 4 files changed, 56 insertions(+), 43 deletions(-) diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index 1433888a66..9dc068d93c 100644 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -1085,14 +1085,23 @@ class CourseManager { $session_id = intval($session_id); $a_users = array(); - $table_users = Database :: get_main_table(TABLE_MAIN_USER); - + $table_users = Database :: get_main_table(TABLE_MAIN_USER); $where = array(); - $sql = 'SELECT DISTINCT user.user_id '; - if ( $session_id == 0 ) { + if ( $session_id == 0 ) + { + $sql = 'SELECT DISTINCT course_rel_user.status, user.user_id '; + } + else + { + $sql = 'SELECT DISTINCT user.user_id '; + } + + if ( $session_id == 0 ) + { $sql .= ', course_rel_user.role, course_rel_user.tutor_id '; - } + } + $sql .= ' FROM '.$table_users.' as user '; if(api_get_setting('use_session_mode')=='true' && $with_session) @@ -1121,17 +1130,20 @@ class CourseManager $sql .= ' '.$order_by; $sql .= ' '.$limit; - + $rs = api_sql_query($sql, __FILE__, __LINE__); while($user = Database::fetch_array($rs)) { - $user_infos = Database :: get_user_info_from_id($user['user_id']); - //$user_infos['status'] = $user['status']; - if ( isset($user['role']) ) { + $user_infos = Database :: get_user_info_from_id($user['user_id']); + $user_infos['status'] = $user['status']; + //$user['status']=$user_infos['status'] ; + if ( isset($user['role']) ) + { $user_infos['role'] = $user['role']; } - if ( isset($user['tutor_id']) ) { + if ( isset($user['tutor_id']) ) + { $user_infos['tutor_id'] = $user['tutor_id']; } $a_users[$user['user_id']] = $user_infos; diff --git a/main/user/user.php b/main/user/user.php index c20ff0decf..d47b4b315c 100644 --- a/main/user/user.php +++ b/main/user/user.php @@ -518,7 +518,7 @@ function get_user_data($from, $number_of_items, $column, $direction) $temp[] = $o_course_user['official_code']; - /* // deprecated feature + // deprecated feature if(isset($o_course_user['tutor_id']) && $o_course_user['tutor_id']==1) { $temp[] = get_lang('Tutor'); @@ -527,7 +527,7 @@ function get_user_data($from, $number_of_items, $column, $direction) { $temp[] = '-'; } - */ + if(isset($o_course_user['status']) && $o_course_user['status']==1) { $temp[] = get_lang('CourseManager'); @@ -653,10 +653,10 @@ $table->set_header($header_nr++, get_lang('OfficialCode')); if( api_is_allowed_to_edit()) { // deprecated feature - // $table->set_header($header_nr++, get_lang('Tutor'),false); + $table->set_header($header_nr++, get_lang('Tutor'),false); $table->set_header($header_nr++, get_lang('CourseManager'),false); $table->set_header($header_nr++, get_lang('Active'),false); - $table->set_column_filter(7,'active_filter'); + $table->set_column_filter(8,'active_filter'); } //actions column diff --git a/main/user/userInfo.php b/main/user/userInfo.php index b1faf708dc..4a2cedb2c8 100644 --- a/main/user/userInfo.php +++ b/main/user/userInfo.php @@ -1,9 +1,9 @@ - "user.php", "name" => get_lang('Users')); +$interbreadcrumb[] = array ('url' => 'user.php', 'name' => get_lang('Users')); if ($origin != 'learnpath') { //so we are not in learnpath tool @@ -102,7 +102,6 @@ $courseCode = $currentCourseID = $_course['sysCode']; $tbl_coursUser = Database :: get_main_table(TABLE_MAIN_COURSE_USER); $userIdViewer = $_user['user_id']; // id fo the user currently online - //$userIdViewed = $_GET['userIdViewed']; // Id of the user we want to view $allowedToEditContent = ($userIdViewer == $userIdViewed) || $is_platformAdmin; @@ -190,7 +189,7 @@ if ($allowedToEditDef) $userProperties['status'] = 1; } - /* deprecated feature + // deprecated feature // is coach if (isset ($_POST['promoteTutor'])) @@ -202,14 +201,14 @@ if ($allowedToEditDef) $userProperties['tutor'] = 1; } } - */ + // role is a string if (isset ($_POST['role'])) { $role=$_POST['role']; $userProperties['role'] = $role; - } - + } + update_user_course_properties($userIdViewed, $courseCode, $userProperties); $displayMode = "viewContentList"; @@ -238,8 +237,7 @@ if ($allowedToEditContent) } elseif (!empty($_GET['editContent'])) { - $displayMode = "viewContentEdit"; - + $displayMode = "viewContentEdit"; $userIdViewed = $userIdViewed; } } @@ -355,14 +353,14 @@ elseif ($displayMode == "viewMainInfoEdit") "", "\n", "\n", - "\n", + "\n", + "\n", "\n", "\n", "", "\n", - ""; - //deprecated feature - //""; + "", + ""; if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) { @@ -388,7 +386,8 @@ elseif ($displayMode == "viewMainInfoEdit") } } - else{ + else + { Display :: display_normal_message(get_lang('ThisStudentIsSubscribeThroughASession')); } } @@ -407,19 +406,20 @@ elseif ($displayMode == "viewContentList") // default display $mainUserInfo = get_main_user_info($userIdViewed, $courseCode); if ($mainUserInfo) - { - + { $image_array=UserManager::get_user_picture_path_by_id($userIdViewed,'web',false,true); echo ''; //DISPLAY TABLE HEADING if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; } - //"\n", + + //"\n", echo "
", get_lang('Name'), "", get_lang('Role'), "", get_lang('Description'), "", get_lang('Tutor'), "", get_lang('CourseManager'), "
", htmlize($mainUserInfo['firstName']), " ", htmlize($mainUserInfo['lastName']), "",get_lang('Tutor'),"",get_lang('Tutor'),"
", "\n", "\n", - "\n", + "\n", + "\n", "\n", ($allowedToEditDef?"\n":""), ($is_allowedToTrack?"\n":""), @@ -430,8 +430,9 @@ elseif ($displayMode == "viewContentList") // default display "\n", ""; - //DISPLAY TABLE CONTENT - /* deprecated feature + //DISPLAY TABLE CONTENT + + // deprecated feature if ($mainUserInfo['tutor_id'] == 1) { echo "\n"; @@ -439,8 +440,7 @@ elseif ($displayMode == "viewContentList") // default display else { echo "\n"; - } - */ + } if ($mainUserInfo['status'] == 1) { diff --git a/main/user/userInfoLib.php b/main/user/userInfoLib.php index 6ca605bce2..adffcdcfdf 100644 --- a/main/user/userInfoLib.php +++ b/main/user/userInfoLib.php @@ -264,11 +264,12 @@ function update_user_course_properties($user_id, $course_code, $properties) } //feature deprecated tutor_id = '".Database::escape_string($properties['tutor'])."' - $sql = "UPDATE $tbl_coursUser - SET ".$sqlChangeStatus." - role = '".Database::escape_string($properties['role'])."' - WHERE user_id = '".$user_id."' - AND course_code = '".$course_code."'"; + $sql = "UPDATE $tbl_coursUser + SET ".$sqlChangeStatus." + role = '".Database::escape_string($properties['role'])."', + tutor_id = '".Database::escape_string($properties['tutor'])."' + WHERE user_id = '".$user_id."' + AND course_code = '".$course_code."'"; $result = api_sql_query($sql,__FILE__,__LINE__);
",get_lang('Name'),"",get_lang('Role'),"",get_lang('Description'),"",get_lang('Tutor'),"",get_lang('CourseManager'),"".get_lang('Edit')."".get_lang('Tracking')."",htmlize($mainUserInfo['firstName'])," ",htmlize($mainUserInfo['lastName']),"",htmlize($mainUserInfo['role']),"",get_lang('Tutor')," -