diff --git a/main/attendance/attendance_edit.php b/main/attendance/attendance_edit.php index f55ac70314..e6a95d443d 100755 --- a/main/attendance/attendance_edit.php +++ b/main/attendance/attendance_edit.php @@ -66,7 +66,12 @@ $default['description'] = Security::remove_XSS($description,STUDENT); $default['attendance_qualify_title'] = $attendance_qualify_title; $default['attendance_weight'] = $attendance_weight; -$link_info = GradebookUtils::is_resource_in_course_gradebook(api_get_course_id(), 7, $attendance_id, api_get_session_id()); +$link_info = GradebookUtils::is_resource_in_course_gradebook( + api_get_course_id(), + 7, + $attendance_id, + api_get_session_id() +); $default['category_id'] = $link_info['category_id']; $form->setDefaults($default); $form->display(); diff --git a/main/course_progress/thematic_advance.php b/main/course_progress/thematic_advance.php index 5b4f437a00..03c37cf4cc 100755 --- a/main/course_progress/thematic_advance.php +++ b/main/course_progress/thematic_advance.php @@ -19,7 +19,12 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { } // display form - $form = new FormValidator('thematic_advance','POST','index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq()); + $form = new FormValidator( + 'thematic_advance', + 'POST', + 'index.php?action=thematic_advance_list&thematic_id='.$thematic_id.'&'.api_get_cidreq( + ) + ); $form->addElement('header', $header_form); //$form->addElement('hidden', 'thematic_advance_token',$token); $form->addElement('hidden', 'action', $action); @@ -68,8 +73,27 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { $form->addElement('html', ''); - $form->addText('duration_in_hours', get_lang('DurationInHours'), false, array('size'=>'3','id'=>'duration_in_hours_element', 'autofocus' => 'autofocus')); - $form->addHtmlEditor('content', get_lang('Content'), false, false, array('ToolbarStartExpanded'=>'false', 'ToolbarSet' => 'TrainingDescription', 'Height' => '150')); + $form->addText( + 'duration_in_hours', + get_lang('DurationInHours'), + false, + array( + 'size' => '3', + 'id' => 'duration_in_hours_element', + 'autofocus' => 'autofocus', + ) + ); + $form->addHtmlEditor( + 'content', + get_lang('Content'), + false, + false, + array( + 'ToolbarStartExpanded' => 'false', + 'ToolbarSet' => 'TrainingDescription', + 'Height' => '150', + ) + ); if ($action == 'thematic_advance_add') { $form->addButtonSave(get_lang('Save')); @@ -131,12 +155,18 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { } else if ($action == 'thematic_advance_list') { // thematic advance list echo '
'; - echo ''.Display::return_icon('back.png', get_lang("BackTo"),'',ICON_SIZE_MEDIUM).''; + echo ''. + Display::return_icon('back.png', get_lang("BackTo"),'',ICON_SIZE_MEDIUM).''; if (api_is_allowed_to_edit(false, true)) { - echo ' '.Display::return_icon('add.png', get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).''; + echo ' '. + Display::return_icon('add.png', get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).''; } echo '
'; - $table = new SortableTable('thematic_advance_list', array('Thematic', 'get_number_of_thematic_advances'), array('Thematic', 'get_thematic_advance_data')); + $table = new SortableTable( + 'thematic_advance_list', + array('Thematic', 'get_number_of_thematic_advances'), + array('Thematic', 'get_thematic_advance_data') + ); //$table->set_additional_parameters($parameters); $table->set_header(0, '', false, array('style'=>'width:20px;')); $table->set_header(1, get_lang('StartDate'), false); @@ -144,7 +174,12 @@ if ($action == 'thematic_advance_add' || $action == 'thematic_advance_edit') { $table->set_header(3, get_lang('Content'), false); if (api_is_allowed_to_edit(null, true)) { - $table->set_header(4, get_lang('Actions'), false,array('style'=>'text-align:center')); + $table->set_header( + 4, + get_lang('Actions'), + false, + array('style' => 'text-align:center') + ); } $table->display(); } diff --git a/main/document/create_document.php b/main/document/create_document.php index 83cfed06f9..4be5f44e85 100755 --- a/main/document/create_document.php +++ b/main/document/create_document.php @@ -521,7 +521,7 @@ if ($form->validate()) { Database::update( $doc_table, $params, - [' c_id = ? AND id = ?' => [$course_id, $document_id]] + ['c_id = ? AND id = ?' => [$course_id, $document_id]] ); } } diff --git a/main/exercice/answer.class.php b/main/exercice/answer.class.php index 9eabc9bc12..4a75bde4ca 100755 --- a/main/exercice/answer.class.php +++ b/main/exercice/answer.class.php @@ -532,7 +532,7 @@ class Answer 'hotspot_coordinates' => $hotspot_coordinates, 'hotspot_type' => $hotspot_type, ]; - Database::update($answerTable, $params, ['id_auto= ?' => $autoId]); + Database::update($answerTable, $params, ['id_auto = ?' => $autoId]); } /** diff --git a/main/exercice/exercise_report.php b/main/exercice/exercise_report.php index e62985beaa..bbc9cd2cb9 100755 --- a/main/exercice/exercise_report.php +++ b/main/exercice/exercise_report.php @@ -185,7 +185,11 @@ if (isset($_REQUEST['comments']) && 'marks' => $my_marks, 'teacher_comment' => $my_comments ]; - Database::update($TBL_TRACK_ATTEMPT, $params, ['question_id = ? AND exe_id = ?' => [$my_questionid, $id]]); + Database::update( + $TBL_TRACK_ATTEMPT, + $params, + ['question_id = ? AND exe_id = ?' => [$my_questionid, $id]] + ); $params = [ 'exe_id' => $id, diff --git a/main/forum/forumfunction.inc.php b/main/forum/forumfunction.inc.php index 4c609819c9..77051d8ee3 100755 --- a/main/forum/forumfunction.inc.php +++ b/main/forum/forumfunction.inc.php @@ -543,7 +543,16 @@ function store_forumcategory($values, $courseInfo = array(), $showMessage = true 'cat_title' => $clean_cat_title, 'cat_comment' => $values['forum_category_comment'], ]; - Database::update($table_categories, $params, ['c_id = ? AND cat_id = ?' => [$course_id, $values['forum_category_id']]]); + Database::update( + $table_categories, + $params, + [ + 'c_id = ? AND cat_id = ?' => [ + $course_id, + $values['forum_category_id'], + ], + ] + ); api_item_property_update( $courseInfo, @@ -3394,13 +3403,14 @@ function store_edit_post($values) } // Update the post_title and the post_text. - $sql = "UPDATE $table_posts SET - post_title ='".Database::escape_string($values['post_title'])."', - post_text ='".Database::escape_string($values['post_text'])."', - post_notification ='".Database::escape_string(isset($values['post_notification']) ? $values['post_notification'] : null)."' - WHERE c_id = $course_id AND post_id = '".intval($values['post_id'])."'"; + $params = [ + 'post_title' => $values['post_title'], + 'post_text' => $values['post_text'], + 'post_notification' => isset($values['post_notification']) ? $values['post_notification'] : '' + ]; + $where = ['c_id = ? AND post_id = ?' => [$course_id, $values['post_id']]]; - Database::query($sql); + Database::update($table_posts, $params, $where); // Update attached files if (!empty($_POST['file_ids']) && is_array($_POST['file_ids'])) { diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index a93e215b05..472fdb4937 100755 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -441,6 +441,7 @@ class Database if (!empty($update_sql)) { //Parsing and cleaning the where conditions $where_return = self::parse_where_conditions($where_conditions); + $sql = "UPDATE $table_name SET $update_sql $where_return "; $statement = self::getManager()->getConnection()->prepare($sql); @@ -521,6 +522,7 @@ class Database $type_condition = strtolower($type_condition); switch ($type_condition) { case 'where': + foreach ($condition_data as $condition => $value_array) { if (is_array($value_array)) { $clean_values = array(); diff --git a/main/inc/lib/thematic.lib.php b/main/inc/lib/thematic.lib.php index 18e8565ebd..49c0d49077 100755 --- a/main/inc/lib/thematic.lib.php +++ b/main/inc/lib/thematic.lib.php @@ -768,10 +768,11 @@ class Thematic 'start_date' => api_get_utc_datetime($start_date), 'duration' => $duration ]; + Database::update( $tbl_thematic_advance, $params, - [['id = ? AND c_id = ?'] => [$id, $this->course_int_id]] + ['id = ? AND c_id = ?' => [$id, $this->course_int_id]] ); api_item_property_update( @@ -781,7 +782,6 @@ class Thematic "ThematicAdvanceUpdated", $user_id ); - } return $last_id;