diff --git a/main/exercice/Hpdownload.php b/main/exercice/Hpdownload.php index ce62c2d3d1..62452b0766 100644 --- a/main/exercice/Hpdownload.php +++ b/main/exercice/Hpdownload.php @@ -148,7 +148,7 @@ if($content_type == 'text/html') " SaveScoreVariable = 1;\n". " if (C.ie)\n". " {\n". -" document.location.href = \"".$exercicePath."savescores.php?origin=$origin&time=$time&test=".$doc_url."&uid=".$_uid."&cid=".$cid."&score=\"+Score;\n". +" document.location.href = \"".$exercicePath."savescores.php?origin=$origin&time=$time&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n". " //window.alert(Score);\n". " }\n". " else\n". diff --git a/main/exercice/exercice.php b/main/exercice/exercice.php index 3443bd6edf..cd767d2493 100644 --- a/main/exercice/exercice.php +++ b/main/exercice/exercice.php @@ -197,9 +197,9 @@ if($is_allowedToEdit) //$time = time(); //$time = date("Y-m-d H:i:s", $time); - //$query = "INSERT INTO $TBL_ITEM_PROPERTY (tool, ref, insert_user_id, insert_date, lastedit_type) VALUES ('".TOOL_DOCUMENT."', $id, $_uid, '$time', 'DocumentAdded' )"; + //$query = "INSERT INTO $TBL_ITEM_PROPERTY (tool, ref, insert_user_id, insert_date, lastedit_type) VALUES ('".TOOL_DOCUMENT."', $id, $_user['user_id'], '$time', 'DocumentAdded' )"; //api_sql_query($query,__FILE__,__LINE__); - api_item_property_update($_course,TOOL_DOCUMENT,$id,'FolderCreated',$_uid); + api_item_property_update($_course,TOOL_DOCUMENT,$id,'FolderCreated',$_user['user_id']); } if(!is_dir($picturePath)) @@ -218,9 +218,9 @@ if($is_allowedToEdit) //$time = time(); //$time = date("Y-m-d H:i:s", $time); - //$query = "INSERT INTO $TBL_ITEM_PROPERTY (tool, ref, insert_user_id, insert_date, lastedit_type) VALUES ('".TOOL_DOCUMENT."', $id, $_uid, '$time', 'DocumentAdded' )"; + //$query = "INSERT INTO $TBL_ITEM_PROPERTY (tool, ref, insert_user_id, insert_date, lastedit_type) VALUES ('".TOOL_DOCUMENT."', $id, $_user['user_id'], '$time', 'DocumentAdded' )"; //api_sql_query($query,__FILE__,__LINE__); - api_item_property_update($_course,TOOL_DOCUMENT,$id,'FolderCreated',$_uid); + api_item_property_update($_course,TOOL_DOCUMENT,$id,'FolderCreated',$_user['user_id']); } } if($origin != 'learnpath'){ @@ -247,7 +247,7 @@ $sql="SELECT count(id) FROM $TBL_EXERCICES"; $res = api_sql_query($sql,__FILE__,__LINE__); list($nbrexerc) = mysql_fetch_row($res); -HotPotGCt($documentPath,1,$_uid); +HotPotGCt($documentPath,1,$_user['user_id']); // only for administrator @@ -272,7 +272,7 @@ if($is_allowedToEdit) $objExerciseTmp->save(); // "WHAT'S NEW" notification: update table item_property (previously last_tooledit) - api_item_property_update($_course, TOOL_QUIZ, $exerciseId, "QuizAdded", $_uid); + api_item_property_update($_course, TOOL_QUIZ, $exerciseId, "QuizAdded", $_user['user_id']); break; case 'disable': // disables an exercise @@ -317,7 +317,7 @@ if($is_allowedToEdit) $query = "SELECT id FROM $TBL_DOCUMENT WHERE path='$file'"; $res = api_sql_query($query,__FILE__,__LINE__); $row = Database::fetch_array($res, 'ASSOC'); - api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_uid); + api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'visible', $_user['user_id']); //$dialogBox = get_lang('ViMod'); break; @@ -326,7 +326,7 @@ if($is_allowedToEdit) $query = "SELECT id FROM $TBL_DOCUMENT WHERE path='$file'"; $res = api_sql_query($query,__FILE__,__LINE__); $row = Database::fetch_array($res, 'ASSOC'); - api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'invisible', $_uid); + api_item_property_update($_course, TOOL_DOCUMENT, $row['id'], 'invisible', $_user['user_id']); #$query = "UPDATE $TBL_DOCUMENT SET visibility='$newVisibilityStatus' WHERE path=\"".$file."\""; //added by Toon #api_sql_query($query,__FILE__,__LINE__); //$dialogBox = get_lang('ViMod'); @@ -636,7 +636,7 @@ if($show == 'test'){   - > + > @@ -674,7 +674,7 @@ if($show == 'test'){   - "> + "> @@ -849,7 +849,7 @@ $message = "

You attempt for the test #test# has been viewed/commented/correct if($is_allowedToEdit) { //get all results (ourself and the others) as an admin should see them - //AND exe_user_id <> $_uid clause has been removed + //AND exe_user_id <> $_user['user_id'] clause has been removed $sql="SELECT CONCAT(`lastname`,' ',`firstname`),`ce`.`title`, `te`.`exe_result` , `te`.`exe_weighting`, UNIX_TIMESTAMP(`te`.`exe_date`),`te`.`exe_Id`,email FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te, $TBL_USER AS user @@ -867,12 +867,12 @@ $message = "

