diff --git a/main/gradebook/index.php b/main/gradebook/index.php index 319dcc5ed0..e0590b803f 100755 --- a/main/gradebook/index.php +++ b/main/gradebook/index.php @@ -94,7 +94,7 @@ $filter_confirm_msg = true; $filter_warning_msg = true; $courseInfo = api_get_course_info(); -$cats = Category:: load( +$cats = Category::load( null, null, $course_code, @@ -107,7 +107,7 @@ $first_time = null; if (empty($cats)) { // first time - $cats = Category:: load( + $cats = Category::load( 0, null, $course_code, @@ -194,7 +194,7 @@ if (isset($_GET['movecat'])) { //move an evaluation if (isset($_GET['moveeval'])) { GradebookUtils::block_students(); - $evals = Evaluation :: load($_GET['moveeval']); + $evals = Evaluation::load($_GET['moveeval']); if (!isset($_GET['targetcat'])) { $move_form = new EvalForm( EvalForm::TYPE_MOVE, @@ -212,7 +212,7 @@ if (isset($_GET['moveeval'])) { exit; } } else { - $targetcat = Category :: load($_GET['targetcat']); + $targetcat = Category::load($_GET['targetcat']); $course_to_crsind = ($evals[0]->get_course_code() != null && $targetcat[0]->get_course_code() == null); if (!($course_to_crsind && !isset($_GET['confirm']))) { @@ -228,7 +228,7 @@ if (isset($_GET['moveeval'])) { //move a link if (isset($_GET['movelink'])) { GradebookUtils::block_students(); - $link = LinkFactory :: load($_GET['movelink']); + $link = LinkFactory::load($_GET['movelink']); $move_form = new LinkForm( LinkForm::TYPE_MOVE, null, @@ -256,7 +256,7 @@ if (isset($_GET['visiblecat'])) { } else { $visibility_command = 0; } - $cats = Category :: load($_GET['visiblecat']); + $cats = Category::load($_GET['visiblecat']); $cats[0]->set_visible($visibility_command); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); @@ -271,7 +271,7 @@ if (isset($_GET['visiblecat'])) { } if (isset($_GET['deletecat'])) { GradebookUtils::block_students(); - $cats = Category :: load($_GET['deletecat']); + $cats = Category::load($_GET['deletecat']); if (isset($cats[0])) { //delete all categories,subcategories and results if ($cats[0] != null) { @@ -293,7 +293,7 @@ if (isset($_GET['visibleeval'])) { } else { $visibility_command = 0; } - $eval = Evaluation :: load($_GET['visibleeval']); + $eval = Evaluation::load($_GET['visibleeval']); $eval[0]->set_visible($visibility_command); $eval[0]->save(); unset($eval); @@ -317,7 +317,7 @@ if (isset($_GET['lockedeval'])) { $type_locked = 1; $confirmation_message = get_lang('EvaluationHasBeenLocked'); } - $eval = Evaluation :: load($locked); + $eval = Evaluation::load($locked); if ($eval[0] != null) { $eval[0]->lock($type_locked); } @@ -327,7 +327,7 @@ if (isset($_GET['lockedeval'])) { if (isset($_GET['deleteeval'])) { GradebookUtils::block_students(); - $eval = Evaluation :: load($_GET['deleteeval']); + $eval = Evaluation::load($_GET['deleteeval']); if ($eval[0] != null) { $eval[0]->delete_with_results(); } @@ -343,7 +343,7 @@ if (isset($_GET['visiblelink'])) { } else { $visibility_command = 0; } - $link = LinkFactory :: load($_GET['visiblelink']); + $link = LinkFactory::load($_GET['visiblelink']); if (isset($link) && isset($link[0])) { $link[0]->set_visible($visibility_command); $link[0]->save(); @@ -365,7 +365,7 @@ if (isset($_GET['deletelink'])) { $get_delete_link = intval($_GET['deletelink']); //fixing #5229 if (!empty($get_delete_link)) { - $link = LinkFactory :: load($get_delete_link); + $link = LinkFactory::load($get_delete_link); if ($link[0] != null) { // Clean forum qualify $sql = 'UPDATE '.$tbl_forum_thread.' SET @@ -445,14 +445,14 @@ if (isset($_POST['action'])) { $number_of_deleted_links = 0; foreach ($_POST['id'] as $indexstr) { if (substr($indexstr, 0, 4) == 'CATE') { - $cats = Category :: load(substr($indexstr, 4)); + $cats = Category::load(substr($indexstr, 4)); if ($cats[0] != null) { $cats[0]->delete_all(); } $number_of_deleted_categories++; } if (substr($indexstr, 0, 4) == 'EVAL') { - $eval = Evaluation :: load(substr($indexstr, 4)); + $eval = Evaluation::load(substr($indexstr, 4)); if ($eval[0] != null) { $eval[0]->delete_with_results(); } @@ -463,7 +463,7 @@ if (isset($_POST['action'])) { //fixing #5229 $id = substr($indexstr, 4); if (!empty($id)) { - $link = LinkFactory :: load($id); + $link = LinkFactory::load($id); if ($link[0] != null) { $link[0]->delete(); } @@ -477,18 +477,18 @@ if (isset($_POST['action'])) { case 'setvisible': foreach ($_POST['id'] as $indexstr) { if (substr($indexstr, 0, 4) == 'CATE') { - $cats = Category :: load(substr($indexstr, 4)); + $cats = Category::load(substr($indexstr, 4)); $cats[0]->set_visible(1); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } if (substr($indexstr, 0, 4) == 'EVAL') { - $eval = Evaluation :: load(substr($indexstr, 4)); + $eval = Evaluation::load(substr($indexstr, 4)); $eval[0]->set_visible(1); $eval[0]->save(); } if (substr($indexstr, 0, 4) == 'LINK') { - $link = LinkFactory :: load(substr($indexstr, 4)); + $link = LinkFactory::load(substr($indexstr, 4)); $link[0]->set_visible(1); $link[0]->save(); } @@ -499,18 +499,18 @@ if (isset($_POST['action'])) { case 'setinvisible': foreach ($_POST['id'] as $indexstr) { if (substr($indexstr, 0, 4) == 'CATE') { - $cats = Category :: load(substr($indexstr, 4)); + $cats = Category::load(substr($indexstr, 4)); $cats[0]->set_visible(0); $cats[0]->save(); $cats[0]->apply_visibility_to_children(); } if (substr($indexstr, 0, 4) == 'EVAL') { - $eval = Evaluation :: load(substr($indexstr, 4)); + $eval = Evaluation::load(substr($indexstr, 4)); $eval[0]->set_visible(0); $eval[0]->save(); } if (substr($indexstr, 0, 4) == 'LINK') { - $link = LinkFactory :: load(substr($indexstr, 4)); + $link = LinkFactory::load(substr($indexstr, 4)); $link[0]->set_visible(0); $link[0]->save(); } @@ -604,12 +604,12 @@ $simple_search_form = ''; if (isset($_GET['studentoverview'])) { //@todo this code also seems to be deprecated ... - $cats = Category :: load($selectCat); + $cats = Category::load($selectCat); $stud_id = (api_is_allowed_to_edit() ? null : $stud_id); $allcat = $cats[0]->get_subcategories($stud_id, $course_code, $session_id); $alleval = $cats[0]->get_evaluations($stud_id, true); $alllink = $cats[0]->get_links($stud_id, true); - if (isset ($_GET['exportpdf'])) { + if (isset($_GET['exportpdf'])) { $datagen = new GradebookDataGenerator($allcat, $alleval, $alllink); $header_names = array( get_lang('Name'), @@ -619,7 +619,7 @@ if (isset($_GET['studentoverview'])) { get_lang('Results') ); $data_array = $datagen->get_data( - GradebookDataGenerator :: GDG_SORT_NAME, + GradebookDataGenerator::GDG_SORT_NAME, 0, null, true diff --git a/main/inc/lib/TicketManager.php b/main/inc/lib/TicketManager.php index b4d1be4a0a..2c196fe33f 100644 --- a/main/inc/lib/TicketManager.php +++ b/main/inc/lib/TicketManager.php @@ -1510,7 +1510,7 @@ class TicketManager } else { $row['assignuser'] = get_lang('Unassign'); } - $row['assigned_date'] = date_to_str_ago($row['assigned_date']); + $row['assigned_date'] = Display::dateToStringAgoAndLongDate($row['assigned_date']); $insertuser = api_get_user_info($row['sys_insert_user_id']); $row['insertuser'] = ''. $insertuser['username'].''; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index 94e6e687ef..4ce23c57ae 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -4341,36 +4341,6 @@ function api_display_language_form($hide_if_no_choice = false, $showAsButton = f $currentLanguageId = api_get_language_id($user_selected_language); $currentLanguageInfo = api_get_language_info($currentLanguageId); - - $original_languages = $language_list['name']; - $folder = $language_list['folder']; // This line is probably no longer needed. - /*$html = '';*/ - //$html .= '
'; - //$html .= ''; - /*$html .= '';*/ $countryCode = languageToCountryIsoCode($currentLanguageInfo['isocode']); $url = api_get_self(); if ($showAsButton) { diff --git a/main/inc/lib/course_category.lib.php b/main/inc/lib/course_category.lib.php index 8016ed70b8..c382a584fe 100755 --- a/main/inc/lib/course_category.lib.php +++ b/main/inc/lib/course_category.lib.php @@ -13,9 +13,9 @@ class CourseCategory */ public static function getCategoryById($categoryId) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $categoryId = intval($categoryId); - $sql = "SELECT * FROM $tbl_category WHERE id = $categoryId"; + $sql = "SELECT * FROM $table WHERE id = $categoryId"; $result = Database::query($sql); if (Database::num_rows($result)) { return Database::fetch_array($result, 'ASSOC'); @@ -31,9 +31,9 @@ class CourseCategory */ public static function getCategory($category) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $category = Database::escape_string($category); - $sql = "SELECT * FROM $tbl_category WHERE code ='$category'"; + $sql = "SELECT * FROM $table WHERE code ='$category'"; $result = Database::query($sql); if (Database::num_rows($result)) { return Database::fetch_array($result, 'ASSOC'); @@ -102,19 +102,19 @@ class CourseCategory */ public static function addNode($code, $name, $canHaveCourses, $parent_id) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $code = trim($code); $name = trim($name); $parent_id = trim($parent_id); $code = CourseManager::generate_course_code($code); - $sql = "SELECT 1 FROM $tbl_category + $sql = "SELECT 1 FROM $table WHERE code = '".Database::escape_string($code)."'"; $result = Database::query($sql); if (Database::num_rows($result)) { return false; } - $result = Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $tbl_category"); + $result = Database::query("SELECT MAX(tree_pos) AS maxTreePos FROM $table"); $row = Database::fetch_array($result); $tree_pos = $row['maxTreePos'] + 1; @@ -128,7 +128,7 @@ class CourseCategory 'auth_cat_child' => 'TRUE' ]; - $categoryId = Database::insert($tbl_category, $params); + $categoryId = Database::insert($table, $params); self::updateParentCategoryChildrenCount($parent_id, 1); self::addToUrl($categoryId); @@ -143,11 +143,11 @@ class CourseCategory */ public static function updateParentCategoryChildrenCount($categoryId, $delta = 1) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $categoryId = Database::escape_string($categoryId); $delta = intval($delta); // First get to the highest level possible in the tree - $result = Database::query("SELECT parent_id FROM $tbl_category WHERE code = '$categoryId'"); + $result = Database::query("SELECT parent_id FROM $table WHERE code = '$categoryId'"); $row = Database::fetch_array($result); if ($row !== false and $row['parent_id'] != 0) { // if a parent was found, enter there to see if he's got one more parent @@ -156,10 +156,10 @@ class CourseCategory // Now we're at the top, get back down to update each child //$children_count = courseCategoryChildrenCount($categoryId); if ($delta >= 0) { - $sql = "UPDATE $tbl_category SET children_count = (children_count + $delta) + $sql = "UPDATE $table SET children_count = (children_count + $delta) WHERE code = '$categoryId'"; } else { - $sql = "UPDATE $tbl_category SET children_count = (children_count - ".abs($delta).") + $sql = "UPDATE $table SET children_count = (children_count - ".abs($delta).") WHERE code = '$categoryId'"; } Database::query($sql); @@ -244,7 +244,7 @@ class CourseCategory */ public static function moveNodeUp($code, $tree_pos, $parent_id) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $code = Database::escape_string($code); $tree_pos = intval($tree_pos); $parent_id = Database::escape_string($parent_id); @@ -255,7 +255,7 @@ class CourseCategory } $sql = "SELECT code,tree_pos - FROM $tbl_category + FROM $table WHERE tree_pos < $tree_pos $parentIdCondition @@ -265,7 +265,7 @@ class CourseCategory $result = Database::query($sql); if (!$row = Database::fetch_array($result)) { $sql = "SELECT code, tree_pos - FROM $tbl_category + FROM $table WHERE tree_pos > $tree_pos $parentIdCondition @@ -277,12 +277,12 @@ class CourseCategory } } - $sql = "UPDATE $tbl_category + $sql = "UPDATE $table SET tree_pos ='".$row['tree_pos']."' WHERE code='$code'"; Database::query($sql); - $sql = "UPDATE $tbl_category + $sql = "UPDATE $table SET tree_pos = '$tree_pos' WHERE code= '".$row['code']."'"; Database::query($sql); @@ -298,19 +298,19 @@ class CourseCategory */ public static function courseCategoryChildrenCount($categoryId) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $categoryId = intval($categoryId); $count = 0; if (empty($categoryId)) { return 0; } - $sql = "SELECT id, code FROM $tbl_category + $sql = "SELECT id, code FROM $table WHERE parent_id = $categoryId"; $result = Database::query($sql); while ($row = Database::fetch_array($result)) { $count += self::courseCategoryChildrenCount($row['id']); } - $sql = "UPDATE $tbl_category SET + $sql = "UPDATE $table SET children_count = $count WHERE id = $categoryId"; Database::query($sql); @@ -325,9 +325,9 @@ class CourseCategory */ public static function getChildren($categoryCode) { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $categoryCode = Database::escape_string($categoryCode); - $sql = "SELECT code, id FROM $tbl_category + $sql = "SELECT code, id FROM $table WHERE parent_id = '$categoryCode'"; $result = Database::query($sql); $children = []; @@ -351,10 +351,10 @@ class CourseCategory return []; } - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $categoryCode = Database::escape_string($categoryCode); $sql = "SELECT code, parent_id - FROM $tbl_category + FROM $table WHERE code = '$categoryCode'"; $result = Database::query($sql); @@ -481,8 +481,8 @@ class CourseCategory */ public static function getCategoriesToDisplayInHomePage() { - $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); - $sql = "SELECT name FROM $tbl_category + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); + $sql = "SELECT name FROM $table WHERE parent_id IS NULL ORDER BY tree_pos"; diff --git a/main/inc/lib/glossary.lib.php b/main/inc/lib/glossary.lib.php index 9d8119645f..ef1d9223c7 100755 --- a/main/inc/lib/glossary.lib.php +++ b/main/inc/lib/glossary.lib.php @@ -24,13 +24,13 @@ class GlossaryManager public static function get_glossary_terms() { $glossary_data = array(); - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $session_id = api_get_session_id(); $sql_filter = api_get_session_condition($session_id); $course_id = api_get_course_int_id(); $sql = "SELECT glossary_id as id, name, description - FROM $glossary_table + FROM $table WHERE c_id = $course_id $sql_filter"; $rs = Database::query($sql); while ($row = Database::fetch_array($rs)) { @@ -49,9 +49,10 @@ class GlossaryManager */ public static function get_glossary_term_by_glossary_id($glossary_id) { - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); - $sql = "SELECT description FROM $glossary_table + $sql = "SELECT description + FROM $table WHERE c_id = $course_id AND glossary_id =".intval($glossary_id); $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { @@ -72,11 +73,11 @@ class GlossaryManager */ public static function get_glossary_term_by_glossary_name($glossary_name) { - $glossary_table = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $session_id = api_get_session_id(); $course_id = api_get_course_int_id(); $sql_filter = api_get_session_condition($session_id); - $sql = 'SELECT * FROM '.$glossary_table.' + $sql = 'SELECT * FROM '.$table.' WHERE c_id = '.$course_id.' AND name LIKE trim("'.Database::escape_string($glossary_name).'")'.$sql_filter; @@ -105,7 +106,7 @@ class GlossaryManager } // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); // get the maximum display order of all the glossary items $max_glossary_item = self::get_max_glossary_item(); @@ -131,10 +132,10 @@ class GlossaryManager 'display_order' => $max_glossary_item + 1, 'session_id' => $session_id, ]; - $id = Database::insert($t_glossary, $params); + $id = Database::insert($table, $params); if ($id) { - $sql = "UPDATE $t_glossary SET glossary_id = $id WHERE iid = $id"; + $sql = "UPDATE $table SET glossary_id = $id WHERE iid = $id"; Database::query($sql); //insert into item_property @@ -166,7 +167,7 @@ class GlossaryManager public static function update_glossary($values, $showMessage = true) { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); // check if the glossary term already exists @@ -180,7 +181,7 @@ class GlossaryManager return false; } else { - $sql = "UPDATE $t_glossary SET + $sql = "UPDATE $table SET name = '".Database::escape_string($values['name'])."', description = '".Database::escape_string($values['description'])."' WHERE @@ -218,9 +219,9 @@ class GlossaryManager public static function get_max_glossary_item() { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); - $get_max = "SELECT MAX(display_order) FROM $t_glossary + $get_max = "SELECT MAX(display_order) FROM $table WHERE c_id = $course_id "; $res_max = Database::query($get_max); if (Database::num_rows($res_max) == 0) { @@ -245,10 +246,10 @@ class GlossaryManager public static function glossary_exists($term, $not_id = '') { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); - $sql = "SELECT name FROM $t_glossary + $sql = "SELECT name FROM $table WHERE c_id = $course_id AND name = '".Database::escape_string($term)."'"; @@ -314,7 +315,7 @@ class GlossaryManager public static function delete_glossary($glossary_id, $showMessage = true) { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); $glossaryInfo = self::get_glossary_information($glossary_id); @@ -324,7 +325,7 @@ class GlossaryManager $glossary_id = (int) $glossary_id; - $sql = "DELETE FROM $t_glossary + $sql = "DELETE FROM $table WHERE c_id = $course_id AND glossary_id='".$glossary_id."'"; @@ -384,7 +385,6 @@ class GlossaryManager // parameter for view type. Meanwhile, use this cheap trick. $view = self::getGlossaryView(); // action links - //echo '
'; $actionsLeft = ''; if (api_is_allowed_to_edit(null, true)) { $actionsLeft .= ''. @@ -473,9 +473,9 @@ class GlossaryManager */ public static function displayGlossaryList() { - $glossary_data = self::get_glossary_data(0, 1000, 0, 'ASC'); + $glossaryList = self::get_glossary_data(0, 1000, 0, 'ASC'); $content = ''; - foreach ($glossary_data as $key => $glossary_item) { + foreach ($glossaryList as $key => $glossary_item) { $actions = ''; if (api_is_allowed_to_edit(null, true)) { $actions = '
'.self::actions_filter($glossary_item[2], '', $glossary_item).'
'; @@ -665,16 +665,16 @@ class GlossaryManager public static function reorder_glossary() { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $t_glossary + $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER by display_order ASC"; $res = Database::query($sql); $i = 1; while ($data = Database::fetch_array($res)) { - $sql = "UPDATE $t_glossary SET display_order = $i + $sql = "UPDATE $table SET display_order = $i WHERE c_id = $course_id AND glossary_id = '".intval($data['glossary_id'])."'"; Database::query($sql); $i++; @@ -690,7 +690,7 @@ class GlossaryManager public static function move_glossary($direction, $glossary_id) { // Database table definition - $t_glossary = Database::get_course_table(TABLE_GLOSSARY); + $table = Database::get_course_table(TABLE_GLOSSARY); // sort direction if ($direction === 'up') { @@ -700,7 +700,7 @@ class GlossaryManager } $course_id = api_get_course_int_id(); - $sql = "SELECT * FROM $t_glossary + $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER BY display_order $sortorder"; $res = Database::query($sql); @@ -717,9 +717,10 @@ class GlossaryManager $found = true; } } - $sql1 = "UPDATE $t_glossary SET display_order = '".Database::escape_string($next_display_order)."' + + $sql1 = "UPDATE $table SET display_order = '".Database::escape_string($next_display_order)."' WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($current_id)."'"; - $sql2 = "UPDATE $t_glossary SET display_order = '".Database::escape_string($current_display_order)."' + $sql2 = "UPDATE $table SET display_order = '".Database::escape_string($current_display_order)."' WHERE c_id = $course_id AND glossary_id = '".Database::escape_string($next_id)."'"; Database::query($sql1); Database::query($sql2); diff --git a/main/inc/lib/grade_model.lib.php b/main/inc/lib/grade_model.lib.php index b55c3ea768..0f7daa4182 100755 --- a/main/inc/lib/grade_model.lib.php +++ b/main/inc/lib/grade_model.lib.php @@ -51,17 +51,17 @@ class GradeModel extends Model /** * Displays the title + grid */ - public function display() + public function display() { - // action links - echo '
'; echo Display::grid_html('grade_model'); - } + } /** * Returns a Form validator Obj @@ -81,10 +81,10 @@ class GradeModel extends Model if ($action == 'edit') { $header = get_lang('Modify'); } - - $form->addElement('header', $header); $id = isset($_GET['id']) ? intval($_GET['id']) : ''; - $form->addElement('hidden', 'id', $id); + + $form->addHeader($header); + $form->addHidden('id', $id); $form->addText('name', get_lang('Name')); $form->addHtmlEditor( 'description', @@ -281,7 +281,6 @@ class GradeModel extends Model } $form->addElement('select', $name, get_lang('GradeModel'), $grade_model_options); $default_platform_setting = api_get_setting('gradebook_default_grade_model_id'); - $default = -1; if ($default_platform_setting == -1) { diff --git a/main/inc/lib/gradebook.lib.php b/main/inc/lib/gradebook.lib.php index 6dfd77ede4..b524a924f9 100755 --- a/main/inc/lib/gradebook.lib.php +++ b/main/inc/lib/gradebook.lib.php @@ -203,7 +203,8 @@ class Gradebook extends Model public function getSkillsByGradebook($gradebook_id) { $gradebook_id = intval($gradebook_id); - $sql = "SELECT skill.id, skill.name FROM {$this->table_skill} skill + $sql = "SELECT skill.id, skill.name + FROM {$this->table_skill} skill INNER JOIN {$this->table_skill_rel_gradebook} skill_rel_gradebook ON skill.id = skill_rel_gradebook.skill_id WHERE skill_rel_gradebook.gradebook_id = $gradebook_id"; diff --git a/main/inc/lib/groupmanager.lib.php b/main/inc/lib/groupmanager.lib.php index b4ad1f1cc1..f0a5cb4df7 100755 --- a/main/inc/lib/groupmanager.lib.php +++ b/main/inc/lib/groupmanager.lib.php @@ -665,9 +665,9 @@ class GroupManager public static function get_number_of_groups() { $course_id = api_get_course_int_id(); - $table_group = Database::get_course_table(TABLE_GROUP); + $table = Database::get_course_table(TABLE_GROUP); $sql = "SELECT COUNT(id) AS number_of_groups - FROM $table_group + FROM $table WHERE c_id = $course_id "; $res = Database::query($sql); $obj = Database::fetch_object($res); @@ -684,8 +684,8 @@ class GroupManager { $course_info = api_get_course_info($course_code); $course_id = $course_info['real_id']; - $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); - $sql = "SELECT * FROM $table_group_cat + $table = Database::get_course_table(TABLE_GROUP_CATEGORY); + $sql = "SELECT * FROM $table WHERE c_id = $course_id ORDER BY display_order"; $res = Database::query($sql); @@ -711,8 +711,8 @@ class GroupManager $course_info = api_get_course_info($course_code); $course_id = $course_info['real_id']; $id = intval($id); - $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); - $sql = "SELECT * FROM $table_group_cat + $table = Database::get_course_table(TABLE_GROUP_CATEGORY); + $sql = "SELECT * FROM $table WHERE c_id = $course_id AND id = $id LIMIT 1"; $res = Database::query($sql); @@ -737,8 +737,8 @@ class GroupManager $course_info = api_get_course_info($course_code); $course_id = $course_info['real_id']; $title = Database::escape_string($title); - $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); - $sql = "SELECT * FROM $table_group_cat + $table = Database::get_course_table(TABLE_GROUP_CATEGORY); + $sql = "SELECT * FROM $table WHERE c_id = $course_id AND title = '$title' LIMIT 1"; $res = Database::query($sql); @@ -940,12 +940,12 @@ class GroupManager $maximum_number_of_students, $groups_per_user ) { - $table_group_category = Database::get_course_table(TABLE_GROUP_CATEGORY); + $table = Database::get_course_table(TABLE_GROUP_CATEGORY); $id = intval($id); $course_id = api_get_course_int_id(); - $sql = "UPDATE ".$table_group_category." SET + $sql = "UPDATE ".$table." SET title='".Database::escape_string($title)."', description='".Database::escape_string($description)."', doc_state = '".Database::escape_string($doc_state)."', @@ -1022,22 +1022,22 @@ class GroupManager */ public static function swap_category_order($id1, $id2) { - $table_group_cat = Database::get_course_table(TABLE_GROUP_CATEGORY); + $table = Database::get_course_table(TABLE_GROUP_CATEGORY); $id1 = intval($id1); $id2 = intval($id2); $course_id = api_get_course_int_id(); - $sql = "SELECT id, display_order FROM $table_group_cat + $sql = "SELECT id, display_order FROM $table WHERE id IN ($id1,$id2) AND c_id = $course_id "; $res = Database::query($sql); $cat1 = Database::fetch_object($res); $cat2 = Database::fetch_object($res); if ($cat1 && $cat2) { - $sql = "UPDATE $table_group_cat SET display_order=$cat2->display_order - WHERE id = $cat1->id AND c_id = $course_id "; + $sql = "UPDATE $table SET display_order=$cat2->display_order + WHERE id = $cat1->id AND c_id = $course_id "; Database::query($sql); - $sql = "UPDATE $table_group_cat SET display_order=$cat1->display_order + $sql = "UPDATE $table SET display_order=$cat1->display_order WHERE id = $cat2->id AND c_id = $course_id "; Database::query($sql); } @@ -1223,14 +1223,14 @@ class GroupManager public static function get_groups_users($groups = []) { $result = array(); - $tbl_group_user = Database::get_course_table(TABLE_GROUP_USER); + $table = Database::get_course_table(TABLE_GROUP_USER); $course_id = api_get_course_int_id(); $groups = array_map('intval', $groups); // protect individual elements with surrounding quotes $groups = implode(', ', $groups); $sql = "SELECT DISTINCT user_id - FROM $tbl_group_user gu + FROM $table gu WHERE c_id = $course_id AND gu.group_id IN ($groups)"; $rs = Database::query($sql); while ($row = Database::fetch_array($rs)) { @@ -1321,7 +1321,7 @@ class GroupManager */ public static function number_of_students($group_id, $course_id = null) { - $table_group_user = Database::get_course_table(TABLE_GROUP_USER); + $table = Database::get_course_table(TABLE_GROUP_USER); $group_id = intval($group_id); if (empty($course_id)) { $course_id = api_get_course_int_id(); @@ -1329,7 +1329,7 @@ class GroupManager $course_id = intval($course_id); } $sql = "SELECT COUNT(*) AS number_of_students - FROM $table_group_user + FROM $table WHERE c_id = $course_id AND group_id = $group_id"; $result = Database::query($sql); $db_object = Database::fetch_object($result); @@ -1344,10 +1344,10 @@ class GroupManager */ public static function maximum_number_of_students($group_id) { - $table_group = Database::get_course_table(TABLE_GROUP); + $table = Database::get_course_table(TABLE_GROUP); $group_id = intval($group_id); $course_id = api_get_course_int_id(); - $sql = "SELECT max_student FROM $table_group + $sql = "SELECT max_student FROM $table WHERE c_id = $course_id AND iid = $group_id"; $db_result = Database::query($sql); $db_object = Database::fetch_object($db_result); @@ -1405,10 +1405,10 @@ class GroupManager return false; } $groupIid = $groupInfo['iid']; - $table_group = Database::get_course_table(TABLE_GROUP); + $table = Database::get_course_table(TABLE_GROUP); if (isset($groupIid)) { $sql = "SELECT status, self_registration_allowed - FROM $table_group + FROM $table WHERE c_id = $course_id AND iid = $groupIid"; $result = Database::query($sql); $group = Database::fetch_object($result); @@ -1435,11 +1435,11 @@ class GroupManager return false; } $groupIid = $groupInfo['iid']; - $table_group = Database::get_course_table(TABLE_GROUP); + $table = Database::get_course_table(TABLE_GROUP); $course_id = api_get_course_int_id(); $sql = "SELECT status, self_unregistration_allowed - FROM $table_group + FROM $table WHERE c_id = $course_id AND iid = $groupIid"; $result = Database::query($sql); $group = Database::fetch_object($result); @@ -1463,11 +1463,11 @@ class GroupManager if (empty($user_id) || empty($groupInfo) || empty($course_id)) { return false; } - $table_group_user = Database::get_course_table(TABLE_GROUP_USER); + $table = Database::get_course_table(TABLE_GROUP_USER); $group_id = intval($groupInfo['id']); $user_id = intval($user_id); - $sql = "SELECT 1 FROM $table_group_user + $sql = "SELECT 1 FROM $table WHERE c_id = $course_id AND group_id = $group_id AND diff --git a/main/inc/lib/legal.lib.php b/main/inc/lib/legal.lib.php index d4c5184c15..e3e610476b 100755 --- a/main/inc/lib/legal.lib.php +++ b/main/inc/lib/legal.lib.php @@ -79,9 +79,9 @@ class LegalManager */ public static function get_last_condition_version($language) { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $language = Database::escape_string($language); - $sql = "SELECT version FROM $legal_conditions_table + $sql = "SELECT version FROM $table WHERE language_id = '".$language."' ORDER BY id DESC LIMIT 1 "; $result = Database::query($sql); @@ -100,9 +100,9 @@ class LegalManager */ public static function get_last_condition($language) { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $language = Database::escape_string($language); - $sql = "SELECT * FROM $legal_conditions_table + $sql = "SELECT * FROM $table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 "; @@ -175,9 +175,9 @@ class LegalManager */ public static function get_last_version($language) { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $language = intval($language); - $sql = "SELECT version FROM $legal_conditions_table + $sql = "SELECT version FROM $table WHERE language_id = '".$language."' ORDER BY version DESC LIMIT 1 "; @@ -241,14 +241,14 @@ class LegalManager */ public static function get_legal_data($from, $number_of_items, $column) { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $lang_table = Database::get_main_table(TABLE_MAIN_LANGUAGE); $from = intval($from); $number_of_items = intval($number_of_items); $column = intval($column); $sql = "SELECT version, original_name as language, content, changes, type, FROM_UNIXTIME(date) - FROM $legal_conditions_table + FROM $table INNER JOIN $lang_table l ON (language_id = l.id) ORDER BY language, version ASC @@ -279,9 +279,9 @@ class LegalManager */ public static function count() { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $sql = "SELECT count(*) as count_result - FROM $legal_conditions_table + FROM $table ORDER BY id DESC "; $result = Database::query($sql); $url = Database::fetch_array($result, 'ASSOC'); @@ -298,11 +298,11 @@ class LegalManager */ public static function get_type_of_terms_and_conditions($legal_id, $language_id) { - $legal_conditions_table = Database::get_main_table(TABLE_MAIN_LEGAL); + $table = Database::get_main_table(TABLE_MAIN_LEGAL); $legal_id = intval($legal_id); $language_id = intval($language_id); - $sql = 'SELECT type FROM '.$legal_conditions_table.' - WHERE id = "'.$legal_id.'" AND language_id="'.$language_id.'"'; + $sql = 'SELECT type FROM '.$table.' + WHERE id = "'.$legal_id.'" AND language_id="'.$language_id.'"'; $rs = Database::query($sql); return Database::result($rs, 0, 'type'); diff --git a/main/inc/lib/message.lib.php b/main/inc/lib/message.lib.php index 13c89d4c5b..b295dff16b 100755 --- a/main/inc/lib/message.lib.php +++ b/main/inc/lib/message.lib.php @@ -477,14 +477,14 @@ class MessageManager $user_list = $usergroup->get_users_by_group( $group_id, false, - array(), + [], 0, 1000 ); // Adding more sense to the message group $subject = sprintf(get_lang('ThereIsANewMessageInTheGroupX'), $group_info['name']); - $new_user_list = array(); + $new_user_list = []; foreach ($user_list as $user_data) { $new_user_list[] = $user_data['id']; } @@ -886,7 +886,7 @@ class MessageManager msg_status NOT IN ('".MESSAGE_STATUS_OUTBOX."', '".MESSAGE_STATUS_DELETED."') ORDER BY id"; $rs = Database::query($sql); - $data = array(); + $data = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { $data[] = $row; @@ -915,8 +915,8 @@ class MessageManager ORDER BY id "; $rs = Database::query($sql); - $data = array(); - $parents = array(); + $data = []; + $parents = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { if ($message_id == $row['parent_id'] || in_array($row['parent_id'], $parents)) { @@ -963,7 +963,7 @@ class MessageManager $condition_group_id ORDER BY send_date DESC $condition_limit "; $rs = Database::query($sql); - $data = array(); + $data = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs)) { $data[$row['id']] = $row; @@ -1275,7 +1275,7 @@ class MessageManager if (is_array($rows) && count($rows) > 0) { // prepare array for topics with its items - $topics = array(); + $topics = []; $x = 0; foreach ($rows as $index => $value) { if (empty($value['parent_id'])) { @@ -1283,7 +1283,7 @@ class MessageManager } } - $new_topics = array(); + $new_topics = []; foreach ($topics as $id => $value) { $rows = null; @@ -1297,7 +1297,7 @@ class MessageManager $new_topics[$id] = $value; } - $array_html = array(); + $array_html = []; foreach ($new_topics as $index => $topic) { $html = ''; // topics @@ -1338,10 +1338,10 @@ class MessageManager $date = ''; if ($topic['send_date'] != $topic['update_date']) { if (!empty($topic['update_date'])) { - $date .= ' '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']); + $date .= ' '.get_lang('LastUpdate').' '.Display::dateToStringAgoAndLongDate($topic['update_date']); } } else { - $date .= ' '.get_lang('Created').' '.date_to_str_ago($topic['send_date']); + $date .= ' '.get_lang('Created').' '.Display::dateToStringAgoAndLongDate($topic['send_date']); } $html .= '
'.$label.' - '.$date.$actions.'
'; $html .= '
'; @@ -1363,7 +1363,7 @@ class MessageManager // grids for items and topics with paginations $html_messages .= Display::return_sortable_grid( 'topics', - array(), + [], $array_html, array( 'hide_navigation' => false, @@ -1432,15 +1432,7 @@ class MessageManager 'items_page_nr' => $items_page_nr, 'topic_id' => $main_message['id'] ]); - if (api_is_platform_admin()) { - $links .= Display::url( - Display::returnFontAwesomeIcon('trash'), - 'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id, - [ - 'class' => 'btn btn-default' - ] - ); - } + $links .= Display::url( Display::returnFontAwesomeIcon('pencil'), $urlEdit, @@ -1475,6 +1467,17 @@ class MessageManager 'data-size' => 'lg' ] ); + + if (api_is_platform_admin()) { + $links .= Display::url( + Display::returnFontAwesomeIcon('trash'), + 'group_topics.php?action=delete&id='.$group_id.'&topic_id='.$topic_id, + [ + 'class' => 'btn btn-default' + ] + ); + } + $links .= ''; $links .= ''; @@ -1493,13 +1496,13 @@ class MessageManager if (!empty($main_message['update_date'])) { $date = '
'. Display::returnFontAwesomeIcon('calendar').' '.get_lang('LastUpdate').' '. - date_to_str_ago($main_message['update_date']). + Display::dateToStringAgoAndLongDate($main_message['update_date']). '
'; } } else { $date = '
'. Display::returnFontAwesomeIcon('calendar').' '.get_lang('Created').' '. - date_to_str_ago($main_message['send_date']). + Display::dateToStringAgoAndLongDate($main_message['send_date']). '
'; } $attachment = '
'.(!empty($files_attachments) ? implode('
', $files_attachments) : '').'
'; @@ -1524,7 +1527,7 @@ class MessageManager if (is_array($rows) && count($rows) > 0) { $topics = $rows; - $array_html_items = array(); + $array_html_items = []; foreach ($topics as $index => $topic) { if (empty($topic['id'])) { continue; @@ -1553,19 +1556,22 @@ class MessageManager $user_link = ''.$name.' '; $html_items .= '
'; $html_items .= '
'; - $html_items .= '
'.$name.'
'; + $html_items .= '
'; + $html_items .= ''.$name.'
'; $html_items .= '
'; $date = ''; if ($topic['send_date'] != $topic['update_date']) { if (!empty($topic['update_date'])) { $date = '
'. - Display::returnFontAwesomeIcon('calendar').' '.get_lang('LastUpdate').' '.date_to_str_ago($topic['update_date']). + Display::returnFontAwesomeIcon('calendar').' '. + get_lang('LastUpdate').' '.Display::dateToStringAgoAndLongDate($topic['update_date']). '
'; } } else { $date = '
'. - Display::returnFontAwesomeIcon('calendar').get_lang('Created').' '.date_to_str_ago($topic['send_date']). + Display::returnFontAwesomeIcon('calendar'). + get_lang('Created').' '.Display::dateToStringAgoAndLongDate($topic['send_date']). '
'; } $attachment = '
'.(!empty($files_attachments) ? implode('
', $files_attachments) : '').'
'; @@ -1604,7 +1610,7 @@ class MessageManager if (!empty($array_html_items)) { $html .= Display::return_sortable_grid( 'items_'.$topic['id'], - array(), + [], $array_html_items, $options, $query_vars, @@ -1626,13 +1632,13 @@ class MessageManager */ public static function calculate_children($rows, $first_seed) { - $rows_with_children = array(); + $rows_with_children = []; foreach ($rows as $row) { $rows_with_children[$row["id"]] = $row; $rows_with_children[$row["parent_id"]]["children"][] = $row["id"]; } $rows = $rows_with_children; - $sorted_rows = array(0 => array()); + $sorted_rows = array(0 => []); self::message_recursive_sort($rows, $sorted_rows, $first_seed); unset($sorted_rows[0]); @@ -1685,14 +1691,13 @@ class MessageManager */ public static function get_links_message_attachment_files($messageId, $type = '') { - $tbl_message_attach = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); + $table = Database::get_main_table(TABLE_MESSAGE_ATTACHMENT); $messageId = intval($messageId); // get file attachments by message id - $links_attach_file = array(); + $links_attach_file = []; if (!empty($messageId)) { - - $sql = "SELECT * FROM $tbl_message_attach + $sql = "SELECT * FROM $table WHERE message_id = '$messageId'"; $rs_file = Database::query($sql); @@ -1727,7 +1732,7 @@ class MessageManager id = '$messageId' AND msg_status <> '".MESSAGE_STATUS_DELETED."' "; $res = Database::query($sql); - $item = array(); + $item = []; if (Database::num_rows($res) > 0) { $item = Database::fetch_array($res, 'ASSOC'); } @@ -1761,7 +1766,7 @@ class MessageManager * @param array $params * @return string */ - public static function generate_invitation_form($id, $params = array()) + public static function generate_invitation_form($id, $params = []) { $form = new FormValidator('send_invitation'); $form->addTextarea( diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index b786d2d837..9fabdd85d4 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -102,14 +102,14 @@ class SocialManager extends UserManager */ public static function getCountFriends($userId) { - $tbl_my_friend = Database::get_main_table(TABLE_MAIN_USER_REL_USER); + $table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); $userId = (int) $userId; if (empty($userId)) { return 0; } $sql = 'SELECT count(friend_user_id) count - FROM '.$tbl_my_friend.' + FROM '.$table.' WHERE relation_type NOT IN ('.USER_RELATION_TYPE_DELETED.', '.USER_RELATION_TYPE_RRHH.') AND friend_user_id<>'.($userId).' AND diff --git a/main/social/group_topics.php b/main/social/group_topics.php index 596ae7f584..e03b749869 100755 --- a/main/social/group_topics.php +++ b/main/social/group_topics.php @@ -1,5 +1,6 @@ @@ -11,7 +12,7 @@ require_once __DIR__.'/../inc/global.inc.php'; api_block_anonymous_users(); if (api_get_setting('allow_social_tool') != 'true') { - api_not_allowed(); + api_not_allowed(true); } $group_id = intval($_GET['id']); @@ -49,6 +50,7 @@ if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'delete') { exit; } } + // My friends $friend_html = SocialManager::listMyFriendsBlock( $user_id @@ -82,7 +84,7 @@ if (isset($_POST['action'])) { ); } else { if ($_POST['action'] == 'add_message_group' && !$is_member) { - api_not_allowed(); + api_not_allowed(true); } $res = MessageManager::send_message( 0, @@ -99,7 +101,7 @@ if (isset($_POST['action'])) { // display error messages if (!$res) { - $social_right_content .= Display::return_message(get_lang('Error'), 'error'); + Display::addFlash(Display::return_message(get_lang('Error'), 'error')); } $topic_id = isset($_GET['topic_id']) ? intval($_GET['topic_id']) : null; if ($_POST['action'] == 'add_message_group') {