Format code, remove unused code.

1.10.x
Julio Montoya 10 years ago
parent c7c85d5c20
commit d62dffa8e6
  1. 3
      main/admin/group_list.php
  2. 38
      main/admin/user_edit.php
  3. 28
      main/dropbox/index.php
  4. 13
      main/exercice/answer.class.php
  5. 10
      main/exercice/exercise_result.php
  6. 12
      main/exercice/question.class.php
  7. 17
      main/inc/ajax/course_home.ajax.php
  8. 4
      main/inc/lib/SequenceManager.php
  9. 16
      main/newscorm/learnpath.class.php
  10. 6
      tests/main/chat/chat_functions.lib.test.php

@ -249,7 +249,8 @@ function lock_unlock_user($status, $user_id) {
}
if (($status_db == '1' OR $status_db == '0') AND is_numeric($user_id)) {
$sql = "UPDATE $user_table SET active=".intval($status_db)." WHERE user_id=".intval($user_id)."";
$sql = "UPDATE $user_table SET active=".intval($status_db)."
WHERE user_id=".intval($user_id)."";
$result = Database::query($sql);
}

@ -396,44 +396,6 @@ if ($form->validate()) {
$extraFieldValue = new ExtraFieldValue('user');
$extraFieldValue->saveFieldValues($user);
/*foreach ($user as $key => $value) {
if (substr($key, 0, 6) == 'extra_') {
//an extra field
//@todo remove this as well as in the profile.php ad put it in a function
if (is_array($value) && isset($value['Y']) && isset($value['F']) && isset($value['d'])) {
if (isset($value['H']) && isset($value['i'])) {
// extra field date time
$time = mktime($value['H'],$value['i'],0,$value['F'],$value['d'],$value['Y']);
$value = date('Y-m-d H:i:s',$time);
} else {
// extra field date
$time = mktime(0,0,0,$value['F'],$value['d'],$value['Y']);
$value = date('Y-m-d',$time);
}
}
// For array $value -> if exists key 'tmp_name' then must not be empty
// This avoid delete from user field value table when doesn't upload a file
if (is_array($value)) {
if (array_key_exists('tmp_name', $value) && empty($value['tmp_name'])) {
//Nothing to do
} else {
if (array_key_exists('tmp_name', $value)) {
$value['tmp_name'] = Security::filter_filename($value['tmp_name']);
}
if (array_key_exists('name', $value)) {
$value['name'] = Security::filter_filename($value['name']);
}
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} else {
UserManager::update_extra_field_value($user_id, substr($key, 6), $value);
}
} elseif (strpos($key, 'remove_extra') !== false) {
$extra_value = Security::filter_filename(urldecode(key($value)));
// To remove from user_field_value and folder
UserManager::update_extra_field_value($user_id, substr($key,13), $extra_value);
}
}*/
$tok = Security::get_token();
header('Location: user_list.php?action=show_message&message='.urlencode(get_lang('UserUpdated')).'&sec_token='.$tok);
exit();

@ -71,15 +71,15 @@ if (isset($_POST['submitWork'])) {
}
// Display the form for adding a category
if ($action == 'addreceivedcategory' or $action == 'addsentcategory') {
if ($action == 'addreceivedcategory' || $action == 'addsentcategory') {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
display_addcategory_form($_POST['category_name'],'',$_GET['action']);
display_addcategory_form($_POST['category_name'], '', $_GET['action']);
}
// Editing a category: displaying the form
if ($action == 'editcategory' and isset($_GET['id'])) {
if ($action == 'editcategory' && isset($_GET['id'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
@ -108,7 +108,7 @@ if (isset($_POST['StoreCategory'])) {
// Move a File
if (($action == 'movesent' OR $action == 'movereceived') AND isset($_GET['move_id'])) {
if (($action == 'movesent' || $action == 'movereceived') AND isset($_GET['move_id'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
@ -127,7 +127,7 @@ if (isset($_POST['do_move'])) {
}
// Delete a file
if (($action == 'deletereceivedfile' OR $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
if (($action == 'deletereceivedfile' || $action == 'deletesentfile') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
@ -144,7 +144,7 @@ if (($action == 'deletereceivedfile' OR $action == 'deletesentfile') AND isset($
}
// Delete a category
if (($action == 'deletereceivedcategory' OR $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
if (($action == 'deletereceivedcategory' || $action == 'deletesentcategory') AND isset($_GET['id']) AND is_numeric($_GET['id'])) {
if (api_get_session_id() != 0 && !api_is_allowed_to_session_edit(false, true)) {
api_not_allowed();
}
@ -205,7 +205,7 @@ if ($action != 'add') {
}
// ACTIONS
if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
//echo '<h3>'.get_lang('ReceivedFiles').'</h3>';
// This is for the categories
@ -242,7 +242,7 @@ if ($action != 'add') {
}
}
if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($viewSentCategory) AND $viewSentCategory != '') {
$view_dropbox_category_sent = $viewSentCategory;
@ -284,7 +284,7 @@ if ($action != 'add') {
if ($dropbox_cnf['sent_received_tabs']) {
?>
<ul class="nav nav-tabs">
<li <?php if (!$view OR $view == 'sent') { echo 'class="active"'; } ?> >
<li <?php if (!$view || $view == 'sent') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=sent" ><?php echo get_lang('SentFiles'); ?></a></li>
<li <?php if ($view == 'received') { echo 'class="active"'; } ?> >
<a href="index.php?<?php echo api_get_cidreq(); ?>&view=received" ><?php echo get_lang('ReceivedFiles'); ?></a></li>
@ -294,7 +294,7 @@ if ($action != 'add') {
/* RECEIVED FILES */
if ($view == 'received' OR !$dropbox_cnf['sent_received_tabs']) {
if ($view == 'received' || !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($viewReceivedCategory) AND $viewReceivedCategory != '') {
$view_dropbox_category_received = $viewReceivedCategory;
@ -303,7 +303,8 @@ if ($action != 'add') {
}
// Object initialisation
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor); // note: are the $is_courseAdmin and $is_courseTutor parameters needed????
$dropbox_person = new Dropbox_Person(api_get_user_id(), $is_courseAdmin, $is_courseTutor);
// note: are the $is_courseAdmin and $is_courseTutor parameters needed????
// Constructing the array that contains the total number of feedback messages per document.
$number_feedback = get_total_number_feedback();
@ -463,7 +464,7 @@ if ($action != 'add') {
/* SENT FILES */
if (!$view OR $view == 'sent' OR !$dropbox_cnf['sent_received_tabs']) {
if (!$view || $view == 'sent' || !$dropbox_cnf['sent_received_tabs']) {
// This is for the categories
if (isset($viewSentCategory) AND $viewSentCategory != '') {
$view_dropbox_category_sent = $viewSentCategory;
@ -576,7 +577,8 @@ if ($action != 'add') {
if ($category['sent'] == '1') {
$moveList[$category['cat_id']] = $category['cat_name'];
$dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear.
$dropbox_category_data[] = $category['cat_id'];
// This is where the checkbox icon for the files appear.
$link_open = '<a href="'.api_get_self().'?'.api_get_cidreq().'&view_received_category='.$viewReceivedCategory.'&view_sent_category='.$category['cat_id'].'&view='.$view.'">';
$dropbox_category_data[] = $link_open.DocumentManager::build_document_icon_tag('folder', Security::remove_XSS($category['cat_name'])).'</a>';
$dropbox_category_data[] = '<a href="dropbox_download.php?'.api_get_cidreq().'&cat_id='.$category['cat_id'].'&action=downloadcategory&sent_received=sent">'.Display::return_icon('save_pack.png', get_lang('Save'), array('style' => 'float:right;'),ICON_SIZE_SMALL).'</a>'.$link_open.Security::remove_XSS($category['cat_name']).'</a>';

@ -622,19 +622,6 @@ class Answer
}
}
/*if (!empty($answerList)) {
foreach ($answerList as $autoId => $counterId) {
$sql = "UPDATE $answerTable SET answer = $autoId
WHERE
answer = $counterId AND
c_id = $c_id AND
question_id = $questionId
";
Database::query($sql);
}
}*/
if (count($this->position) > $this->new_nbrAnswers) {
$i = $this->new_nbrAnswers + 1;
while ($this->position[$i]) {

@ -135,16 +135,6 @@ Display :: display_normal_message(get_lang('Saved').'<br />',false);
// Display and save questions
ExerciseLib::display_question_list_by_attempt($objExercise, $exe_id, true);
//If is not valid
/*
$session_control_key = ExerciseLib::get_session_time_control_key($objExercise->id, $learnpath_id, $learnpath_item_id);
if (isset($session_control_key) && !ExerciseLib::exercise_time_control_is_valid($objExercise->id, $learnpath_id, $learnpath_item_id)) {
$TBL_TRACK_ATTEMPT = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT);
$sql_fraud = "UPDATE $TBL_TRACK_ATTEMPT SET answer = 0, marks = 0, position = 0 WHERE exe_id = $exe_id ";
Database::query($sql_fraud);
}*/
//Unset session for clock time
ExerciseLib::exercise_time_control_delete($objExercise->id, $learnpath_id, $learnpath_item_id);
ExerciseLib::delete_chat_exercise_session($exe_id);

@ -380,10 +380,7 @@ abstract class Question
$res = Database::query($sql);
$row = Database::fetch_array($res);
if ($row['nb'] > 0) {
//DO nothing
//$sql = "UPDATE $TBL_QUESTION_REL_CATEGORY SET category_id = $category_id
//WHERE question_id=$question_id AND c_id=".api_get_course_int_id();
//$res = Database::query($sql);
// DO nothing
} else {
$sql = "INSERT INTO $TBL_QUESTION_REL_CATEGORY (c_id, question_id, category_id)
VALUES (" . api_get_course_int_id() . ", $question_id, $category_id)";
@ -910,13 +907,6 @@ abstract class Question
// if the question is created in an exercise
if ($exerciseId) {
/*
$sql = 'UPDATE '.Database::get_course_table(TABLE_LP_ITEM).'
SET max_score = '.intval($weighting).'
WHERE item_type = "'.TOOL_QUIZ.'"
AND path='.intval($exerciseId);
Database::query($sql);
*/
// adds the exercise into the exercise list of this question
$this->addToList($exerciseId, TRUE);
}

@ -49,23 +49,6 @@ switch ($action) {
// HIDE AND REACTIVATE TOOL
if ($_GET["id"] == strval(intval($_GET["id"]))) {
/* -- session condition for visibility
if (!empty($session_id)) {
$sql = "select session_id FROM $tool_table WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
$rs = Database::query($sql);
if (Database::num_rows($rs) > 0) {
$sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."' AND session_id = '$session_id'";
} else {
$sql_select = "select * FROM $tool_table WHERE id='".$_GET["id"]."'";
$res_select = Database::query($sql_select);
$row_select = Database::fetch_array($res_select);
$sql = "INSERT INTO $tool_table(name,link,image,visibility,admin,address,added_tool,target,category,session_id)
VALUES('{$row_select['name']}','{$row_select['link']}','{$row_select['image']}','0','{$row_select['admin']}','{$row_select['address']}','{$row_select['added_tool']}','{$row_select['target']}','{$row_select['category']}','$session_id')";
}
} else $sql="UPDATE $tool_table SET visibility=$requested_visible WHERE id='".$_GET["id"]."'";
*/
$sql = "UPDATE $tool_table SET
visibility = $requested_visible
WHERE c_id = $course_id AND id='" . intval($_GET['id']) . "'";

@ -1017,10 +1017,6 @@ class SequenceManager
if ($row_entity_id_prev !== 0 || $row_entity_id_next !== 0) {
$seq_table = Database::get_main_table(TABLE_MAIN_SEQUENCE);
// Old code
/*$sql = "UPDATE $seq_table SET sequence_row_entity_id = $row_entity_id_prev WHERE sequence_row_entity_id_next = $row_entity_id_next";
Database::query($sql);*/
// Check if exists.
$sql = "SELECT count(*) as count FROM $seq_table

@ -998,22 +998,6 @@ class learnpath
return false;
}
$this->current_time_stop = time();
if ($this->save) {
/*
$learnpath_view_table = Database :: get_course_table(TABLE_LP_VIEW);
$sql = "UPDATE $learnpath_view_table " .
"SET " .
"stop_time = ".$this->current_time_stop.", " .
"score = ".$this->current_score.", ".
"WHERE learnpath_id = '".$this->lp_id."'";
//$res = Database::query($sql);
$res = Database::query($res);
if (Database::affected_rows($res) < 1) {
$this->error = 'Could not update learnpath_view table while closing learnpath';
return false;
}
*/
}
$this->ordered_items = array();
$this->index = 0;
unset ($this->lp_id);

@ -43,9 +43,11 @@ class TestChatFunctions extends UnitTestCase {
//The user_id exists so we must do an UPDATE and not a INSERT
$current_time = date('Y-m-d H:i:s');
if (Database::num_rows($result)==0) {
$query="INSERT INTO $tbl_chat_connected(user_id,last_connection,session_id) VALUES(1,'$current_time','$session_id')";
$query="INSERT INTO $tbl_chat_connected(user_id,last_connection,session_id)
VALUES(1,'$current_time','$session_id')";
} else {
$query="UPDATE $tbl_chat_connected set last_connection='".$current_time."' WHERE user_id=1 AND session_id='$session_id'";
$query="UPDATE $tbl_chat_connected set last_connection='".$current_time."'
WHERE user_id=1 AND session_id='$session_id'";
}
Database::query($query);
}

Loading…
Cancel
Save