You attempt for the test #test# has been viewed/commented/correct { // get only this user's results $sql="SELECT '',`ce`.`title`, `te`.`exe_result` , `te`.`exe_weighting`, UNIX_TIMESTAMP(`te`.`exe_date`),`te`.`exe_Id` FROM $TBL_EXERCICES AS ce , `$TBL_TRACK_EXERCICES` AS te - WHERE `te`.`exe_exo_id` = `ce`.`id` AND `te`.`exe_user_id`='$_uid' AND `te`.`exe_cours_id`='$_cid' + WHERE `te`.`exe_exo_id` = `ce`.`id` AND `te`.`exe_user_id`='".$_user['user_id']."' AND `te`.`exe_cours_id`='$_cid' ORDER BY `te`.`exe_cours_id` ASC, `ce`.`title` ASC, `te`.`exe_date`ASC"; $hpsql="SELECT '',exe_name, exe_result , exe_weighting, UNIX_TIMESTAMP(exe_date) FROM `$TBL_TRACK_HOTPOTATOES` - WHERE exe_user_id = '$_uid' AND exe_cours_id = '".$_cid."' + WHERE exe_user_id = '".$_user['user_id']."' AND exe_cours_id = '".$_cid."' ORDER BY exe_cours_id ASC, exe_date ASC"; } diff --git a/main/exercice/exercise.class.php b/main/exercice/exercise.class.php index 066fbf669d..c272762fba 100644 --- a/main/exercice/exercise.class.php +++ b/main/exercice/exercise.class.php @@ -1,4 +1,4 @@ -read($questionId); diff --git a/main/exercice/hotspot_savescore.inc.php b/main/exercice/hotspot_savescore.inc.php index 00586a6e07..4c41b692b8 100644 --- a/main/exercice/hotspot_savescore.inc.php +++ b/main/exercice/hotspot_savescore.inc.php @@ -65,7 +65,7 @@ $TBL_TRACK_E_HOTSPOT = Database::get_statistic_table(STATISTIC_TRACK_E_HOTSPOTS); // Save into db - $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('$_uid', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')"; + $sql = "INSERT INTO $TBL_TRACK_E_HOTSPOT (`user_id` , `course_id` , `quiz_id` , `question_id` , `answer_id` , `correct` , `coordinate` ) VALUES ('".$_user['user_id']."', '$courseCode', '$exerciseId', '$questionId', '$answerId', '$hit', '$coordinates')"; $result = api_sql_query($sql,__FILE__,__LINE__); // Save insert id into session if users changes answer. diff --git a/main/exercice/savescores.php b/main/exercice/savescores.php index 1966c770d8..719adb2edf 100644 --- a/main/exercice/savescores.php +++ b/main/exercice/savescores.php @@ -38,12 +38,11 @@ include_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php'); $documentPath = api_get_path(SYS_COURSE_PATH).$_course['path']."/document"; $full_file_path = $documentPath.$test; -my_delete($full_file_path.$_uid.".t.html"); +my_delete($full_file_path.$_user['user_id'].".t.html"); $TABLETRACK_HOTPOTATOES = $statsDbName."`.`track_e_hotpotatoes"; $tbl_learnpath_user = Database::get_course_table(LEARNPATH_USER_TABLE); //$_course['dbNameGlu']."learnpath_user"; -$_uid = $uid; $_cid = $cid; $test = mysql_real_escape_string($_REQUEST['test']); $score = mysql_real_escape_string($_REQUEST['score']); @@ -52,7 +51,7 @@ $origin = $_REQUEST['origin']; function save_scores($file, $score) { global $is_trackingEnabled, $origin, $tbl_learnpath_user, - $learnpath_id, $learnpath_item_id, $_uid, $_cid, + $learnpath_id, $learnpath_item_id, $_user, $_cid, $TABLETRACK_HOTPOTATOES; // if tracking is disabled record nothing $weighting = 100; // 100% @@ -61,9 +60,9 @@ function save_scores($file, $score) if (!$is_trackingEnabled){return 0;} - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { diff --git a/main/exercice/showinframes.php b/main/exercice/showinframes.php index 744413cc00..3d3691c213 100644 --- a/main/exercice/showinframes.php +++ b/main/exercice/showinframes.php @@ -43,7 +43,6 @@ require_once(api_get_path(SYS_PATH).'main/exercice/hotpotatoes.lib.php'); // init $doc_url=urldecode($_GET['file']); $cid = $_course['official_code']; -$_uid = $_SESSION['_uid']; $documentPath= api_get_path(SYS_COURSE_PATH).$_course['path']."/document"; $documentWebPath= api_get_path(WEB_COURSE_PATH).$_course['path']."/document"; $origin = $_REQUEST['origin']; @@ -53,8 +52,8 @@ $time = $_REQUEST['time']; // read content $full_file_path = $documentPath.$doc_url; -my_delete($full_file_path.$_uid.".t.html"); -$content = ReadFileCont($full_file_path.$_uid.".t.html"); +my_delete($full_file_path.$_user['user_id'].".t.html"); +$content = ReadFileCont($full_file_path.$_user['user_id'].".t.html"); if ($content=="") { @@ -69,7 +68,7 @@ if ($content=="") " SaveScoreVariable = 1;\n". " if (C.ie)\n". " {\n". - " document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=$time&test=".$doc_url."&uid=".$_uid."&cid=".$cid."&score=\"+Score;\n". + " document.location.href = \"".api_get_path(WEB_PATH)."main/exercice/"."savescores.php?origin=$origin&learnpath_id=$learnpath_id&learnpath_item_id=$learnpath_item_id&time=$time&test=".$doc_url."&uid=".$_user['user_id']."&cid=".$cid."&score=\"+Score;\n". " //window.alert(Score);\n". " }\n". " else\n". @@ -88,17 +87,17 @@ if ($content=="") $newcontent = str_replace($prehref,$posthref,$newcontent); - if (CheckSubFolder($full_file_path.$_uid.".t.html")==0) + if (CheckSubFolder($full_file_path.$_user['user_id'].".t.html")==0) { $newcontent = ReplaceImgTag($newcontent); } } else { - //my_delete($full_file_path.$_uid.".t.html"); + //my_delete($full_file_path.$_user['user_id'].".t.html"); $newcontent = $content; } -WriteFileCont($full_file_path.$_uid.".t.html",$newcontent); +WriteFileCont($full_file_path.$_user['user_id'].".t.html",$newcontent); /* $prehref="javascript:void(0);"; $posthref=$rootWeb."main/exercice/Hpdownload.php?doc_url=".$doc_url."&cid=".$cid."&uid=".$uid; @@ -110,7 +109,7 @@ WriteFileCont($full_file_path.$_uid.".t.html",$newcontent); */ $doc_url = GetFolderPath($doc_url).urlencode(GetFileName($doc_url)); -// echo $documentWebPath.$doc_url.$_uid.".t.html"; +// echo $documentWebPath.$doc_url.$_user['user_id'].".t.html"; // exit; ?> @@ -123,7 +122,7 @@ if ($origin!='learnpath') { ?> - "> + "> <body> <p>This page uses frames, but your browser doesn't support them. @@ -136,7 +135,7 @@ if ($origin!='learnpath') { } else { ?> <script language='Javascript' type='text/javascript'> - s='<?php echo $documentWebPath.$doc_url.$_uid; ?>.t.html?time=<?php echo $time; ?>'; + s='<?php echo $documentWebPath.$doc_url.$_user['user_id']; ?>.t.html?time=<?php echo $time; ?>'; //document.write(s); window.location=s; </script> diff --git a/main/forum/editpost.php b/main/forum/editpost.php index 7fc1b01b71..fb27efb521 100644 --- a/main/forum/editpost.php +++ b/main/forum/editpost.php @@ -147,7 +147,7 @@ if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $curr { forum_not_allowed_here(); } -if (!$_uid AND $current_forum['allow_anonymous']==0) +if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) { forum_not_allowed_here(); } diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index dd4da1c209..3250fa27c0 100644 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -397,7 +397,7 @@ function store_forumcategory($values) { global $table_categories; global $_course; - global $_uid; + global $_user; // find the max cat_order. The new forum category is added at the end => max cat_order + & $sql="SELECT MAX(cat_order) as sort_max FROM ".mysql_real_escape_string($table_categories); @@ -410,7 +410,7 @@ function store_forumcategory($values) $sql="UPDATE ".$table_categories." SET cat_title='".mysql_real_escape_string($values['forum_category_title'])."', cat_comment='".mysql_real_escape_string($values['forum_category_comment'])."' WHERE cat_id='".mysql_real_escape_string($values['forum_category_id'])."'"; api_sql_query($sql); $last_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM_CATEGORY, $values['forum_category_id'],"ForumCategoryAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM_CATEGORY, $values['forum_category_id'],"ForumCategoryAdded", $_user['user_id']); $return_message=get_lang('ForumCategoryEdited'); } else @@ -418,7 +418,7 @@ function store_forumcategory($values) $sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".mysql_real_escape_string($values['forum_category_title'])."','".mysql_real_escape_string($values['forum_category_comment'])."','".mysql_real_escape_string($new_max)."')"; api_sql_query($sql); $last_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']); $return_message=get_lang('ForumCategoryAdded'); } @@ -438,7 +438,7 @@ function store_forum($values) { global $table_forums; global $_course; - global $_uid; + global $_user; // find the max forum_order for the given category. The new forum is added at the end => max cat_order + & $sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']); @@ -483,7 +483,7 @@ function store_forum($values) '".mysql_real_escape_string($new_max)."')"; api_sql_query($sql, __LINE__,__FILE__); $last_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']); $return_message=get_lang('ForumAdded'); } @@ -1516,7 +1516,7 @@ function store_thread($values) { global $table_threads; global $table_posts; - global $_uid; + global $_user; global $_course; global $current_forum; @@ -1535,20 +1535,20 @@ function store_thread($values) $sql="INSERT INTO $table_threads (thread_title, forum_id, thread_poster_id, thread_poster_name, thread_date, thread_sticky) VALUES ('".mysql_real_escape_string($values['post_title'])."', '".mysql_real_escape_string($values['forum_id'])."', - '".mysql_real_escape_string($_uid)."', + '".mysql_real_escape_string($_user['user_id'])."', '".mysql_real_escape_string($values['poster_name'])."', '".mysql_real_escape_string($post_date)."', '".mysql_real_escape_string($values['thread_sticky'])."')"; $result=api_sql_query($sql, __LINE__, __FILE__); $last_thread_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']); // if the forum properties tell that the posts have to be approved we have to put the whole thread invisible // because otherwise the students will see the thread and not the post in the thread. // we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have // to make the thread visible AND the post if ($visible==0) { - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_uid); + api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_user['user_id']); $visible=1; } @@ -1559,7 +1559,7 @@ function store_thread($values) '".mysql_real_escape_string($values['post_text'])."', '".mysql_real_escape_string($last_thread_id)."', '".mysql_real_escape_string($values['forum_id'])."', - '".mysql_real_escape_string($_uid)."', + '".mysql_real_escape_string($_user['user_id'])."', '".mysql_real_escape_string($values['poster_name'])."', '".mysql_real_escape_string($post_date)."', '".mysql_real_escape_string($values['post_notification'])."','0', @@ -1610,7 +1610,6 @@ function show_add_post_form($action='', $id='', $form_values='') global $forum_setting; global $current_forum; global $_user; - global $_uid; // initiate the object $form = new FormValidator('thread', 'post', $_SERVER['PHP_SELF'].'?forum='.$_GET['forum'].'&thread='.$_GET['thread'].'&post='.$_GET['post'].'&action='.$_GET['action']); @@ -1621,7 +1620,7 @@ function show_add_post_form($action='', $id='', $form_values='') $form->addElement('hidden', 'thread_id', $_GET['thread']); // if anonymous posts are allowed we also display a form to allow the user to put his name or username in - if ($current_forum['allow_anonymous']==1 AND !isset($_uid)) + if ($current_forum['allow_anonymous']==1 AND !isset($_user['user_id'])) { $form->addElement('text', 'poster_name', get_lang('Name')); } @@ -1629,7 +1628,7 @@ function show_add_post_form($action='', $id='', $form_values='') $form->addElement('text', 'post_title', get_lang('Title')); $form->addElement('html_editor', 'post_text', get_lang('Text')); - if ($forum_setting['allow_post_notificiation'] AND isset($_uid)) + if ($forum_setting['allow_post_notificiation'] AND isset($_user['user_id'])) { $form->addElement('checkbox', 'post_notification', '', get_lang('NotifyByEmail').' ('.$_user['mail'].')'); } @@ -1676,7 +1675,7 @@ function show_add_post_form($action='', $id='', $form_values='') // the course admin can make a thread sticky (=appears with special icon and always on top) $form->addRule('post_title', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required'); - if ($current_forum['allow_anonymous']==1 AND !isset($_uid)) + if ($current_forum['allow_anonymous']==1 AND !isset($_user['user_id'])) { $form->addRule('poster_name', '<div class="required">'.get_lang('ThisFieldIsRequired'), 'required'); } @@ -1709,7 +1708,7 @@ function store_reply($values) { global $table_threads; global $table_posts; - global $_uid; + global $_user; global $_course; global $current_forum; @@ -1729,7 +1728,7 @@ function store_reply($values) '".mysql_real_escape_string($values['post_text'])."', '".mysql_real_escape_string($values['thread_id'])."', '".mysql_real_escape_string($values['forum_id'])."', - '".mysql_real_escape_string($_uid)."', + '".mysql_real_escape_string($_user['user_id'])."', '".mysql_real_escape_string($post_date)."', '".mysql_real_escape_string($values['post_notification'])."', '".mysql_real_escape_string($values['post_parent_id'])."', @@ -1745,7 +1744,7 @@ function store_reply($values) update_thread($values['thread_id'], $new_post_id,$post_date); // update the forum - api_item_property_update($_course, TOOL_FORUM, $values['forum_id'],"NewMessageInForum", $_uid); + api_item_property_update($_course, TOOL_FORUM, $values['forum_id'],"NewMessageInForum", $_user['user_id']); $message=get_lang('ReplyAdded').'<br />'; if ($current_forum['approval_direct_post']=='1' AND !api_is_allowed_to_edit()) @@ -1987,7 +1986,7 @@ function forum_not_allowed_here() */ function get_whats_new() { - global $_uid; + global $_user; global $_course; global $table_posts; @@ -2001,7 +2000,7 @@ function get_whats_new() if (!$_SESSION['last_forum_access']) { $tracking_last_tool_access=Database::get_statistic_table(STATISTIC_TRACK_E_LASTACCESS_TABLE); - $sql="SELECT * FROM ".$tracking_last_tool_access." WHERE access_user_id='".mysql_real_escape_string($_uid)."' AND access_cours_code='".mysql_real_escape_string($_course['sysCode'])."' AND access_tool='".mysql_real_escape_string($tool)."'"; + $sql="SELECT * FROM ".$tracking_last_tool_access." WHERE access_user_id='".mysql_real_escape_string($_user['user_id'])."' AND access_cours_code='".mysql_real_escape_string($_course['sysCode'])."' AND access_tool='".mysql_real_escape_string($tool)."'"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result); $_SESSION['last_forum_access']=$row['access_date']; @@ -2316,7 +2315,7 @@ function handle_mail_cue($content, $id) function send_mail($user_info=array(), $thread_information=array()) { global $_course; - global $_uid; + global $_user; $email_subject = get_lang('NewForumPost')." - ".$_course['official_code']; @@ -2336,7 +2335,7 @@ function send_mail($user_info=array(), $thread_information=array()) if(empty($charset)){$charset='ISO-8859-1';} $encoding = 'Content-Type: text/html; charset='. $charset; - if ($user_info['user_id']<>$_uid) + if ($user_info['user_id']<>$_user['user_id']) { $newmail = api_mail($user_info["lastname"].' '.$user_info["firstname"], $user_info["email"], $email_subject, $email_body, $_SESSION['_user']['lastName'].' '.$_SESSION['_user']['firstName'], $_SESSION['_user']['mail'],$encoding); } diff --git a/main/forum/index.php b/main/forum/index.php index df99912eb6..d6b9b87f7a 100644 --- a/main/forum/index.php +++ b/main/forum/index.php @@ -138,7 +138,7 @@ $forum_list=get_forums(); */ // the groups of the user $groups_of_user=array(); -$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_uid); +$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']); // all groups in the course (and sorting them as the id of the group = the key of the array $all_groups=GroupManager::get_group_list(); if(is_array($all_groups)) diff --git a/main/forum/newthread.php b/main/forum/newthread.php index 6a0164c677..934d3237a4 100644 --- a/main/forum/newthread.php +++ b/main/forum/newthread.php @@ -151,7 +151,7 @@ if (!api_is_allowed_to_edit() AND $current_forum['allow_new_threads']<>1) forum_not_allowed_here(); } // 4. anonymous posts are not allowed and the user is not logged in -if (!$_uid AND $current_forum['allow_anonymous']<>1) +if (!$_user['user_id'] AND $current_forum['allow_anonymous']<>1) { forum_not_allowed_here(); } diff --git a/main/forum/reply.php b/main/forum/reply.php index a09dac26ec..fc4aec3ba4 100644 --- a/main/forum/reply.php +++ b/main/forum/reply.php @@ -148,7 +148,7 @@ if (!api_is_allowed_to_edit() AND ($current_forum_category['locked']<>0 OR $curr { forum_not_allowed_here(); } -if (!$_uid AND $current_forum['allow_anonymous']==0) +if (!$_user['user_id'] AND $current_forum['allow_anonymous']==0) { forum_not_allowed_here(); } diff --git a/main/forum/viewforum.php b/main/forum/viewforum.php index 8a69b6c629..a13c76a14e 100644 --- a/main/forum/viewforum.php +++ b/main/forum/viewforum.php @@ -168,7 +168,7 @@ if (isset($message)) // 1. the course admin is here // 2. the course member is here and new threads are allowed // 3. a visitor is here and new threads AND allowed AND anonymous posts are allowed -if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_uid)) OR ($current_forum['allow_new_threads']==1 AND !isset($_uid) AND $current_forum['allow_anonymous']==1)) +if (api_is_allowed_to_edit() OR ($current_forum['allow_new_threads']==1 AND isset($_user['user_id'])) OR ($current_forum['allow_new_threads']==1 AND !isset($_user['user_id']) AND $current_forum['allow_anonymous']==1)) { echo '<a href="newthread.php?forum='.$_GET['forum'].'">'.get_lang('NewTopic').'</a>'; } diff --git a/main/forum/viewforumcategory.php b/main/forum/viewforumcategory.php index d6f1972a82..1e048f9623 100644 --- a/main/forum/viewforumcategory.php +++ b/main/forum/viewforumcategory.php @@ -146,7 +146,7 @@ $forum_list=get_forums(); ------------------------------------------------------------------------------------------------------ */ $groups_of_user=array(); -$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_uid); +$groups_of_user=GroupManager::get_group_ids($_course['dbName'], $_user['user_id']); //my_print_r($groups_of_user); diff --git a/main/forum/viewthread.php b/main/forum/viewthread.php index 4f66cf7f8b..0f096cc5ea 100644 --- a/main/forum/viewthread.php +++ b/main/forum/viewthread.php @@ -179,7 +179,7 @@ if ($message<>'PostDeletedSpecial') // in this case the first and only post of t if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit()) { // The link should only appear when the user is logged in or when anonymous posts are allowed. - if ($_uid OR ($current_forum['allow_anonymous']==1 AND !$_uid)) + if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;action=replythread">'.get_lang('ReplyToThread').'</a>'; } diff --git a/main/forum/viewthread_flat.inc.php b/main/forum/viewthread_flat.inc.php index 8f17b24cf9..12a43c2eef 100644 --- a/main/forum/viewthread_flat.inc.php +++ b/main/forum/viewthread_flat.inc.php @@ -88,7 +88,7 @@ foreach ($rows as $row) echo $row['post_date'].'<br /><br />'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always - if (($current_forum['allow_edit']==1 AND $row['user_id']==$_uid) or api_is_allowed_to_edit()) + if (($current_forum['allow_edit']==1 AND $row['user_id']==$_user['user_id']) or api_is_allowed_to_edit()) { echo "<a href=\"editpost.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;post=".$row['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n"; } @@ -103,7 +103,7 @@ foreach ($rows as $row) //if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit()) { - if ($_uid OR ($current_forum['allow_anonymous']==1 AND !$_uid)) + if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=replymessage">'.get_lang('ReplyToMessage').'</a><br />'; echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$row['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />'; @@ -134,7 +134,7 @@ foreach ($rows as $row) { $post_image=icon('../img/forumpost.gif'); } - if ($row['post_notification']=='1' AND $row['poster_id']==$_uid) + if ($row['post_notification']=='1' AND $row['poster_id']==$_user['user_id']) { $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } diff --git a/main/forum/viewthread_nested.inc.php b/main/forum/viewthread_nested.inc.php index 5dadc54a6f..ec3885993f 100644 --- a/main/forum/viewthread_nested.inc.php +++ b/main/forum/viewthread_nested.inc.php @@ -93,7 +93,7 @@ foreach ($rows as $post) echo $post['post_date'].'<br /><br />'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always - if (($current_forum['allow_edit']==1 AND $post['user_id']==$_uid) or api_is_allowed_to_edit()) + if (($current_forum['allow_edit']==1 AND $post['user_id']==$_user['user_id']) or api_is_allowed_to_edit()) { echo "<a href=\"editpost.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;post=".$post['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n"; } @@ -108,7 +108,7 @@ foreach ($rows as $post) //if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit()) { - if ($_uid OR ($current_forum['allow_anonymous']==1 AND !$_uid)) + if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$post['post_id'].'&amp;action=replymessage">'.get_lang('ReplyToMessage').'</a><br />'; echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$post['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />'; @@ -139,7 +139,7 @@ foreach ($rows as $post) { $post_image=icon('../img/forumpost.gif'); } - if ($post['post_notification']=='1' AND $post['poster_id']==$_uid) + if ($post['post_notification']=='1' AND $post['poster_id']==$_user['user_id']) { $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } diff --git a/main/forum/viewthread_threaded.inc.php b/main/forum/viewthread_threaded.inc.php index f93be7550c..2b91f6cb3f 100644 --- a/main/forum/viewthread_threaded.inc.php +++ b/main/forum/viewthread_threaded.inc.php @@ -104,7 +104,7 @@ echo display_user_link($rows[$display_post_id]['user_id'], $name).'<br />'; echo $rows[$display_post_id]['post_date'].'<br /><br />'; // The user who posted it can edit his thread only if the course admin allowed this in the properties of the forum // The course admin him/herself can do this off course always -if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['user_id']==$_uid) or api_is_allowed_to_edit()) +if (($current_forum['allow_edit']==1 AND $rows[$display_post_id]['user_id']==$_user['user_id']) or api_is_allowed_to_edit()) { echo "<a href=\"editpost.php?forum=".$_GET['forum']."&amp;thread=".$_GET['thread']."&amp;post=".$rows[$display_post_id]['post_id']."\">".icon('../img/edit.gif',get_lang('Edit'))."</a>\n"; } @@ -119,7 +119,7 @@ echo '<br /><br />'; //if (($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0) OR api_is_allowed_to_edit()) if ($current_forum_category['locked']==0 AND $current_forum['locked']==0 AND $current_thread['locked']==0 OR api_is_allowed_to_edit()) { - if ($_uid OR ($current_forum['allow_anonymous']==1 AND !$_uid)) + if ($_user['user_id'] OR ($current_forum['allow_anonymous']==1 AND !$_user['user_id'])) { echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$rows[$display_post_id]['post_id'].'&amp;action=replymessage">'.get_lang('ReplyToMessage').'</a><br />'; echo '<a href="reply.php?forum='.$_GET['forum'].'&amp;thread='.$_GET['thread'].'&amp;post='.$rows[$display_post_id]['post_id'].'&amp;action=quote">'.get_lang('QuoteMessage').'</a><br /><br />'; @@ -150,7 +150,7 @@ else { $post_image=icon('../img/forumpost.gif'); } -if ($rows[$display_post_id]['post_notification']=='1' AND $rows[$display_post_id]['poster_id']==$_uid) +if ($rows[$display_post_id]['post_notification']=='1' AND $rows[$display_post_id]['poster_id']==$_user['user_id']) { $post_image.=icon('../img/forumnotification.gif',get_lang('YouWillBeNotified')); } diff --git a/main/group/group.php b/main/group/group.php index afb0dae88e..452a806524 100644 --- a/main/group/group.php +++ b/main/group/group.php @@ -252,7 +252,7 @@ foreach ($group_cats as $index => $category) { $totalRegistered = 0; // Determine wether current user is tutor for this course - $user_is_tutor = GroupManager :: is_tutor($_uid); + $user_is_tutor = GroupManager :: is_tutor($_user['user_id']); $group_data = array (); foreach ($group_list as $index => $this_group) { @@ -268,7 +268,7 @@ foreach ($group_cats as $index => $category) } // group name - if (api_is_allowed_to_edit() || in_array($_uid,$tutorsids_of_group) || $this_group['is_member'] || GroupManager::user_has_access($_uid,$this_group['id'],GROUP_TOOL_FORUM) || GroupManager::user_has_access($_uid,$this_group['id'],GROUP_TOOL_DOCUMENTS)) + if (api_is_allowed_to_edit() || in_array($_user['user_id'],$tutorsids_of_group) || $this_group['is_member'] || GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_FORUM) || GroupManager::user_has_access($_user['user_id'],$this_group['id'],GROUP_TOOL_DOCUMENTS)) { $group_name = '<a href="group_space.php?'.api_get_cidreq().'&amp;origin='.$origin.'&amp;gidReq='.$this_group['id'].'">'.$this_group['name'].'</a>'; if ($_SESSION['_uid'] && $_SESSION['_uid'] == $this_group['id_tutor']) @@ -288,11 +288,11 @@ foreach ($group_cats as $index => $category) // self-registration / unregistration if (!api_is_allowed_to_edit()) { - if (GroupManager :: is_self_registration_allowed($_uid, $this_group['id'])) + if (GroupManager :: is_self_registration_allowed($_user['user_id'], $this_group['id'])) { $row[] = '<a href="group.php?category='.$category['id'].'&amp;action=self_reg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;">'.get_lang("GroupSelfRegInf").'</a>'; } - elseif (GroupManager :: is_self_unregistration_allowed($_uid, $this_group['id'])) + elseif (GroupManager :: is_self_unregistration_allowed($_user['user_id'], $this_group['id'])) { $row[] = '<a href="group.php?category='.$category['id'].'&amp;action=self_unreg&amp;group_id='.$this_group['id'].'" onclick="javascript:if(!confirm('."'".addslashes(htmlentities(get_lang("ConfirmYourChoice")))."'".')) return false;">'.get_lang("GroupSelfUnRegInf").'</a>'; } diff --git a/main/group/group_space.php b/main/group/group_space.php index 960cdb0163..fc35ffd75e 100644 --- a/main/group/group_space.php +++ b/main/group/group_space.php @@ -91,7 +91,7 @@ if ($_GET['selfUnReg'] && GroupManager :: is_self_unregistration_allowed($_SESSI /* * Edit the group */ -if (api_is_allowed_to_edit() or GroupManager :: is_tutor($_uid)) +if (api_is_allowed_to_edit() or GroupManager :: is_tutor($_user['user_id'])) { echo "<a href=\"group_edit.php?origin=$origin\">".get_lang("EditGroup")."</a><br/><br/>"; } diff --git a/main/inc/lib/events.lib.inc.php b/main/inc/lib/events.lib.inc.php index 5df4306af7..6ae8d2533a 100644 --- a/main/inc/lib/events.lib.inc.php +++ b/main/inc/lib/events.lib.inc.php @@ -111,7 +111,7 @@ function event_login() // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $TABLETRACK_LOGIN; $reallyNow = time(); $sql = "INSERT INTO `".$TABLETRACK_LOGIN."` @@ -121,7 +121,7 @@ function event_login() `login_date`) VALUES - ('".$_uid."', + ('".$_user['user_id']."', '".$_SERVER['REMOTE_ADDR']."', FROM_UNIXTIME(".$reallyNow."))"; $res = api_sql_query($sql,__FILE__,__LINE__); @@ -140,7 +140,7 @@ function event_access_course() // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_ACCESS; global $TABLETRACK_LASTACCESS; //for "what's new" notification @@ -155,9 +155,9 @@ function event_access_course() } $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { @@ -211,7 +211,7 @@ function event_access_tool($tool, $id_session=0) global $is_trackingEnabled; // if tracking is disabled record nothing // if( ! $is_trackingEnabled ) return 0; //commented because "what's new" notification must always occur - global $_uid; + global $_user; global $_cid; global $TABLETRACK_ACCESS; global $rootWeb; @@ -228,7 +228,7 @@ function event_access_tool($tool, $id_session=0) } $reallyNow = time(); - $user_id = $_uid ? "'".$_uid."'" : "NULL"; // "NULL" is anonymous + $user_id = $_user['user_id'] ? "'".$_user['user_id']."'" : "NULL"; // "NULL" is anonymous // record information // only if user comes from the course $_cid //if( eregi($rootWeb.$_cid,$_SERVER['HTTP_REFERER'] ) ) @@ -288,13 +288,13 @@ function event_download($doc_url) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_DOWNLOADS; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { @@ -333,13 +333,13 @@ function event_upload($doc_id) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_UPLOADS; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { @@ -377,13 +377,13 @@ function event_link($link_id) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_LINKS; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { @@ -422,14 +422,14 @@ function event_exercice($exo_id, $score, $weighting) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_EXERCICES; global $origin, $learnpath_id, $learnpath_item_id; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { @@ -482,14 +482,14 @@ function event_subscription($cours_id, $action) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $TABLETRACK_SUBSCRIPTIONS; $sql = "INSERT INTO `$TABLETRACK_SUBSCRIPTIONS` (`sub_user_id`, `sub_cours_id`, `sub_action`) VALUES - ('".$_uid."', + ('".$_user['user_id']."', '".$cours_id."', '".$action."')"; $res = api_sql_query($sql,__FILE__,__LINE__); @@ -511,19 +511,19 @@ function event_default($type_event, $values) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_DEFAULT; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { $user_id = "NULL"; } - if ($_uid) + if ($_user['user_id']) { $cours_id = "'".$_cid."'"; } @@ -555,14 +555,14 @@ function exercise_attempt($score,$answer,$quesId,$exeId,$j) // if tracking is disabled record nothing if (!$is_trackingEnabled) return 0; - global $_uid; + global $_user; global $_cid; global $TABLETRACK_ATTEMPT; global $origin, $learnpath_id, $learnpath_item_id; $reallyNow = time(); - if ($_uid) + if ($_user['user_id']) { - $user_id = "'".$_uid."'"; + $user_id = "'".$_user['user_id']."'"; } else // anonymous { diff --git a/main/inc/lib/fckeditor/editor/plugins/Attachment/fck_Attachment.php b/main/inc/lib/fckeditor/editor/plugins/Attachment/fck_Attachment.php index 1957fceff5..ec73b8e60d 100644 --- a/main/inc/lib/fckeditor/editor/plugins/Attachment/fck_Attachment.php +++ b/main/inc/lib/fckeditor/editor/plugins/Attachment/fck_Attachment.php @@ -23,7 +23,7 @@ if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') //if the group id is set, $group_properties = GroupManager::get_group_properties($_SESSION['_gid']); $noPHP_SELF=true; - if($is_allowed_to_edit || GroupManager::is_user_in_group($_uid,$_SESSION['_gid'])) //only courseadmin or group members allowed + if($is_allowed_to_edit || GroupManager::is_user_in_group($_user['user_id'],$_SESSION['_gid'])) //only courseadmin or group members allowed { $to_group_id = $_SESSION['_gid']; $req_gid = '&amp;gidReq='.$_SESSION['_gid']; @@ -72,7 +72,7 @@ if($_POST['fileupload']=="Attach File"){ if($upload_ok) { //file got on the server without problems, now process it - $new_path = handle_uploaded_document($_course, $_FILES['uploadedfile'],$base_work_dir,$path,$_uid,$to_group_id,$to_user_id,$max_filled_space,0,'overwrite'); + $new_path = handle_uploaded_document($_course, $_FILES['uploadedfile'],$base_work_dir,$path,$_user['user_id'],$to_group_id,$to_user_id,$max_filled_space,0,'overwrite'); $new_comment = isset($_POST['comment']) ? trim($_POST['comment']) : ''; $new_title = isset($_POST['title']) ? trim($_POST['title']) : ''; diff --git a/main/inc/lib/fileUpload.lib.php b/main/inc/lib/fileUpload.lib.php index 9996ae0c65..9fcab65741 100644 --- a/main/inc/lib/fileUpload.lib.php +++ b/main/inc/lib/fileUpload.lib.php @@ -889,7 +889,7 @@ function unzip_uploaded_file($uploadedFile, $uploadPath, $baseWorkDir, $maxFille function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $max_filled_space, $output = true) { global $_course; - global $_uid; + global $_user; global $to_user_id; global $to_group_id; @@ -966,7 +966,7 @@ function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $ $folder_id = add_document($_course,$upload_path.dirname($cleaned_up_filename),'folder',0,basename(dirname($cleaned_up_filename))); if($folder_id) { - api_item_property_update($_course,TOOL_DOCUMENT,$folder_id,'FolderAdded',$_uid,$to_group_id,$to_user_id); + api_item_property_update($_course,TOOL_DOCUMENT,$folder_id,'FolderAdded',$_user['user_id'],$to_group_id,$to_user_id); //echo('folder '.$upload_path.dirname($cleaned_up_filename)." added<br>\n"); } } @@ -988,7 +988,7 @@ function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $ { $lastedit_type = ($filetype=='folder')?'FolderAdded':'DocumentAdded'; //update item property for document - api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$lastedit_type,$_uid,$to_group_id,$to_user_id); + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$lastedit_type,$_user['user_id'],$to_group_id,$to_user_id); } } //file/dir exists -> update @@ -996,14 +996,14 @@ function unzip_uploaded_document($uploaded_file, $upload_path, $base_work_dir, $ { $lastedit_type = ($filetype=='folder')?'FolderUpdated':'DocumentUpdated'; //update the document in item_property - api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$lastedit_type,$_uid,$to_group_id,$to_user_id); + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,$lastedit_type,$_user['user_id'],$to_group_id,$to_user_id); } } } //print_r_pre($zip_content_array); //if the file is in a folder, we need to update all parent folders - item_property_update_on_folder($_course,$upload_path,$_uid); + item_property_update_on_folder($_course,$upload_path,$_user['user_id']); //display success message to user chdir($save_dir); //return to previous dir position if($output){ @@ -1757,7 +1757,7 @@ function build_missing_files_form($missing_files,$upload_path,$file_name) * @param string $base_work_dir * @param string $current_path, needed for recursivity */ -function add_all_documents_in_folder_to_database($_course,$_uid,$base_work_dir,$current_path='') +function add_all_documents_in_folder_to_database($_course,$user_id,$base_work_dir,$current_path='') { $path = $base_work_dir.$current_path; @@ -1779,12 +1779,12 @@ $handle=opendir($path); if(!DocumentManager::get_document_id($_course, $current_path.'/'.$safe_file)) { $document_id=add_document($_course,$current_path.'/'.$safe_file,'folder',0,$title); - api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_uid); + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$user_id); //echo $current_path.'/'.$safe_file." added!<br/>"; } //recursive - add_all_documents_in_folder_to_database($_course,$_uid,$base_work_dir,$current_path.'/'.$safe_file); + add_all_documents_in_folder_to_database($_course,$user_id,$base_work_dir,$current_path.'/'.$safe_file); } //file! else @@ -1797,7 +1797,7 @@ $handle=opendir($path); $title=get_document_title($file); $size = filesize($base_work_dir.$current_path.'/'.$safe_file); $document_id = add_document($_course,$current_path.'/'.$safe_file,'file',$size,$title); - api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$_uid); + api_item_property_update($_course,TOOL_DOCUMENT,$document_id,'DocumentAdded',$user_id); //echo $current_path.'/'.$safe_file." added!<br/>"; } } diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index a778a9f500..10162921ee 100644 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -93,7 +93,7 @@ class GroupManager */ function get_group_list($category = null, $course_code = null) { - global $_uid; + global $_user; $course_db = ''; if ($course_code != null) { @@ -116,7 +116,7 @@ class GroupManager COUNT(ug2.id) number_of_members FROM ".$table_group." `g` LEFT JOIN ".$table_group_user." `ug` - ON `ug`.`group_id` = `g`.`id` AND `ug`.`user_id` = '".$_uid."' + ON `ug`.`group_id` = `g`.`id` AND `ug`.`user_id` = '".$_user['user_id']."' LEFT JOIN ".$table_group_user." `ug2` ON `ug2`.`group_id` = `g`.`id`"; if ($category != null) @@ -144,7 +144,7 @@ class GroupManager */ function create_group($name, $category_id, $tutor, $places) { - global $_course,$_uid; + global $_course,$_user; $currentCourseRepository = $_course['path']; $coursesRepositorySys = api_get_path(SYS_COURSE_PATH); $table_group = Database :: get_course_table(GROUP_TABLE); @@ -165,7 +165,7 @@ class GroupManager FileManager :: mkdirs($coursesRepositorySys.$currentCourseRepository."/group/".$secret_directory, 0777); */ $desired_dir_name= '/'.replace_dangerous_char($name,'strict').'_groupdocs'; - $dir_name = create_unexisting_directory($_course,$_uid,$lastId,NULL,$coursesRepositorySys.$currentCourseRepository.'/document',$desired_dir_name); + $dir_name = create_unexisting_directory($_course,$_user['user_id'],$lastId,NULL,$coursesRepositorySys.$currentCourseRepository.'/document',$desired_dir_name); /* Stores the directory path into the group table */ $sql = "UPDATE ".$table_group." SET name = '".mysql_real_escape_string($name)."', secret_directory = '".$dir_name."' WHERE id ='".$lastId."'"; api_sql_query($sql,__FILE__,__LINE__); @@ -821,7 +821,7 @@ class GroupManager global $_course; $course_code = $_course['sysCode']; $category = GroupManager :: get_category_from_group($group_id); - $result = CourseManager :: is_user_subscribed_in_real_or_linked_course($_uid, $course_code); + $result = CourseManager :: is_user_subscribed_in_real_or_linked_course($user_id, $course_code); $result = !GroupManager :: is_subscribed($user_id, $group_id); $result &= (GroupManager :: number_of_students($group_id) < GroupManager :: maximum_number_of_students($group_id)); if ($category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT) @@ -1141,14 +1141,14 @@ class GroupManager */ function get_complete_list_of_users_that_can_be_added_to_group($course_code, $group_id) { - global $_course, $_uid; + global $_course, $_user; $category = GroupManager :: get_category_from_group($group_id, $course_code); $number_of_groups_limit = $category['groups_per_user'] == GROUP_PER_MEMBER_NO_LIMIT ? INFINITE : $category['groups_per_user']; $real_course_code = $_course['sysCode']; $real_course_info = Database :: get_course_info($real_course_code); $real_course_user_list = CourseManager :: get_user_list_from_course_code($virtual_course_code); //get list of all virtual courses - $user_subscribed_course_list = CourseManager :: get_list_of_virtual_courses_for_specific_user_and_real_course($_uid, $real_course_code); + $user_subscribed_course_list = CourseManager :: get_list_of_virtual_courses_for_specific_user_and_real_course($_user['user_id'], $real_course_code); //add real course to the list $user_subscribed_course_list[] = $real_course_info; if (!is_array($user_subscribed_course_list)) diff --git a/main/inc/lib/javascript/email_links.lib.js.php b/main/inc/lib/javascript/email_links.lib.js.php index 01f881e8cf..f82a28575b 100644 --- a/main/inc/lib/javascript/email_links.lib.js.php +++ b/main/inc/lib/javascript/email_links.lib.js.php @@ -9,7 +9,7 @@ * If the user is not logged in, don't define anything, so the normal * handling of mailto link can proceed */ -if(!empty($_uid) AND string_2_boolean(api_get_setting('allow_email_editor'))){ +if(!empty($_user['user_id']) AND string_2_boolean(api_get_setting('allow_email_editor'))){ ?> <script language="javascript" version="1.3" type="text/javascript"> /** diff --git a/main/inc/lib/online.inc.php b/main/inc/lib/online.inc.php index 084726722e..1bdd8104e9 100644 --- a/main/inc/lib/online.inc.php +++ b/main/inc/lib/online.inc.php @@ -180,14 +180,14 @@ function ClearURL($path) function chatcall() { - global $_uid, $_cid; + global $_user, $_cid; - if (!$_uid) + if (!$_user['user_id']) { return (false); } $track_user_table = Database::get_main_table(MAIN_USER_TABLE); - $sql="select chatcall_user_id, chatcall_date from $track_user_table where ( user_id = $_uid )"; + $sql="select chatcall_user_id, chatcall_date from $track_user_table where ( user_id = '".$_user['user_id']."' )"; $result=api_sql_query($sql,__FILE__,__LINE__); $row=mysql_fetch_array($result); diff --git a/main/inc/lib/surveymanager.lib.php b/main/inc/lib/surveymanager.lib.php index 3d28cdd242..17cae3621d 100644 --- a/main/inc/lib/surveymanager.lib.php +++ b/main/inc/lib/surveymanager.lib.php @@ -51,8 +51,8 @@ class SurveyManager * @return int new user id - if the new user creation succeeds * boolean false otherwise * - * @desc The function tries to retrieve $tbl_user and $_uid from the global space. - * if it exists, $_uid is the creator id + * @desc The function tries to retrieve $tbl_user and $_user['user_id'] from the global space. + * if it exists, $_user['user_id'] is the creator id * If a problem arises, it stores the error message in global $api_failureList * @todo rework to use Database API diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index d7d8e35bd5..b35f77222d 100644 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -116,7 +116,7 @@ class SystemAnnouncementManager return; } - function display_all_announcements($visible, $id = -1,$start = 0,$_uid) + function display_all_announcements($visible, $id = -1,$start = 0,$user_id) { $user_selected_language = $_SESSION["user_language_choice"] ? $_SESSION["user_language_choice"] : get_setting('platformLanguage'); @@ -159,7 +159,7 @@ class SystemAnnouncementManager echo '<table align="center">'; echo '<tr>'; echo '<td>'; - SystemAnnouncementManager :: display_fleche($_uid); + SystemAnnouncementManager :: display_fleche($user_id); echo '</td>'; echo '</tr>'; echo '</table>'; @@ -185,7 +185,7 @@ class SystemAnnouncementManager echo '<table align="center">'; echo '<tr>'; echo '<td>'; - SystemAnnouncementManager :: display_fleche($_uid); + SystemAnnouncementManager :: display_fleche($user_id); echo '</td>'; echo '</tr>'; echo '</table>'; @@ -194,10 +194,10 @@ class SystemAnnouncementManager return; } - function display_fleche($_uid) + function display_fleche($user_id) { $start = (int)$_GET['start']; - $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$_uid); + $nb_announcement = SystemAnnouncementManager :: count_nb_announcement($start,$user_id); $next = ((int)$_GET['start']+19); $prev = ((int)$_GET['start']-19); @@ -223,7 +223,7 @@ class SystemAnnouncementManager } - function count_nb_announcement($start = 0,$_uid = '') + function count_nb_announcement($start = 0,$user_id = '') { $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT; $user_selected_language = $_SESSION["user_language_choice"] ? $_SESSION["user_language_choice"] : get_setting('platformLanguage'); @@ -231,7 +231,7 @@ class SystemAnnouncementManager $sql = 'SELECT id FROM '.$db_table.' WHERE lang="'.$user_selected_language.'"'; - if (isset($_uid)) + if (isset($user_id)) { switch ($visibility) { diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 3d8a20993f..7baedb7775 100644 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -51,20 +51,24 @@ class UserManager * @return int new user id - if the new user creation succeeds * boolean false otherwise * - * @desc The function tries to retrieve $_uid from the global space. - * if it exists, $_uid is the creator id If a problem arises, + * @desc The function tries to retrieve $_user['user_id'] from the global space. + * if it exists, $_user['user_id'] is the creator id If a problem arises, * it stores the error message in global $api_failureList * * @todo Add the user language to the parameters */ function create_user($firstName, $lastName, $status, $email, $loginName, $password, $official_code = '', $language="english", $phone = '', $picture_uri = '', $auth_source = PLATFORM_AUTH_SOURCE, $expiration_date = '0000-00-00 00:00:00', $active = 1) { - global $_uid, $userPasswordCrypted; + global $_user, $userPasswordCrypted; $table_user = Database::get_main_table(MAIN_USER_TABLE); - if ($_uid) - $creator_id = $_uid; + if ($_user['user_id']) + { + $creator_id = $_user['user_id']; + } else + { $creator_id = ''; + } // First check wether the login already exists if (! UserManager::is_username_available($loginName)) return api_set_failure('login-pass already taken'); diff --git a/main/install/update_db.inc.php b/main/install/update_db.inc.php index 467da65a9d..39b966f6c2 100644 --- a/main/install/update_db.inc.php +++ b/main/install/update_db.inc.php @@ -981,12 +981,13 @@ else /** * This function stores the forum category in the database. The new category is added to the end. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function store_forumcategory($values) { global $table_categories; global $_course; - global $_uid; + global $_user; // find the max cat_order. The new forum category is added at the end => max cat_order + & $sql="SELECT MAX(cat_order) as sort_max FROM ".mysql_real_escape_string($table_categories); @@ -997,19 +998,20 @@ function store_forumcategory($values) $sql="INSERT INTO ".$table_categories." (cat_title, cat_comment, cat_order) VALUES ('".mysql_real_escape_string($values['forum_category_title'])."','".mysql_real_escape_string($values['forum_category_comment'])."','".mysql_real_escape_string($new_max)."')"; api_sql_query($sql); $last_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM_CATEGORY, $last_id,"ForumCategoryAdded", $_user['user_id']); return array('id'=>$last_id,'title'=>$values['forum_category_title']) ; } /** * This function stores the forum in the database. The new forum is added to the end. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function store_forum($values) { global $table_forums; global $_course; - global $_uid; + global $_user; // find the max forum_order for the given category. The new forum is added at the end => max cat_order + & $sql="SELECT MAX(forum_order) as sort_max FROM ".$table_forums." WHERE forum_category=".mysql_real_escape_string($values['forum_category']); @@ -1034,7 +1036,7 @@ function store_forum($values) '".mysql_real_escape_string($new_max)."')"; api_sql_query($sql, __LINE__,__FILE__); $last_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM, $last_id,"ForumCategoryAdded", $_user['user_id']); return array('id'=>$last_id, 'title'=>$values['forum_title']); } @@ -1042,12 +1044,13 @@ function store_forum($values) * This function stores a new thread. This is done through an entry in the forum_thread table AND * in the forum_post table because. The threads are also stored in the item_property table. (forum posts are not (yet)) * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function store_thread($values) { global $table_threads; global $table_posts; - global $_uid; + global $_user; global $_course; global $current_forum; @@ -1062,14 +1065,14 @@ function store_thread($values) '".mysql_real_escape_string($values['thread_sticky'])."')"; $result=api_sql_query($sql, __LINE__, __FILE__); $last_thread_id=mysql_insert_id(); - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_uid); + api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"ForumThreadAdded", $_user['user_id']); // if the forum properties tell that the posts have to be approved we have to put the whole thread invisible // because otherwise the students will see the thread and not the post in the thread. // we also have to change $visible because the post itself has to be visible in this case (otherwise the teacher would have // to make the thread visible AND the post if ($values['visible']==0) { - api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_uid); + api_item_property_update($_course, TOOL_FORUM_THREAD, $last_thread_id,"invisible", $_user['user_id']); $visible=1; } @@ -1081,6 +1084,7 @@ function store_thread($values) * @param $phpbb_forum_id the forum_id of the old (phpbb) forum * @param $new_forum_id the forum_id in the new forum * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id) { @@ -1130,6 +1134,7 @@ function migrate_threads_of_forum($phpbb_forum_id, $new_forum_id) * @param $phpbb_forum_id the forum_id of the old (phpbb) forum * @param $new_forum_id the forum_id in the new forum * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_forum_id) { @@ -1207,6 +1212,7 @@ function migrate_posts_of_thread($phpbb_thread_id, $new_forum_thread_id, $new_fo /** * This function gets all the added resources for phpbb forum posts * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function get_added_resources() { @@ -1226,6 +1232,7 @@ function get_added_resources() /** * This function gets the forum category information based on the name * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University +* @todo is this the same function as in forumfunction.inc.php? If this is the case then it should not appear here. */ function get_forumcategory_id_by_name($forum_category_name) {