diff --git a/main/dashboard/index.php b/main/dashboard/index.php index ce4109bcb0..8157dd195f 100755 --- a/main/dashboard/index.php +++ b/main/dashboard/index.php @@ -31,7 +31,7 @@ if (isset($_GET['action']) && in_array($_GET['action'], $actions)) { } // load styles from dashboard plugins -$htmlHeadXtra[] = DashboardManager::get_links_for_styles_from_dashboard_plugins(); +$htmlHeadXtra[] = DashboardManager::getStyleSheet(); // course description controller object $dashboard_controller = new DashboardController(); diff --git a/main/exercise/exercise.class.php b/main/exercise/exercise.class.php index 54e32b0363..698cf936e8 100755 --- a/main/exercise/exercise.class.php +++ b/main/exercise/exercise.class.php @@ -2814,7 +2814,7 @@ class Exercise $di = new ChamiloIndexer(); isset($_POST['language']) ? $lang = Database::escape_string($_POST['language']) : $lang = 'english'; $di->connectDb(null, null, $lang); - $di->remove_document((int) $se_ref['search_did']); + $di->remove_document($se_ref['search_did']); $di->addChunk($ic_slide); //index and return search engine document id @@ -2849,7 +2849,7 @@ class Exercise if (Database::num_rows($res) > 0) { $row = Database::fetch_array($res); $di = new ChamiloIndexer(); - $di->remove_document((int) $row['search_did']); + $di->remove_document($row['search_did']); unset($di); $tbl_quiz_question = Database::get_course_table(TABLE_QUIZ_QUESTION); foreach ($this->questionList as $question_i) { diff --git a/main/exercise/question.class.php b/main/exercise/question.class.php index d66f97a175..964f79401c 100755 --- a/main/exercise/question.class.php +++ b/main/exercise/question.class.php @@ -1177,7 +1177,7 @@ abstract class Question //TODO: index answers, see also form validation on question_admin.inc.php - $di->remove_document((int) $se_ref['search_did']); + $di->remove_document($se_ref['search_did']); $di->addChunk($ic_slide); //index and return search engine document id diff --git a/main/inc/lib/ScheduledAnnouncement.php b/main/inc/lib/ScheduledAnnouncement.php index a7b272d2ae..33881c54cd 100644 --- a/main/inc/lib/ScheduledAnnouncement.php +++ b/main/inc/lib/ScheduledAnnouncement.php @@ -64,6 +64,7 @@ class ScheduledAnnouncement extends Model /** * Displays the title + grid * @param int $sessionId + * @return string */ public function getGrid($sessionId) { @@ -203,10 +204,10 @@ class ScheduledAnnouncement extends Model "] ); - $form->addElement('html', '
'); + $form->addHtml('
'); $form->addDateTimePicker('date', get_lang('Date')); - $form->addElement('html', '
'); - $form->addElement('html', ''); + $form->addHtml(''); - + $form->addHtml('
'); $form->addText('subject', get_lang('Subject')); $form->addHtmlEditor('message', get_lang('Message')); $this->setTagsInForm($form); diff --git a/main/inc/lib/SequenceResourceManager.php b/main/inc/lib/SequenceResourceManager.php index 5257632285..c930b9a59c 100644 --- a/main/inc/lib/SequenceResourceManager.php +++ b/main/inc/lib/SequenceResourceManager.php @@ -1,7 +1,7 @@ getRepository( - 'ChamiloCoreBundle:GradebookCategory' - ); + $gradebookCategoryRepo = $entityManager->getRepository('ChamiloCoreBundle:GradebookCategory'); foreach ($sequences as $sequenceId => $sequence) { $item = [ @@ -83,10 +80,8 @@ class SequenceResourceManager } } } - $item['requirements'][$sessionRequired->getId()] = $itemSession; } - $sequenceList[$sequenceId] = $item; } diff --git a/main/inc/lib/attendance.lib.php b/main/inc/lib/attendance.lib.php index 95afddbd60..31c2b924a3 100755 --- a/main/inc/lib/attendance.lib.php +++ b/main/inc/lib/attendance.lib.php @@ -60,19 +60,16 @@ class Attendance /** * Get attendance list only the id, name and attendance_qualify_max fields - * @param string $course_id course db name (optional) + * @param int $course_id course db name (optional) * @param int $session_id session id (optional) * @return array attendances list */ - public function get_attendances_list($course_id = '', $session_id = 0) + public function get_attendances_list($course_id = 0, $session_id = 0) { - $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); - $data = array(); - + $table = Database::get_course_table(TABLE_ATTENDANCE); + $course_id = intval($course_id); if (empty($course_id)) { $course_id = api_get_course_int_id(); - } else { - $course_id = intval($course_id); } $session_id = !empty($session_id) ? intval($session_id) : api_get_session_id(); @@ -80,11 +77,12 @@ class Attendance // Get attendance data $sql = "SELECT id, name, attendance_qualify_max - FROM $tbl_attendance + FROM $table WHERE c_id = $course_id AND active = 1 $condition_session "; - $rs = Database::query($sql); - if (Database::num_rows($rs) > 0) { - while ($row = Database::fetch_array($rs, 'ASSOC')) { + $result = Database::query($sql); + $data = []; + if (Database::num_rows($result) > 0) { + while ($row = Database::fetch_array($result, 'ASSOC')) { $data[$row['id']] = $row; } } @@ -142,7 +140,7 @@ class Attendance LIMIT $from,$number_of_items "; $res = Database::query($sql); - $attendances = array(); + $attendances = []; $user_info = api_get_user_info(); $allowDelete = api_get_setting('allow_delete_attendance'); @@ -186,19 +184,19 @@ class Attendance if (api_is_platform_admin()) { $actions .= ''. - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).' '; + Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).' '; // Visible if ($attendance[5] == 1) { $actions .= ''. - Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).''; } else { $actions .= ''. - Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).''; $attendance[2] = ''.$attendance[2].''; } if ($allowDelete === 'true') { $actions .= ''. - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).''; } } else { $is_locked_attendance = self::is_locked_attendance($attendance[0]); @@ -207,19 +205,19 @@ class Attendance $actions .= Display::return_icon('visible.png', get_lang('Hide')); } else { $actions .= ''. - Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).' '; + Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).' '; if ($attendance[5] == 1) { $actions .= ' '. - Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).''; } else { $actions .= ' '. - Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).''; $attendance[2] = ''.$attendance[2].''; } if ($allowDelete === 'true') { $actions .= ' '. - Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).''; + Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).''; } } } @@ -279,7 +277,7 @@ class Attendance $tbl_attendance = Database::get_course_table(TABLE_ATTENDANCE); $attendanceId = intval($attendanceId); $course_id = api_get_course_int_id(); - $attendance_data = array(); + $attendance_data = []; $sql = "SELECT * FROM $tbl_attendance WHERE c_id = $course_id AND id = '$attendanceId'"; $res = Database::query($sql); @@ -643,7 +641,7 @@ class Attendance $current_session_id = api_get_session_id(); $current_course_id = api_get_course_id(); $currentCourseIntId = api_get_course_int_id(); - $studentInGroup = array(); + $studentInGroup = []; if (!empty($current_session_id)) { $a_course_users = CourseManager:: get_user_list_from_course_code( @@ -672,9 +670,9 @@ class Attendance } // get registered users inside current course - $a_users = array(); + $a_users = []; foreach ($a_course_users as $key => $user_data) { - $value = array(); + $value = []; $uid = $user_data['user_id']; $userInfo = api_get_user_info($uid); $status = $user_data['status']; @@ -867,7 +865,7 @@ class Attendance null, true ); - $calendar_ids = array(); + $calendar_ids = []; // get all dates from calendar by current attendance foreach ($attendance_calendar as $cal) { $calendar_ids[] = $cal['id']; @@ -1019,7 +1017,7 @@ class Attendance { $user_id = intval($user_id); $attendanceId = intval($attendanceId); - $results = array(); + $results = []; $calendar_count = self::get_number_of_attendance_calendar( $attendanceId, $groupId, @@ -1077,7 +1075,7 @@ class Attendance // get all courses of current user $courses = CourseManager::get_courses_list_by_user_id($user_id, true); $user_id = intval($user_id); - $results = array(); + $results = []; $total_faults = $total_weight = $porcent = 0; foreach ($courses as $course) { //$course_code = $course['code']; @@ -1133,7 +1131,7 @@ class Attendance $course_info = api_get_course_info($course_code); $tbl_attendance_result = Database::get_course_table(TABLE_ATTENDANCE_RESULT); $user_id = intval($user_id); - $results = array(); + $results = []; $total_faults = $total_weight = $porcent = 0; $attendances_by_course = $this->get_attendances_list( $course_info['real_id'], @@ -1188,7 +1186,7 @@ class Attendance null, $groupId ); - $calendar_ids = array(); + $calendar_ids = []; // get all dates from calendar by current attendance foreach ($attendance_calendar as $cal) { $calendar_ids[] = $cal['id']; @@ -1196,7 +1194,7 @@ class Attendance $course_id = api_get_course_int_id(); - $data = array(); + $data = []; if (empty($user_id)) { // get all registered users inside current course $users = $this->get_users_rel_course(); @@ -1362,7 +1360,7 @@ class Attendance $sql = "SELECT * FROM $table WHERE c_id = $course_id AND id = '$calendar_id' "; $rs = Database::query($sql); - $data = array(); + $data = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs)) { $row['date_time'] = api_get_local_time($row['date_time']); @@ -1449,7 +1447,7 @@ class Attendance $sql .= " ORDER BY date_time "; $rs = Database::query($sql); - $data = array(); + $data = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs, 'ASSOC')) { $row['db_date_time'] = $row['date_time']; @@ -1627,7 +1625,7 @@ class Attendance * @param array $groupList * @return int affected rows */ - public function attendance_calendar_add($attendanceId, $groupList = array()) + public function attendance_calendar_add($attendanceId, $groupList = []) { $tbl_attendance_calendar = Database::get_course_table(TABLE_ATTENDANCE_CALENDAR); $affected_rows = 0; @@ -1775,7 +1773,7 @@ class Attendance $start_date, $end_date, $repeat_type, - $groupList = array() + $groupList = [] ) { $attendanceId = intval($attendanceId); // save start date @@ -2053,7 +2051,7 @@ class Attendance $dateTimeEnd->format('Y-m-d H:i:s') ); - $results = array(); + $results = []; if (!empty($accessData)) { foreach ($accessData as $data) { $onlyDate = substr($data['login_course_date'], 0, 10); diff --git a/main/inc/lib/career.lib.php b/main/inc/lib/career.lib.php index c554604dfa..b5ef71f632 100755 --- a/main/inc/lib/career.lib.php +++ b/main/inc/lib/career.lib.php @@ -36,7 +36,7 @@ class Career extends Model $row = Database::select( 'count(*) as count', $this->table, - array(), + [], 'first' ); return $row['count']; @@ -120,9 +120,9 @@ class Career extends Model $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->addElement('text', 'name', get_lang('Name'), array('size' => '70')); $form->addHtmlEditor( 'description', @@ -214,9 +214,9 @@ class Career extends Model */ public function get_status($career_id) { - $TBL_CAREER = Database::get_main_table(TABLE_CAREER); + $table = Database::get_main_table(TABLE_CAREER); $career_id = intval($career_id); - $sql = "SELECT status FROM $TBL_CAREER WHERE id = '$career_id'"; + $sql = "SELECT status FROM $table WHERE id = '$career_id'"; $result = Database::query($sql); if (Database::num_rows($result) > 0) { $data = Database::fetch_array($result); @@ -296,9 +296,6 @@ class Career extends Model if (!($graph instanceof Graph)) { return ''; } - - $debug = false; - // Getting max column $maxColumn = 0; foreach ($graph->getVertices() as $vertex) { diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index c9e94a7c4c..21d0675522 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -28,7 +28,7 @@ class CourseManager * list (userportal), footer, etc */ const USER_SEPARATOR = ' |'; const COURSE_FIELD_TYPE_CHECKBOX = 10; - public $columns = array(); + public $columns = []; /** * Creates a course @@ -93,7 +93,6 @@ class CourseManager $params['directory'] = $keys['currentCourseRepository']; $course_info = api_get_course_info($params['code']); - if (empty($course_info)) { $course_id = AddCourse::register_course($params); $course_info = api_get_course_info_by_id($course_id); @@ -903,103 +902,6 @@ class CourseManager return $result['number'] > 0; } - /** - * Get course list as coach - * - * @param int $user_id - * @param bool $include_courses_in_sessions - * @return array Course list - * - **/ - public static function get_course_list_as_coach( - $user_id, - $include_courses_in_sessions = false - ) { - // 1. Getting courses as teacher (No session) - $courses_temp = self::get_course_list_of_user_as_course_admin($user_id); - $courseList = array(); - if (!empty($courses_temp)) { - foreach ($courses_temp as $course_item) { - $courseList[0][$course_item['code']] = $course_item['code']; - } - } - - //2. Include courses in sessions - if ($include_courses_in_sessions) { - $sessions = Tracking::get_sessions_coached_by_user($user_id); - - if (!empty($sessions)) { - foreach ($sessions as $session_item) { - $courses = Tracking::get_courses_followed_by_coach( - $user_id, - $session_item['id'] - ); - if (is_array($courses)) { - foreach ($courses as $course_item) { - $courseList[$session_item['id']][$course_item] = $course_item; - } - } - } - } - } - - return $courseList; - } - - /** - * @param int $user_id - * @param bool $include_sessions - * @return array - */ - public static function get_user_list_from_courses_as_coach($user_id, $include_sessions = true) - { - $students_in_courses = array(); - $sessions = self::get_course_list_as_coach($user_id, true); - - if (!empty($sessions)) { - foreach ($sessions as $session_id => $courses) { - if (!$include_sessions) { - if (!empty($session_id)) { - continue; - } - } - if (empty($session_id)) { - foreach ($courses as $course_code) { - $students_in_course = self::get_user_list_from_course_code($course_code); - - foreach ($students_in_course as $user_item) { - //Only students - if ($user_item['status_rel'] == STUDENT) { - $students_in_courses[$user_item['user_id']] = $user_item['user_id']; - } - } - } - } else { - $students_in_course = SessionManager::get_users_by_session($session_id, '0'); - if (is_array($students_in_course)) { - foreach ($students_in_course as $user_item) { - $students_in_courses[$user_item['user_id']] = $user_item['user_id']; - } - } - } - } - } - - $students = Tracking:: get_student_followed_by_coach($user_id); - if (!empty($students_in_courses)) { - if (!empty($students)) { - $students = array_merge($students, $students_in_courses); - } else { - $students = $students_in_courses; - } - } - - if (!empty($students)) { - $students = array_unique($students); - } - return $students; - } - /** * @param int $user_id * @param string $startsWith Optional @@ -1009,14 +911,14 @@ class CourseManager public static function get_course_list_of_user_as_course_admin($user_id, $startsWith = '') { if ($user_id != strval(intval($user_id))) { - return array(); + return []; } // Definitions database tables and variables $tbl_course = Database::get_main_table(TABLE_MAIN_COURSE); $tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); $user_id = intval($user_id); - $data = array(); + $data = []; $sql = "SELECT course.code, @@ -1163,8 +1065,7 @@ class CourseManager return true; } - $sql = 'SELECT 1 FROM '.$tableSessionCourseUser. - ' WHERE user_id = '.$user_id.' AND status=2 '.$condition_course; + $sql = 'SELECT 1 FROM '.$tableSessionCourseUser.' WHERE user_id = '.$user_id.' AND status=2 '.$condition_course; if (Database::num_rows(Database::query($sql)) > 0) { return true; } @@ -1256,10 +1157,10 @@ class CourseManager // A course coach? if (Database::num_rows(Database::query("SELECT user_id - FROM " . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." - WHERE session_id='" . $session_id."' + FROM ".Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER)." + WHERE session_id='".$session_id."' AND user_id = '$user_id' AND status = 2 - AND c_id ='$courseId'")) + AND c_id = '$courseId'")) ) { return true; } @@ -1267,8 +1168,8 @@ class CourseManager // A session coach? if (Database::num_rows(Database::query("SELECT id_coach FROM " . Database::get_main_table(TABLE_MAIN_SESSION)." AS session - WHERE session.id='" . $session_id."' - AND id_coach='$user_id'")) + WHERE session.id='".$session_id."' + AND id_coach = '$user_id'")) ) { return true; } @@ -2177,15 +2078,15 @@ class CourseManager if ($in_get_empty_group == 0) { // get only groups that are not empty $sql = "SELECT DISTINCT g.id, g.iid, g.name - FROM " . Database::get_course_table(TABLE_GROUP)." AS g - INNER JOIN " . Database::get_course_table(TABLE_GROUP_USER)." gu + FROM ".Database::get_course_table(TABLE_GROUP)." AS g + INNER JOIN ".Database::get_course_table(TABLE_GROUP_USER)." gu ON (g.id = gu.group_id AND g.c_id = $course_id AND gu.c_id = $course_id) $session_condition ORDER BY g.name"; } else { // get all groups even if they are empty $sql = "SELECT g.id, g.name, g.iid - FROM " . Database::get_course_table(TABLE_GROUP)." AS g + FROM ".Database::get_course_table(TABLE_GROUP)." AS g $session_condition AND c_id = $course_id"; } @@ -2214,7 +2115,6 @@ class CourseManager * @todo When deleting a virtual course: unsubscribe users from that virtual * course from the groups in the real course if they are not subscribed in * that real course. - * @todo Remove globals */ public static function delete_course($code) { @@ -2378,13 +2278,12 @@ class CourseManager $extraFieldValues->deleteValuesByItem($courseId); // Add event to system log - $user_id = api_get_user_id(); Event::addEvent( LOG_COURSE_DELETE, LOG_COURSE_CODE, $code, api_get_utc_datetime(), - $user_id, + api_get_user_id(), $courseId ); } @@ -2461,7 +2360,7 @@ class CourseManager ); $sql = 'SELECT course.code as code, course.title as title, cu.sort as sort - FROM ' . $TABLECOURSUSER.' as cu, '.$TABLECOURSE.' as course + FROM '.$TABLECOURSUSER.' as cu, '.$TABLECOURSE.' as course WHERE course.id = cu.c_id AND user_id = "' . $user_id.'" AND cu.relation_type<>' . COURSE_RELATION_TYPE_RRHH.' AND user_course_cat = 0 @@ -2509,8 +2408,13 @@ class CourseManager // We must register the course in the beginning of the list if (!$course_found) { - $course_sort = Database::result(Database::query('SELECT min(sort) as min_sort FROM '.$TABLECOURSUSER.' WHERE user_id="'.$user_id.'" AND user_course_cat="0"'), - 0, 0); + $course_sort = Database::result( + Database::query( + 'SELECT min(sort) as min_sort FROM '.$TABLECOURSUSER.' WHERE user_id="'.$user_id.'" AND user_course_cat="0"' + ), + 0, + 0 + ); Database::query('UPDATE '.$TABLECOURSUSER.' SET sort = sort+1 WHERE user_id= "'.$user_id.'" AND user_course_cat="0"'); } } @@ -2525,7 +2429,7 @@ class CourseManager public static function course_exists($course_code) { $sql = 'SELECT 1 FROM '.Database::get_main_table(TABLE_MAIN_COURSE).' - WHERE code="' . Database::escape_string($course_code).'"'; + WHERE code="'.Database::escape_string($course_code).'"'; return Database::num_rows(Database::query($sql)); } @@ -2577,8 +2481,12 @@ class CourseManager $emailbody .= get_lang('FirstName').': '.$student['firstname']."\n"; } $emailbody .= get_lang('Email').': '.$student['email']."\n\n"; - $recipient_name = api_get_person_name($tutor['firstname'], $tutor['lastname'], null, - PERSON_NAME_EMAIL_ADDRESS); + $recipient_name = api_get_person_name( + $tutor['firstname'], + $tutor['lastname'], + null, + PERSON_NAME_EMAIL_ADDRESS + ); $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_admin = api_get_setting('emailAdministrator'); @@ -2714,6 +2622,7 @@ class CourseManager * @param bool $loadSpecialCourses * @param array $skipCourseList List of course ids to skip * @param bool $useUserLanguageFilterIfAvailable + * @param bool $showCoursesSessionWithDifferentKey * @return array List of codes and db name * @author isaac flores paz */ @@ -2911,7 +2820,7 @@ class CourseManager * */ public static function get_emails_of_tutors_to_course($courseId) { - $list = array(); + $list = []; $res = Database::query("SELECT user_id FROM ".Database::get_main_table(TABLE_MAIN_COURSE_USER)." WHERE c_id ='" . intval($courseId)."' AND status=1"); while ($list_users = Database::fetch_array($res)) { @@ -3159,9 +3068,9 @@ class CourseManager */ public static function get_course_category($code) { - $table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY); + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); $code = Database::escape_string($code); - $sql = "SELECT * FROM $table_categories WHERE code = '$code'"; + $sql = "SELECT * FROM $table WHERE code = '$code'"; return Database::fetch_array(Database::query($sql)); } @@ -3169,18 +3078,18 @@ class CourseManager * Returns the details of a course category * * @param string Category code - * @return array Course category + * @return array Course category list */ public static function getCategoriesList() { - $table_categories = Database::get_main_table(TABLE_MAIN_CATEGORY); - $sql = "SELECT * FROM $table_categories"; + $table = Database::get_main_table(TABLE_MAIN_CATEGORY); + $sql = "SELECT * FROM $table"; $result = Database::query($sql); - $category = array(); + $categoryList = []; while ($row = Database::fetch_array($result, 'ASSOC')) { - $category[$row['code']] = $row['name']; + $categoryList[$row['code']] = $row['name']; } - return $category; + return $categoryList; } /** @@ -3650,13 +3559,13 @@ class CourseManager $params['edit_actions'] .= api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code']; if ($load_dirs) { $params['document'] = '' - . Display::returnFontAwesomeIcon('folder-open').''; + .Display::returnFontAwesomeIcon('folder-open').''; $params['document'] .= Display::div('', ['id' => 'document_result_'.$courseId.'_0', 'class' => 'document_preview_container']); } } else { if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED && $load_dirs) { $params['document'] = '' - . Display::returnFontAwesomeIcon('folder-open').''; + .Display::returnFontAwesomeIcon('folder-open').''; $params['document'] .= Display::div('', ['id' => 'document_result_'.$courseId.'_0', 'class' => 'document_preview_container']); } } @@ -3894,14 +3803,26 @@ class CourseManager $params['edit_actions'] .= api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course_info['code']; if ($load_dirs) { $params['document'] = '' - . Display::returnFontAwesomeIcon('folder-open').''; - $params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container')); + .Display::returnFontAwesomeIcon('folder-open').''; + $params['document'] .= Display::div( + '', + array( + 'id' => 'document_result_'.$course_info['real_id'].'_0', + 'class' => 'document_preview_container', + ) + ); } } if ($load_dirs) { $params['document'] = '' . Display::returnFontAwesomeIcon('folder-open').''; - $params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container')); + $params['document'] .= Display::div( + '', + array( + 'id' => 'document_result_'.$course_info['real_id'].'_0', + 'class' => 'document_preview_container', + ) + ); } $courseUrl = api_get_path(WEB_COURSE_PATH).$course_info['path'].'/index.php?id_session=0'; @@ -4051,7 +3972,7 @@ class CourseManager } if ($load_dirs) { $params['document'] = '' - . Display::returnFontAwesomeIcon('folder-open').''; + .Display::returnFontAwesomeIcon('folder-open').''; $params['document'] .= Display::div('', array('id' => 'document_result_'.$course_info['real_id'].'_0', 'class' => 'document_preview_container')); } @@ -4096,8 +4017,8 @@ class CourseManager public static function get_user_course_categories($userId = 0) { $userId = empty($userId) ? api_get_user_id() : (int) $userId; - $table_category = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); - $sql = "SELECT * FROM $table_category + $table = Database::get_main_table(TABLE_USER_COURSE_CATEGORY); + $sql = "SELECT * FROM $table WHERE user_id = $userId ORDER BY sort ASC "; @@ -4217,7 +4138,7 @@ class CourseManager // Display course entry. // Show a hyperlink to the course, unless the course is closed and user is not course admin. $session_url = ''; - $params = array(); + $params = []; $params['icon'] = Display::return_icon( 'blackboard_blue.png', null, @@ -4383,7 +4304,7 @@ class CourseManager if (Skill::isAllowed($user_id, false)) { $em = Database::getManager(); - $objUser = $em->find('ChamiloUserBundle:User', $user_id); + $objUser = api_get_user_entity($user_id); $objCourse = $em->find('ChamiloCoreBundle:Course', $course['real_id']); $objSession = $em->find('ChamiloCoreBundle:Session', $session_id); @@ -4444,7 +4365,7 @@ class CourseManager * @param string source course code * @param int source session id * @param int destination session id - * @param bool new copied tools (Exercises and LPs)will be set to invisible by default? + * @param array $params * * @return array */ @@ -4453,7 +4374,7 @@ class CourseManager $source_course_code, $source_session_id = 0, $destination_session_id = 0, - $params = array() + $params = [] ) { $source_course_info = api_get_course_info($source_course_code); if (!empty($source_course_info)) { @@ -4721,9 +4642,7 @@ class CourseManager ) { // Course catalog stats modifications see #4191 $table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING); - $now = api_get_utc_datetime(); - $course_id = empty($course_id) ? api_get_course_int_id() : intval($course_id); $session_id = empty($session_id) ? api_get_session_id() : intval($session_id); $url_id = empty($url_id) ? api_get_current_access_url_id() : intval($url_id); @@ -5071,12 +4990,12 @@ class CourseManager */ public static function return_most_accessed_courses($limit = 5) { - $table_course_ranking = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING); + $table = Database::get_main_table(TABLE_STATISTIC_TRACK_COURSE_RANKING); $params['url_id'] = api_get_current_access_url_id(); $result = Database::select( 'c_id, accesses, total_score, users', - $table_course_ranking, + $table, array('where' => array('url_id = ?' => $params), 'order' => 'accesses DESC', 'limit' => $limit), 'all', true @@ -5233,7 +5152,7 @@ class CourseManager * * @return mixed 'enter' for a link to go to the course or 'register' for a link to subscribe, or false if no access */ - static function get_access_link_by_user($uid, $course, $user_courses = array()) + static function get_access_link_by_user($uid, $course, $user_courses = []) { if (empty($uid) || empty($course)) { return false; @@ -6180,20 +6099,6 @@ class CourseManager return $form_data; } - /** - * return html code for displaying a course title in the standard view (not the Session view) - * @param $courseId - * @param bool $loadDirs - * @return string - */ - public static function displayCourseHtml($courseId, $loadDirs = false) - { - $params = self::getCourseParamsForDisplay($courseId, $loadDirs); - $html = self::course_item_html($params, false); - - return $html; - } - /** * Return tab of params to display a course title in the My Courses tab * Check visibility, right, and notification icons, and load_dirs option @@ -6284,7 +6189,9 @@ class CourseManager if (api_is_platform_admin()) { if ($loadDirs) { $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; - $params['right_actions'] .= ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; + $params['right_actions'] .= ''. + Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL). + ''; $params['right_actions'] .= Display::div( '', array( @@ -6293,16 +6200,14 @@ class CourseManager ) ); } else { - $params['right_actions'] .= ''.Display::returnFontAwesomeIcon('pencil').''; - } - - if ($course_info['status'] == COURSEMANAGER) { - //echo Display::return_icon('teachers.gif', get_lang('Status').': '.get_lang('Teacher'), array('style'=>'width: 11px; height: 11px;')); + $params['right_actions'] .= ''. + Display::returnFontAwesomeIcon('pencil').''; } } else { if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) { if ($loadDirs) { - $params['right_actions'] .= ''.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; + $params['right_actions'] .= ''. + Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; $params['right_actions'] .= Display::div( '', array( @@ -6312,7 +6217,8 @@ class CourseManager ); } else { if ($course_info['status'] == COURSEMANAGER) { - $params['right_actions'] .= ''.Display::returnFontAwesomeIcon('pencil').''; + $params['right_actions'] .= ''. + Display::returnFontAwesomeIcon('pencil').''; } } } @@ -6557,22 +6463,26 @@ class CourseManager */ public static function returnDescriptionButton($course) { - $title = $course['title']; - $html = ''; + if (empty($course)) { + return ''; + } + if (api_get_setting('show_courses_descriptions_in_catalog') == 'true') { + $title = $course['title']; + $url = api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code']; $html = Display::url( Display::returnFontAwesomeIcon('info-circle', 2), - api_get_path(WEB_CODE_PATH).'inc/ajax/course_home.ajax.php?a=show_course_information&code='.$course['code'], - array( + $url, + [ 'class' => 'ajax btn btn-default btn-sm', 'data-title' => $title, 'title' => get_lang('Description'), 'aria-label' => get_lang('Description'), 'data-size' => 'lg' - ) + ] ); + return $html; } - - return $html; + return ''; } } diff --git a/main/inc/lib/course_description.lib.php b/main/inc/lib/course_description.lib.php index dbbdf22af1..92c3b2a738 100755 --- a/main/inc/lib/course_description.lib.php +++ b/main/inc/lib/course_description.lib.php @@ -238,7 +238,7 @@ class CourseDescription ); } - return ($last_id > 0) ? 1 : 0; + return $last_id > 0 ? 1 : 0; } /** @@ -304,7 +304,7 @@ class CourseDescription ); if ($this->id > 0) { - //insert into item_property + // Insert into item_property api_item_property_update( api_get_course_info(), TOOL_COURSE_DESCRIPTION, @@ -375,7 +375,7 @@ class CourseDescription */ public function get_default_description_title() { - $default_description_titles = array(); + $default_description_titles = []; $default_description_titles[1] = get_lang('GeneralDescription'); $default_description_titles[2] = get_lang('Objectives'); $default_description_titles[3] = get_lang('Topics'); @@ -394,7 +394,7 @@ class CourseDescription */ public function get_default_description_title_editable() { - $default_description_title_editable = array(); + $default_description_title_editable = []; $default_description_title_editable[1] = true; $default_description_title_editable[2] = true; $default_description_title_editable[3] = true; @@ -413,7 +413,7 @@ class CourseDescription */ public function get_default_description_icon() { - $default_description_icon = array(); + $default_description_icon = []; $default_description_icon[1] = 'info.png'; $default_description_icon[2] = 'objective.png'; $default_description_icon[3] = 'topics.png'; @@ -433,7 +433,7 @@ class CourseDescription */ public function get_default_question() { - $question = array(); + $question = []; $question[1] = get_lang('GeneralDescriptionQuestions'); $question[2] = get_lang('ObjectivesQuestions'); $question[3] = get_lang('TopicsQuestions'); @@ -452,7 +452,7 @@ class CourseDescription */ public function get_default_information() { - $information = array(); + $information = []; $information[1] = get_lang('GeneralDescriptionInformation'); $information[2] = get_lang('ObjectivesInformation'); $information[3] = get_lang('TopicsInformation'); diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index c4d22268bd..23aef06cd2 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -35,7 +35,8 @@ class CourseHome $condition_display_tools = ' WHERE a.c_id = '.$course_id.' AND a.link=t.link AND (t.position="basic" OR a.name = "'.TOOL_TRACKING.'") '; } - $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t + $sql = "SELECT a.*, t.image img, t.row, t.column + FROM $TBL_ACCUEIL a, $TABLE_TOOLS t $condition_display_tools ORDER BY t.row, t.column"; break; case 'External': @@ -52,12 +53,16 @@ class CourseHome } break; case 'courseAdmin': - $sql = "SELECT a.*, t.image img, t.row, t.column FROM $TBL_ACCUEIL a, $TABLE_TOOLS t - WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link ORDER BY t.row, t.column"; + $sql = "SELECT a.*, t.image img, t.row, t.column + FROM $TBL_ACCUEIL a, $TABLE_TOOLS t + WHERE a.c_id = $course_id AND admin=1 AND a.link=t.link + ORDER BY t.row, t.column"; break; case 'platformAdmin': - $sql = "SELECT *, image img FROM $TBL_ACCUEIL WHERE c_id = $course_id AND visibility = 2 ORDER BY id"; + $sql = "SELECT *, image img FROM $TBL_ACCUEIL + WHERE c_id = $course_id AND visibility = 2 + ORDER BY id"; } $result = Database::query($sql); @@ -729,15 +734,14 @@ class CourseHome // Get blog members if ($is_platform_admin) { - $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user - WHERE blog_id =".$blog_id; + $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user + WHERE blog_id = ".$blog_id; } else { - $sql_blogs = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user - WHERE blog_id =".$blog_id." AND user_id = ".$userId; + $sql = "SELECT * FROM $tbl_blogs_rel_user blogs_rel_user + WHERE blog_id = ".$blog_id." AND user_id = ".$userId; } - $result_blogs = Database::query($sql_blogs); - - if (Database::num_rows($result_blogs) > 0) { + $result = Database::query($sql); + if (Database::num_rows($result) > 0) { $all_tools_list[] = $tool; } } else { @@ -1028,7 +1032,9 @@ class CourseHome 'onclick' => 'javascript: window.open(\''.$tool['link'].'\',\'window_visio'.api_get_course_id().'\',config=\'height=\'+730+\', width=\'+1020+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')', 'target' => $tool['target'] ); - } elseif (strpos($tool['name'], 'chat') !== false && api_get_course_setting('allow_open_chat_window')) { + } elseif (strpos($tool['name'], 'chat') !== false && + api_get_course_setting('allow_open_chat_window') + ) { $tool_link_params = array( 'id' => 'tooldesc_'.$toolIid, 'class' => $class, @@ -1167,7 +1173,7 @@ class CourseHome * Shows the general data for a particular meeting * * @param int $id_session - * @return string session data + * @return string session data */ public static function show_session_data($id_session) { @@ -1214,8 +1220,8 @@ class CourseHome /** * Retrieves the name-field within a tool-record and translates it on necessity. - * @param array $tool The input record. - * @return string Returns the name of the corresponding tool. + * @param array $tool The input record. + * @return string Returns the name of the corresponding tool. */ public static function translate_tool_name(& $tool) { diff --git a/main/inc/lib/dashboard.lib.php b/main/inc/lib/dashboard.lib.php index 3dd730cf81..dde1639423 100755 --- a/main/inc/lib/dashboard.lib.php +++ b/main/inc/lib/dashboard.lib.php @@ -26,7 +26,7 @@ class DashboardManager /* We scan the plugin directory. Each folder is a potential plugin. */ $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; - $possibleplugins = self::getPossibleDashboardPluginsPath(); + $possiblePlugins = self::getPossibleDashboardPluginsPath(); $table_cols = array('name', 'version', 'description'); echo Display::page_subheader(get_lang('DashboardPlugins')); @@ -42,7 +42,7 @@ class DashboardManager $disabled_blocks_data = self::get_block_data_without_plugin(); // We display all the possible enabled or disabled plugins - foreach ($possibleplugins as $testplugin) { + foreach ($possiblePlugins as $testplugin) { $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info"; if (file_exists($plugin_info_file) && is_readable($plugin_info_file)) { $plugin_info = api_parse_info_file($plugin_info_file); @@ -143,14 +143,14 @@ class DashboardManager // get all plugins path inside plugin directory $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; - $possibleplugins = self::getPossibleDashboardPluginsPath(); + $possiblePlugins = self::getPossibleDashboardPluginsPath(); - if (count($possibleplugins) > 0) { - $selected_plugins = array_intersect(array_keys($plugin_paths), $possibleplugins); - $not_selected_plugins = array_diff($possibleplugins, array_keys($plugin_paths)); + if (count($possiblePlugins) > 0) { + $selected_plugins = array_intersect(array_keys($plugin_paths), $possiblePlugins); + $not_selected_plugins = array_diff($possiblePlugins, array_keys($plugin_paths)); // get blocks id from not selected path - $not_selected_blocks_id = array(); + $not_selected_blocks_id = []; foreach ($not_selected_plugins as $plugin) { $block_data = self::get_enabled_dashboard_blocks($plugin); if (!empty($block_data[$plugin])) { @@ -176,8 +176,8 @@ class DashboardManager } // get columns and blocks id for updating extra user data - $columns = array(); - $user_blocks_id = array(); + $columns = []; + $user_blocks_id = []; foreach ($user_block_data as $data) { $user_blocks_id[$data['block_id']] = true; $columns[$data['block_id']] = $data['column']; @@ -214,7 +214,7 @@ class DashboardManager } else { // insert $plugin_info_file = $dashboard_pluginpath.$testplugin."/$testplugin.info"; - $plugin_info = array(); + $plugin_info = []; if (file_exists($plugin_info_file)) { $plugin_info = api_parse_info_file($plugin_info_file); } @@ -258,7 +258,7 @@ class DashboardManager { // get all plugins path inside plugin directory /* We scan the plugin directory. Each folder is a potential plugin. */ - $possiblePlugins = array(); + $possiblePlugins = []; $dashboard_pluginpath = api_get_path(SYS_PLUGIN_PATH).'dashboard/'; $handle = @opendir($dashboard_pluginpath); while (false !== ($file = readdir($handle))) { @@ -278,14 +278,14 @@ class DashboardManager public static function get_block_data_without_plugin() { $tbl_block = Database::get_main_table(TABLE_MAIN_BLOCK); - $possibleplugins = self::getPossibleDashboardPluginsPath(); + $possiblePlugins = self::getPossibleDashboardPluginsPath(); // We check if plugin exists inside directory for updating active field $sql = "SELECT * FROM $tbl_block"; $rs = Database::query($sql); if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs)) { - if (!in_array($row['path'], $possibleplugins)) { + if (!in_array($row['path'], $possiblePlugins)) { $active = 0; } else { $active = 1; @@ -298,7 +298,7 @@ class DashboardManager } // get disabled block data - $block_data = array(); + $block_data = []; $sql = "SELECT * FROM $tbl_block WHERE active = 0"; $rs_block = Database::query($sql); if (Database::num_rows($rs_block) > 0) { @@ -326,7 +326,7 @@ class DashboardManager $sql = "SELECT * FROM $tbl_block WHERE active = 1 $condition_path "; $rs = Database::query($sql); - $block_data = array(); + $block_data = []; if (Database::num_rows($rs) > 0) { while ($row = Database::fetch_array($rs)) { $block_data[$row['path']] = $row; @@ -446,14 +446,14 @@ class DashboardManager */ public static function store_user_blocks($user_id, $enabled_blocks, $columns) { - $selected_blocks_id = array(); + $selected_blocks_id = []; if (is_array($enabled_blocks) && count($enabled_blocks) > 0) { $selected_blocks_id = array_keys($enabled_blocks); } // build data for storing inside extra user field $fname = 'dashboard'; - $fvalue = array(); + $fvalue = []; foreach ($selected_blocks_id as $block_id) { $fvalue[] = $block_id.':'.$columns[$block_id]; } @@ -477,7 +477,7 @@ class DashboardManager $field_variable = 'dashboard'; $extra_user_data = UserManager::get_extra_user_data_by_field($user_id, $field_variable); $extra_user_data = explode(';', $extra_user_data[$field_variable]); - $data = array(); + $data = []; foreach ($extra_user_data as $extra) { $split_extra = explode(':', $extra); if (!empty($split_extra)) { @@ -507,8 +507,8 @@ class DashboardManager } // get columns and blocks id for updating extra user data - $columns = array(); - $user_blocks_id = array(); + $columns = []; + $user_blocks_id = []; foreach ($user_block_data as $data) { $user_blocks_id[$data['block_id']] = true; $columns[$data['block_id']] = $data['column']; @@ -524,7 +524,7 @@ class DashboardManager * get links for styles from dashboard plugins * @return string links */ - public static function get_links_for_styles_from_dashboard_plugins() + public static function getStyleSheet() { return ''.PHP_EOL; } diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 77546563b3..6fcfade967 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -1253,7 +1253,7 @@ class DocumentManager if (Database::num_rows($res) > 0) { $row2 = Database::fetch_array($res); $di = new ChamiloIndexer(); - $di->remove_document((int) $row2['search_did']); + $di->remove_document($row2['search_did']); } $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_DOCUMENT, $document_id); diff --git a/main/inc/lib/exercise_show_functions.lib.php b/main/inc/lib/exercise_show_functions.lib.php index cdb2031380..8d2308a2a1 100755 --- a/main/inc/lib/exercise_show_functions.lib.php +++ b/main/inc/lib/exercise_show_functions.lib.php @@ -38,7 +38,12 @@ class ExerciseShowFunctions $originalStudentAnswer = '', $showTotalScoreAndUserChoices ) { - $answerHTML = FillBlanks::getHtmlDisplayForAnswer($answer, $feedbackType, $resultsDisabled, $showTotalScoreAndUserChoices); + $answerHTML = FillBlanks::getHtmlDisplayForAnswer( + $answer, + $feedbackType, + $resultsDisabled, + $showTotalScoreAndUserChoices + ); if (strpos($originalStudentAnswer, 'font color') !== false) { $answerHTML = $originalStudentAnswer; } @@ -156,8 +161,7 @@ class ExerciseShowFunctions $fileUrl = null, $results_disabled = 0, $questionScore = 0 - ) - { + ) { if (isset($fileUrl)) { echo ' diff --git a/main/inc/lib/grade_model.lib.php b/main/inc/lib/grade_model.lib.php index 0f7daa4182..2169406265 100755 --- a/main/inc/lib/grade_model.lib.php +++ b/main/inc/lib/grade_model.lib.php @@ -170,7 +170,6 @@ class GradeModel extends Model //New rule added in the formvalidator compare_fields that filters a group of fields in order to compare with the wanted value $form->addRule($component_array, get_lang('AllMustWeight100'), 'compare_fields', '==@100'); - $form->addElement('label', '', get_lang('AllMustWeight100')); if ($action == 'edit') { diff --git a/main/inc/lib/gradebook.lib.php b/main/inc/lib/gradebook.lib.php index b524a924f9..6499efb8b3 100755 --- a/main/inc/lib/gradebook.lib.php +++ b/main/inc/lib/gradebook.lib.php @@ -162,8 +162,9 @@ class Gradebook extends Model if (!isset($header)) { $header = get_lang('Add'); } - $form->addElement('header', '', $header); $id = isset($_GET['id']) ? intval($_GET['id']) : ''; + + $form->addHeader($header); $form->addElement('hidden', 'id', $id); $skill = new Skill(); diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index 15bb226264..e45c1403c2 100755 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -94,7 +94,7 @@ class Link extends Model if (!empty($id)) { // iid $sql = "UPDATE ".$this->table." SET id = iid WHERE iid = $id"; - Database:: query($sql); + Database::query($sql); api_item_property_update( $course_info, @@ -459,7 +459,7 @@ class Link extends Model if (Database:: num_rows($res) > 0) { $row = Database::fetch_array($res); $di = new ChamiloIndexer(); - $di->remove_document((int) $row['search_did']); + $di->remove_document($row['search_did']); } $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s LIMIT 1'; $sql = sprintf($sql, $tbl_se_ref, $course_id, TOOL_LINK, $link_id); @@ -679,7 +679,7 @@ class Link extends Model $di = new ChamiloIndexer(); isset ($_POST['language']) ? $lang = Database:: escape_string($_POST['language']) : $lang = 'english'; $di->connectDb(null, null, $lang); - $di->remove_document((int) $se_ref['search_did']); + $di->remove_document($se_ref['search_did']); $di->addChunk($ic_slide); // Index and return search engine document id. @@ -727,11 +727,12 @@ class Link extends Model /** * @param int $id + * @param array $values * @return bool */ public static function editCategory($id, $values) { - $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY); + $table = Database::get_course_table(TABLE_LINK_CATEGORY); $course_id = api_get_course_int_id(); $id = intval($id); @@ -741,7 +742,7 @@ class Link extends Model 'description' => $values['description'] ]; Database::update( - $tbl_categories, + $table, $params, ['c_id = ? AND id = ?' => [$course_id, $id]] ); @@ -1196,11 +1197,11 @@ class Link extends Model ).''; } else { $tools .= Display:: return_icon( - 'down_na.png', - get_lang('Down'), - array(), - ICON_SIZE_SMALL - ).''; + 'down_na.png', + get_lang('Down'), + array(), + ICON_SIZE_SMALL + ).''; } $tools .= ' is removed from value. - if (!($url = trim($linkdata['url'])) || !($title = trim($linkdata['title']))) { return 0; // 0 = fail } diff --git a/main/inc/lib/plugin.class.php b/main/inc/lib/plugin.class.php index 5400ffbdbd..c9d9ed5aa3 100755 --- a/main/inc/lib/plugin.class.php +++ b/main/inc/lib/plugin.class.php @@ -226,7 +226,7 @@ class Plugin switch ($type) { case 'html': - $result->addElement('html', $this->get_lang($name)); + $result->addHtml($this->get_lang($name)); break; case 'wysiwyg': $result->addHtmlEditor($name, $this->get_lang($name), false); @@ -872,7 +872,11 @@ class Plugin { $settings = api_get_settings_params_simple( array( - "subkey = ? AND category = ? AND type = ? AND variable = 'status' " => array($this->get_name(), 'Plugins', 'setting') + "subkey = ? AND category = ? AND type = ? AND variable = 'status' " => array( + $this->get_name(), + 'Plugins', + 'setting', + ) ) ); if (is_array($settings) && isset($settings['selected_value']) && $settings['selected_value'] == 'installed') { diff --git a/main/inc/lib/plugin.lib.php b/main/inc/lib/plugin.lib.php index 03de66cb27..df05a3bc47 100755 --- a/main/inc/lib/plugin.lib.php +++ b/main/inc/lib/plugin.lib.php @@ -29,8 +29,8 @@ class AppPlugin 'course_tool_plugin' ); - public $installedPluginListName = array(); - public $installedPluginListObject = array(); + public $installedPluginListName = []; + public $installedPluginListObject = []; /** * Constructor @@ -47,7 +47,7 @@ class AppPlugin { /* We scan the plugin directory. Each folder is a potential plugin. */ $pluginPath = api_get_path(SYS_PLUGIN_PATH); - $plugins = array(); + $plugins = []; $handle = @opendir($pluginPath); while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..' && is_dir(api_get_path(SYS_PLUGIN_PATH).$file)) { @@ -65,7 +65,7 @@ class AppPlugin */ public function get_installed_plugins_by_region() { - $plugins = array(); + $plugins = []; /* We retrieve all the active plugins. */ $result = api_get_settings('Plugins'); if (!empty($result)) { @@ -106,7 +106,7 @@ class AppPlugin public function setInstalledPluginListObject() { $pluginListName = $this->getInstalledPluginListName(); - $pluginList = array(); + $pluginList = []; if (!empty($pluginListName)) { foreach ($pluginListName as $pluginName) { $pluginInfo = $this->getPluginInfo($pluginName); @@ -123,7 +123,7 @@ class AppPlugin */ public function get_installed_plugins() { - $installedPlugins = array(); + $installedPlugins = []; $plugins = api_get_settings_params( array( "variable = ? AND selected_value = ? AND category = ? " => array('status', 'installed', 'Plugins') @@ -208,7 +208,7 @@ class AppPlugin public function get_areas_by_plugin($pluginName) { $result = api_get_settings('Plugins'); - $areas = array(); + $areas = []; foreach ($result as $row) { if ($pluginName == $row['selected_value']) { $areas[] = $row['variable']; @@ -369,7 +369,7 @@ class AppPlugin if (isset($_template)) { $_template['plugin_info'] = $plugin_info; } else { - $_template = array(); + $_template = []; $_template['plugin_info'] = $plugin_info; } @@ -377,7 +377,7 @@ class AppPlugin $template->assign($plugin_name, $_template); // Loading the Twig template plugin files if exists - $template_list = array(); + $template_list = []; if (isset($plugin_info) && isset($plugin_info['templates'])) { $template_list = $plugin_info['templates']; } @@ -415,7 +415,7 @@ class AppPlugin } else { $plugin_file = api_get_path(SYS_PLUGIN_PATH)."$plugin_name/plugin.php"; - $plugin_info = array(); + $plugin_info = []; if (file_exists($plugin_file)) { require $plugin_file; } @@ -433,7 +433,7 @@ class AppPlugin ) ); - $settings_filtered = array(); + $settings_filtered = []; foreach ($plugin_settings as $item) { if (!empty($item['selected_value'])) { if (@unserialize($item['selected_value']) !== false) { @@ -576,7 +576,7 @@ class AppPlugin
'); - $groups = array(); + $groups = []; foreach ($obj->course_settings as $setting) { if ($obj->validateCourseSetting($setting['name']) === false) { continue; @@ -621,7 +621,7 @@ class AppPlugin { $pluginList = $this->getInstalledPluginListObject(); /** @var Plugin $obj */ - $courseSettings = array(); + $courseSettings = []; if (!empty($pluginList)) { foreach ($pluginList as $obj) { $pluginCourseSetting = $obj->getCourseSettings(); @@ -644,8 +644,7 @@ class AppPlugin /** @var Plugin $obj */ foreach ($pluginList as $obj) { $settings = $obj->getCourseSettings(); - - $subValues = array(); + $subValues = []; if (!empty($settings)) { foreach ($settings as $v) { if (isset($values[$v])) { diff --git a/main/inc/lib/search/xapian/XapianIndexer.class.php b/main/inc/lib/search/xapian/XapianIndexer.class.php index 2698891c5f..39790c728e 100755 --- a/main/inc/lib/search/xapian/XapianIndexer.class.php +++ b/main/inc/lib/search/xapian/XapianIndexer.class.php @@ -235,7 +235,8 @@ abstract class XapianIndexer if ($this->db == null) { $this->connectDb(); } - if (is_numeric($did) && $did > 0) { + $did = (int) $did; + if ($did > 0) { $doc = $this->get_document($did); if ($doc !== false) { $this->db->delete_document($did); diff --git a/main/inc/lib/security.lib.php b/main/inc/lib/security.lib.php index 64e22c8d85..5a94dfaf50 100755 --- a/main/inc/lib/security.lib.php +++ b/main/inc/lib/security.lib.php @@ -167,7 +167,7 @@ class Security /** * Checks the user agent of the client as recorder by get_ua() to prevent * most session hijacking attacks. - * @return bool True if the user agent is the same, false otherwise + * @return bool True if the user agent is the same, false otherwise */ public static function check_ua() { @@ -197,7 +197,7 @@ class Security * the one that sent this form in knowingly (this form hasn't been generated from * another website visited by the user at the same time). * Check the token with check_token() - * @return string Hidden-type input ready to insert into a form + * @return string Hidden-type input ready to insert into a form */ public static function get_HTML_token() { @@ -215,7 +215,7 @@ class Security * the one that sent this form in knowingly (this form hasn't been generated from * another website visited by the user at the same time). * Check the token with check_token() - * @return string Token + * @return string Token */ public static function get_token() { @@ -438,9 +438,11 @@ class Security } /** - * This method provides specific protection (against XSS and other kinds of attacks) for static images (icons) used by the system. - * Image paths are supposed to be given by programmers - people who know what they do, anyway, this method encourages - * a safe practice for generating icon paths, without using heavy solutions based on HTMLPurifier for example. + * This method provides specific protection (against XSS and other kinds of attacks) + * for static images (icons) used by the system. + * Image paths are supposed to be given by programmers - people who know what they do, anyway, + * this method encourages a safe practice for generating icon paths, without using heavy solutions + * based on HTMLPurifier for example. * @param string $img_path The input path of the image, it could be relative or absolute URL. * @return string Returns sanitized image path or an empty string when the image path is not secure. * @author Ivan Tcholakov, March 2011 diff --git a/main/inc/lib/skill.lib.php b/main/inc/lib/skill.lib.php index 44ce654275..9f902a45e0 100755 --- a/main/inc/lib/skill.lib.php +++ b/main/inc/lib/skill.lib.php @@ -132,7 +132,7 @@ class SkillRelProfile extends Model { $profileId = intval($profileId); $skills = $this->get_all(array('where' => array('profile_id = ? ' => $profileId))); - $return = array(); + $return = []; if (!empty($skills)) { foreach ($skills as $skill_data) { $return[] = $skill_data['skill_id']; @@ -184,7 +184,7 @@ class SkillRelSkill extends Model public function getSkillInfo($id) { if (empty($id)) { - return array(); + return []; } $result = Database::select( '*', @@ -212,7 +212,7 @@ class SkillRelSkill extends Model $skill = Database::store_result($result, 'ASSOC'); $skill = isset($skill[0]) ? $skill[0] : null; - $parents = array(); + $parents = []; if (!empty($skill)) { if ($skill['parent_id'] != null) { $parents = self::getSkillParents($skill['parent_id']); @@ -237,7 +237,7 @@ class SkillRelSkill extends Model $result = Database::query($sql); $skill = Database::store_result($result, 'ASSOC'); $skill = isset($skill[0]) ? $skill[0] : null; - $parents = array(); + $parents = []; if (!empty($skill)) { $parents[] = $skill; } @@ -271,7 +271,7 @@ class SkillRelSkill extends Model if ($load_user_data) { $passed_skills = $skill_rel_user->getUserSkills($user_id); - $done_skills = array(); + $done_skills = []; foreach ($passed_skills as $done_skill) { $done_skills[] = $done_skill['skill_id']; } @@ -385,7 +385,7 @@ class SkillRelGradebook extends Model public function getSkillInfo($skill_id, $gradebookId) { if (empty($skill_id)) { - return array(); + return []; } $result = Database::select( '*', @@ -413,9 +413,9 @@ class SkillRelGradebook extends Model 'all', array('where' => array('skill_id = ?' => array($skill_id))) ); - $gradebooks_to_remove = array(); - $gradebooks_to_add = array(); - $original_gradebook_list_ids = array(); + $gradebooks_to_remove = []; + $gradebooks_to_add = []; + $original_gradebook_list_ids = []; if (!empty($original_gradebook_list)) { foreach ($original_gradebook_list as $gradebook) { @@ -505,7 +505,7 @@ class SkillRelUser extends Model */ public function getUserBySkills($skill_list) { - $users = array(); + $users = []; if (!empty($skill_list)) { $skill_list = array_map('intval', $skill_list); $skill_list = implode("', '", $skill_list); @@ -529,7 +529,7 @@ class SkillRelUser extends Model public function getUserSkills($userId, $courseId = 0, $sessionId = 0) { if (empty($userId)) { - return array(); + return []; } $courseId = intval($courseId); @@ -847,7 +847,7 @@ class Skill extends Model ORDER BY ss.id, ss.parent_id"; $result = Database::query($sql); - $skills = array(); + $skills = []; $webPath = api_get_path(WEB_UPLOAD_PATH); if (Database::num_rows($result)) { while ($row = Database::fetch_array($result, 'ASSOC')) { @@ -1012,7 +1012,7 @@ class Skill extends Model if (!empty($params['gradebook_id'])) { foreach ($params['gradebook_id'] as $gradebook_id) { - $attributes = array(); + $attributes = []; $attributes['gradebook_id'] = $gradebook_id; $attributes['skill_id'] = $skill_id; $skillRelGradebook->save($attributes); @@ -1174,7 +1174,7 @@ class Skill extends Model $result = Database::query($sql); $skills = Database::store_result($result, 'ASSOC'); - $skillList = array(); + $skillList = []; if (!empty($skills)) { foreach ($skills as $skill) { if ($getSkillData) { @@ -1418,12 +1418,12 @@ class Skill extends Model } } - $refs = array(); + $refs = []; $skills_tree = null; // Create references for all nodes - $flat_array = array(); - $family = array(); + $flat_array = []; + $family = []; if (!empty($skills)) { foreach ($skills as &$skill) { if ($skill['parent_id'] == 0) { @@ -1484,7 +1484,7 @@ class Skill extends Model // Checking family value $family_id = 1; - $new_family_array = array(); + $new_family_array = []; foreach ($family as $main_family_id => $family_items) { if (!empty($family_items)) { foreach ($family_items as $item) { @@ -1515,7 +1515,7 @@ class Skill extends Model 'name' => get_lang('SkillRootName'), 'id' => 'root', 'children' => $refs['root']['children'], - 'data' => array(), + 'data' => [], ); } @@ -1547,7 +1547,7 @@ class Skill extends Model $return_flat_array, true ); - $simple_tree = array(); + $simple_tree = []; if (!empty($tree['children'])) { foreach ($tree['children'] as $element) { $children = []; @@ -1573,11 +1573,11 @@ class Skill extends Model */ public function getSkillToJson($subtree, $depth = 1, $max_depth = 2) { - $simple_sub_tree = array(); + $simple_sub_tree = []; if (is_array($subtree)) { $counter = 1; foreach ($subtree as $elem) { - $tmp = array(); + $tmp = []; $tmp['name'] = $elem['name']; $tmp['id'] = $elem['id']; $tmp['isSearched'] = self::isSearched($elem['id']); @@ -1662,7 +1662,7 @@ class Skill extends Model return Database::store_result($result, 'ASSOC'); } - return array(); + return []; } /** @@ -1818,10 +1818,10 @@ class Skill extends Model $courseId = intval($courseId); if ($courseId == 0) { - return array(); + return []; } - $list = array(); + $list = []; $sql = "SELECT course.id c_id, @@ -1864,10 +1864,10 @@ class Skill extends Model $skillId = intval($skillId); if ($skillId == 0) { - return array(); + return []; } - $list = array(); + $list = []; $sql = "SELECT course.id c_id, course.title c_name, diff --git a/main/inc/lib/skill.visualizer.lib.php b/main/inc/lib/skill.visualizer.lib.php index 88db8e6f16..e0c185e5b0 100755 --- a/main/inc/lib/skill.visualizer.lib.php +++ b/main/inc/lib/skill.visualizer.lib.php @@ -35,6 +35,11 @@ class SkillVisualizer $this->center_x = intval($this->offset_x + $this->canvas_x / 2 - $this->block_size / 2); } + /** + * @param $skill + * @param $position + * @param $class + */ public function prepare_skill_box($skill, $position, $class) { $block_id = $skill['id']; @@ -59,7 +64,6 @@ class SkillVisualizer //$this->html .= Display::url(Display::return_icon('add.png', get_lang('Add'), array(), ICON_SIZE_SMALL), '#', array('id'=>'edit_block_'.$block_id,'class'=>'edit_block')); //$this->html .= Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), '#', array('id=>"edit_block_'.$block_id,'class'=>'edit_block')); //$this->html .= Display::url(Display::return_icon('up.png', get_lang('Close'), array(), ICON_SIZE_SMALL), '#', array('id'=>'close_block_'.$block_id,'class'=>'close_block')); - //$this->html .= Display::url(Display::return_icon('down.png', get_lang('Open'), array(), ICON_SIZE_SMALL), '#', array('id'=>'open_block_'.$block_id,'class'=>'open_block')); } $this->html .= '
'; diff --git a/main/inc/lib/social.lib.php b/main/inc/lib/social.lib.php index 9fabdd85d4..21408a7802 100755 --- a/main/inc/lib/social.lib.php +++ b/main/inc/lib/social.lib.php @@ -28,12 +28,12 @@ class SocialManager extends UserManager */ public static function show_list_type_friends() { - $friend_relation_list = array(); $table = Database::get_main_table(TABLE_MAIN_USER_FRIEND_RELATION_TYPE); $sql = 'SELECT id, title FROM '.$table.' WHERE id<>6 ORDER BY id ASC'; $result = Database::query($sql); + $friend_relation_list = array(); while ($row = Database::fetch_array($result, 'ASSOC')) { $friend_relation_list[] = $row; } diff --git a/main/lp/learnpath.class.php b/main/lp/learnpath.class.php index 626ee5482e..ea68a06c86 100755 --- a/main/lp/learnpath.class.php +++ b/main/lp/learnpath.class.php @@ -1265,7 +1265,7 @@ class learnpath if (Database::num_rows($res) > 0) { $row2 = Database::fetch_array($res); $di = new ChamiloIndexer(); - $di->remove_document((int) $row2['search_did']); + $di->remove_document($row2['search_did']); } $sql = 'DELETE FROM %s WHERE course_code=\'%s\' AND tool_id=\'%s\' AND ref_id_high_level=%s AND ref_id_second_level=%d