From c657323dd14f85333d67644755c82805319771a8 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Wed, 16 Jul 2008 00:13:13 +0200 Subject: [PATCH] [svn r15793] No more column coach in userInfo.php we can now edit the teacher option (see FS#2701 ) --- main/user/user.php | 66 +++++++++++++++++++--------- main/user/userInfo.php | 91 ++++++++++++++++++++++++++------------- main/user/userInfoLib.php | 15 ++++--- 3 files changed, 115 insertions(+), 57 deletions(-) diff --git a/main/user/user.php b/main/user/user.php index ab48d8f0db..c20ff0decf 100644 --- a/main/user/user.php +++ b/main/user/user.php @@ -39,6 +39,7 @@ * @todo convert normal table display to display function (refactor virtual course display function) * @todo display table functions need support for align and valign (e.g. to center text in cells) (this is now possible) * @author Roan Embrechts, refactoring + virtual courses support +* @author Julio Montoya Armas Several fixes * @package dokeos.user ============================================================================== */ @@ -381,7 +382,7 @@ $is_allowed_to_track = ($is_courseAdmin || $is_courseTutor) && $_configuration[' */ Display::display_introduction_section(TOOL_USER, $is_allowed); - if( api_is_allowed_to_edit()) +if( api_is_allowed_to_edit()) { echo "
"; echo ''.Display::return_icon('excel.gif', get_lang('ExportAsCSV')).' '.get_lang('ExportAsCSV').' | '; @@ -394,6 +395,18 @@ Display::display_introduction_section(TOOL_USER, $is_allowed); } echo "
"; } +/* +if (1) // platform setting api_get_setting('subscribe_user_by_coach') +{ + if (!api_is_allowed_to_edit() && $is_courseTutor) + { + echo "
"; + echo ''.Display::return_icon('add_user_big.gif',get_lang("SubscribeUserToCourse")).' '.get_lang("SubscribeUserToCourse").''; + echo "
"; + } +}*/ + + /* -------------------------------------- DISPLAY USERS LIST @@ -432,23 +445,25 @@ function get_number_of_users() $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true); } - foreach($a_course_users as $user_id=>$o_course_user){ - - if( (isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'],$o_course_user['lastname'],$o_course_user['username'],$o_course_user['official_code'],$_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])){ + foreach($a_course_users as $user_id=>$o_course_user) + { + if( (isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'],$o_course_user['lastname'],$o_course_user['username'],$o_course_user['official_code'],$_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])) + { $counter++; } } - return $counter; } -function search_keyword($firstname,$lastname,$username,$official_code,$keyword){ - - if(strripos($firstname,$keyword)!==false || strripos($lastname,$keyword)!==false || strripos($username,$keyword)!==false || strripos($official_code,$keyword)!==false){ +function search_keyword($firstname,$lastname,$username,$official_code,$keyword) +{ + if(strripos($firstname,$keyword)!==false || strripos($lastname,$keyword)!==false || strripos($username,$keyword)!==false || strripos($official_code,$keyword)!==false) + { return true; } - else{ + else + { return false; } @@ -468,22 +483,22 @@ function get_user_data($from, $number_of_items, $column, $direction) // order by switch($column) { - case 1 : $order_by = 'ORDER BY user.firstname';break; - case 2: $order_by = 'ORDER BY user.lastname';break; - case 5: $order_by = 'ORDER BY user.official_code';break; - default : $order_by = 'ORDER BY user.lastname';break; + case 1 : $order_by = 'ORDER BY user.firstname';break; + case 2 : $order_by = 'ORDER BY user.lastname';break; + case 5 : $order_by = 'ORDER BY user.official_code';break; + default: $order_by = 'ORDER BY user.lastname';break; } $order_by .= ' '.$direction; - if(!empty($_SESSION["id_session"])){ - + if(!empty($_SESSION["id_session"])) + { $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, $_SESSION['id_session'], $limit, $order_by); } else { $a_course_users = CourseManager :: get_user_list_from_course_code($_SESSION['_course']['id'], true, 0, $limit, $order_by); } - + foreach($a_course_users as $user_id=>$o_course_user) { if( (isset ($_GET['keyword']) && search_keyword($o_course_user['firstname'],$o_course_user['lastname'],$o_course_user['username'],$o_course_user['official_code'],$_GET['keyword'])) || !isset($_GET['keyword']) || empty($_GET['keyword'])){ @@ -503,19 +518,27 @@ function get_user_data($from, $number_of_items, $column, $direction) $temp[] = $o_course_user['official_code']; - + /* // deprecated feature if(isset($o_course_user['tutor_id']) && $o_course_user['tutor_id']==1) + { $temp[] = get_lang('Tutor'); + } else + { $temp[] = '-'; + } + */ if(isset($o_course_user['status']) && $o_course_user['status']==1) + { $temp[] = get_lang('CourseManager'); + } else + { $temp[] = '-'; + } $temp[] = $o_course_user['active']; - $temp[] = $user_id; - + $temp[] = $user_id; } else { @@ -629,10 +652,11 @@ $table->set_header($header_nr++, get_lang('OfficialCode')); if( api_is_allowed_to_edit()) { - $table->set_header($header_nr++, get_lang('Tutor'),false); + // deprecated feature + // $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(8,'active_filter'); + $table->set_column_filter(7,'active_filter'); } //actions column diff --git a/main/user/userInfo.php b/main/user/userInfo.php index eb1c3d6dd7..b1faf708dc 100644 --- a/main/user/userInfo.php +++ b/main/user/userInfo.php @@ -1,4 +1,4 @@ - '; - + //"", get_lang('Tutor'), "\n", echo "
\n", "\n", "", "\n", "\n", - "\n", - "\n", + "\n", "\n", "\n", "", "\n", - "", - ""; + ""; + //deprecated feature + //""; if (!($is_courseAdmin && $_user['user_id'] == $userIdViewed)) { @@ -374,9 +403,9 @@ elseif ($displayMode == "viewContentList") // default display //not supported yet: editing users of virtual courses $allowedToEditDef = false; } - + $mainUserInfo = get_main_user_info($userIdViewed, $courseCode); - + if ($mainUserInfo) { @@ -385,15 +414,15 @@ elseif ($displayMode == "viewContentList") // default display //DISPLAY TABLE HEADING if ($origin == 'learnpath') { $allowedToEditDef=false; $is_allowedToTrack=false; } + //"\n", echo "
", get_lang('Name'), "", get_lang('Role'), "", get_lang('Tutor'), "", get_lang('Role'), "", get_lang('CourseManager'), "
", htmlize($mainUserInfo['firstName']), " ", htmlize($mainUserInfo['lastName']), "",get_lang('Tutor'),"
", "\n", "\n", - "\n", - "\n", + "\n", "\n", ($allowedToEditDef?"\n":""), - ($is_allowedToTrack?"\n":""), + ($is_allowedToTrack?"\n":""), "\n", "\n", @@ -402,6 +431,7 @@ elseif ($displayMode == "viewContentList") // default display ""; //DISPLAY TABLE CONTENT + /* deprecated feature if ($mainUserInfo['tutor_id'] == 1) { echo "\n"; @@ -410,6 +440,7 @@ elseif ($displayMode == "viewContentList") // default display { echo "\n"; } + */ if ($mainUserInfo['status'] == 1) { @@ -430,7 +461,7 @@ elseif ($displayMode == "viewContentList") // default display } if ($is_allowedToTrack) { - echo "
",get_lang('Name'),"",get_lang('Description'),"",get_lang('Tutor'),"",get_lang('Role'),"",get_lang('CourseManager'),"".get_lang('Edit')."".get_lang('Tracking')."".get_lang('Tracking')."
",htmlize($mainUserInfo['role']),"",get_lang('Tutor')," - ", + echo "", "", "\"".get_lang('Tracking')."", "", diff --git a/main/user/userInfoLib.php b/main/user/userInfoLib.php index cf679fe4c3..6ca605bce2 100644 --- a/main/user/userInfoLib.php +++ b/main/user/userInfoLib.php @@ -260,14 +260,17 @@ function update_user_course_properties($user_id, $course_code, $properties) $course_code = Database::escape_string($course_code); if ($user_id != $_user['user_id']) { - $sqlChangeStatus = "status = '".$properties['status']."',"; + $sqlChangeStatus = "status = '".Database::escape_string($properties['status'])."',"; } - $result = api_sql_query("UPDATE $tbl_coursUser - SET role = '".$properties['role']."', - ".$sqlChangeStatus." - tutor_id = '".$properties['tutor']."' + + //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."'",__FILE__,__LINE__); + AND course_code = '".$course_code."'"; + + $result = api_sql_query($sql,__FILE__,__LINE__); if (mysql_affected_rows() > 0) {