Update from 1.11.x

pull/3006/head
Julio Montoya 6 years ago
parent 387d5b64d0
commit 15378b6c1f
  1. 199
      main/admin/user_list.php
  2. 2
      main/auth/courses_list.php
  3. 19
      main/auth/profile.php
  4. 27
      main/course_info/infocours.php
  5. 8
      main/cron/import_csv.php
  6. 2
      main/document/document.php
  7. 2
      main/document/download_scorm.php
  8. 10
      main/exercise/exercise.class.php
  9. 53
      main/exercise/exercise_show.php
  10. 13
      main/exercise/question_list_admin.inc.php
  11. 2
      main/exercise/stats.php
  12. 166
      main/forum/forumfunction.inc.php
  13. 15
      main/forum/index.php
  14. 2
      main/gradebook/gradebook_edit_cat.php
  15. 19
      main/gradebook/index.php
  16. 49
      main/gradebook/lib/GradebookUtils.php
  17. 6
      main/gradebook/lib/be/abstractlink.class.php
  18. 94
      main/gradebook/lib/be/category.class.php
  19. 18
      main/gradebook/lib/be/evaluation.class.php
  20. 4
      main/gradebook/lib/be/studentpublicationlink.class.php
  21. 4
      main/gradebook/lib/fe/catform.class.php
  22. 8
      main/gradebook/lib/fe/displaygradebook.php
  23. 4
      main/gradebook/lib/scoredisplay.class.php
  24. 3
      main/inc/ajax/document.ajax.php
  25. 6
      main/inc/ajax/message.ajax.php
  26. 40
      main/inc/ajax/model.ajax.php
  27. 17
      main/inc/ajax/social.ajax.php
  28. 20
      main/inc/lib/api.lib.php
  29. 2
      main/inc/lib/array.lib.php
  30. 22
      main/inc/lib/certificate.lib.php
  31. 20
      main/inc/lib/chat.lib.php
  32. 37
      main/inc/lib/course.lib.php
  33. 1
      main/inc/lib/database.constants.inc.php
  34. 30
      main/inc/lib/display.lib.php
  35. 15
      main/inc/lib/document.lib.php
  36. 109
      main/inc/lib/pear/HTML/QuickForm/select.php
  37. 3
      main/inc/lib/pear/HTML/QuickForm/text.php
  38. 2
      main/install/install.lib.php

