From 954e7be9899aff70f0bd7ab4bace8d22beefec31 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Tue, 8 Sep 2015 14:09:29 +0200 Subject: [PATCH] Fix PHP warnings. --- main/forum/forumfunction.inc.php | 16 ++++----- main/gradebook/lib/fe/catform.class.php | 33 ++++++++----------- main/inc/lib/fileDisplay.lib.php | 3 +- .../lib/formvalidator/Element/DatePicker.php | 1 - 4 files changed, 23 insertions(+), 30 deletions(-) diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index b305877bdb..a9956f0008 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -2380,13 +2380,13 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa 'thread_title' => $clean_post_title, 'forum_id' => $values['forum_id'], 'thread_poster_id' => $_user['user_id'], - 'thread_poster_name' => stripslashes(isset($values['poster_name']) ? $values['poster_name'] : null), + 'thread_poster_name' => stripslashes(isset($values['poster_name']) ? $values['poster_name'] : ''), 'thread_date' => $post_date, - 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : null, - 'thread_title_qualify' => stripslashes($values['calification_notebook_title']), - 'thread_qualify_max' => $values['numeric_calification'], - 'thread_weight' => $values['weight_calification'], - 'thread_peer_qualify' => $values['thread_peer_qualify'], + 'thread_sticky' => isset($values['thread_sticky']) ? $values['thread_sticky'] : '', + 'thread_title_qualify' => isset($values['calification_notebook_title']) ? $values['calification_notebook_title'] : '', + 'thread_qualify_max' => isset($values['numeric_calification']) ? $values['numeric_calification'] : '', + 'thread_weight' => isset($values['weight_calification']) ? $values['weight_calification'] : '', + 'thread_peer_qualify' => isset($values['thread_peer_qualify']) ? $values['thread_peer_qualify'] : '', 'session_id' => api_get_session_id() ] ); @@ -2473,9 +2473,9 @@ function store_thread($current_forum, $values, $courseInfo = array(), $showMessa 'thread_id' => $last_thread_id, 'forum_id' => $values['forum_id'], 'poster_id' => $_user['user_id'], - 'poster_name' => isset($values['poster_name']) ? $values['poster_name'] : null, + 'poster_name' => isset($values['poster_name']) ? $values['poster_name'] : '', 'post_date' => $post_date, - 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : null, + 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : '', 'post_parent_id' => 0, 'visible' => $visible, ]; diff --git a/main/gradebook/lib/fe/catform.class.php b/main/gradebook/lib/fe/catform.class.php index 52fca1a648..f13b13cbd6 100755 --- a/main/gradebook/lib/fe/catform.class.php +++ b/main/gradebook/lib/fe/catform.class.php @@ -321,19 +321,13 @@ class CatForm extends FormValidator //Getting grade models $obj = new GradeModel(); - $obj->fill_grade_model_select_in_form($this, 'grade_model_id', $this->category_object->get_grade_model_id()); - - /* - $grade_models = $obj->get_all(); - $options = array(-1 => get_lang('None')); - foreach ($grade_models as $item) { - $options[$item['id']] = $item['name']; - } - $this->addElement('select', 'grade_model_id', array(get_lang('GradeModel'), get_lang('OnlyActiveWhenThereAreAnyComponents')), $options); - * - */ + $obj->fill_grade_model_select_in_form( + $this, + 'grade_model_id', + $this->category_object->get_grade_model_id() + ); - //Freeze or not + // Freeze or not $course_code = api_get_course_id(); $session_id = api_get_session_id(); $test_cats = Category :: load( @@ -357,7 +351,6 @@ class CatForm extends FormValidator } $generateCertificatesParams = array(); - if ($this->category_object->getGenerateCertificates()) { $generateCertificatesParams['checked'] = 'checked'; } @@ -371,7 +364,7 @@ class CatForm extends FormValidator ); } - if (!empty(api_get_session_id())) { + if (!empty($session_id)) { $isRequirementCheckbox = $this->addCheckBox( 'is_requirement', [ @@ -393,16 +386,13 @@ class CatForm extends FormValidator $this->addButtonUpdate(get_lang('EditCategory')); } - //if (!empty($grading_contents)) { $this->addRule('weight', get_lang('OnlyNumbers'), 'numeric'); - //$this->addRule('weight',get_lang('NoDecimals'),'nopunctuation'); $this->addRule( array('weight', 'zero'), get_lang('NegativeValue'), 'compare', '>=' ); - //} $setting = api_get_setting('tool_visible_by_default_at_creation'); $visibility_default = 1; @@ -418,11 +408,16 @@ class CatForm extends FormValidator */ protected function build_select_course_form() { - $select = $this->addElement('select','select_course',array(get_lang('PickACourse'),'test'), null); + $select = $this->addElement( + 'select', + 'select_course', + array(get_lang('PickACourse'), 'test'), + null + ); $coursecat = Category :: get_all_courses(api_get_user_id()); //only return courses that are not yet created by the teacher - foreach($coursecat as $row) { + foreach ($coursecat as $row) { $select->addoption($row[1],$row[0]); } $this->setDefaults(array( diff --git a/main/inc/lib/fileDisplay.lib.php b/main/inc/lib/fileDisplay.lib.php index 845a3d9857..7b3b14bc6b 100755 --- a/main/inc/lib/fileDisplay.lib.php +++ b/main/inc/lib/fileDisplay.lib.php @@ -21,8 +21,7 @@ function choose_image($file_name) static $type, $image; /* TABLES INITIALISATION */ - if (!$type || !$image) - { + if (!$type || !$image) { $type['word' ] = array('doc', 'dot', 'rtf', 'mcw', 'wps', 'psw', 'docm', 'docx', 'dotm', 'dotx'); $type['web' ] = array('htm', 'html', 'htx', 'xml', 'xsl', 'php', 'xhtml'); $type['image' ] = array('gif', 'jpg', 'png', 'bmp', 'jpeg', 'tif', 'tiff'); diff --git a/main/inc/lib/formvalidator/Element/DatePicker.php b/main/inc/lib/formvalidator/Element/DatePicker.php index 45459968b3..cecd31d2ac 100755 --- a/main/inc/lib/formvalidator/Element/DatePicker.php +++ b/main/inc/lib/formvalidator/Element/DatePicker.php @@ -196,5 +196,4 @@ class DatePicker extends HTML_QuickForm_text break; } } - }