Fix inserts/updates

1.10.x
Julio Montoya 9 years ago
parent a8b5bf130b
commit a5b4f26fa9
  1. 7
      main/attendance/attendance_edit.php
  2. 49
      main/course_progress/thematic_advance.php
  3. 2
      main/document/create_document.php
  4. 2
      main/exercice/answer.class.php
  5. 6
      main/exercice/exercise_report.php
  6. 24
      main/forum/forumfunction.inc.php
  7. 2
      main/inc/lib/database.lib.php
  8. 4
      main/inc/lib/thematic.lib.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();

@ -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', '</div>');
$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 '<div class="actions">';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_details">'.Display::return_icon('back.png', get_lang("BackTo"),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_details">'.
Display::return_icon('back.png', get_lang("BackTo"),'',ICON_SIZE_MEDIUM).'</a>';
if (api_is_allowed_to_edit(false, true)) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_advance_add&amp;thematic_id='.$thematic_id.'"> '.Display::return_icon('add.png', get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a>';
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;action=thematic_advance_add&amp;thematic_id='.$thematic_id.'"> '.
Display::return_icon('add.png', get_lang('NewThematicAdvance'),'',ICON_SIZE_MEDIUM).'</a>';
}
echo '</div>';
$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();
}

@ -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]]
);
}
}

@ -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]);
}
/**

@ -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,

@ -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'])) {

@ -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();

@ -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;

Loading…
Cancel
Save