@ -219,21 +219,22 @@ function prepare_user_sql_query($getCount)
if ($getCount) { if ($getCount) {
$sql .= "SELECT COUNT(u.id) AS total_number_of_items FROM $user_table u"; $sql .= "SELECT COUNT(u.id) AS total_number_of_items FROM $user_table u";
} else { } else {
$sql .= "SELECT u.id AS col0, u.official_code AS col2, "; $sql .= 'SELECT u.id AS col0, u.official_code AS col2, ';
if (api_is_western_name_order()) { if (api_is_western_name_order()) {
$sql .= "u.firstname AS col3, u.lastname AS col4, "; $sql .= 'u.firstname AS col3, u.lastname AS col4, ';
} else { } else {
$sql .= "u.lastname AS col3, u.firstname AS col4, "; $sql .= 'u.lastname AS col3, u.firstname AS col4, ';
} }
$sql .= " u.username AS col5, $sql .= " u.username AS col5,
u.email AS col6, u.email AS col6,
u.status AS col7, u.status AS col7,
u.active AS col8, u.active AS col8,
u.id AS col9, u.registration_date AS col9,
u.registration_date AS col10, u.last_login as col10,
u.expiration_date AS exp, u.id AS col11,
u.expiration_date AS exp,
u.password u.password
FROM $user_table u"; FROM $user_table u";
} }
@ -277,9 +278,7 @@ function prepare_user_sql_query($getCount)
$extra_info = UserManager::get_extra_field_information_by_name($keyword_extra_data); $extra_info = UserManager::get_extra_field_information_by_name($keyword_extra_data);
$field_id = $extra_info['id']; $field_id = $extra_info['id'];
$sql.= " INNER JOIN user_field_values ufv ON u.id=ufv.user_id AND ufv.field_id=$field_id "; $sql.= " INNER JOIN user_field_values ufv ON u.id=ufv.user_id AND ufv.field_id=$field_id ";
} } */
*/
if (isset($_GET['keyword']) && !empty($_GET['keyword'])) { if (isset($_GET['keyword']) && !empty($_GET['keyword'])) {
$keywordFiltered = Database::escape_string("%".$_GET['keyword']."%"); $keywordFiltered = Database::escape_string("%".$_GET['keyword']."%");
$sql .= " WHERE ( $sql .= " WHERE (
@ -332,18 +331,18 @@ function prepare_user_sql_query($getCount)
if (isset($keywordListValues['keyword_active']) && if (isset($keywordListValues['keyword_active']) &&
!isset($keywordListValues['keyword_inactive']) !isset($keywordListValues['keyword_inactive'])
) { ) {
$sql .= " AND u.active = 1"; $sql .= ' AND u.active = 1';
} elseif (isset($keywordListValues['keyword_inactive']) && } elseif (isset($keywordListValues['keyword_inactive']) &&
!isset($keywordListValues['keyword_active']) !isset($keywordListValues['keyword_active'])
) { ) {
$sql .= " AND u.active = 0"; $sql .= ' AND u.active = 0';
} }
$sql .= " ) "; $sql .= ' ) ';
} }
$preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users'); $preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users');
if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') { if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') {
$sql .= " AND u.creator_id = ".api_get_user_id(); $sql .= ' AND u.creator_id = '.api_get_user_id();
} }
$variables = Session::read('variables_to_show', []); $variables = Session::read('variables_to_show', []);
@ -410,7 +409,7 @@ function prepare_user_sql_query($getCount)
if ((api_is_platform_admin() || api_is_session_admin()) && if ((api_is_platform_admin() || api_is_session_admin()) &&
api_get_multiple_access_url() api_get_multiple_access_url()
) { ) {
$sql .= " AND url_rel_user.access_url_id=".api_get_current_access_url_id(); $sql .= ' AND url_rel_user.access_url_id = '.api_get_current_access_url_id();
} }
return $sql; return $sql;
@ -448,97 +447,49 @@ function get_user_data($from, $number_of_items, $column, $direction)
if (!in_array($direction, ['ASC', 'DESC'])) { if (!in_array($direction, ['ASC', 'DESC'])) {
$direction = 'ASC'; $direction = 'ASC';
} }
$_admins_list = Session::read('admin_list', []); $column = (int) $column;
$column = intval($column); $from = (int) $from;
$from = intval($from); $number_of_items = (int) $number_of_items;
$number_of_items = intval($number_of_items);
$sql .= " ORDER BY col$column $direction "; $sql .= " ORDER BY col$column $direction ";
$sql .= " LIMIT $from,$number_of_items"; $sql .= " LIMIT $from, $number_of_items";
$res = Database::query($sql); $res = Database::query($sql);
$users = []; $users = [];
$t = time(); $t = time();
$currentUser = api_get_current_user(); while ($user = Database::fetch_array($res)) {
while ($user = Database::fetch_row($res)) {
$userPicture = UserManager::getUserPicture( $userPicture = UserManager::getUserPicture(
$user[0], $user[0],
USER_IMAGE_SIZE_SMALL USER_IMAGE_SIZE_SMALL
); );
$is_admin = in_array($user[0], $_admins_list);
$photo = '<img $photo = '<img
src="'.$userPicture.'" class="rounded-circle avatar" src="'.$userPicture.'" width="22" height="22"
alt="'.api_get_person_name($user[2], $user[3]).'" alt="'.api_get_person_name($user[2], $user[3]).'"
title="'.api_get_person_name($user[2], $user[3]).'" />'; title="'.api_get_person_name($user[2], $user[3]).'" />';
if ($user[7] == 1 && !empty($user[10])) { if ($user[7] == 1 && !empty($user['exp'])) {
// check expiration date // check expiration date
$expiration_time = convert_sql_date($user[10]); $expiration_time = convert_sql_date($user['exp']);
// if expiration date is passed, store a special value for active field // if expiration date is passed, store a special value for active field
if ($expiration_time < $t) { if ($expiration_time < $t) {
$user[7] = '-1'; $user[7] = '-1';
} }
} }
$iconAdmin = '';
if ($is_admin) {
$iconAdmin .= Display::return_icon(
'admin_star.png',
get_lang('IsAdministrator'),
null,
ICON_SIZE_SMALL
);
}
$iconActive = null;
$action = null;
$image = null;
if ($user[7] == '1') {
$action = 'Lock';
$image = 'accept';
} elseif ($user[7] == '-1') {
$action = 'edit';
$image = 'warning';
} elseif ($user[7] == '0') {
$action = 'Unlock';
$image = 'error';
}
if ($action === 'edit') {
$iconActive = Display::return_icon(
$image.'.png',
get_lang('AccountExpired'),
[],
16
);
} elseif ($user['0'] != $currentUser->getId()) {
// you cannot lock yourself out otherwise you could disable all the
// accounts including your own => everybody is locked out and nobody
// can change it anymore.
$iconActive = Display::return_icon(
$image.'.png',
get_lang(ucfirst($action)),
['onclick' => 'active_user(this);', 'id' => 'img_'.$user['0']],
16
);
}
$profile = '<div class="avatar-user">'.$photo.'<span class="is-admin">'
.$iconAdmin.'</span><span class="is-active">'.$iconActive.'</span></div>';
// forget about the expiration date field // forget about the expiration date field
$users[] = [ $users[] = [
$user[0], $user[0], // id
$profile, $photo,
$user[1], $user[1],
$user[2], $user[2],
$user[3], $user[3],
$user[4], $user[4], // username
$user[5], $user[5], // email
$user[6], $user[6],
api_get_local_time($user[9]), $user[7], // active
api_get_local_time($user[8]),
api_get_local_time($user[9], null, null, true),
$user[0], $user[0],
]; ];
} }
@ -555,13 +506,13 @@ function get_user_data($from, $number_of_items, $column, $direction)
*/ */
function email_filter($email) function email_filter($email)
{ {
return Display:: encrypted_mailto_link($email, $email, null, true); return Display::encrypted_mailto_link($email, $email);
} }
/** /**
* Returns a mailto-link. * Returns a mailto-link.
* *
* @param string $email An email-address * @param string $name
* @param array $params Deprecated * @param array $params Deprecated
* @param array $row * @param array $row
* *
@ -585,6 +536,8 @@ function user_filter($name, $params, $row)
*/ */
function modify_filter($user_id, $url_params, $row) function modify_filter($user_id, $url_params, $row)
{ {
$_admins_list = Session::read('admin_list', []);
$is_admin = in_array($user_id, $_admins_list);
$statusname = api_get_status_langvars(); $statusname = api_get_status_langvars();
$user_is_anonymous = false; $user_is_anonymous = false;
$current_user_status_label = $row['7']; $current_user_status_label = $row['7'];
@ -592,7 +545,7 @@ function modify_filter($user_id, $url_params, $row)
if ($current_user_status_label == $statusname[ANONYMOUS]) { if ($current_user_status_label == $statusname[ANONYMOUS]) {
$user_is_anonymous = true; $user_is_anonymous = true;
} }
$result = '<div class="toolbar-table">'; $result = '';
if (!$user_is_anonymous) { if (!$user_is_anonymous) {
$icon = Display::return_icon( $icon = Display::return_icon(
'course.png', 'course.png',
@ -601,7 +554,7 @@ function modify_filter($user_id, $url_params, $row)
); );
$result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" > $result .= '<a href="javascript:void(0)" onclick="load_course_list(\'div_'.$user_id.'\','.$user_id.')" >
'.$icon.' '.$icon.'
<div class="blackboard_hide" id="div_'.$user_id.'"></div> <div class="blackboard_hide" id="div_'.$user_id.'">&nbsp;&nbsp;</div>
</a>'; </a>';
$icon = Display::return_icon( $icon = Display::return_icon(
@ -611,26 +564,26 @@ function modify_filter($user_id, $url_params, $row)
); );
$result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" > $result .= '<a href="javascript:void(0)" onclick="load_session_list(\'div_s_'.$user_id.'\','.$user_id.')" >
'.$icon.' '.$icon.'
<div class="blackboard_hide" id="div_s_'.$user_id.'"></div> <div class="blackboard_hide" id="div_s_'.$user_id.'">&nbsp;&nbsp;</div>
</a>'; </a>';
} else { } else {
$result .= Display::return_icon('course_na.png', get_lang('Courses')); $result .= Display::return_icon('course_na.png', get_lang('Courses')).'&nbsp;&nbsp;';
$result .= Display::return_icon('course_na.png', get_lang('Sessions')); $result .= Display::return_icon('course_na.png', get_lang('Sessions')).'&nbsp;&nbsp;';
} }
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
if (!$user_is_anonymous) { if (!$user_is_anonymous) {
$result .= '<a href="user_information.php?user_id='.$user_id.'">'. $result .= '<a href="user_information.php?user_id='.$user_id.'">'.
Display::return_icon('info2.png', get_lang('Info')).'</a>'; Display::return_icon('info2.png', get_lang('Info')).'</a>&nbsp;&nbsp;';
} else { } else {
$result .= Display::return_icon('info2_na.png', get_lang('Info')); $result .= Display::return_icon('info2_na.png', get_lang('Info')).'&nbsp;&nbsp;';
} }
} }
//only allow platform admins to login_as, or session admins only for students (not teachers nor other admins) // Only allow platform admins to login_as, or session admins only for students (not teachers nor other admins)
$loginAsStatusForSessionAdmins = [$statusname[STUDENT]]; $loginAsStatusForSessionAdmins = [$statusname[STUDENT]];
//except when session.allow_session_admin_login_as_teacher is enabled, then can login_as teachers also // Except when session.allow_session_admin_login_as_teacher is enabled, then can login_as teachers also
if (api_get_configuration_value('session.allow_session_admin_login_as_teacher')) { if (api_get_configuration_value('session.allow_session_admin_login_as_teacher')) {
$loginAsStatusForSessionAdmins[] = $statusname[COURSEMANAGER]; $loginAsStatusForSessionAdmins[] = $statusname[COURSEMANAGER];
} }
@ -642,26 +595,26 @@ function modify_filter($user_id, $url_params, $row)
if (!$user_is_anonymous) { if (!$user_is_anonymous) {
if (api_global_admin_can_edit_admin($user_id, null, $sessionAdminCanLoginAs)) { if (api_global_admin_can_edit_admin($user_id, null, $sessionAdminCanLoginAs)) {
$result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::getTokenFromSession().'">'. $result .= '<a href="user_list.php?action=login_as&user_id='.$user_id.'&sec_token='.Security::getTokenFromSession().'">'.
Display::return_icon('login_as.png', get_lang('LoginAs')).'</a>'; Display::return_icon('login_as.png', get_lang('LoginAs')).'</a>&nbsp;';
} else { } else {
$result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')); $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;';
} }
} else { } else {
$result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')); $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;';
} }
} else { } else {
$result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')); $result .= Display::return_icon('login_as_na.png', get_lang('LoginAs')).'&nbsp;';
} }
if ($current_user_status_label != $statusname[STUDENT]) { if ($current_user_status_label != $statusname[STUDENT]) {
$result .= Display::return_icon( $result .= Display::return_icon(
'statistics_na.png', 'statistics_na.png',
get_lang('Reporting') get_lang('Reporting')
); ).'&nbsp;';
} else { } else {
$result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'. $result .= '<a href="../mySpace/myStudents.php?student='.$user_id.'">'.
Display::return_icon('statistics.png', get_lang('Reporting')). Display::return_icon('statistics.png', get_lang('Reporting')).
'</a>'; '</a>&nbsp;';
} }
if (api_is_platform_admin(true)) { if (api_is_platform_admin(true)) {
@ -676,14 +629,14 @@ function modify_filter($user_id, $url_params, $row)
[], [],
ICON_SIZE_SMALL ICON_SIZE_SMALL
). ).
'</a>'; '</a>&nbsp;';
} else { } else {
$result .= Display::return_icon( $result .= Display::return_icon(
'edit_na.png', 'edit_na.png',
get_lang('Edit'), get_lang('Edit'),
[], [],
ICON_SIZE_SMALL ICON_SIZE_SMALL
).'</a>'; ).'</a>&nbsp;';
} }
} }
@ -701,6 +654,19 @@ function modify_filter($user_id, $url_params, $row)
); );
} }
if ($is_admin) {
$result .= Display::return_icon(
'admin_star.png',
get_lang('IsAdministrator'),
['width' => ICON_SIZE_SMALL, 'heigth' => ICON_SIZE_SMALL]
);
} else {
$result .= Display::return_icon(
'admin_star_na.png',
get_lang('IsNotAdministrator')
);
}
// actions for assigning sessions, courses or users // actions for assigning sessions, courses or users
if (!api_is_session_admin()) { if (!api_is_session_admin()) {
if ($current_user_status_label == $statusname[SESSIONADMIN]) { if ($current_user_status_label == $statusname[SESSIONADMIN]) {
@ -814,7 +780,6 @@ function modify_filter($user_id, $url_params, $row)
); );
} }
} }
$result .= '</div>';
} }
return $result; return $result;
@ -884,17 +849,17 @@ function active_filter($active, $params, $row)
*/ */
function status_filter($status) function status_filter($status)
{ {
$statusname = api_get_status_langvars(); $name = api_get_status_langvars();
return $statusname[$status]; return $name[$status];
} }
if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) { if (isset($_GET['keyword']) || isset($_GET['keyword_firstname'])) {
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')];
$interbreadcrumb[] = ["url" => 'user_list.php', "name" => get_lang('UserList')]; $interbreadcrumb[] = ['url' => 'user_list.php', 'name' => get_lang('UserList')];
$tool_name = get_lang('SearchUsers'); $tool_name = get_lang('SearchUsers');
} else { } else {
$interbreadcrumb[] = ["url" => 'index.php', "name" => get_lang('PlatformAdmin')]; $interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')];
$tool_name = get_lang('UserList'); $tool_name = get_lang('UserList');
} }
@ -1015,7 +980,7 @@ $form->addText(
get_lang('Search'), get_lang('Search'),
false, false,
[ [
'aria-label' => get_lang("SearchUsers"), 'aria-label' => get_lang('SearchUsers'),
] ]
); );
$form->addButtonSearch(get_lang('Search')); $form->addButtonSearch(get_lang('Search'));
@ -1134,16 +1099,22 @@ if (api_is_western_name_order()) {
$table->set_header(5, get_lang('LoginName')); $table->set_header(5, get_lang('LoginName'));
$table->set_header(6, get_lang('Email')); $table->set_header(6, get_lang('Email'));
$table->set_header(7, get_lang('Profile')); $table->set_header(7, get_lang('Profile'));
//$table->set_header(8, get_lang('Active'), true); $table->set_header(8, get_lang('Active'), true, 'width="15px"');
$table->set_header(8, get_lang('RegistrationDate'), true); $table->set_header(9, get_lang('RegistrationDate'), true, 'width="90px"');
$table->set_header(9, get_lang('Action'), false); $table->set_header(10, get_lang('LatestLogin'), true, 'width="90px"');
$table->set_header(11, get_lang('Action'), false, 'width="220px"');
$table->set_column_filter(3, 'user_filter'); $table->set_column_filter(3, 'user_filter');
$table->set_column_filter(4, 'user_filter'); $table->set_column_filter(4, 'user_filter');
$table->set_column_filter(6, 'email_filter'); $table->set_column_filter(6, 'email_filter');
$table->set_column_filter(7, 'status_filter'); $table->set_column_filter(7, 'status_filter');
//$table->set_column_filter(8, 'active_filter'); $table->set_column_filter(8, 'active_filter');
$table->set_column_filter(9, 'modify_filter'); $table->set_column_filter(11, 'modify_filter');
// Hide email column if login is email, to avoid column with same data
if (api_get_setting('login_is_email') === 'true') {
$table->setHideColumn(6);
}
// Only show empty actions bar if delete users has been blocked // Only show empty actions bar if delete users has been blocked
$actionsList = []; $actionsList = [];
@ -1159,7 +1130,7 @@ $table->set_form_actions($actionsList);
$table_result = $table->return_table(); $table_result = $table->return_table();
$extra_search_options = ''; $extra_search_options = '';
//Try to search the user everywhere // Try to search the user everywhere
if ($table->get_total_number_of_items() == 0) { if ($table->get_total_number_of_items() == 0) {
if (api_get_multiple_access_url() && isset($_REQUEST['keyword'])) { if (api_get_multiple_access_url() && isset($_REQUEST['keyword'])) {
$keyword = Database::escape_string($_REQUEST['keyword']); $keyword = Database::escape_string($_REQUEST['keyword']);

@ -51,7 +51,7 @@ if (!empty($user_course_categories)) {
} }
if ($action != 'unsubscribe') { if ($action != 'unsubscribe') {
if ($allowCollapsable) { if ($allowCollapsable) {
if ($row['collapsed'] == 0) { if (isset($row['collapsed']) && $row['collapsed'] == 0) {
echo Display::url( echo Display::url(
'<i class="fa fa-folder-open"></i>', '<i class="fa fa-folder-open"></i>',
$url.'&action=set_collapsable&option=1' $url.'&action=set_collapsable&option=1'

@ -26,7 +26,6 @@ $logInfo = [
'tool_id' => 0, 'tool_id' => 0,
'tool_id_detail' => 0, 'tool_id_detail' => 0,
'action' => $this_section, 'action' => $this_section,
'info' => '',
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
@ -538,6 +537,7 @@ if ($form->validate()) {
//Only update values that are request by the "profile" setting //Only update values that are request by the "profile" setting
//Adding missing variables //Adding missing variables
$available_values_to_modify = []; $available_values_to_modify = [];
foreach ($profileList as $key) { foreach ($profileList as $key) {
switch ($key) { switch ($key) {
@ -562,7 +562,7 @@ if ($form->validate()) {
} }
} }
// Fixing missing variables //Fixing missing variables
$available_values_to_modify = array_merge( $available_values_to_modify = array_merge(
$available_values_to_modify, $available_values_to_modify,
['competences', 'diplomas', 'openarea', 'teach', 'openid', 'address'] ['competences', 'diplomas', 'openarea', 'teach', 'openid', 'address']
@ -617,7 +617,6 @@ if ($form->validate()) {
} }
$sql .= " WHERE id = '".api_get_user_id()."'"; $sql .= " WHERE id = '".api_get_user_id()."'";
Database::query($sql); Database::query($sql);
if (isset($user_data['language']) && !empty($user_data['language'])) { if (isset($user_data['language']) && !empty($user_data['language'])) {
@ -652,23 +651,21 @@ if ($form->validate()) {
Session::write('_user', $userInfo); Session::write('_user', $userInfo);
if ($hook) { if ($hook) {
Database::getManager()->clear(User::class); //Avoid cache issue (user entity is used before) Database::getManager()->clear(User::class); // Avoid cache issue (user entity is used before)
$user = api_get_user_entity(api_get_user_id()); // Get updated user info for hook event
$user = api_get_user_entity(api_get_user_id()); //Get updated user info for hook event
$hook->setEventData(['user' => $user]); $hook->setEventData(['user' => $user]);
$hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST); $hook->notifyUpdateUser(HOOK_EVENT_TYPE_POST);
} }
Session::erase('system_timezone');
$url = api_get_self(); $url = api_get_self();
header("Location: $url"); header("Location: $url");
exit; exit;
} }
// the header
$actions = ''; $actions = '';
if (api_get_setting('allow_social_tool') !== 'true') { if ($allowSocialTool) {
if (api_get_setting('extended_profile') === 'true') { if (api_get_setting('extended_profile') === 'true') {
if (api_get_setting('allow_message_tool') === 'true') { if (api_get_setting('allow_message_tool') === 'true') {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'. $actions .= '<a href="'.api_get_path(WEB_PATH).'main/social/profile.php">'.
@ -701,7 +698,7 @@ if ($actions) {
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages');
if (api_get_setting('allow_social_tool') === 'true') { if ($allowSocialTool) {
SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home'); SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'home');
$menu = SocialManager::show_social_menu( $menu = SocialManager::show_social_menu(
'home', 'home',

@ -126,7 +126,6 @@ $form->applyFilter('department_url', 'html_filter');
// Extra fields // Extra fields
$extra_field = new ExtraField('course'); $extra_field = new ExtraField('course');
$extraFieldAdminPermissions = false; $extraFieldAdminPermissions = false;
$showOnlyTheseFields = ['tags', 'video_url', 'course_hours_duration', 'max_subscribed_students']; $showOnlyTheseFields = ['tags', 'video_url', 'course_hours_duration', 'max_subscribed_students'];
$extra = $extra_field->addElements( $extra = $extra_field->addElements(
@ -212,8 +211,6 @@ $form->addButtonSave(get_lang('SaveSettings'), 'submit_save');
$form->addHtml(card_settings_close()); $form->addHtml(card_settings_close());
//************* COURSE ACCESS ******************//
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
'radio', 'radio',
@ -313,9 +310,7 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
//************** END COURSE ACCESS *************// // Documents
//************** START DOCUMENTS ***************//
$globalGroup = []; $globalGroup = [];
if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') { if (api_get_setting('documents_default_visibility_defined_in_course') == 'true') {
$group = [ $group = [
@ -356,12 +351,7 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
// *************** END DOCUMENTS ***************** //
// ************** START EMAIL NOTIFICATIONS *******************//
$globalGroup = []; $globalGroup = [];
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
'radio', 'radio',
@ -505,8 +495,6 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
//************** END EMAIL NOTIFICATIONS ******************//
//******************* START USER *******************//
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
'radio', 'radio',
@ -576,10 +564,8 @@ $form->addPanelOption(
false, false,
'accordionSettings' 'accordionSettings'
); );
//****************** END USER ****************//
//***************** CHAT SETTINGS ***************//
// CHAT SETTINGS
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
'radio', 'radio',
@ -605,8 +591,6 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
//*************** START LEARNING PATH *************** //
$globalGroup = []; $globalGroup = [];
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
@ -721,9 +705,7 @@ $form->addPanelOption(
false, false,
'accordionSettings' 'accordionSettings'
); );
// ********** END CONFIGURE LEARN PATH ***************//
// ********** EXERCISE ********************* //
if (api_get_configuration_value('allow_exercise_auto_launch')) { if (api_get_configuration_value('allow_exercise_auto_launch')) {
$globalGroup = []; $globalGroup = [];
@ -814,9 +796,6 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
// ************* END THEMATIC *********** //
// ************* CERTIFICATE SETTINGS ***************** //
if (api_get_setting('allow_public_certificates') === 'true') { if (api_get_setting('allow_public_certificates') === 'true') {
$group = []; $group = [];
$group[] = $form->createElement( $group[] = $form->createElement(
@ -872,7 +851,7 @@ $form->addPanelOption(
'accordionSettings' 'accordionSettings'
); );
//********** STUDENT PUBLICATION ***************** // // Student publication
$group = [ $group = [
$form->createElement('radio', 'show_score', null, get_lang('NewVisible'), 0), $form->createElement('radio', 'show_score', null, get_lang('NewVisible'), 0),
$form->createElement('radio', 'show_score', null, get_lang('NewUnvisible'), 1), $form->createElement('radio', 'show_score', null, get_lang('NewUnvisible'), 1),

@ -1226,16 +1226,12 @@ class ImportCsv
$update = false; $update = false;
$item = null; $item = null;
if (!isset($event[$extraFieldName])) { if (!isset($event[$extraFieldName])) {
$this->logger->addInfo( $this->logger->addInfo('No external_calendar_itemID found. Skipping ...');
"No external_calendar_itemID found. Skipping ..."
);
continue; continue;
} else { } else {
$externalEventId = $event[$extraFieldName]; $externalEventId = $event[$extraFieldName];
if (empty($externalEventId)) { if (empty($externalEventId)) {
$this->logger->addInfo( $this->logger->addInfo('external_calendar_itemID was set but empty. Skipping ...');
"external_calendar_itemID was set but empty. Skipping ..."
);
continue; continue;
} }

@ -1658,6 +1658,8 @@ if ($is_certificate_mode && $curdirpath != '/certificates') {
); );
} }
$column_show = [];
if ($isAllowedToEdit || if ($isAllowedToEdit ||
$groupMemberWithUploadRights || $groupMemberWithUploadRights ||
DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId) DocumentManager::is_my_shared_folder(api_get_user_id(), $curdirpath, $sessionId)

@ -29,7 +29,7 @@ if (empty($obj)) {
} }
// If is visible for the current user // If is visible for the current user
if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id())) { if (!learnpath::is_lp_visible_for_student($obj->get_id(), api_get_user_id(), $_course)) {
api_not_allowed(); api_not_allowed();
} }

@ -3607,8 +3607,8 @@ class Exercise
if ($from_database) { if ($from_database) {
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
WHERE WHERE
exe_id = '".$exeId."' AND exe_id = $exeId AND
question_id= '".$questionId."'"; question_id = $questionId";
$result = Database::query($sql); $result = Database::query($sql);
$choice = Database::result($result, 0, 'answer'); $choice = Database::result($result, 0, 'answer');
@ -3804,7 +3804,7 @@ class Exercise
if ($from_database) { if ($from_database) {
$choice = []; $choice = [];
$sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT $sql = "SELECT answer FROM $TBL_TRACK_ATTEMPT
WHERE exe_id = $exeId AND question_id= $questionId"; WHERE exe_id = $exeId AND question_id = $questionId";
$resultans = Database::query($sql); $resultans = Database::query($sql);
while ($row = Database::fetch_array($resultans)) { while ($row = Database::fetch_array($resultans)) {
$choice[$row['answer']] = 1; $choice[$row['answer']] = 1;
@ -4235,7 +4235,7 @@ class Exercise
FROM $TBL_TRACK_ATTEMPT FROM $TBL_TRACK_ATTEMPT
WHERE WHERE
exe_id = $exeId AND exe_id = $exeId AND
question_id= ".intval($questionId); question_id = $questionId";
$result = Database::query($sql); $result = Database::query($sql);
$resultData = Database::fetch_array($result, 'ASSOC'); $resultData = Database::fetch_array($result, 'ASSOC');
$answer = $resultData['answer']; $answer = $resultData['answer'];
@ -4560,7 +4560,7 @@ class Exercise
WHERE WHERE
hotspot_exe_id = $exeId AND hotspot_exe_id = $exeId AND
hotspot_question_id= $questionId AND hotspot_question_id= $questionId AND
hotspot_answer_id = ".intval($answerAutoId)." hotspot_answer_id = $answerAutoId
ORDER BY hotspot_id ASC"; ORDER BY hotspot_id ASC";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {

@ -16,7 +16,7 @@ use ChamiloSession as Session;
* @todo small letters for table variables * @todo small letters for table variables
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
$debug = false;
$origin = api_get_origin(); $origin = api_get_origin();
$currentUserId = api_get_user_id(); $currentUserId = api_get_user_id();
$printHeaders = $origin === 'learnpath'; $printHeaders = $origin === 'learnpath';
@ -67,7 +67,7 @@ if (empty($exerciseResult)) {
if (empty($choiceDegreeCertainty)) { if (empty($choiceDegreeCertainty)) {
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null; $choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : null;
} }
$questionId = isset($_REQUEST['questionId']) ? $_REQUEST['questionId'] : null; $questionId = isset($_REQUEST['questionId']) ? (int) $_REQUEST['questionId'] : null;
if (empty($choice)) { if (empty($choice)) {
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null; $choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : null;
@ -309,29 +309,24 @@ if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLa
} }
$i = $totalScore = $totalWeighting = 0; $i = $totalScore = $totalWeighting = 0;
if ($debug > 0) {
error_log("ExerciseResult: ".print_r($exerciseResult, 1));
error_log("QuestionList: ".print_r($questionList, 1));
}
$arrques = []; $arrques = [];
$arrans = []; $arrans = [];
$user_restriction = $is_allowedToEdit ? '' : "AND user_id=".intval($student_id)." "; $user_restriction = $is_allowedToEdit ? '' : " AND user_id= $student_id ";
$sql = "SELECT attempts.question_id, answer $sql = "SELECT attempts.question_id, answer
FROM $TBL_TRACK_ATTEMPT as attempts FROM $TBL_TRACK_ATTEMPT as attempts
INNER JOIN ".$TBL_TRACK_EXERCISES." AS stats_exercises INNER JOIN $TBL_TRACK_EXERCISES AS stats_exercises
ON stats_exercises.exe_id=attempts.exe_id ON stats_exercises.exe_id = attempts.exe_id
INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions INNER JOIN $TBL_EXERCISE_QUESTION AS quizz_rel_questions
ON ON
quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND quizz_rel_questions.exercice_id=stats_exercises.exe_exo_id AND
quizz_rel_questions.question_id = attempts.question_id AND quizz_rel_questions.question_id = attempts.question_id AND
quizz_rel_questions.c_id=".api_get_course_int_id()." quizz_rel_questions.c_id=".api_get_course_int_id()."
INNER JOIN ".$TBL_QUESTIONS." AS questions INNER JOIN $TBL_QUESTIONS AS questions
ON ON
questions.id = quizz_rel_questions.question_id AND questions.id = quizz_rel_questions.question_id AND
questions.c_id = ".api_get_course_int_id()." questions.c_id = ".api_get_course_int_id()."
WHERE WHERE
attempts.exe_id = ".$id." $user_restriction attempts.exe_id = $id $user_restriction
GROUP BY quizz_rel_questions.question_order, attempts.question_id"; GROUP BY quizz_rel_questions.question_order, attempts.question_id";
$result = Database::query($sql); $result = Database::query($sql);
$question_list_from_database = []; $question_list_from_database = [];
@ -548,15 +543,13 @@ foreach ($questionList as $questionId) {
$overlap_color = 'red'; $overlap_color = 'red';
} }
$missing_color = 'red';
if ($missing_color) { if ($missing_color) {
$missing_color = 'green'; $missing_color = 'green';
} else {
$missing_color = 'red';
} }
$excess_color = 'red';
if ($excess_color) { if ($excess_color) {
$excess_color = 'green'; $excess_color = 'green';
} else {
$excess_color = 'red';
} }
if (!is_numeric($final_overlap)) { if (!is_numeric($final_overlap)) {
@ -648,9 +641,9 @@ foreach ($questionList as $questionId) {
echo '<p>'.$comment.'</p>'; echo '<p>'.$comment.'</p>';
} }
//showing the score // Showing the score
$queryfree = "SELECT marks from ".$TBL_TRACK_ATTEMPT." $queryfree = "SELECT marks FROM $TBL_TRACK_ATTEMPT
WHERE exe_id = ".intval($id)." AND question_id= ".intval($questionId); WHERE exe_id = $id AND question_id= ".intval($questionId);
$resfree = Database::query($queryfree); $resfree = Database::query($queryfree);
$questionScore = Database::result($resfree, 0, "marks"); $questionScore = Database::result($resfree, 0, "marks");
$totalScore += $questionScore; $totalScore += $questionScore;
@ -738,7 +731,7 @@ foreach ($questionList as $questionId) {
$url_name = get_lang('EditCommentsAndMarks'); $url_name = get_lang('EditCommentsAndMarks');
} else { } else {
$url_name = get_lang('AddComments'); $url_name = get_lang('AddComments');
if ($action == 'edit') { if ($action === 'edit') {
$url_name = get_lang('EditIndividualComment'); $url_name = get_lang('EditIndividualComment');
} }
} }
@ -842,24 +835,6 @@ foreach ($questionList as $questionId) {
} }
$formMark->display(); $formMark->display();
/*echo '<form name="smarksform_'.$questionId.'" method="post" action="">';
echo get_lang('AssignMarks');
echo "&nbsp;<select name='marks' id='select_marks_".$questionId."' class='selectpicker exercise_mark_select'>";
if (empty($model)) {
for ($i = 0; $i <= $questionWeighting; $i++) {
echo '<option value="'.$i.'" '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$i.'</option>';
}
} else {
foreach ($model['score_list'] as $item) {
$i = api_number_format($item['score_to_qualify'] / 100 * $questionWeighting, 2);
$model = ExerciseLib::getModelStyle($item, $i);
echo '<option class = "'.$item['css_class'].'" value="'.$i.'" '.(($i == $questionScore) ? "selected='selected'" : '').'>'.$model.'</option>';
}
}
echo '</select>';
echo '</form><br /></div>';*/
echo '</div>'; echo '</div>';
if ($questionScore == -1) { if ($questionScore == -1) {
$questionScore = 0; $questionScore = 0;
@ -1002,7 +977,7 @@ if ($answerType != MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
// Total score // Total score
$myTotalScoreTemp = $totalScore; $myTotalScoreTemp = $totalScore;
if ($origin != 'learnpath' || ($origin == 'learnpath' && isset($_GET['fb_type']))) { if ($origin != 'learnpath' || ($origin === 'learnpath' && isset($_GET['fb_type']))) {
if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) { if ($show_results || $show_only_total_score || $showTotalScoreAndUserChoicesInLastAttempt) {
$totalScoreText .= '<div class="question_row">'; $totalScoreText .= '<div class="question_row">';
if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) { if ($objExercise->selectPropagateNeg() == 0 && $myTotalScoreTemp < 0) {

@ -216,13 +216,17 @@ if (!$inATest) {
if (is_array($questionList)) { if (is_array($questionList)) {
foreach ($questionList as $id) { foreach ($questionList as $id) {
//To avoid warning messages // To avoid warning messages.
if (!is_numeric($id)) { if (!is_numeric($id)) {
continue; continue;
} }
/** @var Question $objQuestionTmp */ /** @var Question $objQuestionTmp */
$objQuestionTmp = Question::read($id); $objQuestionTmp = Question::read($id);
if (empty($objQuestionTmp)) {
continue;
}
$clone_link = Display::url( $clone_link = Display::url(
Display::return_icon( Display::return_icon(
'cd.png', 'cd.png',
@ -233,7 +237,8 @@ if (!$inATest) {
api_get_self().'?'.api_get_cidreq().'&clone_question='.$id.'&page='.$page, api_get_self().'?'.api_get_cidreq().'&clone_question='.$id.'&page='.$page,
['class' => 'btn btn-default btn-sm'] ['class' => 'btn btn-default btn-sm']
); );
$edit_link = $objQuestionTmp->type == CALCULATED_ANSWER && $objQuestionTmp->isAnswered()
$edit_link = $objQuestionTmp->selectType() == CALCULATED_ANSWER && $objQuestionTmp->isAnswered()
? Display::span( ? Display::span(
Display::return_icon( Display::return_icon(
'edit_na.png', 'edit_na.png',
@ -311,11 +316,11 @@ if (!$inATest) {
TestCategory::getCategoryNameForQuestion($objQuestionTmp->id) TestCategory::getCategoryNameForQuestion($objQuestionTmp->id)
); );
if (empty($txtQuestionCat)) { if (empty($txtQuestionCat)) {
$txtQuestionCat = "-"; $txtQuestionCat = '-';
} }
// Question level // Question level
$txtQuestionLevel = $objQuestionTmp->level; $txtQuestionLevel = $objQuestionTmp->getLevel();
if (empty($objQuestionTmp->level)) { if (empty($objQuestionTmp->level)) {
$txtQuestionLevel = '-'; $txtQuestionLevel = '-';
} }

@ -235,7 +235,7 @@ if (!empty($question_list)) {
$answer_id, $answer_id,
$question_id, $question_id,
$exerciseId, $exerciseId,
api_get_course_int_id(), $courseCode,
$sessionId $sessionId
); );
$percentage = 0; $percentage = 0;

@ -100,7 +100,7 @@ function handle_forum_and_forumcategories($lp_id = null)
$get_content = isset($_GET['content']) ? $_GET['content'] : ''; $get_content = isset($_GET['content']) ? $_GET['content'] : '';
$post_submit_cat = isset($_POST['SubmitForumCategory']) ? true : false; $post_submit_cat = isset($_POST['SubmitForumCategory']) ? true : false;
$post_submit_forum = isset($_POST['SubmitForum']) ? true : false; $post_submit_forum = isset($_POST['SubmitForum']) ? true : false;
$get_id = isset($_GET['id']) ? intval($_GET['id']) : ''; $get_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$forum_categories_list = get_forum_categories(); $forum_categories_list = get_forum_categories();
// Verify if forum category exists // Verify if forum category exists
@ -111,23 +111,23 @@ function handle_forum_and_forumcategories($lp_id = null)
$content = ''; $content = '';
// Adding a forum category // Adding a forum category
if (($action_forum_cat == 'add' && $get_content == 'forumcategory') || $post_submit_cat) { if (($action_forum_cat === 'add' && $get_content === 'forumcategory') || $post_submit_cat) {
$content = show_add_forumcategory_form([], $lp_id); //$lp_id when is called from learning path $content = show_add_forumcategory_form([], $lp_id); //$lp_id when is called from learning path
} }
// Adding a forum // Adding a forum
if ((($action_forum_cat == 'add' || $action_forum_cat == 'edit') && $get_content == 'forum') || if ((($action_forum_cat === 'add' || $action_forum_cat === 'edit') && $get_content === 'forum') ||
$post_submit_forum $post_submit_forum
) { ) {
$inputvalues = []; $inputvalues = [];
if ($action_forum_cat == 'edit' && $get_id || $post_submit_forum) { if ($action_forum_cat === 'edit' && $get_id || $post_submit_forum) {
$inputvalues = get_forums($get_id); $inputvalues = get_forums($get_id);
} }
$content = show_add_forum_form($inputvalues, $lp_id); $content = show_add_forum_form($inputvalues, $lp_id);
} }
// Edit a forum category // Edit a forum category
if (($action_forum_cat == 'edit' && $get_content == 'forumcategory') || if (($action_forum_cat === 'edit' && $get_content === 'forumcategory') ||
(isset($_POST['SubmitEditForumCategory'])) ? true : false (isset($_POST['SubmitEditForumCategory'])) ? true : false
) { ) {
$forum_category = get_forum_categories($get_id); $forum_category = get_forum_categories($get_id);
@ -135,10 +135,8 @@ function handle_forum_and_forumcategories($lp_id = null)
} }
// Delete a forum category // Delete a forum category
if ($action_forum_cat == 'delete') { if ($action_forum_cat === 'delete') {
$id_forum = intval($get_id); $list_threads = get_threads($get_id);
$list_threads = get_threads($id_forum);
for ($i = 0; $i < count($list_threads); $i++) { for ($i = 0; $i < count($list_threads); $i++) {
deleteForumCategoryThread('thread', $list_threads[$i]['thread_id']); deleteForumCategoryThread('thread', $list_threads[$i]['thread_id']);
$link_info = GradebookUtils::isResourceInCourseGradebook( $link_info = GradebookUtils::isResourceInCourseGradebook(
@ -155,21 +153,21 @@ function handle_forum_and_forumcategories($lp_id = null)
} }
// Change visibility of a forum or a forum category. // Change visibility of a forum or a forum category.
if ($action_forum_cat == 'invisible' || $action_forum_cat == 'visible') { if ($action_forum_cat === 'invisible' || $action_forum_cat === 'visible') {
$return_message = change_visibility($get_content, $get_id, $action_forum_cat); $return_message = change_visibility($get_content, $get_id, $action_forum_cat);
Display::addFlash( Display::addFlash(
Display::return_message($return_message, 'confirmation', false) Display::return_message($return_message, 'confirmation', false)
); );
} }
// Change lock status of a forum or a forum category. // Change lock status of a forum or a forum category.
if ($action_forum_cat == 'lock' || $action_forum_cat == 'unlock') { if ($action_forum_cat === 'lock' || $action_forum_cat === 'unlock') {
$return_message = change_lock_status($get_content, $get_id, $action_forum_cat); $return_message = change_lock_status($get_content, $get_id, $action_forum_cat);
Display::addFlash( Display::addFlash(
Display::return_message($return_message, 'confirmation', false) Display::return_message($return_message, 'confirmation', false)
); );
} }
// Move a forum or a forum category. // Move a forum or a forum category.
if ($action_forum_cat == 'move' && isset($_GET['direction'])) { if ($action_forum_cat === 'move' && isset($_GET['direction'])) {
$return_message = move_up_down($get_content, $_GET['direction'], $get_id); $return_message = move_up_down($get_content, $_GET['direction'], $get_id);
Display::addFlash( Display::addFlash(
Display::return_message($return_message, 'confirmation', false) Display::return_message($return_message, 'confirmation', false)
@ -268,14 +266,14 @@ function show_add_forum_form($inputvalues = [], $lp_id)
$form_title = get_lang('EditForum'); $form_title = get_lang('EditForum');
} }
$form->addElement('header', $form_title); $form->addHeader($form_title);
// We have a hidden field if we are editing. // We have a hidden field if we are editing.
if (!empty($inputvalues) && is_array($inputvalues)) { if (!empty($inputvalues) && is_array($inputvalues)) {
$my_forum_id = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null; $my_forum_id = isset($inputvalues['forum_id']) ? $inputvalues['forum_id'] : null;
$form->addElement('hidden', 'forum_id', $my_forum_id); $form->addElement('hidden', 'forum_id', $my_forum_id);
} }
$lp_id = intval($lp_id); $lp_id = (int) $lp_id;
// hidden field if from learning path // hidden field if from learning path
$form->addElement('hidden', 'lp_id', $lp_id); $form->addElement('hidden', 'lp_id', $lp_id);
@ -893,7 +891,6 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$logInfo = [ $logInfo = [
'tool' => TOOL_FORUM, 'tool' => TOOL_FORUM,
'tool_id' => $values['forum_id'], 'tool_id' => $values['forum_id'],
'tool_id_detail' => 0,
'action' => 'update-forum', 'action' => 'update-forum',
'action_details' => 'forum', 'action_details' => 'forum',
'info' => $values['forum_title'], 'info' => $values['forum_title'],
@ -922,7 +919,7 @@ function store_forum($values, $courseInfo = [], $returnId = false)
'end_time' => !empty($values['end_time']) ? api_get_utc_datetime($values['end_time']) : null, 'end_time' => !empty($values['end_time']) ? api_get_utc_datetime($values['end_time']) : null,
'forum_order' => isset($new_max) ? $new_max : null, 'forum_order' => isset($new_max) ? $new_max : null,
'session_id' => $session_id, 'session_id' => $session_id,
'lp_id' => isset($values['lp_id']) ? intval($values['lp_id']) : 0, 'lp_id' => isset($values['lp_id']) ? (int) $values['lp_id'] : 0,
'locked' => 0, 'locked' => 0,
'forum_id' => 0, 'forum_id' => 0,
]; ];
@ -931,6 +928,25 @@ function store_forum($values, $courseInfo = [], $returnId = false)
if ($forumId > 0) { if ($forumId > 0) {
$sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $forumId"; $sql = "UPDATE $table_forums SET forum_id = iid WHERE iid = $forumId";
Database::query($sql); Database::query($sql);
$courseCode = $courseInfo['code'];
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseCode);
$status = STUDENT;
if (!empty($session_id)) {
$status = 0;
}
if ($subscribe === 1) {
$userList = CourseManager::get_user_list_from_course_code(
$courseCode,
$session_id,
null,
null,
$status
);
foreach ($userList as $userInfo) {
set_notification('forum', $forumId, false, $userInfo, $courseInfo);
}
}
api_item_property_update( api_item_property_update(
$courseInfo, $courseInfo,
@ -951,7 +967,6 @@ function store_forum($values, $courseInfo = [], $returnId = false)
$logInfo = [ $logInfo = [
'tool' => TOOL_FORUM, 'tool' => TOOL_FORUM,
'tool_id' => $forumId, 'tool_id' => $forumId,
'tool_id_detail' => 0,
'action' => 'new-forum', 'action' => 'new-forum',
'action_details' => 'forum', 'action_details' => 'forum',
'info' => $values['forum_title'], 'info' => $values['forum_title'],
@ -1000,7 +1015,7 @@ function deleteForumCategoryThread($content, $id)
$groupId = api_get_group_id(); $groupId = api_get_group_id();
$groupInfo = GroupManager::get_group_properties($groupId); $groupInfo = GroupManager::get_group_properties($groupId);
$userId = api_get_user_id(); $userId = api_get_user_id();
$id = intval($id); $id = (int) $id;
// Delete all attachment file about this tread id. // Delete all attachment file about this tread id.
$sql = "SELECT post_id FROM $table_forums_post $sql = "SELECT post_id FROM $table_forums_post
@ -1012,7 +1027,7 @@ function deleteForumCategoryThread($content, $id)
$tool_constant = null; $tool_constant = null;
$return_message = ''; $return_message = '';
if ($content == 'forumcategory') { if ($content === 'forumcategory') {
$tool_constant = TOOL_FORUM_CATEGORY; $tool_constant = TOOL_FORUM_CATEGORY;
$return_message = get_lang('ForumCategoryDeleted'); $return_message = get_lang('ForumCategoryDeleted');
@ -1034,7 +1049,7 @@ function deleteForumCategoryThread($content, $id)
} }
} }
if ($content == 'forum') { if ($content === 'forum') {
$tool_constant = TOOL_FORUM; $tool_constant = TOOL_FORUM;
$return_message = get_lang('ForumDeleted'); $return_message = get_lang('ForumDeleted');
@ -1056,7 +1071,7 @@ function deleteForumCategoryThread($content, $id)
} }
} }
if ($content == 'thread') { if ($content === 'thread') {
$tool_constant = TOOL_FORUM_THREAD; $tool_constant = TOOL_FORUM_THREAD;
$return_message = get_lang('ThreadDeleted'); $return_message = get_lang('ThreadDeleted');
Skill::deleteSkillsFromItem($id, ITEM_TYPE_FORUM_THREAD); Skill::deleteSkillsFromItem($id, ITEM_TYPE_FORUM_THREAD);
@ -5624,58 +5639,68 @@ function get_forums_of_group($groupInfo)
/** /**
* This function stores which users have to be notified of which forums or threads. * This function stores which users have to be notified of which forums or threads.
* *
* @param string $content does the user want to be notified about a forum or about a thread * @param string $content does the user want to be notified about a forum or about a thread
* @param int $id the id of the forum or thread * @param int $id the id of the forum or thread
* @param bool $addOnly
* @param array $userInfo
* @param array $courseInfo
* *
* @return string language variable * @return string language variable
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* * @author Julio Montoya
* @version May 2008, dokeos 1.8.5
* *
* @since May 2008, dokeos 1.8.5 * @since May 2008 v1.8.5
*/ */
function set_notification($content, $id, $add_only = false) function set_notification($content, $id, $addOnly = false, $userInfo = [], $courseInfo = [])
{ {
$_user = api_get_user_info(); $userInfo = empty($userInfo) ? api_get_user_info() : $userInfo;
$courseInfo = empty($courseInfo) ? api_get_course_info() : $courseInfo;
$id = (int) $id;
if (empty($userInfo) || empty($courseInfo) || empty($id) || empty($content)) {
return false;
}
// Database table definition // Database table definition
$table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION); $table_notification = Database::get_course_table(TABLE_FORUM_NOTIFICATION);
$course_id = api_get_course_int_id(); $course_id = $courseInfo['real_id'];
// Which database field do we have to store the id in? // Which database field do we have to store the id in?
if ($content == 'forum') { $field = 'thread_id';
$database_field = 'forum_id'; if ($content === 'forum') {
} else { $field = 'forum_id';
$database_field = 'thread_id';
} }
$userId = $userInfo['user_id'];
// First we check if the notification is already set for this. // First we check if the notification is already set for this.
$sql = "SELECT * FROM $table_notification $sql = "SELECT * FROM $table_notification
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
$database_field = '".Database::escape_string($id)."' AND $field = $id AND
user_id = '".intval($_user['user_id'])."'"; user_id = $userId ";
$result = Database::query($sql); $result = Database::query($sql);
$total = Database::num_rows($result); $total = Database::num_rows($result);
// If the user did not indicate that (s)he wanted to be notified already // If the user did not indicate that (s)he wanted to be notified already
// then we store the notification request (to prevent double notification requests). // then we store the notification request (to prevent double notification requests).
if ($total <= 0) { if ($total <= 0) {
$sql = "INSERT INTO $table_notification (c_id, $database_field, user_id) $sql = "INSERT INTO $table_notification (c_id, $field, user_id)
VALUES (".$course_id.", '".Database::escape_string($id)."','".intval($_user['user_id'])."')"; VALUES ($course_id, '$id','$userId')";
Database::query($sql); Database::query($sql);
Session::erase('forum_notification'); Session::erase('forum_notification');
getNotificationsPerUser(0, true); getNotificationsPerUser(0, true);
return get_lang('YouWillBeNotifiedOfNewPosts'); return get_lang('YouWillBeNotifiedOfNewPosts');
} else { } else {
if (!$add_only) { if (!$addOnly) {
$sql = "DELETE FROM $table_notification $sql = "DELETE FROM $table_notification
WHERE WHERE
c_id = $course_id AND c_id = $course_id AND
$database_field = '".Database::escape_string($id)."' AND $field = $id AND
user_id = '".intval($_user['user_id'])."'"; user_id = $userId ";
Database::query($sql); Database::query($sql);
Session::erase('forum_notification'); Session::erase('forum_notification');
getNotificationsPerUser(0, true); getNotificationsPerUser(0, true);
@ -5695,6 +5720,7 @@ function set_notification($content, $id, $add_only = false)
* @return array returns * @return array returns
* *
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @author Julio Montoya
* *
* @version May 2008, dokeos 1.8.5 * @version May 2008, dokeos 1.8.5
* *
@ -5708,18 +5734,19 @@ function get_notifications($content, $id)
$course_id = api_get_course_int_id(); $course_id = api_get_course_int_id();
// Which database field contains the notification? // Which database field contains the notification?
if ($content == 'forum') { $field = 'thread_id';
$database_field = 'forum_id'; if ($content === 'forum') {
} else { $field = 'forum_id';
$database_field = 'thread_id';
} }
$id = (int) $id;
$sql = "SELECT user.user_id, user.firstname, user.lastname, user.email, user.user_id user $sql = "SELECT user.user_id, user.firstname, user.lastname, user.email, user.user_id user
FROM $table_users user, $table_notification notification FROM $table_users user, $table_notification notification
WHERE WHERE
notification.c_id = $course_id AND user.active = 1 AND notification.c_id = $course_id AND user.active = 1 AND
user.user_id = notification.user_id AND user.user_id = notification.user_id AND
notification.$database_field= '".Database::escape_string($id)."'"; notification.$field = $id ";
$result = Database::query($sql); $result = Database::query($sql);
$return = []; $return = [];
@ -5749,20 +5776,7 @@ function get_notifications($content, $id)
*/ */
function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0) function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
{ {
//$_course = api_get_course_info();
/*$forumCourseId = api_get_configuration_value('global_forums_course_id');
if (!empty($forumCourseId)) {
if ($_course['real_id'] == $forumCourseId) {
return false;
}
}*/
$forum_id = (int) $forum_id; $forum_id = (int) $forum_id;
// The content of the mail
//$thread_link = api_get_path(WEB_CODE_PATH).'forum/viewthread.php?'.api_get_cidreq().'&forum='.$forum_id.'&thread='.$thread_id;
// Users who subscribed to the forum // Users who subscribed to the forum
if ($forum_id != 0) { if ($forum_id != 0) {
$users_to_be_notified_by_forum = get_notifications('forum', $forum_id); $users_to_be_notified_by_forum = get_notifications('forum', $forum_id);
@ -5771,8 +5785,6 @@ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0)
} }
$current_thread = get_thread_information($forum_id, $thread_id); $current_thread = get_thread_information($forum_id, $thread_id);
//$current_forum = get_forum_information($current_thread['forum_id']);
//$subject = get_lang('NewForumPost').' - '.$_course['official_code'].' - '.$current_forum['forum_title'].' - '.$current_thread['thread_title'];
// User who subscribed to the thread // User who subscribed to the thread
if ($thread_id != 0) { if ($thread_id != 0) {
@ -6228,8 +6240,8 @@ function editAttachedFile($array, $id, $courseId = null)
{ {
// Init variables // Init variables
$setString = ''; $setString = '';
$id = intval($id); $id = (int) $id;
$courseId = intval($courseId); $courseId = (int) $courseId;
if (empty($courseId)) { if (empty($courseId)) {
// $courseId can be null, use api method // $courseId can be null, use api method
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
@ -6277,8 +6289,7 @@ function editAttachedFile($array, $id, $courseId = null)
*/ */
function getAttachmentsAjaxTable($postId = 0) function getAttachmentsAjaxTable($postId = 0)
{ {
// Init variables $postId = (int) $postId;
$postId = intval($postId);
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
$attachIds = getAttachmentIdsByPostId($postId, $courseId); $attachIds = getAttachmentIdsByPostId($postId, $courseId);
$fileDataContent = ''; $fileDataContent = '';
@ -6357,10 +6368,10 @@ function getAttachedFiles(
$attachId = 0, $attachId = 0,
$courseId = 0 $courseId = 0
) { ) {
$forumId = intval($forumId); $forumId = (int) $forumId;
$courseId = intval($courseId); $courseId = (int) $courseId;
$attachId = intval($attachId); $attachId = (int) $attachId;
$postId = intval($postId); $postId = (int) $postId;
$threadId = !empty($threadId) ? intval($threadId) : isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : ''; $threadId = !empty($threadId) ? intval($threadId) : isset($_REQUEST['thread']) ? intval($_REQUEST['thread']) : '';
if (empty($courseId)) { if (empty($courseId)) {
// $courseId can be null, use api method // $courseId can be null, use api method
@ -6368,7 +6379,7 @@ function getAttachedFiles(
} }
if (empty($forumId)) { if (empty($forumId)) {
if (!empty($_REQUEST['forum'])) { if (!empty($_REQUEST['forum'])) {
$forumId = intval($_REQUEST['forum']); $forumId = (int) $_REQUEST['forum'];
} else { } else {
// if forum ID is empty, cannot generate delete url // if forum ID is empty, cannot generate delete url
@ -6438,11 +6449,11 @@ function getAttachedFiles(
* *
* @return array * @return array
*/ */
function clearAttachedFiles($postId = null, $courseId = null) function clearAttachedFiles($postId = 0, $courseId = 0)
{ {
// Init variables // Init variables
$courseId = intval($courseId); $courseId = (int) $courseId;
$postId = intval($postId); $postId = (int) $postId;
$array = []; $array = [];
if (empty($courseId)) { if (empty($courseId)) {
// $courseId can be null, use api method // $courseId can be null, use api method
@ -6488,8 +6499,8 @@ function clearAttachedFiles($postId = null, $courseId = null)
function getAttachmentIdsByPostId($postId, $courseId = 0) function getAttachmentIdsByPostId($postId, $courseId = 0)
{ {
$array = []; $array = [];
$courseId = intval($courseId); $courseId = (int) $courseId;
$postId = intval($postId); $postId = (int) $postId;
if (empty($courseId)) { if (empty($courseId)) {
// $courseId can be null, use api method // $courseId can be null, use api method
$courseId = api_get_course_int_id(); $courseId = api_get_course_int_id();
@ -6520,7 +6531,8 @@ function getAttachmentIdsByPostId($postId, $courseId = 0)
*/ */
function getForumCategoryByTitle($title, $courseId, $sessionId = 0) function getForumCategoryByTitle($title, $courseId, $sessionId = 0)
{ {
$sessionId = intval($sessionId); $sessionId = (int) $sessionId;
$courseId = (int) $courseId;
$forumCategoryTable = Database::get_course_table(TABLE_FORUM_CATEGORY); $forumCategoryTable = Database::get_course_table(TABLE_FORUM_CATEGORY);
$itemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY); $itemProperty = Database::get_course_table(TABLE_ITEM_PROPERTY);
@ -6550,7 +6562,7 @@ function getForumCategoryByTitle($title, $courseId, $sessionId = 0)
'ip.tool = ? AND ' => TOOL_FORUM_CATEGORY, 'ip.tool = ? AND ' => TOOL_FORUM_CATEGORY,
'fc.session_id = ? AND ' => $sessionId, 'fc.session_id = ? AND ' => $sessionId,
'fc.cat_title = ? AND ' => $title, 'fc.cat_title = ? AND ' => $title,
'fc.c_id = ?' => intval($courseId), 'fc.c_id = ?' => $courseId,
], ],
], ],
'first' 'first'

@ -62,9 +62,9 @@ if (api_is_in_gradebook()) {
$search_forum = isset($_GET['search']) ? Security::remove_XSS($_GET['search']) : ''; $search_forum = isset($_GET['search']) ? Security::remove_XSS($_GET['search']) : '';
/* ACTIONS */ /* ACTIONS */
$actions = isset($_GET['action']) ? $_GET['action'] : ''; $action = isset($_GET['action']) ? $_GET['action'] : '';
if ($actions === 'add') { if ($action === 'add') {
switch ($_GET['content']) { switch ($_GET['content']) {
case 'forum': case 'forum':
$interbreadcrumb[] = [ $interbreadcrumb[] = [
@ -102,12 +102,12 @@ $form_count = 0;
$formContent = ''; $formContent = '';
if (api_is_allowed_to_edit(false, true)) { if (api_is_allowed_to_edit(false, true)) {
//if is called from a learning path lp_id //if is called from a learning path lp_id
$lp_id = isset($_REQUEST['lp_id']) ? intval($_REQUEST['lp_id']) : null; $lp_id = isset($_REQUEST['lp_id']) ? (int) $_REQUEST['lp_id'] : null;
$formContent = handle_forum_and_forumcategories($lp_id); $formContent = handle_forum_and_forumcategories($lp_id);
} }
// Notification // Notification
if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) { if ($action == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
if (api_get_session_id() != 0 && if (api_get_session_id() != 0 &&
api_is_allowed_to_session_edit(false, true) == false api_is_allowed_to_session_edit(false, true) == false
) { ) {
@ -120,14 +120,11 @@ if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
get_whats_new(); get_whats_new();
$whatsnew_post_info = Session::read('whatsnew_post_info'); $whatsnew_post_info = Session::read('whatsnew_post_info');
/* TRACKING */
Event::event_access_tool(TOOL_FORUM); Event::event_access_tool(TOOL_FORUM);
$logInfo = [ $logInfo = [
'tool' => TOOL_FORUM, 'tool' => TOOL_FORUM,
'tool_id' => 0, 'action' => !empty($action) ? $action : 'list-category',
'tool_id_detail' => 0,
'action' => !empty($actions) ? $actions : 'list-category',
'action_details' => isset($_GET['content']) ? $_GET['content'] : '', 'action_details' => isset($_GET['content']) ? $_GET['content'] : '',
]; ];
Event::registerLog($logInfo); Event::registerLog($logInfo);
@ -557,7 +554,7 @@ if (is_array($forumCategories)) {
} }
} }
if (!api_is_anonymous() && api_is_allowed_to_session_edit(false, true) && $hideNotifications == false) { if ($hideNotifications == false && !api_is_anonymous() && api_is_allowed_to_session_edit(false, true)) {
$toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq() $toolActions .= '<a href="'.api_get_self().'?'.api_get_cidreq()
.'&action=notify&content=forum&id='.$forum['forum_id'].'">' .'&action=notify&content=forum&id='.$forum['forum_id'].'">'
.Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL) .Display::return_icon($iconnotify, get_lang('NotifyMe'), null, ICON_SIZE_SMALL)

@ -2,8 +2,6 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* Script.
*
* @package chamilo.gradebook * @package chamilo.gradebook
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';

@ -178,8 +178,6 @@ $my_actions = implode(';', $list_actions);
$my_actions_values = implode(';', $list_values); $my_actions_values = implode(';', $list_values);
$logInfo = [ $logInfo = [
'tool' => TOOL_GRADEBOOK, 'tool' => TOOL_GRADEBOOK,
'tool_id' => 0,
'tool_id_detail' => 0,
'action' => $my_actions, 'action' => $my_actions,
'action_details' => $my_actions_values, 'action_details' => $my_actions_values,
]; ];
@ -260,19 +258,19 @@ if (isset($_GET['visiblelog'])) {
//move a category //move a category
if (isset($_GET['movecat'])) { if (isset($_GET['movecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$cats = Category::load($_GET['movecat']); $moveCategoryId = isset($_GET['movecat']) ? (int) $_GET['movecat'] : 0;
$cats = Category::load($moveCategoryId);
if (!isset($_GET['targetcat'])) { if (!isset($_GET['targetcat'])) {
$move_form = new CatForm( $move_form = new CatForm(
CatForm::TYPE_MOVE, CatForm::TYPE_MOVE,
$cats[0], $cats[0],
'move_cat_form', 'move_cat_form',
null, null,
api_get_self().'?movecat='.intval($_GET['movecat']).'&selectcat='.$selectCat api_get_self().'?movecat='.$moveCategoryId.'&selectcat='.$selectCat
); );
if ($move_form->validate()) { if ($move_form->validate()) {
header('Location: '.api_get_self().'?selectcat='.$selectCat header('Location: '.api_get_self().'?selectcat='.$selectCat
.'&movecat='.intval($_GET['movecat']) .'&movecat='.$moveCategoryId.'&targetcat='.$move_form->exportValue('move_cat'));
.'&targetcat='.$move_form->exportValue('move_cat'));
exit; exit;
} }
} else { } else {
@ -370,7 +368,7 @@ if (isset($_GET['deletecat'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$cats = Category::load($_GET['deletecat']); $cats = Category::load($_GET['deletecat']);
if (isset($cats[0])) { if (isset($cats[0])) {
//delete all categories,subcategories and results // Delete all categories,subcategories and results
if ($cats[0] != null) { if ($cats[0] != null) {
if ($cats[0]->get_id() != 0) { if ($cats[0]->get_id() != 0) {
// better don't try to delete the root... // better don't try to delete the root...
@ -406,12 +404,11 @@ if (isset($_GET['visibleeval'])) {
if (isset($_GET['lockedeval'])) { if (isset($_GET['lockedeval'])) {
GradebookUtils::block_students(); GradebookUtils::block_students();
$locked = (int) $_GET['lockedeval']; $locked = (int) $_GET['lockedeval'];
$type_locked = 1;
$confirmation_message = get_lang('EvaluationHasBeenLocked');
if (isset($_GET['typelocked']) && api_is_platform_admin()) { if (isset($_GET['typelocked']) && api_is_platform_admin()) {
$type_locked = 0; $type_locked = 0;
$confirmation_message = get_lang('EvaluationHasBeenUnLocked'); $confirmation_message = get_lang('EvaluationHasBeenUnLocked');
} else {
$type_locked = 1;
$confirmation_message = get_lang('EvaluationHasBeenLocked');
} }
$eval = Evaluation::load($locked); $eval = Evaluation::load($locked);
if ($eval[0] != null) { if ($eval[0] != null) {
@ -493,7 +490,7 @@ if (!empty($course_to_crsind) && !isset($_GET['confirm'])) {
die('Error: movecat or moveeval not defined'); die('Error: movecat or moveeval not defined');
} }
$button = '<form name="confirm" method="post" action="'.api_get_self().'?confirm=' $button = '<form name="confirm" method="post" action="'.api_get_self().'?confirm='
.(isset($_GET['movecat']) ? '&movecat='.intval($_GET['movecat']) .(isset($_GET['movecat']) ? '&movecat='.$moveCategoryId
: '&moveeval='.intval($_GET['moveeval'])).'&selectcat='.$selectCat.'&targetcat='.intval($_GET['targetcat']).'"> : '&moveeval='.intval($_GET['moveeval'])).'&selectcat='.$selectCat.'&targetcat='.intval($_GET['targetcat']).'">
<input type="submit" value="'.get_lang('Ok').'"> <input type="submit" value="'.get_lang('Ok').'">
</form>'; </form>';

@ -713,9 +713,12 @@ class GradebookUtils
$date_certificate $date_certificate
) { ) {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT COUNT(id) as count $cat_id = (int) $cat_id;
FROM '.$table.' gc $user_id = (int) $user_id;
WHERE gc.cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'" ';
$sql = "SELECT COUNT(id) as count
FROM $table gc
WHERE gc.cat_id = $cat_id AND user_id = $user_id ";
$rs_exist = Database::query($sql); $rs_exist = Database::query($sql);
$row = Database::fetch_array($rs_exist); $row = Database::fetch_array($rs_exist);
if ($row['count'] == 0) { if ($row['count'] == 0) {
@ -740,8 +743,11 @@ class GradebookUtils
public static function get_certificate_by_user_id($cat_id, $user_id) public static function get_certificate_by_user_id($cat_id, $user_id)
{ {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT * FROM '.$table.' $cat_id = (int) $cat_id;
WHERE cat_id="'.intval($cat_id).'" AND user_id="'.intval($user_id).'"'; $user_id = (int) $user_id;
$sql = "SELECT * FROM $table
WHERE cat_id = $cat_id AND user_id = $user_id ";
$result = Database::query($sql); $result = Database::query($sql);
$row = Database::fetch_array($result, 'ASSOC'); $row = Database::fetch_array($result, 'ASSOC');
@ -796,27 +802,28 @@ class GradebookUtils
$user_id, $user_id,
$cat_id = null $cat_id = null
) { ) {
$user_id = (int) $user_id;
$table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE); $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
$sql = 'SELECT $sql = 'SELECT
gc.score_certificate, gc.score_certificate,
gc.created_at, gc.created_at,
gc.path_certificate, gc.path_certificate,
gc.cat_id, gc.cat_id,
gc.user_id, gc.user_id,
gc.id gc.id
FROM '.$table_certificate.' gc FROM '.$table_certificate.' gc
WHERE gc.user_id="'.intval($user_id).'" '; WHERE gc.user_id = "'.$user_id.'" ';
if (!is_null($cat_id) && $cat_id > 0) { if (!is_null($cat_id) && $cat_id > 0) {
$sql .= ' AND cat_id='.intval($cat_id); $sql .= ' AND cat_id='.intval($cat_id);
} }
$rs = Database::query($sql); $rs = Database::query($sql);
$list_certificate = []; $list = [];
while ($row = Database::fetch_array($rs)) { while ($row = Database::fetch_array($rs)) {
$list_certificate[] = $row; $list[] = $row;
} }
return $list_certificate; return $list;
} }
/** /**
@ -854,9 +861,9 @@ class GradebookUtils
//add print header //add print header
if (!$hide_print_button) { if (!$hide_print_button) {
$print = '<style>#print_div { $print = '<style>#print_div {
padding:4px;border: 0 none;position: absolute;top: 0px;right: 0px; padding:4px;border: 0 none;position: absolute;top: 0px;right: 0px;
} }
@media print { @media print {
#print_div { #print_div {
display: none !important; display: none !important;
@ -903,11 +910,11 @@ class GradebookUtils
$sql = "SELECT * FROM $t $sql = "SELECT * FROM $t
WHERE c_id = '".$courseInfo['real_id']."' "; WHERE c_id = '".$courseInfo['real_id']."' ";
if (!empty($session_id)) { if (!empty($session_id)) {
$sql .= " AND session_id = ".(int) $session_id; $sql .= " AND session_id = ".$session_id;
} else { } else {
$sql .= " AND (session_id IS NULL OR session_id = 0) "; $sql .= ' AND (session_id IS NULL OR session_id = 0) ';
} }
$sql .= " ORDER BY id"; $sql .= ' ORDER BY id ';
$res = Database::query($sql); $res = Database::query($sql);
if (Database::num_rows($res) < 1) { if (Database::num_rows($res) < 1) {
//there is no unique category for this course+session combination, //there is no unique category for this course+session combination,
@ -1190,7 +1197,7 @@ class GradebookUtils
"; ";
} else { } else {
$sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code $sql = 'SELECT user.user_id, user.username, lastname, firstname, official_code
FROM '.$tbl_course_user.' as course_rel_user FROM '.$tbl_course_user.' as course_rel_user
INNER JOIN '.$tbl_user.' as user INNER JOIN '.$tbl_user.' as user
ON (course_rel_user.user_id = user.id) ON (course_rel_user.user_id = user.id)
WHERE WHERE

@ -721,6 +721,8 @@ abstract class AbstractLink implements GradebookItem
$itemId = (int) $itemId; $itemId = (int) $itemId;
$linkType = (int) $linkType; $linkType = (int) $linkType;
$sessionId = (int) $sessionId; $sessionId = (int) $sessionId;
$sessionCondition = api_get_session_condition($sessionId, true, false, 'c.session_id');
$courseCode = Database::escape_string($courseCode); $courseCode = Database::escape_string($courseCode);
$sql = "SELECT DISTINCT l.* $sql = "SELECT DISTINCT l.*
@ -729,8 +731,8 @@ abstract class AbstractLink implements GradebookItem
WHERE WHERE
ref_id = $itemId AND ref_id = $itemId AND
type = $linkType AND type = $linkType AND
l.course_code = '$courseCode' AND l.course_code = '$courseCode'
c.session_id = $sessionId"; $sessionCondition ";
$result = Database::query($sql); $result = Database::query($sql);
if (Database::num_rows($result)) { if (Database::num_rows($result)) {

@ -35,6 +35,7 @@ class Category implements GradebookItem
private $isRequirement; private $isRequirement;
private $courseDependency; private $courseDependency;
private $minimumToValidate; private $minimumToValidate;
private $documentId;
/** @var int */ /** @var int */
private $gradeBooksToValidateInDependence; private $gradeBooksToValidateInDependence;
@ -101,9 +102,9 @@ class Category implements GradebookItem
{ {
if (!empty($this->certificate_min_score)) { if (!empty($this->certificate_min_score)) {
return $this->certificate_min_score; return $this->certificate_min_score;
} else {
return null;
} }
return null;
} }
/** /**
@ -527,9 +528,7 @@ class Category implements GradebookItem
$result = Database::query($sql); $result = Database::query($sql);
$categories = []; $categories = [];
if (Database::num_rows($result) > 0) { if (Database::num_rows($result) > 0) {
$categories = self::create_category_objects_from_sql_result( $categories = self::create_category_objects_from_sql_result($result);
$result
);
} }
return $categories; return $categories;
@ -755,19 +754,6 @@ class Category implements GradebookItem
Database::query($sql); Database::query($sql);
} }
/**
* Not delete this category from the database,when visible=3 is category eliminated.
*
* @param int $courseId
*/
public function update_category_delete($courseId)
{
$tbl_grade_categories = Database :: get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = 'UPDATE '.$tbl_grade_categories.' SET visible=3
WHERE c_id ="'.intval($courseId).'"';
Database::query($sql);
}
/** /**
* Delete the gradebook categories from a course, including course sessions. * Delete the gradebook categories from a course, including course sessions.
* *
@ -832,7 +818,7 @@ class Category implements GradebookItem
* *
* @return array * @return array
*/ */
public function showAllCategoryInfo($categoryId = 0) public function showAllCategoryInfo($categoryId)
{ {
$categoryId = (int) $categoryId; $categoryId = (int) $categoryId;
if (empty($categoryId)) { if (empty($categoryId)) {
@ -848,54 +834,6 @@ class Category implements GradebookItem
return $row; return $row;
} }
/**
* Check if a category name (with the same parent category) already exists.
*
* @param string $name name to check (if not given, the name property of this object will be checked)
* @param int $parent parent category
*
* @return bool
*/
public function does_name_exist($name, $parent)
{
if (!isset($name)) {
$name = $this->name;
$parent = $this->parent;
}
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
$sql = "SELECT count(id) AS number
FROM $table
WHERE name = '".Database::escape_string($name)."'";
if (api_is_allowed_to_edit()) {
$parent = self::load($parent);
$code = $parent[0]->get_course_code();
$courseInfo = api_get_course_info($code);
$courseId = $courseInfo['real_id'];
if (isset($code) && $code != '0') {
$main_course_user_table = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$sql .= ' AND user_id IN (
SELECT user_id FROM '.$main_course_user_table.'
WHERE c_id = '.$courseId.' AND status = '.COURSEMANAGER.'
)';
} else {
$sql .= ' AND user_id = '.api_get_user_id();
}
} else {
$sql .= ' AND user_id = '.api_get_user_id();
}
if (!isset($parent)) {
$sql .= ' AND parent_id is null';
} else {
$sql .= ' AND parent_id = '.intval($parent);
}
$result = Database::query($sql);
$number = Database::fetch_row($result);
return $number[0] != 0;
}
/** /**
* Checks if the certificate is available for the given user in this category. * Checks if the certificate is available for the given user in this category.
* *
@ -2131,7 +2069,7 @@ class Category implements GradebookItem
$category_id = (int) $category_id; $category_id = (int) $category_id;
// Generating the total score for a course // Generating the total score for a course
$cats_course = self::load( $category = self::load(
$category_id, $category_id,
null, null,
null, null,
@ -2142,7 +2080,7 @@ class Category implements GradebookItem
); );
/** @var Category $category */ /** @var Category $category */
$category = $cats_course[0]; $category = $category[0];
if (empty($category)) { if (empty($category)) {
return false; return false;
@ -2202,20 +2140,18 @@ class Category implements GradebookItem
return false; return false;
} }
$cattotal = self::load($category_id); $scoretotal = $category->calc_score($user_id);
$scoretotal = $cattotal[0]->calc_score($user_id);
// Do not remove this the gradebook/lib/fe/gradebooktable.class.php // Do not remove this the gradebook/lib/fe/gradebooktable.class.php
// file load this variable as a global // file load this variable as a global
$scoredisplay = ScoreDisplay::instance(); $scoredisplay = ScoreDisplay::instance();
$my_score_in_gradebook = $scoredisplay->display_score( $my_score_in_gradebook = $scoredisplay->display_score(
$scoretotal, $scoretotal,
SCORE_SIMPLE SCORE_SIMPLE
); );
$my_certificate = GradebookUtils::get_certificate_by_user_id( $my_certificate = GradebookUtils::get_certificate_by_user_id(
$category->get_id(), $category_id,
$user_id $user_id
); );
@ -2227,7 +2163,7 @@ class Category implements GradebookItem
api_get_utc_datetime() api_get_utc_datetime()
); );
$my_certificate = GradebookUtils::get_certificate_by_user_id( $my_certificate = GradebookUtils::get_certificate_by_user_id(
$category->get_id(), $category_id,
$user_id $user_id
); );
} }
@ -2242,8 +2178,16 @@ class Category implements GradebookItem
$fileWasGenerated = $certificate_obj->isHtmlFileGenerated(); $fileWasGenerated = $certificate_obj->isHtmlFileGenerated();
// Fix when using custom certificate BT#15937
if (api_get_plugin_setting('customcertificate', 'enable_plugin_customcertificate') === 'true') {
$infoCertificate = CustomCertificatePlugin::getCertificateData($my_certificate['id'], $user_id);
if (!empty($infoCertificate)) {
$fileWasGenerated = true;
}
}
if (!empty($fileWasGenerated)) { if (!empty($fileWasGenerated)) {
$url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id']; $url = api_get_path(WEB_PATH).'certificates/index.php?id='.$my_certificate['id'].'&user_id='.$user_id;
$certificates = Display::toolbarButton( $certificates = Display::toolbarButton(
get_lang('DisplayCertificate'), get_lang('DisplayCertificate'),
$url, $url,

@ -74,7 +74,7 @@ class Evaluation implements GradebookItem
*/ */
public function get_id() public function get_id()
{ {
return $this->id; return (int) $this->id;
} }
/** /**
@ -471,7 +471,7 @@ class Evaluation implements GradebookItem
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'SELECT count(id) AS number $sql = 'SELECT count(id) AS number
FROM '.$table.' FROM '.$table.'
WHERE evaluation_id = '.intval($this->id); WHERE evaluation_id = '.intval($this->get_id());
$result = Database::query($sql); $result = Database::query($sql);
$number = Database::fetch_row($result); $number = Database::fetch_row($result);
@ -485,7 +485,7 @@ class Evaluation implements GradebookItem
{ {
$table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT); $table = Database::get_main_table(TABLE_MAIN_GRADEBOOK_RESULT);
$sql = 'DELETE FROM '.$table.' $sql = 'DELETE FROM '.$table.'
WHERE evaluation_id = '.intval($this->id); WHERE evaluation_id = '.$this->get_id();
Database::query($sql); Database::query($sql);
} }
@ -761,7 +761,7 @@ class Evaluation implements GradebookItem
lastname LIKE '".Database::escape_string($first_letter_user)."%' AND lastname LIKE '".Database::escape_string($first_letter_user)."%' AND
status = ".STUDENT." AND user_id NOT IN ( status = ".STUDENT." AND user_id NOT IN (
SELECT user_id FROM $table SELECT user_id FROM $table
WHERE evaluation_id = ".intval($this->id)." WHERE evaluation_id = ".$this->get_id()."
) )
ORDER BY lastname"; ORDER BY lastname";
@ -817,7 +817,7 @@ class Evaluation implements GradebookItem
$table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION); $table_evaluation = Database::get_main_table(TABLE_MAIN_GRADEBOOK_EVALUATION);
$sql = "UPDATE $table_evaluation $sql = "UPDATE $table_evaluation
SET locked = '".intval($locked)."' SET locked = '".intval($locked)."'
WHERE id='".intval($this->id)."'"; WHERE id='".$this->get_id()."'";
Database::query($sql); Database::query($sql);
} }
@ -954,13 +954,15 @@ class Evaluation implements GradebookItem
/** /**
* Internal function used by get_target_categories(). * Internal function used by get_target_categories().
* *
* @param int $level * @param array $targets
* @param int $level
* @param int $categoryId
* *
* @return array * @return array
*/ */
private function addTargetSubcategories($targets, $level, $catid) private function addTargetSubcategories($targets, $level, $categoryId)
{ {
$subcats = Category::load(null, null, null, $catid); $subcats = Category::load(null, null, null, $categoryId);
foreach ($subcats as $cat) { foreach ($subcats as $cat) {
$targets[] = [$cat->get_id(), $cat->get_name(), $level + 1]; $targets[] = [$cat->get_id(), $cat->get_name(), $level + 1];
$targets = $this->addTargetSubcategories( $targets = $this->addTargetSubcategories(

@ -10,8 +10,8 @@
*/ */
class StudentPublicationLink extends AbstractLink class StudentPublicationLink extends AbstractLink
{ {
private $studpub_table = null; private $studpub_table;
private $itemprop_table = null; private $itemprop_table;
/** /**
* Constructor. * Constructor.

@ -273,6 +273,10 @@ class CatForm extends FormValidator
} }
$defaultCertification = 0; $defaultCertification = 0;
if (!empty($this->category_object)) {
$defaultCertification = $this->category_object->getCertificateMinScore();
}
if (isset($this->category_object) && if (isset($this->category_object) &&
$this->category_object->get_parent_id() == 0 $this->category_object->get_parent_id() == 0
) { ) {

@ -393,7 +393,8 @@ class DisplayGradebook
isset($_GET['selectcat']) && $_GET['selectcat'] != 0) && isset($_GET['selectcat']) && $_GET['selectcat'] != 0) &&
isset($_GET['studentoverview']) isset($_GET['studentoverview'])
) { ) {
$header .= '<td style="vertical-align: top;"><a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank"> $header .= '<td style="vertical-align: top;">
<a href="'.api_get_self().'?'.api_get_cidreq().'&studentoverview=&exportpdf=&selectcat='.$catobj->get_id().'" target="_blank">
'.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).' '.Display::return_icon('pdf.png', get_lang('ExportPDF'), [], ICON_SIZE_MEDIUM).'
'.get_lang('ExportPDF').'</a>'; '.get_lang('ExportPDF').'</a>';
} }
@ -550,17 +551,16 @@ class DisplayGradebook
'</a>'; '</a>';
} }
if (api_is_allowed_to_edit(null, true) || $isCoach) { if ($isCoach || api_is_allowed_to_edit(null, true)) {
echo $toolbar = Display::toolbarAction( echo $toolbar = Display::toolbarAction(
'gradebook-actions', 'gradebook-actions',
[$actionsLeft, $actionsRight] [$actionsLeft, $actionsRight]
); );
} }
if (api_is_allowed_to_edit(null, true) || $accessToEdit) { if ($accessToEdit || api_is_allowed_to_edit(null, true)) {
$weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0; $weight = intval($catobj->get_weight()) > 0 ? $catobj->get_weight() : 0;
$weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight; $weight = '<strong>'.get_lang('TotalWeight').' : </strong>'.$weight;
$min_certification = intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0; $min_certification = intval($catobj->getCertificateMinScore() > 0) ? $catobj->getCertificateMinScore() : 0;
if (!empty($min_certification)) { if (!empty($min_certification)) {

@ -21,6 +21,8 @@ class ScoreDisplay
/** /**
* Protected constructor - call instance() to instantiate. * Protected constructor - call instance() to instantiate.
*
* @param int $category_id
*/ */
public function __construct($category_id = 0) public function __construct($category_id = 0)
{ {
@ -53,7 +55,7 @@ class ScoreDisplay
foreach ($displays as $display) { foreach ($displays as $display) {
$data = explode('::', $display['selected_value']); $data = explode('::', $display['selected_value']);
if (empty($data[1])) { if (empty($data[1])) {
$data[1] = ""; $data[1] = '';
} }
$portal_displays[$data[0]] = [ $portal_displays[$data[0]] = [
'score' => $data[0], 'score' => $data[0],

@ -17,8 +17,7 @@ switch ($action) {
$repo = Container::$container->get('Chamilo\CourseBundle\Repository\CDocumentRepository'); $repo = Container::$container->get('Chamilo\CourseBundle\Repository\CDocumentRepository');
$size = $repo->getFolderSize(api_get_course_int_id(), $path); $size = $repo->getFolderSize(api_get_course_int_id(), $path);
//var_dump($size);
//$size = DocumentManager::getTotalFolderSize($path, $isAllowedToEdit);
echo format_file_size($size); echo format_file_size($size);
break; break;
case 'get_document_quota': case 'get_document_quota':

@ -60,12 +60,12 @@ switch ($action) {
// Setting notifications // Setting notifications
$count_unread_message = 0; $count_unread_message = 0;
if (api_get_setting('allow_message_tool') == 'true') { if (api_get_setting('allow_message_tool') === 'true') {
// get count unread message and total invitations // get count unread message and total invitations
$count_unread_message = MessageManager::getNumberOfMessages(true); $count_unread_message = MessageManager::getNumberOfMessages(['message_status' => [MESSAGE_STATUS_UNREAD]]);
} }
if (api_get_setting('allow_social_tool') == 'true') { if (api_get_setting('allow_social_tool') === 'true') {
$number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(
$userId $userId
); );

@ -1211,6 +1211,10 @@ switch ($action) {
); );
break; break;
case 'get_work_user_list_all': case 'get_work_user_list_all':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] === 'simple') { if (isset($_GET['type']) && $_GET['type'] === 'simple') {
$columns = [ $columns = [
'fullname', 'fullname',
@ -1219,8 +1223,9 @@ switch ($action) {
'sent_date', 'sent_date',
'qualificator_id', 'qualificator_id',
'correction', 'correction',
'actions',
]; ];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else { } else {
$columns = [ $columns = [
'fullname', 'fullname',
@ -1228,8 +1233,9 @@ switch ($action) {
'qualification', 'qualification',
'sent_date', 'sent_date',
'correction', 'correction',
'actions',
]; ];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} }
$whereCondition = " AND $whereCondition "; $whereCondition = " AND $whereCondition ";
@ -1244,12 +1250,21 @@ switch ($action) {
); );
break; break;
case 'get_work_user_list_others': case 'get_work_user_list_others':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] === 'simple') { if (isset($_GET['type']) && $_GET['type'] === 'simple') {
$columns = [ $columns = [
'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions', 'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id',
]; ];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else { } else {
$columns = ['type', 'firstname', 'lastname', 'title', 'sent_date', 'actions']; $columns = ['type', 'firstname', 'lastname', 'title', 'sent_date'];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} }
if (trim($whereCondition) === '1 = 1') { if (trim($whereCondition) === '1 = 1') {
@ -1267,14 +1282,21 @@ switch ($action) {
); );
break; break;
case 'get_work_user_list': case 'get_work_user_list':
$plagiarismColumns = [];
if (api_get_configuration_value('allow_compilatio_tool')) {
$plagiarismColumns = ['compilatio'];
}
if (isset($_GET['type']) && $_GET['type'] == 'simple') { if (isset($_GET['type']) && $_GET['type'] == 'simple') {
$columns = [ $columns = [
'type', 'title', 'qualification', 'sent_date', 'qualificator_id', 'actions', 'type', 'title', 'qualification', 'sent_date', 'qualificator_id',
]; ];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} else { } else {
$columns = ['type', 'title', 'qualification', 'sent_date', 'actions']; $columns = ['type', 'title', 'qualification', 'sent_date'];
$columns = array_merge($columns, $plagiarismColumns);
$columns[] = 'actions';
} }
$documents = getAllDocumentToWork($work_id, api_get_course_int_id()); $documents = getAllDocumentToWork($work_id, api_get_course_int_id());
if (trim($whereCondition) === '1 = 1') { if (trim($whereCondition) === '1 = 1') {
@ -1282,7 +1304,7 @@ switch ($action) {
} }
if (empty($documents)) { if (empty($documents)) {
$whereCondition .= " AND u.user_id = ".api_get_user_id(); $whereCondition .= ' AND u.user_id = '.api_get_user_id();
$result = get_work_user_list( $result = get_work_user_list(
$start, $start,
$limit, $limit,
@ -2272,7 +2294,7 @@ $allowed_actions = [
'get_exercise_categories', 'get_exercise_categories',
]; ];
//5. Creating an obj to return a json // 5. Creating an obj to return a json
if (in_array($action, $allowed_actions)) { if (in_array($action, $allowed_actions)) {
$response = new stdClass(); $response = new stdClass();
$response->page = $page; $response->page = $page;

@ -219,19 +219,12 @@ switch ($action) {
$comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : ''; $comment = isset($_REQUEST['comment']) ? $_REQUEST['comment'] : '';
if (!empty($comment)) { if (!empty($comment)) {
$messageId = SocialManager::sendWallMessage( $messageId = SocialManager::sendWallMessage(
api_get_user_id(), $userId,
$messageInfo['user_receiver_id'], $messageInfo['user_receiver_id'],
$comment, $comment,
$messageId, $messageId,
MESSAGE_STATUS_WALL MESSAGE_STATUS_WALL
); );
/*if ($messageId && !empty($_FILES['picture']['tmp_name'])) {
self::sendWallMessageAttachmentFile(
$friendId,
$_FILES['picture'],
$messageId
);
}*/
if ($messageId) { if ($messageId) {
$messageInfo = MessageManager::get_message_by_id($messageId); $messageInfo = MessageManager::get_message_by_id($messageId);
echo SocialManager::processPostComment($messageInfo); echo SocialManager::processPostComment($messageInfo);
@ -273,6 +266,7 @@ switch ($action) {
$start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0; $start = isset($_REQUEST['start']) ? (int) $_REQUEST['start'] : 0;
$length = isset($_REQUEST['length']) ? (int) $_REQUEST['length'] : 10; $length = isset($_REQUEST['length']) ? (int) $_REQUEST['length'] : 10;
$userId = isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : api_get_user_id(); $userId = isset($_REQUEST['u']) ? (int) $_REQUEST['u'] : api_get_user_id();
$html = ''; $html = '';
if ($userId == api_get_user_id()) { if ($userId == api_get_user_id()) {
$threadList = SocialManager::getThreadList($userId); $threadList = SocialManager::getThreadList($userId);
@ -281,7 +275,12 @@ switch ($action) {
$threadIdList = array_column($threadList, 'id'); $threadIdList = array_column($threadList, 'id');
} }
$html = SocialManager::getMyWallMessages($userId, $start, SocialManager::DEFAULT_SCROLL_NEW_POST, $threadIdList); $html = SocialManager::getMyWallMessages(
$userId,
$start,
SocialManager::DEFAULT_SCROLL_NEW_POST,
$threadIdList
);
$html = $html['posts']; $html = $html['posts'];
} else { } else {
$messages = SocialManager::getWallMessages( $messages = SocialManager::getWallMessages(

@ -150,6 +150,7 @@ define('TOOL_NOTEBOOK', 'notebook');
define('TOOL_ATTENDANCE', 'attendance'); define('TOOL_ATTENDANCE', 'attendance');
define('TOOL_COURSE_PROGRESS', 'course_progress'); define('TOOL_COURSE_PROGRESS', 'course_progress');
define('TOOL_PORTFOLIO', 'portfolio'); define('TOOL_PORTFOLIO', 'portfolio');
define('TOOL_PLAGIARISM', 'compilatio');
// CONSTANTS defining Chamilo interface sections // CONSTANTS defining Chamilo interface sections
define('SECTION_CAMPUS', 'mycampus'); define('SECTION_CAMPUS', 'mycampus');
@ -579,6 +580,7 @@ define('MESSAGE_STATUS_WALL_DELETE', '9');
define('MESSAGE_STATUS_WALL_POST', '10'); define('MESSAGE_STATUS_WALL_POST', '10');
define('MESSAGE_STATUS_CONVERSATION', '11'); define('MESSAGE_STATUS_CONVERSATION', '11');
define('MESSAGE_STATUS_FORUM', '12'); define('MESSAGE_STATUS_FORUM', '12');
define('MESSAGE_STATUS_PROMOTED', '13');
// Images // Images
define('IMAGE_WALL_SMALL_SIZE', 200); define('IMAGE_WALL_SMALL_SIZE', 200);
@ -2596,7 +2598,6 @@ function api_get_session_visibility(
} }
$now = time(); $now = time();
if (empty($session_id)) { if (empty($session_id)) {
return 0; // Means that the session is still available. return 0; // Means that the session is still available.
} }
@ -3478,7 +3479,6 @@ function api_is_allowed_to_edit(
) { ) {
$allowSessionAdminEdit = api_get_setting('session.session_admins_edit_courses_content') === true; $allowSessionAdminEdit = api_get_setting('session.session_admins_edit_courses_content') === true;
// Admins can edit anything. // Admins can edit anything.
// Admins can edit anything.
if (api_is_platform_admin($allowSessionAdminEdit)) { if (api_is_platform_admin($allowSessionAdminEdit)) {
//The student preview was on //The student preview was on
if ($check_student_view && api_is_student_view_active()) { if ($check_student_view && api_is_student_view_active()) {
@ -8437,11 +8437,11 @@ function api_is_allowed_in_course()
* Set the cookie to go directly to the course code $in_firstpage * Set the cookie to go directly to the course code $in_firstpage
* after login. * after login.
* *
* @param string $in_firstpage is the course code of the course to go * @param string $value is the course code of the course to go
*/ */
function api_set_firstpage_parameter($in_firstpage) function api_set_firstpage_parameter($value)
{ {
//setcookie('GotoCourse', $in_firstpage); setcookie('GotoCourse', $value);
} }
/** /**
@ -9445,18 +9445,20 @@ function api_set_noreply_and_from_address_to_mailer(PHPMailer $mailer, array $se
$senderName = !empty($sender['name']) ? $sender['name'] : $notification->getDefaultPlatformSenderName(); $senderName = !empty($sender['name']) ? $sender['name'] : $notification->getDefaultPlatformSenderName();
$senderEmail = !empty($sender['email']) ? $sender['email'] : $notification->getDefaultPlatformSenderEmail(); $senderEmail = !empty($sender['email']) ? $sender['email'] : $notification->getDefaultPlatformSenderEmail();
// Send errors to the platform admin
$adminEmail = api_get_setting('emailAdministrator');
if (PHPMailer::ValidateAddress($adminEmail)) {
$mailer->AddCustomHeader('Errors-To: '.$adminEmail);
}
// Reply to first // Reply to first
if (!$avoidReplyToAddress) { if (!$avoidReplyToAddress) {
$mailer->AddCustomHeader('Errors-To: '.$notification->getDefaultPlatformSenderEmail());
if ( if (
!empty($replyToAddress) && !empty($replyToAddress) &&
isset($platformEmail['SMTP_UNIQUE_REPLY_TO']) && $platformEmail['SMTP_UNIQUE_REPLY_TO'] && isset($platformEmail['SMTP_UNIQUE_REPLY_TO']) && $platformEmail['SMTP_UNIQUE_REPLY_TO'] &&
PHPMailer::ValidateAddress($replyToAddress['mail']) PHPMailer::ValidateAddress($replyToAddress['mail'])
) { ) {
$mailer->AddReplyTo($replyToAddress['email'], $replyToAddress['name']); $mailer->AddReplyTo($replyToAddress['email'], $replyToAddress['name']);
// Errors to sender
$mailer->AddCustomHeader('Errors-To: '.$replyToAddress['mail']);
$mailer->Sender = $replyToAddress['mail']; $mailer->Sender = $replyToAddress['mail'];
} }
} }

@ -81,7 +81,7 @@ function msort($array, $id = 'id', $order = 'desc')
*/ */
function utf8_sort($array) function utf8_sort($array)
{ {
$old_locale = setlocale(LC_ALL, null); $old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode(); $code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8']; $locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
$try_sort = false; $try_sort = false;

@ -89,8 +89,8 @@ class Certificate extends Model
$this->html_file = $this->certification_user_path.basename($this->certificate_data['path_certificate']); $this->html_file = $this->certification_user_path.basename($this->certificate_data['path_certificate']);
$this->qr_file = $this->certification_user_path.$pathinfo['filename'].'_qr.png'; $this->qr_file = $this->certification_user_path.$pathinfo['filename'].'_qr.png';
} else { } else {
$value = api_get_configuration_value('allow_general_certificate'); $this->check_certificate_path();
if ($value === true) { if (api_get_configuration_value('allow_general_certificate')) {
// General certificate // General certificate
$name = md5($this->user_id).'.html'; $name = md5($this->user_id).'.html';
$my_path_certificate = $this->certification_user_path.$name; $my_path_certificate = $this->certification_user_path.$name;
@ -127,13 +127,6 @@ class Certificate extends Model
$updateCertificateData $updateCertificateData
); );
$this->certificate_data['path_certificate'] = $path_certificate; $this->certificate_data['path_certificate'] = $path_certificate;
if ($this->isHtmlFileGenerated()) {
if (!empty($file_info)) {
//$text = $this->parse_certificate_variables($new_content_html['variables']);
//$this->generate_qr($text, $qr_code_filename);
}
}
} }
} }
} }
@ -220,6 +213,7 @@ class Certificate extends Model
$params['hide_print_button'] = isset($params['hide_print_button']) ? true : false; $params['hide_print_button'] = isset($params['hide_print_button']) ? true : false;
$categoryId = 0; $categoryId = 0;
$my_category = [];
if (isset($this->certificate_data) && isset($this->certificate_data['cat_id'])) { if (isset($this->certificate_data) && isset($this->certificate_data['cat_id'])) {
$categoryId = $this->certificate_data['cat_id']; $categoryId = $this->certificate_data['cat_id'];
$my_category = Category::load($categoryId); $my_category = Category::load($categoryId);
@ -236,7 +230,6 @@ class Certificate extends Model
$sessionId = $category->get_session_id(); $sessionId = $category->get_session_id();
$skill = new Skill(); $skill = new Skill();
$skill->addSkillToUser( $skill->addSkillToUser(
$this->user_id, $this->user_id,
$category, $category,
@ -334,6 +327,8 @@ class Certificate extends Model
} }
} }
} else { } else {
$this->check_certificate_path();
// General certificate // General certificate
$name = md5($this->user_id).'.html'; $name = md5($this->user_id).'.html';
$my_path_certificate = $this->certification_user_path.$name; $my_path_certificate = $this->certification_user_path.$name;
@ -368,13 +363,6 @@ class Certificate extends Model
$path_certificate $path_certificate
); );
$this->certificate_data['path_certificate'] = $path_certificate; $this->certificate_data['path_certificate'] = $path_certificate;
if ($this->isHtmlFileGenerated()) {
if (!empty($file_info)) {
//$text = $this->parse_certificate_variables($new_content_html['variables']);
//$this->generate_qr($text, $qr_code_filename);
}
}
} }
return $result; return $result;

@ -330,27 +330,11 @@ class Chat extends Model
]; ];
} }
/*if (!empty($_SESSION['openChatBoxes'])) {
foreach ($_SESSION['openChatBoxes'] as $userId => $time) {
if (!isset($_SESSION['tsChatBoxes'][$userId])) {
$now = time() - $time;
$time = api_convert_and_format_date($time, DATE_TIME_FORMAT_SHORT_TIME_FIRST);
$message = sprintf(get_lang('SentAtX'), $time);
if ($now > 180) {
if (isset($chatHistory[$userId])) {
$chatHistory[$userId]['items'][] = $item;
}
$_SESSION['tsChatBoxes'][$userId] = 1;
}
}
}
}*/
Session::write('chatHistory', $chatHistory); Session::write('chatHistory', $chatHistory);
$sql = "UPDATE ".$this->table." $sql = "UPDATE ".$this->table."
SET recd = 1 SET recd = 1
WHERE to_user = '".$currentUserId."' AND recd = 0"; WHERE to_user = $currentUserId AND recd = 0";
Database::query($sql); Database::query($sql);
echo json_encode(['items' => $chatHistory]); echo json_encode(['items' => $chatHistory]);
@ -439,7 +423,7 @@ class Chat extends Model
/** /**
* Close a specific chat box (user ID taken from $_POST['chatbox']). * Close a specific chat box (user ID taken from $_POST['chatbox']).
* *
* @param $userId * @param int $userId
*/ */
public function closeWindow($userId) public function closeWindow($userId)
{ {

@ -785,6 +785,16 @@ class CourseManager
); );
} }
$subscribe = (int) api_get_course_setting('subscribe_users_to_forum_notifications', $courseCode);
if ($subscribe === 1) {
require_once api_get_path(SYS_CODE_PATH).'forum/forumfunction.inc.php';
$forums = get_forums(0, $courseCode, true, $sessionId);
foreach ($forums as $forum) {
$forumId = $forum['iid'];
set_notification('forum', $forumId, false, $userInfo, $courseInfo);
}
}
// Add event to the system log // Add event to the system log
Event::addEvent( Event::addEvent(
LOG_SUBSCRIBE_USER_TO_COURSE, LOG_SUBSCRIBE_USER_TO_COURSE,
@ -4775,20 +4785,21 @@ class CourseManager
return []; return [];
} }
$limit = intval($limit); $limit = (int) $limit;
$userId = api_get_user_id();
// Getting my courses // Getting my courses
$my_course_list = self::get_courses_list_by_user_id(api_get_user_id()); $my_course_list = self::get_courses_list_by_user_id($userId);
$my_course_code_list = []; $codeList = [];
foreach ($my_course_list as $course) { foreach ($my_course_list as $course) {
$my_course_code_list[$course['real_id']] = $course['real_id']; $codeList[$course['real_id']] = $course['real_id'];
} }
if (api_is_drh()) { if (api_is_drh()) {
$courses = self::get_courses_followed_by_drh(api_get_user_id()); $courses = self::get_courses_followed_by_drh($userId);
foreach ($courses as $course) { foreach ($courses as $course) {
$my_course_code_list[$course['real_id']] = $course['real_id']; $codeList[$course['real_id']] = $course['real_id'];
} }
} }
@ -4817,10 +4828,9 @@ class CourseManager
$result = Database::query($sql); $result = Database::query($sql);
$courses = []; $courses = [];
if (Database::num_rows($result)) { if (Database::num_rows($result)) {
$courses = Database::store_result($result, 'ASSOC'); $courses = Database::store_result($result, 'ASSOC');
$courses = self::processHotCourseItem($courses, $my_course_code_list); $courses = self::processHotCourseItem($courses, $codeList);
} }
return $courses; return $courses;
@ -4828,11 +4838,11 @@ class CourseManager
/** /**
* @param array $courses * @param array $courses
* @param array $my_course_code_list * @param array $codeList
* *
* @return mixed * @return mixed
*/ */
public static function processHotCourseItem($courses, $my_course_code_list = []) public static function processHotCourseItem($courses, $codeList = [])
{ {
$hotCourses = []; $hotCourses = [];
$ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote'; $ajax_url = api_get_path(WEB_AJAX_PATH).'course.ajax.php?a=add_course_vote';
@ -4850,7 +4860,7 @@ class CourseManager
$access_link = self::get_access_link_by_user( $access_link = self::get_access_link_by_user(
api_get_user_id(), api_get_user_id(),
$course_info, $course_info,
$my_course_code_list $codeList
); );
$userRegisteredInCourse = self::is_user_subscribed_in_course($user_id, $course_info['code']); $userRegisteredInCourse = self::is_user_subscribed_in_course($user_id, $course_info['code']);
@ -5327,6 +5337,7 @@ class CourseManager
'student_delete_own_publication', 'student_delete_own_publication',
'hide_forum_notifications', 'hide_forum_notifications',
'quiz_question_limit_per_day', 'quiz_question_limit_per_day',
'subscribe_users_to_forum_notifications',
]; ];
$courseModels = ExerciseLib::getScoreModels(); $courseModels = ExerciseLib::getScoreModels();
@ -5431,8 +5442,8 @@ class CourseManager
$endDate $endDate
) { ) {
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
$courseId = intval($courseId); $courseId = (int) $courseId;
$sessionId = intval($sessionId); $sessionId = (int) $sessionId;
$startDate = Database::escape_string($startDate); $startDate = Database::escape_string($startDate);
$endDate = Database::escape_string($endDate); $endDate = Database::escape_string($endDate);

@ -160,6 +160,7 @@ define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT', 'student_publication_assignment')
define('TABLE_STUDENT_PUBLICATION_REL_DOCUMENT', 'student_publication_rel_document'); define('TABLE_STUDENT_PUBLICATION_REL_DOCUMENT', 'student_publication_rel_document');
define('TABLE_STUDENT_PUBLICATION_REL_USER', 'student_publication_rel_user'); define('TABLE_STUDENT_PUBLICATION_REL_USER', 'student_publication_rel_user');
define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT', 'student_publication_comment'); define('TABLE_STUDENT_PUBLICATION_ASSIGNMENT_COMMENT', 'student_publication_comment');
define('TABLE_PLAGIARISM', 'plagiarism_compilatio_docs');
// Course forum tables // Course forum tables
define('TABLE_FORUM_CATEGORY', 'forum_category'); define('TABLE_FORUM_CATEGORY', 'forum_category');

@ -1473,7 +1473,7 @@ class Display
$beforeSelectRow = null; $beforeSelectRow = null;
if (isset($extra_params['beforeSelectRow'])) { if (isset($extra_params['beforeSelectRow'])) {
$beforeSelectRow = "beforeSelectRow: ".$extra_params['beforeSelectRow'].", "; $beforeSelectRow = 'beforeSelectRow: '.$extra_params['beforeSelectRow'].', ';
unset($extra_params['beforeSelectRow']); unset($extra_params['beforeSelectRow']);
} }
@ -1533,6 +1533,16 @@ class Display
$json_encode = str_replace('"formatter":"extra_formatter"', 'formatter:extra_formatter', $json_encode); $json_encode = str_replace('"formatter":"extra_formatter"', 'formatter:extra_formatter', $json_encode);
$json_encode = str_replace(['{"first":"first",', '"end":"end"}'], '', $json_encode); $json_encode = str_replace(['{"first":"first",', '"end":"end"}'], '', $json_encode);
if (api_get_configuration_value('allow_compilatio_tool') &&
(strpos($_SERVER['REQUEST_URI'], 'work/work.php') !== false ||
strpos($_SERVER['REQUEST_URI'], 'work/work_list_all.php') != false
)
) {
$json_encode = str_replace('"function () { compilatioInit() }"',
'function () { compilatioInit() }',
$json_encode
);
}
// Creating the jqgrid element. // Creating the jqgrid element.
$json .= '$("#'.$div_id.'").jqGrid({'; $json .= '$("#'.$div_id.'").jqGrid({';
//$json .= $beforeSelectRow; //$json .= $beforeSelectRow;
@ -1751,7 +1761,7 @@ class Display
} }
if ($notification['tool'] == TOOL_LEARNPATH) { if ($notification['tool'] == TOOL_LEARNPATH) {
if (!learnpath::is_lp_visible_for_student($notification['ref'], $user_id, $course_code)) { if (!learnpath::is_lp_visible_for_student($notification['ref'], $user_id, $courseInfo)) {
continue; continue;
} }
} }
@ -1919,15 +1929,6 @@ class Display
'; ';
$html .= '</ul></div>'; $html .= '</ul></div>';
$html .= '</section>'; $html .= '</section>';
/*$html.= '<ul id="'.$id.'" class="star-rating">
<li class="current-rating" style="width:'.$percentage.'px;"></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=1" title="'.$star_label.'" class="one-star">1</a></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=2" title="'.$star_label.'" class="two-stars">2</a></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=3" title="'.$star_label.'" class="three-stars">3</a></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=4" title="'.$star_label.'" class="four-stars">4</a></li>
<li><a href="javascript:void(0);" data-link="'.$url.'&amp;star=5" title="'.$star_label.'" class="five-stars">5</a></li>
</ul>';*/
$labels = []; $labels = [];
$labels[] = $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes'); $labels[] = $number_of_users_who_voted == 1 ? $number_of_users_who_voted.' '.get_lang('Vote') : $number_of_users_who_voted.' '.get_lang('Votes');
@ -2031,15 +2032,18 @@ class Display
* @param int $percentage int value between 0 and 100 * @param int $percentage int value between 0 and 100
* @param bool $show_percentage * @param bool $show_percentage
* @param string $extra_info * @param string $extra_info
* @param string $class danger/success/infowarning
* *
* @return string * @return string
*/ */
public static function bar_progress($percentage, $show_percentage = true, $extra_info = '') public static function bar_progress($percentage, $show_percentage = true, $extra_info = '', $class = '')
{ {
$percentage = (int) $percentage; $percentage = (int) $percentage;
$class = empty($class) ? '' : "progress-bar-$class";
$div = '<div class="progress"> $div = '<div class="progress">
<div <div
class="progress-bar progress-bar-striped" class="progress-bar progress-bar-striped '.$class.'"
role="progressbar" role="progressbar"
aria-valuenow="'.$percentage.'" aria-valuenow="'.$percentage.'"
aria-valuemin="0" aria-valuemin="0"

@ -558,13 +558,13 @@ class DocumentManager
$toUserId = (int) $toUserId; $toUserId = (int) $toUserId;
$userGroupFilter = "last.to_user_id = $toUserId"; $userGroupFilter = "last.to_user_id = $toUserId";
if (empty($toUserId)) { if (empty($toUserId)) {
$userGroupFilter = " (last.to_user_id = 0 OR last.to_user_id IS NULL) "; $userGroupFilter = ' (last.to_user_id = 0 OR last.to_user_id IS NULL) ';
} }
} else { } else {
$toGroupId = (int) $toGroupId; $toGroupId = (int) $toGroupId;
$userGroupFilter = "last.to_group_id = $toGroupId"; $userGroupFilter = "last.to_group_id = $toGroupId";
if (empty($toGroupId)) { if (empty($toGroupId)) {
$userGroupFilter = "( last.to_group_id = 0 OR last.to_group_id IS NULL) "; $userGroupFilter = '( last.to_group_id = 0 OR last.to_group_id IS NULL) ';
} }
} }
@ -647,6 +647,17 @@ class DocumentManager
} }
} }
if (self::isBasicCourseFolder($row['path'], $sessionId)) {
$basicCourseDocumentsContent = self::getAllDocumentData(
$courseInfo,
$row['path']
);
if (empty($basicCourseDocumentsContent)) {
continue;
}
}
$rows[$row['id']] = $row; $rows[$row['id']] = $row;
} }

@ -184,10 +184,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function apiVersion() function apiVersion()
{ {
return 2.3; return 2.3;
} //end func apiVersion }
// }}}
// {{{ setSelected()
/** /**
* Sets the default values of the select box * Sets the default values of the select box
@ -200,32 +197,14 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function setSelected($values) function setSelected($values)
{ {
if (is_string($values) && $this->getMultiple()) { if (is_string($values) && $this->getMultiple()) {
$values = explode("[ ]?,[ ]?", $values); $values = explode('[ ]?,[ ]?', $values);
} }
if (is_array($values)) { if (is_array($values)) {
$this->_values = array_values($values); $this->_values = array_values($values);
} else { } else {
$this->_values = array($values); $this->_values = array($values);
} }
} //end func setSelected }
// }}}
// {{{ getSelected()
/**
* Returns an array of the selected values
*
* @since 1.0
* @access public
* @return array of selected values
*/
function getSelected()
{
return $this->_values;
} // end func getSelected
// }}}
// {{{ setName()
/** /**
* Sets the input field name * Sets the input field name
@ -238,10 +217,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function setName($name) function setName($name)
{ {
$this->updateAttributes(array('name' => $name)); $this->updateAttributes(array('name' => $name));
} //end func setName }
// }}}
// {{{ getName()
/** /**
* Returns the element name * Returns the element name
@ -253,10 +229,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function getName() function getName()
{ {
return $this->getAttribute('name'); return $this->getAttribute('name');
} //end func getName }
// }}}
// {{{ getPrivateName()
/** /**
* Returns the element name (possibly with brackets appended) * Returns the element name (possibly with brackets appended)
@ -272,10 +245,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
} else { } else {
return $this->getName(); return $this->getName();
} }
} //end func getPrivateName }
// }}}
// {{{ setValue()
/** /**
* Sets the value of the form element * Sets the value of the form element
@ -288,10 +258,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function setValue($value) function setValue($value)
{ {
$this->setSelected($value); $this->setSelected($value);
} // end func setValue }
// }}}
// {{{ getValue()
/** /**
* Returns an array of the selected values * Returns an array of the selected values
@ -303,10 +270,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function getValue() function getValue()
{ {
return $this->_values; return $this->_values;
} // end func getValue }
// }}}
// {{{ setSize()
/** /**
* Sets the select field size, only applies to 'multiple' selects * Sets the select field size, only applies to 'multiple' selects
@ -319,10 +283,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function setSize($size) function setSize($size)
{ {
$this->updateAttributes(array('size' => $size)); $this->updateAttributes(array('size' => $size));
} //end func setSize }
// }}}
// {{{ getSize()
/** /**
* Returns the select field size * Returns the select field size
@ -334,11 +295,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function getSize() function getSize()
{ {
return $this->getAttribute('size'); return $this->getAttribute('size');
} //end func getSize }
// }}}
// {{{ setMultiple()
/** /**
* Sets the select mutiple attribute * Sets the select mutiple attribute
@ -355,10 +312,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
} else { } else {
$this->removeAttribute('multiple'); $this->removeAttribute('multiple');
} }
} //end func setMultiple }
// }}}
// {{{ getMultiple()
/** /**
* Returns the select mutiple attribute * Returns the select mutiple attribute
@ -370,10 +324,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
function getMultiple() function getMultiple()
{ {
return (bool)$this->getAttribute('multiple'); return (bool)$this->getAttribute('multiple');
} //end func getMultiple }
// }}}
// {{{ addOption()
/** /**
* Adds a new OPTION to the SELECT * Adds a new OPTION to the SELECT
@ -408,10 +359,9 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
} else { } else {
$this->_options[] = array('text' => $text, 'attr' => $attributes); $this->_options[] = array('text' => $text, 'attr' => $attributes);
} }
} // end func addOption }
/** /**
* Adds a new OPTION to the SELECT * Adds a new OPTION to the SELECT
* *
* @param string $text Display text for the OPTION * @param string $text Display text for the OPTION
@ -527,10 +477,7 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
} }
} }
return $html; return $html;
} //end func getFrozenHtml }
// }}}
// {{{ exportValue()
/** /**
* We check the options and return only the values that _could_ have been * We check the options and return only the values that _could_ have been
@ -585,6 +532,24 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
} }
} }
/**
* @param FormValidator $form
*/
public function updateSelectWithSelectedOption(FormValidator $form)
{
$id = $this->getAttribute('id');
$form->addHtml('<script>
$(function(){
var optionClass = $("#'.$id.'").find("option:checked").attr("class");
$("#'.$id.'").attr("class", "form-control " + optionClass);
$("#'.$id.'").on("change", function() {
var optionClass = ($(this).find("option:checked").attr("class"));
$(this).attr("class", "form-control " + optionClass);
});
});
</script>');
}
/** /**
* Show an icon at the left side of an input * Show an icon at the left side of an input
* @return string * @return string
@ -676,12 +641,4 @@ class HTML_QuickForm_select extends HTML_QuickForm_element
break; break;
} }
} }
/**
* Remove all options
*/
public function clearOptions()
{
$this->_options = [];
}
} }

@ -53,7 +53,8 @@ class HTML_QuickForm_text extends HTML_QuickForm_input
$attributes = []; $attributes = [];
} }
if (is_array($attributes) || empty($attributes)) { if (is_array($attributes) || empty($attributes)) {
$attributes['class'] = 'form-control'; $classFromAttributes = isset($attributes['class']) ? $attributes['class'] : '';
$attributes['class'] = $classFromAttributes.' form-control';
} }
$inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null; $inputSize = isset($attributes['input-size']) ? $attributes['input-size'] : null;
$this->setInputSize($inputSize); $this->setInputSize($inputSize);

@ -3395,7 +3395,7 @@ function finishInstallationWithContainer(
UserManager::setPasswordEncryption($encryptPassForm); UserManager::setPasswordEncryption($encryptPassForm);
// Create admin user. // Create admin user.
UserManager::create_user( @UserManager::create_user(
$adminFirstName, $adminFirstName,
$adminLastName, $adminLastName,
1, 1,

Loading…
Cancel
Save