Merge branch '1.11.x' of https://github.com/chamilo/chamilo-lms into 1.11.x

pull/2487/head
Alex Aragon 8 years ago
commit ca0313602c
  1. 2
      main/dashboard/index.php
  2. 4
      main/exercise/exercise.class.php
  3. 2
      main/exercise/question.class.php
  4. 10
      main/inc/lib/ScheduledAnnouncement.php
  5. 9
      main/inc/lib/SequenceResourceManager.php
  6. 68
      main/inc/lib/attendance.lib.php
  7. 13
      main/inc/lib/career.lib.php
  8. 232
      main/inc/lib/course.lib.php
  9. 14
      main/inc/lib/course_description.lib.php
  10. 26
      main/inc/lib/course_home.lib.php
  11. 42
      main/inc/lib/dashboard.lib.php
  12. 2
      main/inc/lib/document.lib.php
  13. 10
      main/inc/lib/exercise_show_functions.lib.php
  14. 1
      main/inc/lib/grade_model.lib.php
  15. 3
      main/inc/lib/gradebook.lib.php
  16. 13
      main/inc/lib/link.lib.php
  17. 8
      main/inc/lib/plugin.class.php
  18. 29
      main/inc/lib/plugin.lib.php
  19. 3
      main/inc/lib/search/xapian/XapianIndexer.class.php
  20. 8
      main/inc/lib/security.lib.php
  21. 54
      main/inc/lib/skill.lib.php
  22. 6
      main/inc/lib/skill.visualizer.lib.php
  23. 2
      main/inc/lib/social.lib.php
  24. 2
      main/lp/learnpath.class.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();

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

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

@ -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', '<div id="specific_date">');
$form->addHtml('<div id="specific_date">');
$form->addDateTimePicker('date', get_lang('Date'));
$form->addElement('html', '</div>');
$form->addElement('html', '<div id="options" style="display:none">');
$form->addHtml('</div>');
$form->addHtml('<div id="options" style="display:none">');
$startDate = $sessionInfo['access_start_date'];
$endDate = $sessionInfo['access_end_date'];
@ -237,8 +238,7 @@ class ScheduledAnnouncement extends Model
$form->addSelect('base_date', get_lang('BaseDate'), $options);
}
$form->addElement('html', '</div>');
$form->addHtml('</div>');
$form->addText('subject', get_lang('Subject'));
$form->addHtmlEditor('message', get_lang('Message'));
$this->setTagsInForm($form);

@ -1,7 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use \Chamilo\CoreBundle\Entity\SequenceResource;
use Chamilo\CoreBundle\Entity\SequenceResource;
/**
* SequenceResourceManager class
@ -42,10 +42,7 @@ class SequenceResourceManager
{
$sequenceList = [];
$entityManager = Database::getManager();
$gradebookCategoryRepo = $entityManager->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;
}

@ -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 .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>&nbsp;';
// Visible
if ($attendance[5] == 1) {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'.
Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).'</a>';
} else {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'.
Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).'</a>';
$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
}
if ($allowDelete === 'true') {
$actions .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
}
} 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 .= '<a href="index.php?'.api_get_cidreq().'&action=attendance_edit&attendance_id='.$attendance[0].'">'.
Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).'</a>&nbsp;';
Display::return_icon('edit.png', get_lang('Edit'), [], ICON_SIZE_SMALL).'</a>&nbsp;';
if ($attendance[5] == 1) {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_invisible&attendance_id='.$attendance[0].'">'.
Display::return_icon('visible.png', get_lang('Hide'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('visible.png', get_lang('Hide'), [], ICON_SIZE_SMALL).'</a>';
} else {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_set_visible&attendance_id='.$attendance[0].'">'.
Display::return_icon('invisible.png', get_lang('Show'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('invisible.png', get_lang('Show'), [], ICON_SIZE_SMALL).'</a>';
$attendance[2] = '<span class="muted">'.$attendance[2].'</span>';
}
if ($allowDelete === 'true') {
$actions .= ' <a href="index.php?'.api_get_cidreq().'&action=attendance_delete&attendance_id='.$attendance[0].'">'.
Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL).'</a>';
Display::return_icon('delete.png', get_lang('Delete'), [], ICON_SIZE_SMALL).'</a>';
}
}
}
@ -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);

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

@ -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;
}
@ -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
);
}
@ -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"');
}
}
@ -2577,8 +2481,12 @@ class CourseManager
$emailbody .= get_lang('FirstName').': '.$student['firstname']."\n";
}
$emailbody .= get_lang('Email').': <a href="mailto:'.$student['email'].'">'.$student['email']."</a>\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;
}
/**
@ -3895,13 +3804,25 @@ class CourseManager
if ($load_dirs) {
$params['document'] = '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
.Display::returnFontAwesomeIcon('folder-open').'</a>';
$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',
)
);
}
}
if ($load_dirs) {
$params['document'] = '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview btn btn-default btn-sm" href="javascript:void(0);">'
. Display::returnFontAwesomeIcon('folder-open').'</a>';
$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';
@ -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'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
$params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
$params['right_actions'] .= '<a href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.
Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).
'</a>';
$params['right_actions'] .= Display::div(
'',
array(
@ -6293,16 +6200,14 @@ class CourseManager
)
);
} else {
$params['right_actions'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::returnFontAwesomeIcon('pencil').'</a>';
}
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'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.
Display::returnFontAwesomeIcon('pencil').'</a>';
}
} else {
if ($course_info['visibility'] != COURSE_VISIBILITY_CLOSED) {
if ($loadDirs) {
$params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
$params['right_actions'] .= '<a id="document_preview_'.$course_info['real_id'].'_0" class="document_preview" href="javascript:void(0);">'.
Display::return_icon('folder.png', get_lang('Documents'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).'</a>';
$params['right_actions'] .= Display::div(
'',
array(
@ -6312,7 +6217,8 @@ class CourseManager
);
} else {
if ($course_info['status'] == COURSEMANAGER) {
$params['right_actions'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.Display::returnFontAwesomeIcon('pencil').'</a>';
$params['right_actions'] .= '<a class="btn btn-default btn-sm" title="'.get_lang('Edit').'" href="'.api_get_path(WEB_CODE_PATH).'course_info/infocours.php?cidReq='.$course['code'].'">'.
Display::returnFontAwesomeIcon('pencil').'</a>';
}
}
}
@ -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 '';
}
}

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

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

@ -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 '<link rel="stylesheet" href="'.api_get_path(WEB_PLUGIN_PATH).'dashboard/css/default.css" type="text/css" />'.PHP_EOL;
}

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

@ -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 '
<tr>

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

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

@ -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]]
);
@ -1292,6 +1293,7 @@ class Link extends Model
* CSV file import functions
* @author René Haentjens , Ghent University
* @param string $catname
* @return int
*/
public static function get_cat($catname)
{
@ -1409,7 +1411,6 @@ class Link extends Model
public static function import_link($linkdata)
{
// url, category_id, title, description, ...
// Field names used in the uploaded file
$known_fields = array(
'url',
@ -1429,9 +1430,7 @@ class Link extends Model
);
// All other fields are added to description, as "name:value".
// Only one hide_field is assumed to be present, <> is removed from value.
if (!($url = trim($linkdata['url'])) || !($title = trim($linkdata['title']))) {
return 0; // 0 = fail
}

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

@ -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
<div class="panel-body">
');
$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])) {

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

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

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

@ -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 .= '</div>';

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

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

Loading…
Cancel
Save