Skip to content

Commit

Permalink
Update and adjust code to match new database current settings - refs …
Browse files Browse the repository at this point in the history
…#7538
  • Loading branch information
ywarnier committed May 24, 2015
1 parent b990fc7 commit 9acc020
Show file tree
Hide file tree
Showing 50 changed files with 192 additions and 253 deletions.
7 changes: 3 additions & 4 deletions certificates/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@

switch ($action) {
case 'export':
if (
api_get_configuration_value('hide_certificate_export_link') ||
(api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
) {
$hideExportLink = api_get_setting('hide_certificate_export_link');
$hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
api_not_allowed(true);
}

Expand Down
6 changes: 2 additions & 4 deletions custompages/language.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,8 @@ function custompages_get_lang($variable) {
$lang_match = $chamilo_langs[$_REQUEST['lang']];
}

global $_configuration;
if (isset($_configuration['auto_detect_language_custom_pages']) &&
$_configuration['auto_detect_language_custom_pages'] == true
) {
$detect = api_get_setting('auto_detect_language_custom_pages');
if ($detect === 'true') {
// Auto detect
$_user['language'] = $lang_match;
$_SESSION['user_language_choice'] = $lang_match;
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@


// Display the Site Use Cookie Warning Validation
$useCookieValidation = api_get_configuration_value('cookie_warning');
if ($useCookieValidation) {
$useCookieValidation = api_get_setting('cookie_warning');
if ($useCookieValidation === 'true') {
if (isset($_POST['acceptCookies'])) {
api_set_site_use_cookie_warning_cookie();
} else if (!api_site_use_cookie_warning_cookie_exist()) {
Expand Down
16 changes: 6 additions & 10 deletions main/admin/add_users_to_usergroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ function change_select(val) {
$order = array('firstname');
}

global $_configuration;
if (isset($_configuration['order_user_list_by_official_code']) &&
$_configuration['order_user_list_by_official_code']
) {
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$order = array('official_code', 'lastname');
}

Expand Down Expand Up @@ -249,9 +247,8 @@ function change_select(val) {
$item['lastname']
).' ('.$item['username'].') '.$officialCode;

if (isset($_configuration['order_user_list_by_official_code']) &&
$_configuration['order_user_list_by_official_code']
) {
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$officialCode = !empty($item['official_code']) ? $item['official_code'].' - ' : '? - ';
$person_name = $officialCode.api_get_person_name(
$item['firstname'],
Expand Down Expand Up @@ -297,9 +294,8 @@ function change_select(val) {
$item['lastname']
).' ('.$item['username'].') '.$officialCode;

if (isset($_configuration['order_user_list_by_official_code']) &&
$_configuration['order_user_list_by_official_code']
) {
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$officialCode = !empty($item['official_code']) ? $item['official_code'].' - ' : '? - ';
$person_name = $officialCode.api_get_person_name(
$item['firstname'],
Expand Down
4 changes: 2 additions & 2 deletions main/admin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -454,8 +454,8 @@
$tpl = new Template();

// Display the Site Use Cookie Warning Validation
$useCookieValidation = api_get_configuration_value('cookie_warning');
if ($useCookieValidation) {
$useCookieValidation = api_get_setting('cookie_warning');
if ($useCookieValidation === 'true') {
if (isset($_POST['acceptCookies'])) {
api_set_site_use_cookie_warning_cookie();
} else if (!api_site_use_cookie_warning_cookie_exist()) {
Expand Down
5 changes: 3 additions & 2 deletions main/admin/skill_badge.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
}
$backpack = 'https://backpack.openbadges.org/';

if (array_key_exists('openbadges_backpack', $_configuration)) {
$backpack = $_configuration['openbadges_backpack'];
$configBackpack = api_get_seeting('openbadges_backpack');
if (strcmp($backpack, $configBackpack) !== 0) {
$backpack = $configBackpack;
}

$interbreadcrumb = array(
Expand Down
6 changes: 2 additions & 4 deletions main/admin/subscribe_user2course.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,8 @@ function validate_filter() {
$target_name = api_sort_by_first_name() ? 'firstname' : 'lastname';
$orderBy = $target_name;
$showOfficialCode = false;
global $_configuration;
if (isset($_configuration['order_user_list_by_official_code']) &&
$_configuration['order_user_list_by_official_code']
) {
$orderListByOfficialCode = api_get_setting('order_user_list_by_official_code');
if ($orderListByOfficialCode === 'true') {
$showOfficialCode = true;
$orderBy = " official_code, firstname, lastname";
}
Expand Down
3 changes: 2 additions & 1 deletion main/admin/user_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,8 @@ function get_user_data($from, $number_of_items, $column, $direction) {
$from = intval($from);
$number_of_items = intval($number_of_items);

if (api_is_session_admin() && api_get_setting('prevent_session_admins_to_manage_all_users') == 'true') {
$preventSessionAdminsToManageAllUsers = api_get_setting('prevent_session_admins_to_manage_all_users');
if (api_is_session_admin() && $preventSessionAdminsToManageAllUsers === 'true') {
$sql .= " WHERE u.creator_id = ".api_get_user_id();
}

Expand Down
4 changes: 2 additions & 2 deletions main/attendance/attendance_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@ public function attendance_edit($attendance_id)
*/
public function attendance_delete($attendance_id)
{
$allowDeleteAttendance = api_get_configuration_value('allow_delete_attendance');
if ($allowDeleteAttendance == false) {
$allowDeleteAttendance = api_get_setting('allow_delete_attendance');
if ($allowDeleteAttendance !== 'true') {
$this->attendance_list();
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions main/attendance/attendance_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
'attendance_set_visible_select' => get_lang('SetVisible')
);

$allow = api_get_configuration_value('allow_delete_attendance');
if ($allow) {
$allow = api_get_setting('allow_delete_attendance');
if ($allow === 'true') {
$actions['attendance_delete_select'] = get_lang('DeleteAllSelectedAttendances');
}
$table->set_form_actions($actions);
Expand Down
4 changes: 2 additions & 2 deletions main/auth/courses.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,8 @@ function(responseText, textStatus, XMLHttpRequest) {
$courses_controller->sessionsList($action, $nameTools, $limit);
break;
case 'subscribe_to_session':
$registrationAllowed = api_get_configuration_value('catalog_allow_session_auto_subscription');
if ($registrationAllowed) {
$registrationAllowed = api_get_setting('catalog_allow_session_auto_subscription');
if ($registrationAllowed === 'true') {
SessionManager::suscribe_users_to_session(
$_GET['session_id'],
array($_GET['user_id'])
Expand Down
8 changes: 5 additions & 3 deletions main/auth/courses_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,9 @@ public function courses_categories($action, $category_code = null, $message = ''

$data['catalogShowCoursesSessions'] = 0;

if (isset($_configuration['catalog_show_courses_sessions'])) {
$data['catalogShowCoursesSessions'] = $_configuration['catalog_show_courses_sessions'];
$showCoursesSessions = intval('catalog_show_courses_sessions');

This comment has been minimized.

Copy link
@jmontoyaa

jmontoyaa Jun 18, 2018

Member

Something is wrong here ...

This comment has been minimized.

Copy link
@ywarnier

ywarnier Jun 18, 2018

Author Member

😮
Indeed, did you fix it or is it still wrong?
From what I see, the setting is already in settings_current, so it should be

$showCoursesSessions = intval(api_get_setting('catalog_show_courses_sessions'));

This comment has been minimized.

Copy link
@jmontoyaa

jmontoyaa Jul 5, 2018

Member

Fixed:

0bf462d

if ($showCoursesSessions > 0) {
$data['catalogShowCoursesSessions'] = $showCoursesSessions;
}

// render to the view
Expand Down Expand Up @@ -570,7 +571,8 @@ public function sessionsList($action, $nameTools, $limit = array())

$key = 'name';
$catalogSessionAutoSubscriptionAllowed = false;
if (api_get_configuration_value('catalog_allow_session_auto_subscription')) {
$catalogSessionAutoSubscription = api_get_setting('catalog_allow_session_auto_subscription');
if ($catalogSessionAutoSubscription === 'true') {
$key = 'id';
$catalogSessionAutoSubscriptionAllowed = true;
}
Expand Down
29 changes: 14 additions & 15 deletions main/course_home/activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,23 +113,22 @@
$content .= CourseHome::show_tools_category($my_list);
$content .= '</div>';

if (isset($_configuration['allow_session_course_copy_for_teachers'])) {
if ($_configuration['allow_session_course_copy_for_teachers']) {
// Adding only maintenance for coaches.
$myList = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$onlyMaintenanceList = array();

foreach ($myList as $item) {
if ($item['name'] == 'course_maintenance') {
$item['link'] = 'course_info/maintenance_coach.php';

$onlyMaintenanceList[] = $item;
}
}
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
if ($sessionsCopy === 'true') {
// Adding only maintenance for coaches.
$myList = CourseHome::get_tools_category(TOOL_ADMIN_PLATFORM);
$onlyMaintenanceList = array();

foreach ($myList as $item) {
if ($item['name'] == 'course_maintenance') {
$item['link'] = 'course_info/maintenance_coach.php';

$items = CourseHome::show_tools_category($onlyMaintenanceList);
$content .= return_block(get_lang('Administration'), $items);
$onlyMaintenanceList[] = $item;
}
}

$items = CourseHome::show_tools_category($onlyMaintenanceList);
$content .= return_block(get_lang('Administration'), $items);
}
} else {
$tools = CourseHome::get_tools_category(TOOL_STUDENT_VIEW);
Expand Down
6 changes: 2 additions & 4 deletions main/course_info/infocours.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,8 @@ function is_settings_editable() {
$form->addGroup($group, '', array(get_lang("AllowLearningPathTheme")), '');
}

global $_configuration;
if (isset($_configuration['allow_lp_return_link']) &&
$_configuration['allow_lp_return_link']
) {
$allowLPReturnLink = api_get_setting('allow_lp_return_link');
if ($allowLPReturnLink === 'true') {
$group = array(
$form->createElement(
'radio',
Expand Down
4 changes: 2 additions & 2 deletions main/course_info/maintenance_coach.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
api_protect_course_script(true);
api_block_anonymous_users();

if (!isset($_configuration['allow_session_course_copy_for_teachers'])
|| !$_configuration['allow_session_course_copy_for_teachers']){
$sessionsCopy = api_get_setting('allow_session_course_copy_for_teachers');
if ($sessionsCopy !== 'true') {
api_not_allowed(true);
}

Expand Down
2 changes: 1 addition & 1 deletion main/document/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ function setFocus(){
$form->addButtonSend(get_lang('SendDocument'), 'submitDocument');
$form->add_real_progress_bar('DocumentUpload', 'file');

$fileExistsOption = api_get_configuration_value('document_if_file_exists_option');
$fileExistsOption = api_get_setting('document_if_file_exists_option');

$defaultFileExistsOption = 'rename';
if (!empty($fileExistsOption)) {
Expand Down
4 changes: 2 additions & 2 deletions main/dropbox/dropbox_functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -519,9 +519,9 @@ function display_add_form($dropbox_unid, $viewReceivedCategory, $viewSentCategor
);
}

$hideCoach = api_get_configuration_value('dropbox_hide_course_coach');
$hideCoach = api_get_setting('dropbox_hide_course_coach');

if ($hideCoach == false) {
if ($hideCoach !== 'true') {
$complete_user_list2 = CourseManager::get_coach_list_from_course_code(
$course_info['code'],
api_get_session_id()
Expand Down
6 changes: 3 additions & 3 deletions main/exercice/exercise_report.php
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
$group_parameters = implode(';', $group_parameters);
}

$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
$officialCodeInList = api_get_setting('show_official_code_exercise_result_list');

if ($is_allowedToEdit || $is_tutor) {

Expand All @@ -416,7 +416,7 @@
get_lang('Actions')
);

if ($officialCodeInList == true) {
if ($officialCodeInList === 'true') {
$columns = array_merge(array(get_lang('OfficialCode')), $columns);
}

Expand Down Expand Up @@ -448,7 +448,7 @@
array('name' => 'actions', 'index' => 'actions', 'width' => '60', 'align' => 'left', 'search' => 'false')
);

if ($officialCodeInList == true) {
if ($officialCodeInList == 'true') {
$officialCodeRow = array('name' => 'official_code', 'index' => 'official_code', 'width' => '50', 'align' => 'left', 'search' => 'true');
$column_model = array_merge(array($officialCodeRow), $column_model);
}
Expand Down
10 changes: 5 additions & 5 deletions main/exercice/exercise_result.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,8 @@ public function exportCompleteReportCSV(
$data .= get_lang('FirstName').';';
}
}
$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
if ($officialCodeInList) {
$officialCodeInList = api_get_setting('show_official_code_exercise_result_list');
if ($officialCodeInList === 'true') {
$data .= get_lang('OfficialCode').';';
}

Expand Down Expand Up @@ -432,7 +432,7 @@ public function exportCompleteReportXLS(
}
}

$officialCodeInList = api_get_configuration_value('show_official_code_exercise_result_list');
$officialCodeInList = api_get_setting('show_official_code_exercise_result_list');

if ($with_column_user) {
if (api_is_western_name_order()) {
Expand All @@ -447,7 +447,7 @@ public function exportCompleteReportXLS(
$column++;
}

if ($officialCodeInList) {
if ($officialCodeInList === 'true') {
$worksheet->write($line, $column, get_lang('OfficialCode'));
$column++;
}
Expand Down Expand Up @@ -504,7 +504,7 @@ public function exportCompleteReportXLS(
$column++;
}

if ($officialCodeInList) {
if ($officialCodeInList === 'true') {
$worksheet->write($line, $column,api_html_entity_decode(strip_tags($row['official_code']), ENT_QUOTES, $charset));
$column++;
}
Expand Down
2 changes: 1 addition & 1 deletion main/exercice/exercise_show.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
}
}

$maxEditors = isset($_configuration['exercise_max_ckeditors_in_page']) ? $_configuration['exercise_max_ckeditors_in_page'] : 0;
$maxEditors = intval(api_get_setting('exercise_max_ckeditors_in_page'));
$is_allowedToEdit = api_is_allowed_to_edit(null, true) || $is_courseTutor || api_is_session_admin() || api_is_drh() || api_is_student_boss();

//Getting results from the exe_id. This variable also contain all the information about the exercise
Expand Down
5 changes: 3 additions & 2 deletions main/gradebook/get_badges.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@

$backpack = 'https://backpack.openbadges.org/';

if (array_key_exists('openbadges_backpack', $_configuration)) {
$backpack = $_configuration['openbadges_backpack'];
$configBackpack = api_get_seeting('openbadges_backpack');
if (strcmp($backpack, $configBackpack) !== 0) {
$backpack = $configBackpack;
}

$htmlHeadXtra[] = '<script src="' . $backpack . 'issuer.js"></script>';
Expand Down
7 changes: 4 additions & 3 deletions main/gradebook/gradebook_display_certificate.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,11 @@ function confirmation() {
}
}

$filter = api_get_configuration_value('certificate_filter_by_official_code');
$filter = api_get_setting('certificate_filter_by_official_code');
$userList = array();
$filterForm = null;
$certificate_list = array();
if ($filter) {
if ($filter === 'true') {
echo '<br />';
$options = UserManager::getOfficialCodeGrouped();
$options =array_merge(array('all' => get_lang('All')), $options);
Expand Down Expand Up @@ -187,7 +187,8 @@ function confirmation() {
$url = api_get_self().'?action=delete_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default'));

if (count($certificate_list) > 0 && !api_get_configuration_value('hide_certificate_export_link')) {
$hideCertificateExport = api_get_setting('hide_certificate_export_link');
if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') {
$url = api_get_self().'?action=export_all_certificates'.'&'.api_get_cidReq().'&cat_id='.$cat_id.'&filter='.$filterOfficialCode;
echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default'));
}
Expand Down
7 changes: 3 additions & 4 deletions main/gradebook/lib/be/category.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1870,10 +1870,9 @@ public static function register_user_certificate($category_id, $user_id)
"$url&action=export"
);

if (
api_get_configuration_value('hide_certificate_export_link') ||
(api_is_student() && api_get_configuration_value('hide_certificate_export_link_students'))
) {
$hideExportLink = api_get_setting('hide_certificate_export_link');
$hideExportLinkStudent = api_get_setting('hide_certificate_export_link_students');
if ($hideExportLink === 'true' || (api_is_student() && $hideExportLinkStudent === 'true') ) {
$exportToPDF = null;
}

Expand Down
2 changes: 1 addition & 1 deletion main/gradebook/lib/be/studentpublicationlink.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public function calc_score($stud_id = null, $type = null)
$sql .= " AND user_id = $stud_id ";
}

$order = api_get_configuration_value('student_publication_to_take_in_gradebook');
$order = api_get_setting('student_publication_to_take_in_gradebook');

switch ($order) {
case 'last':
Expand Down
Loading

0 comments on commit 9acc020

Please sign in to comment.