Browse Source

Minor - Fixing PHP warnings

Julio Montoya 10 years ago
parent
commit
b666f82031

+ 4 - 2
main/dropbox/index.php

@@ -5,7 +5,7 @@
 require_once 'dropbox_init.inc.php';
 
 // get the last time the user accessed the tool
-if ($_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
+if (isset($_SESSION[$_course['id']]) && $_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] == '') {
 	$last_access = get_last_tool_access(TOOL_DROPBOX);
 	$_SESSION[$_course['id']]['last_access'][TOOL_DROPBOX] = $last_access;
 } else {
@@ -181,9 +181,11 @@ if (isset($_GET['error']) AND !empty($_GET['error'])) {
 	Display :: display_normal_message(get_lang($_GET['error']));
 }
 
+$dropbox_data_sent = array();
+$movelist = array();
+$dropbox_data_recieved = array();
 
 if ($action != 'add') {
-
 	// Getting all the categories in the dropbox for the given user
 	$dropbox_categories = get_dropbox_categories();
 	// Greating the arrays with the categories for the received files and for the sent files

+ 4 - 2
main/exercice/exercise.lib.php

@@ -1379,7 +1379,9 @@ function get_exam_results_data(
         $teacher_id_list[] = $teacher['user_id'];
     }
 
-    //Simple exercises
+    $list_info = array();
+
+    // Simple exercises
     if (empty($hotpotatoe_where)) {
         $column = !empty($column) ? Database::escape_string($column) : null;
         $from = intval($from);
@@ -1407,7 +1409,7 @@ function get_exam_results_data(
 
         $lp_list_obj = new learnpathList(api_get_user_id());
         $lp_list = $lp_list_obj->get_flat_list();
-        $list_info = array();
+
         if (is_array($results)) {
 
             $users_array_id = array();

+ 4 - 3
main/forum/forumfunction.inc.php

@@ -182,6 +182,7 @@ function handle_forum_and_forumcategories($lp_id = null)
         $return_message = delete_forum_forumcategory_thread($get_content, $get_id);
         Display::display_confirmation_message($return_message, false);
     }
+
     // Change visibility of a forum or a forum category.
     if ($action_forum_cat == 'invisible' || $action_forum_cat == 'visible') {
         $return_message = change_visibility($get_content, $get_id, $action_forum_cat);
@@ -1023,9 +1024,9 @@ function display_up_down_icon($content, $id, $list)
 /**
  * This function changes the visibility in the database (item_property)
  *
- * @param $content what is it that we want to make (in)visible: forum category, forum, thread, post
- * @param $id the id of the content we want to make invisible
- * @param $target_visibility what is the current status of the visibility (0 = invisible, 1 = visible)
+ * @param string $content what is it that we want to make (in)visible: forum category, forum, thread, post
+ * @param int $id the id of the content we want to make invisible
+ * @param string $target_visibility what is the current status of the visibility (0 = invisible, 1 = visible)
  *
  * @todo change the get parameter so that it matches the tool constants.
  * @todo check if api_item_property_update returns true or false => returnmessage depends on it.

+ 1 - 1
main/gradebook/gradebook_display_certificate.php

@@ -97,7 +97,7 @@ $this_section = SECTION_COURSES;
 
 Display::display_header('');
 
-if ($_GET['action'] == 'delete') {
+if (isset($_GET['action']) && $_GET['action'] == 'delete') {
     $check = Security::check_token('get');
     if ($check) {
         $certificate = new Certificate($_GET['certificate_id']);

+ 6 - 5
main/gradebook/gradebook_edit_all.php

@@ -57,7 +57,6 @@ $course_id			  =	get_course_id_by_link_id($my_selectcat);
 
 $table_link           = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
 $table_evaluation     = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
-
 $tbl_forum_thread     = Database :: get_course_table(TABLE_FORUM_THREAD);
 $tbl_work             = Database :: get_course_table(TABLE_STUDENT_PUBLICATION);
 $tbl_attendance       = Database :: get_course_table(TABLE_ATTENDANCE);
@@ -77,7 +76,7 @@ if ($submitted==1) {
         require_once 'lib/be/evaluation.class.php';
         $eval_log = new Evaluation();
     }
-    if(isset($_POST['link'])){
+    if (isset($_POST['link'])) {
         require_once 'lib/be/abstractlink.class.php';
         //$eval_link_log = new AbstractLink();
     }
@@ -170,7 +169,7 @@ if ($my_api_cidreq=='') {
 }
 ?>
     <div class="actions">
-        <a href="<?php echo Security::remove_XSS($_SESSION['gradebook_dest']).'?id_session='.api_get_session_id().'&amp;'.$my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
+        <a href="<?php echo Security::remove_XSS($_SESSION['gradebook_dest']).'?'.$my_api_cidreq ?>&selectcat=<?php echo $my_selectcat ?>">
             <?php echo Display::return_icon('back.png',get_lang('FolderView'),'',ICON_SIZE_MEDIUM); ?>
         </a>
     </div>
@@ -178,7 +177,7 @@ if ($my_api_cidreq=='') {
 $warning_message = sprintf(get_lang('TotalWeightMustBeX'), $masked_total);
 Display::display_normal_message($warning_message, false);
 ?>
-    <form method="post" action="gradebook_edit_all.php?id_session=<?php echo $_SESSION['id_session'].'&amp;'.$my_api_cidreq ?>&selectcat=<?php echo $my_selectcat?>">
+    <form method="post" action="gradebook_edit_all.php?<?php echo $my_api_cidreq ?>&selectcat=<?php echo $my_selectcat?>">
         <table class="data_table">
             <tr class="row_odd">
                 <th style="width: 35px;"><?php echo get_lang('Type'); ?></th>
@@ -189,7 +188,9 @@ Display::display_normal_message($warning_message, false);
         </table>
         <input type="hidden" name="submitted" value="1" />
         <br />
-        <button class="save" type="submit" name="name" value="<?php echo get_lang('Save') ?>"><?php echo get_lang('SaveScoringRules') ?></button>
+        <button class="save" type="submit" name="name" value="<?php echo get_lang('Save') ?>">
+            <?php echo get_lang('SaveScoringRules') ?>
+        </button>
     </form>
 <?php
 Display :: display_footer();

+ 30 - 14
main/gradebook/lib/be/abstractlink.class.php

@@ -300,9 +300,9 @@ abstract class AbstractLink implements GradebookItem
     /**
      * Update the properties of this link in the database
      */
-    public function save() {
+    public function save()
+    {
         $this->save_linked_data();
-
         $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
         $sql = "UPDATE $tbl_grade_links SET
                     type        = ".intval($this->get_type()).",
@@ -322,7 +322,7 @@ abstract class AbstractLink implements GradebookItem
     /**
      * @param int $idevaluation
      */
-    public function add_link_log($idevaluation)
+    public static function add_link_log($idevaluation)
     {
         $tbl_grade_linkeval_log = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINKEVAL_LOG);
         $dateobject=AbstractLink::load ($idevaluation,null,null,null,null);
@@ -345,7 +345,8 @@ abstract class AbstractLink implements GradebookItem
     /**
      * Delete this link from the database
      */
-    public function delete() {
+    public function delete()
+    {
         $this->delete_linked_data();
         $tbl_grade_links = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
         $sql = 'DELETE FROM '.$tbl_grade_links.' WHERE id = '.intval($this->id);
@@ -361,7 +362,6 @@ abstract class AbstractLink implements GradebookItem
     public function get_target_categories()
     {
         // links can only be moved to categories inside this course
-
         $targets = array();
         $level = 0;
 
@@ -416,22 +416,26 @@ abstract class AbstractLink implements GradebookItem
                 $foundlinks[] = $link;
             }
         }
+
         return $foundlinks;
     }
 
-
-    // Other methods implementing GradebookItem
+    /**
+     * @return string
+     */
     public function get_item_type()
     {
         return 'L';
     }
 
-    public function get_icon_name() {
+    /**
+     * @return string
+     */
+    public function get_icon_name()
+    {
         return 'link';
     }
 
-    // ABSTRACT FUNCTIONS - to be implemented by subclass
-
     abstract function has_results();
     abstract function get_link();
     abstract function is_valid_link();
@@ -469,19 +473,31 @@ abstract class AbstractLink implements GradebookItem
     {
     }
 
+    /**
+     *
+     */
     public function delete_linked_data()
     {
     }
 
-    public function set_name ($name)
+    /**
+     * @param $name
+     */
+    public function set_name($name)
     {
     }
 
-    public function set_description ($description)
+    /**
+     * @param $description
+     */
+    public function set_description($description)
     {
     }
 
-    public function set_max ($max)
+    /**
+     * @param $max
+     */
+    public function set_max($max)
     {
     }
 
@@ -495,7 +511,7 @@ abstract class AbstractLink implements GradebookItem
      * @param int locked 1 or unlocked 0
      *
      * */
-    function lock($locked)
+    public function lock($locked)
     {
         $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_LINK);
         $sql = "UPDATE $table SET locked = '".intval($locked)."' WHERE id='".$this->id."'";

+ 1 - 1
main/messages/new_message.php

@@ -344,7 +344,7 @@ if (!isset($_POST['compose'])) {
         // post
         if ($restrict) {
             if (!isset($_POST['group_id'])) {
-                $default['users']	 = $_POST['users'];
+                $default['users'] = isset($_POST['users']) ? $_POST['users'] : null;
             } else {
                 $default['group_id'] = $_POST['group_id'];
             }

+ 1 - 0
main/social/group_topics.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * @package chamilo.social
  * @author Julio Montoya <gugli100@gmail.com>

+ 19 - 24
main/social/groups.php

@@ -1,5 +1,6 @@
 <?php
 /* For licensing terms, see /license.txt */
+
 /**
  * @package chamilo.social
  * @author Julio Montoya <gugli100@gmail.com>
@@ -47,9 +48,7 @@ function remove_image_form(id_elem1) {
 	if (filepaths.childNodes.length < 3) {
 		var link_attach = document.getElementById("link-more-attach");
 		if (link_attach) {
-			link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">' . get_lang(
-        'AddOneMoreFile'
-    ) . '</a>\';
+			link_attach.innerHTML=\'<a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a>\';
 		}
 	}
 }
@@ -67,10 +66,7 @@ function add_image_form() {
 	filepaths.appendChild(elem1);
 	id_elem1 = "filepath_"+counter_image;
 	id_elem1 = "\'"+id_elem1+"\'";
-	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(
-        WEB_CODE_PATH
-    ) . 'img/delete.gif\"></a>";
-
+	document.getElementById("filepath_"+counter_image).innerHTML = "<input type=\"file\" name=\"attach_"+counter_image+"\"  size=\"20\" />&nbsp;<a href=\"javascript:remove_image_form("+id_elem1+")\"><img src=\"' . api_get_path(WEB_CODE_PATH) . 'img/delete.gif\"></a>";
 	if (filepaths.childNodes.length == 3) {
 		var link_attach = document.getElementById("link-more-attach");
 		if (link_attach) {
@@ -92,34 +88,33 @@ jQuery(document).ready(function() {
     $("#tab_browse").bind("tabsselect", function(event, ui) {
 		window.location.href=ui.tab;
     });
+
 	$("#tabs").tabs();
 	$("#tab_browse").tabs();
-
     var valor = "' . $anchor . '";
 
     $(".head").click(function() {
-				$(this).next().next().slideToggle("fast");
-				image_clicked = $("#" + this.id + " img").attr("src");
-				image_clicked_info = image_clicked.split("/");
-				image_real_clicked = image_clicked_info[image_clicked_info.length-1];
-				image_path = image_clicked.split("img");
-				current_path = image_path[0]+"img/";
-				if (image_real_clicked == "div_show.gif") {
-					current_path = current_path+"div_hide.gif";
-					$("#" + this.id + " img").attr("src", current_path);
-				} else {
-					current_path = current_path+"div_show.gif";
-					$("#" + this.id + " img").attr("src", current_path)
-				}
-				return false;
-		 	}).next().next().hide();
+        $(this).next().next().slideToggle("fast");
+        image_clicked = $("#" + this.id + " img").attr("src");
+        image_clicked_info = image_clicked.split("/");
+        image_real_clicked = image_clicked_info[image_clicked_info.length-1];
+        image_path = image_clicked.split("img");
+        current_path = image_path[0]+"img/";
+        if (image_real_clicked == "div_show.gif") {
+            current_path = current_path+"div_hide.gif";
+            $("#" + this.id + " img").attr("src", current_path);
+        } else {
+            current_path = current_path+"div_show.gif";
+            $("#" + this.id + " img").attr("src", current_path)
+        }
+        return false;
+    }).next().next().hide();
 
    // anchor for current topic
    if (valor) {
    		$("#"+valor).show();
    		window.location = document.URL+"#"+valor;
    }
-
 });
 </script>';
 

+ 8 - 23
main/social/message_for_group_form.inc.php

@@ -4,9 +4,7 @@
  * Form for group message
  * @package chamilo.social
  */
-/**
- * Initialization
- */
+
 $language_file = array('registration', 'messages', 'userInfo', 'admin');
 $cidReset = true;
 require_once '../inc/global.inc.php';
@@ -36,19 +34,15 @@ if (isset($_REQUEST['user_friend'])) {
 }
 
 $group_id = intval($_GET['group_id']);
+$message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null;
 
-$message_id = intval($_GET['message_id']);
 $actions = array(
     'add_message_group',
     'edit_message_group',
     'reply_message_group'
 );
 
-$allowed_action = (isset($_GET['action']) && in_array(
-        $_GET['action'],
-        $actions
-    )) ? Security::remove_XSS($_GET['action']) : '';
-
+$allowed_action = (isset($_GET['action']) && in_array($_GET['action'], $actions)) ? Security::remove_XSS($_GET['action']) : '';
 $to_group = '';
 $subject = '';
 $message = '';
@@ -75,24 +69,15 @@ if (!empty($group_id) && $allowed_action) {
     }
 }
 
-$page_item = !empty($_GET['topics_page_nr']) ? intval(
-    $_GET['topics_page_nr']
-) : 1;
-$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? ('&items_' . intval(
-        $_GET['topic_id']
-    ) . '_page_nr=' . (!empty($_GET['topics_page_nr']) ? intval(
-        $_GET['topics_page_nr']
-    ) : 1)) : '';
+$page_item = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
+$param_item_page = isset($_GET['items_page_nr']) && isset($_GET['topic_id']) ? ('&items_' . intval($_GET['topic_id']) . '_page_nr=' . (!empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1)) : '';
 $param_item_page .= '&topic_id=' . intval($_GET['topic_id']);
-$page_topic = !empty($_GET['topics_page_nr']) ? intval(
-    $_GET['topics_page_nr']
-) : 1;
+$page_topic = !empty($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : 1;
+$anchor = isset($_GET['anchor_topic']) ? Security::remove_XSS($_GET['anchor_topic']) : null;
 ?>
 
 <form name="form"
-      action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo Security::remove_XSS(
-          $_GET['anchor_topic']
-      ) ?>&topics_page_nr=<?php echo $page_topic . $param_item_page ?>"
+      action="group_topics.php?id=<?php echo $group_id ?>&anchor_topic=<?php echo $anchor; ?>&topics_page_nr=<?php echo $page_topic . $param_item_page ?>"
       method="POST" enctype="multipart/form-data">
     <input type="hidden" name="action" value="<?php echo $allowed_action ?>"/>
     <input type="hidden" name="group_id" value="<?php echo $group_id ?>"/>

+ 6 - 3
main/survey/survey.lib.php

@@ -872,6 +872,7 @@ class survey_manager
         $sql = "SELECT * FROM $table_survey_question_option
 		        WHERE c_id = $course_id AND survey_id='".Database::escape_string($survey_id)."'";
         $result = Database::query($sql);
+        $return = array();
         while ($row = Database::fetch_array($result, 'ASSOC')) {
             $return[$row['question_id']]['answers'][] = $row['option_text'];
         }
@@ -2631,7 +2632,7 @@ class SurveyUtil
      * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
      * @version February 2007
      */
-    static function handle_reporting_actions($survey_data, $people_filled)
+    public static function handle_reporting_actions($survey_data, $people_filled)
     {
         $action = isset($_GET['action']) ? $_GET['action'] : null;
 
@@ -2639,7 +2640,8 @@ class SurveyUtil
         $temp_questions_data = survey_manager::get_questions($_GET['survey_id']);
 
         // Sorting like they should be displayed and removing the non-answer question types (comment and pagebreak)
-        $my_temp_questions_data=($temp_questions_data==null) ? array() : $temp_questions_data;
+        $my_temp_questions_data = ($temp_questions_data==null) ? array() : $temp_questions_data;
+        $questions_data = array();
         foreach ($my_temp_questions_data as $key => & $value) {
             if ($value['type'] != 'comment' && $value['type'] != 'pagebreak') {
                 $questions_data[$value['sort']] = $value;
@@ -2892,6 +2894,7 @@ class SurveyUtil
         }
 
         $currentQuestion = isset($_GET['question']) ? $_GET['question'] : 0;
+        $question = array();
 
         echo '<div class="actions">';
         echo '<a href="'.api_get_path(WEB_CODE_PATH).'survey/reporting.php?survey_id='.Security::remove_XSS($_GET['survey_id']).'">'.
@@ -2938,7 +2941,7 @@ class SurveyUtil
             }
         }
 
-        echo $question['survey_question'];
+        echo isset($question['survey_question']) ? $question['survey_question'] : null;
 
         if ($question['type'] == 'score') {
             /** @todo This function should return the options as this is needed further in the code */