|
|
|
@ -499,7 +499,8 @@ define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_ORDERED', 9); |
|
|
|
|
define('EX_Q_SELECTION_CATEGORIES_ORDERED_BY_PARENT_QUESTIONS_RANDOM', 10); |
|
|
|
|
|
|
|
|
|
// one big string with all question types, for the validator in pear/HTML/QuickForm/Rule/QuestionType |
|
|
|
|
define('QUESTION_TYPES', |
|
|
|
|
define( |
|
|
|
|
'QUESTION_TYPES', |
|
|
|
|
UNIQUE_ANSWER.':'. |
|
|
|
|
MULTIPLE_ANSWER.':'. |
|
|
|
|
FILL_IN_BLANKS.':'. |
|
|
|
@ -752,7 +753,7 @@ function api_get_path($path = '', $configuration = []) |
|
|
|
|
$paths = []; |
|
|
|
|
// Initialise cache with default values. |
|
|
|
|
if (!array_key_exists($root_web, $paths)) { |
|
|
|
|
$paths[$root_web] = array( |
|
|
|
|
$paths[$root_web] = [ |
|
|
|
|
WEB_PATH => '', |
|
|
|
|
SYS_PATH => '', |
|
|
|
|
REL_PATH => '', |
|
|
|
@ -791,7 +792,7 @@ function api_get_path($path = '', $configuration = []) |
|
|
|
|
SYS_PUBLIC_PATH => 'web/', |
|
|
|
|
WEB_FONTS_PATH => 'fonts/', |
|
|
|
|
SYS_FONTS_PATH => 'fonts/', |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$isInitialized = []; |
|
|
|
@ -966,7 +967,8 @@ function api_get_cdn_path($web_path) |
|
|
|
|
* @return bool Return true if CAS authentification is activated |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
function api_is_cas_activated() { |
|
|
|
|
function api_is_cas_activated() |
|
|
|
|
{ |
|
|
|
|
return api_get_setting('cas_activate') == "true"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -974,7 +976,8 @@ function api_is_cas_activated() { |
|
|
|
|
* @return bool Return true if LDAP authentification is activated |
|
|
|
|
* |
|
|
|
|
*/ |
|
|
|
|
function api_is_ldap_activated() { |
|
|
|
|
function api_is_ldap_activated() |
|
|
|
|
{ |
|
|
|
|
global $extAuthSource; |
|
|
|
|
return is_array($extAuthSource[LDAP_AUTH_SOURCE]); |
|
|
|
|
} |
|
|
|
@ -1021,7 +1024,8 @@ function api_remove_trailing_slash($path) |
|
|
|
|
* Note: The built-in function filter_var($urs, FILTER_VALIDATE_URL) has a bug for some versions of PHP. |
|
|
|
|
* @link http://bugs.php.net/51192 |
|
|
|
|
*/ |
|
|
|
|
function api_valid_url($url, $absolute = false) { |
|
|
|
|
function api_valid_url($url, $absolute = false) |
|
|
|
|
{ |
|
|
|
|
if ($absolute) { |
|
|
|
|
if (preg_match(" |
|
|
|
|
/^ # Start at the beginning of the text |
|
|
|
@ -1217,44 +1221,45 @@ function api_block_anonymous_users($printHeaders = true) |
|
|
|
|
/** |
|
|
|
|
* @return array with the navigator name and version |
|
|
|
|
*/ |
|
|
|
|
function api_get_navigator() { |
|
|
|
|
function api_get_navigator() |
|
|
|
|
{ |
|
|
|
|
$navigator = 'Unknown'; |
|
|
|
|
$version = 0; |
|
|
|
|
|
|
|
|
|
if (!isset($_SERVER['HTTP_USER_AGENT'])) { |
|
|
|
|
return array('name' => 'Unknown', 'version' => '0.0.0'); |
|
|
|
|
return ['name' => 'Unknown', 'version' => '0.0.0']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') !== false) { |
|
|
|
|
$navigator = 'Opera'; |
|
|
|
|
list (, $version) = explode('Opera', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Opera', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) { |
|
|
|
|
$navigator = 'Internet Explorer'; |
|
|
|
|
list (, $version) = explode('MSIE', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('MSIE', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Chrome') !== false) { |
|
|
|
|
$navigator = 'Chrome'; |
|
|
|
|
list (, $version) = explode('Chrome', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Chrome', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'safari') !== false) { |
|
|
|
|
$navigator = 'Safari'; |
|
|
|
|
list (, $version) = explode('Version/', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Version/', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') !== false) { |
|
|
|
|
$navigator = 'Mozilla'; |
|
|
|
|
list (, $version) = explode('; rv:', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('; rv:', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') !== false) { |
|
|
|
|
$navigator = 'Netscape'; |
|
|
|
|
list (, $version) = explode('Netscape', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Netscape', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (strpos($_SERVER['HTTP_USER_AGENT'], 'Konqueror') !== false) { |
|
|
|
|
$navigator = 'Konqueror'; |
|
|
|
|
list (, $version) = explode('Konqueror', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Konqueror', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} elseif (stripos($_SERVER['HTTP_USER_AGENT'], 'applewebkit') !== false) { |
|
|
|
|
$navigator = 'AppleWebKit'; |
|
|
|
|
list (, $version) = explode('Version/', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
list(, $version) = explode('Version/', $_SERVER['HTTP_USER_AGENT']); |
|
|
|
|
} |
|
|
|
|
$version = str_replace('/', '', $version); |
|
|
|
|
if (strpos($version, '.') === false) { |
|
|
|
|
$version = number_format(doubleval($version), 1); |
|
|
|
|
} |
|
|
|
|
$return = array('name' => $navigator, 'version' => $version); |
|
|
|
|
$return = ['name' => $navigator, 'version' => $version]; |
|
|
|
|
return $return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1375,7 +1380,7 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true) |
|
|
|
|
$result['firstName'] = $result['firstname']; |
|
|
|
|
$result['lastName'] = $result['lastname']; |
|
|
|
|
|
|
|
|
|
$attributes = array( |
|
|
|
|
$attributes = [ |
|
|
|
|
'phone', |
|
|
|
|
'address', |
|
|
|
|
'picture_uri', |
|
|
|
@ -1392,7 +1397,7 @@ function _api_format_user($user, $add_password = false, $loadAvatars = true) |
|
|
|
|
'expiration_date', |
|
|
|
|
'last_login', |
|
|
|
|
'user_is_online' |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if (api_get_setting('extended_profile') === 'true') { |
|
|
|
|
$attributes[] = 'competences'; |
|
|
|
@ -1537,7 +1542,6 @@ function api_get_user_info( |
|
|
|
|
); |
|
|
|
|
apcu_store($apcVar, $user, 60); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
$user = _api_format_user( |
|
|
|
|
$userFromSession, |
|
|
|
@ -1683,7 +1687,7 @@ function api_get_course_int_id($code = null) |
|
|
|
|
$row = Database::select( |
|
|
|
|
'id', |
|
|
|
|
Database::get_main_table(TABLE_MAIN_COURSE), |
|
|
|
|
array('where'=> array('code = ?' => array($code))), |
|
|
|
|
['where'=> ['code = ?' => [$code]]], |
|
|
|
|
'first' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
@ -2452,7 +2456,7 @@ function api_get_session_image($session_id, $status_id) |
|
|
|
|
$session_img = " ".Display::return_icon( |
|
|
|
|
'star.png', |
|
|
|
|
get_lang('SessionSpecificResource'), |
|
|
|
|
array('align' => 'absmiddle'), |
|
|
|
|
['align' => 'absmiddle'], |
|
|
|
|
ICON_SIZE_SMALL |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
@ -2568,14 +2572,14 @@ function api_get_plugin_setting($plugin, $variable) |
|
|
|
|
function api_get_settings_params($params) |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
|
|
|
|
$result = Database::select('*', $table, array('where' => $params)); |
|
|
|
|
$result = Database::select('*', $table, ['where' => $params]); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function api_get_settings_params_simple($params) |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
|
|
|
|
$result = Database::select('*', $table, array('where' => $params), 'one'); |
|
|
|
|
$result = Database::select('*', $table, ['where' => $params], 'one'); |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3027,7 +3031,7 @@ function api_display_tool_view_option() |
|
|
|
|
$output_string .= '<a class="btn btn-default btn-sm" href="'.$sourceurl.'&isStudentView=true" target="_self">'. |
|
|
|
|
Display::returnFontAwesomeIcon('eye').' '.get_lang('SwitchToStudentView').'</a>'; |
|
|
|
|
} |
|
|
|
|
$html = Display::tag('div', $output_string, array('class'=>'view-options')); |
|
|
|
|
$html = Display::tag('div', $output_string, ['class'=>'view-options']); |
|
|
|
|
return $html; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -3152,10 +3156,10 @@ function api_is_coach_of_course_in_session($sessionId) |
|
|
|
|
if ($visibility != SESSION_VISIBLE && !empty($courseList)) { |
|
|
|
|
// Course Coach session visibility. |
|
|
|
|
$blockedCourseCount = 0; |
|
|
|
|
$closedVisibilityList = array( |
|
|
|
|
$closedVisibilityList = [ |
|
|
|
|
COURSE_VISIBILITY_CLOSED, |
|
|
|
|
COURSE_VISIBILITY_HIDDEN |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
foreach ($courseList as $course) { |
|
|
|
|
// Checking session visibility |
|
|
|
@ -3395,7 +3399,7 @@ function api_not_allowed( |
|
|
|
|
</p>'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$msg = Display::div($msg, array('align'=>'center')); |
|
|
|
|
$msg = Display::div($msg, ['align'=>'center']); |
|
|
|
|
|
|
|
|
|
$show_headers = 0; |
|
|
|
|
if ($print_headers && $origin != 'learnpath') { |
|
|
|
@ -3418,7 +3422,8 @@ function api_not_allowed( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!empty($_SERVER['REQUEST_URI']) && |
|
|
|
|
(!empty($_GET['cidReq']) || |
|
|
|
|
( |
|
|
|
|
!empty($_GET['cidReq']) || |
|
|
|
|
$this_section == SECTION_MYPROFILE || |
|
|
|
|
$this_section == SECTION_PLATFORM_ADMIN |
|
|
|
|
) |
|
|
|
@ -3450,7 +3455,7 @@ function api_not_allowed( |
|
|
|
|
$content .= Display::return_message(sprintf(get_lang('YouHaveAnInstitutionalAccount'), api_get_setting("Institution")), '', false); |
|
|
|
|
$content .= Display::div( |
|
|
|
|
"<br/><a href='".get_cas_direct_URL(api_get_course_id())."'>".sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution"))."</a><br/><br/>", |
|
|
|
|
array('align' => 'center') |
|
|
|
|
['align' => 'center'] |
|
|
|
|
); |
|
|
|
|
$content .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); |
|
|
|
|
$content .= "<p style='text-align:center'><a href='#' onclick='$(this).parent().next().toggle()'>".get_lang('LoginWithExternalAccount')."</a></p>"; |
|
|
|
@ -3500,7 +3505,7 @@ function api_not_allowed( |
|
|
|
|
'', |
|
|
|
|
false |
|
|
|
|
); |
|
|
|
|
$msg .= Display::div("<br/><a href='".get_cas_direct_URL(api_get_course_int_id())."'>".getCASLogoHTML()." ".sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution"))."</a><br/><br/>", array('align'=>'center')); |
|
|
|
|
$msg .= Display::div("<br/><a href='".get_cas_direct_URL(api_get_course_int_id())."'>".getCASLogoHTML()." ".sprintf(get_lang('LoginWithYourAccount'), api_get_setting("Institution"))."</a><br/><br/>", ['align'=>'center']); |
|
|
|
|
$msg .= Display::return_message(get_lang('YouDontHaveAnInstitutionAccount')); |
|
|
|
|
$msg .= "<p style='text-align:center'><a href='#' onclick='$(this).parent().next().toggle()'>".get_lang('LoginWithExternalAccount')."</a></p>"; |
|
|
|
|
$msg .= "<div style='display:none;'>"; |
|
|
|
@ -3556,7 +3561,7 @@ function api_get_not_allowed_login_form() |
|
|
|
|
'post', |
|
|
|
|
$action, |
|
|
|
|
null, |
|
|
|
|
array('class' => 'form-stacked') |
|
|
|
|
['class' => 'form-stacked'] |
|
|
|
|
); |
|
|
|
|
$params = [ |
|
|
|
|
'placeholder' => get_lang('UserName'), |
|
|
|
@ -3576,7 +3581,7 @@ function api_get_not_allowed_login_form() |
|
|
|
|
'password', |
|
|
|
|
'password', |
|
|
|
|
null, |
|
|
|
|
array('placeholder' => get_lang('Password'), 'class' => 'col-md-3') |
|
|
|
|
['placeholder' => get_lang('Password'), 'class' => 'col-md-3'] |
|
|
|
|
); //new |
|
|
|
|
$form->addButtonNext(get_lang('LoginEnter'), 'submitAuth'); |
|
|
|
|
|
|
|
|
@ -3593,9 +3598,9 @@ function api_get_not_allowed_login_form() |
|
|
|
|
*/ |
|
|
|
|
function convert_sql_date($last_post_datetime) |
|
|
|
|
{ |
|
|
|
|
list ($last_post_date, $last_post_time) = explode(' ', $last_post_datetime); |
|
|
|
|
list ($year, $month, $day) = explode('-', $last_post_date); |
|
|
|
|
list ($hour, $min, $sec) = explode(':', $last_post_time); |
|
|
|
|
list($last_post_date, $last_post_time) = explode(' ', $last_post_datetime); |
|
|
|
|
list($year, $month, $day) = explode('-', $last_post_date); |
|
|
|
|
list($hour, $min, $sec) = explode(':', $last_post_time); |
|
|
|
|
return mktime((int) $hour, (int) $min, (int) $sec, (int) $month, (int) $day, (int) $year); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -4686,7 +4691,7 @@ function api_get_themes($getOnlyThemeFromVirtualInstance = false) |
|
|
|
|
// This configuration value is set by the vchamilo plugin |
|
|
|
|
$virtualTheme = api_get_configuration_value('virtual_css_theme_folder'); |
|
|
|
|
|
|
|
|
|
$readCssFolder = function($dir) use ($virtualTheme) { |
|
|
|
|
$readCssFolder = function ($dir) use ($virtualTheme) { |
|
|
|
|
$finder = new Finder(); |
|
|
|
|
$themes = $finder->directories()->in($dir)->depth(0)->sortByName(); |
|
|
|
|
$list = []; |
|
|
|
@ -4761,7 +4766,7 @@ function api_time_to_hms($seconds) |
|
|
|
|
Display::return_icon( |
|
|
|
|
'info2.gif', |
|
|
|
|
get_lang('WrongDatasForTimeSpentOnThePlatform'), |
|
|
|
|
array('align' => 'absmiddle', 'hspace' => '3px') |
|
|
|
|
['align' => 'absmiddle', 'hspace' => '3px'] |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5025,7 +5030,6 @@ function copy_folder_course_session( |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} // en foreach |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5121,7 +5125,8 @@ function api_chmod_R($path, $filemode) |
|
|
|
|
* @return |
|
|
|
|
* The info array. |
|
|
|
|
*/ |
|
|
|
|
function api_parse_info_file($filename) { |
|
|
|
|
function api_parse_info_file($filename) |
|
|
|
|
{ |
|
|
|
|
$info = []; |
|
|
|
|
|
|
|
|
|
if (!file_exists($filename)) { |
|
|
|
@ -5146,7 +5151,7 @@ function api_parse_info_file($filename) { |
|
|
|
|
foreach ($matches as $match) { |
|
|
|
|
// Fetch the key and value string. |
|
|
|
|
$i = 0; |
|
|
|
|
foreach (array('key', 'value1', 'value2', 'value3') as $var) { |
|
|
|
|
foreach (['key', 'value1', 'value2', 'value3'] as $var) { |
|
|
|
|
$$var = isset($match[++$i]) ? $match[$i] : ''; |
|
|
|
|
} |
|
|
|
|
$value = stripslashes(substr($value1, 1, -1)).stripslashes(substr($value2, 1, -1)).$value3; |
|
|
|
@ -5236,7 +5241,7 @@ function api_status_key($status) |
|
|
|
|
*/ |
|
|
|
|
function api_get_status_langvars() |
|
|
|
|
{ |
|
|
|
|
return array( |
|
|
|
|
return [ |
|
|
|
|
COURSEMANAGER => get_lang('Teacher', ''), |
|
|
|
|
SESSIONADMIN => get_lang('SessionsAdmin', ''), |
|
|
|
|
DRH => get_lang('Drh', ''), |
|
|
|
@ -5244,7 +5249,7 @@ function api_get_status_langvars() |
|
|
|
|
ANONYMOUS => get_lang('Anonymous', ''), |
|
|
|
|
STUDENT_BOSS => get_lang('RoleStudentBoss', ''), |
|
|
|
|
INVITEE => get_lang('Invited'), |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -5275,7 +5280,7 @@ function api_set_setting_option($params) |
|
|
|
|
if (empty($params['id'])) { |
|
|
|
|
Database::insert($table, $params); |
|
|
|
|
} else { |
|
|
|
|
Database::update($table, $params, array('id = ? '=> $params['id'])); |
|
|
|
|
Database::update($table, $params, ['id = ? '=> $params['id']]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5291,7 +5296,7 @@ function api_set_setting_simple($params) |
|
|
|
|
$params['access_url'] = $url_id; |
|
|
|
|
Database::insert($table, $params); |
|
|
|
|
} else { |
|
|
|
|
Database::update($table, $params, array('id = ? '=> array($params['id']))); |
|
|
|
|
Database::update($table, $params, ['id = ? '=> [$params['id']]]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5302,7 +5307,7 @@ function api_delete_setting_option($id) |
|
|
|
|
{ |
|
|
|
|
$table = Database::get_main_table(TABLE_MAIN_SETTINGS_OPTIONS); |
|
|
|
|
if (!empty($id)) { |
|
|
|
|
Database::delete($table, array('id = ? '=> $id)); |
|
|
|
|
Database::delete($table, ['id = ? '=> $id]); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -5829,19 +5834,19 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null) |
|
|
|
|
|
|
|
|
|
// Get information to build query depending of the tool. |
|
|
|
|
switch ($tool) { |
|
|
|
|
case TOOL_SURVEY : |
|
|
|
|
case TOOL_SURVEY: |
|
|
|
|
$table_tool = Database::get_course_table(TABLE_SURVEY); |
|
|
|
|
$key_field = 'survey_id'; |
|
|
|
|
break; |
|
|
|
|
case TOOL_ANNOUNCEMENT : |
|
|
|
|
case TOOL_ANNOUNCEMENT: |
|
|
|
|
$table_tool = Database::get_course_table(TABLE_ANNOUNCEMENT); |
|
|
|
|
$key_field = 'id'; |
|
|
|
|
break; |
|
|
|
|
case TOOL_AGENDA : |
|
|
|
|
case TOOL_AGENDA: |
|
|
|
|
$table_tool = Database::get_course_table(TABLE_AGENDA); |
|
|
|
|
$key_field = 'id'; |
|
|
|
|
break; |
|
|
|
|
case TOOL_GROUP : |
|
|
|
|
case TOOL_GROUP: |
|
|
|
|
$table_tool = Database::get_course_table(TABLE_GROUP); |
|
|
|
|
$key_field = 'id'; |
|
|
|
|
break; |
|
|
|
@ -5888,7 +5893,8 @@ function api_replace_dangerous_char($filename, $treat_spaces_as_hyphens = true) |
|
|
|
|
* Fixes the $_SERVER['REQUEST_URI'] that is empty in IIS6. |
|
|
|
|
* @author Ivan Tcholakov, 28-JUN-2006. |
|
|
|
|
*/ |
|
|
|
|
function api_request_uri() { |
|
|
|
|
function api_request_uri() |
|
|
|
|
{ |
|
|
|
|
if (!empty($_SERVER['REQUEST_URI'])) { |
|
|
|
|
return $_SERVER['REQUEST_URI']; |
|
|
|
|
} |
|
|
|
@ -6046,8 +6052,7 @@ function api_is_windows_os() |
|
|
|
|
elseif (isset($_ENV['OS'])) { |
|
|
|
|
// Sometimes $_ENV['OS'] may not be present (bugs?) |
|
|
|
|
$os = $_ENV['OS']; |
|
|
|
|
} |
|
|
|
|
elseif (defined('PHP_OS')) { |
|
|
|
|
} elseif (defined('PHP_OS')) { |
|
|
|
|
// PHP_OS means on which OS PHP was compiled, this is why |
|
|
|
|
// using PHP_OS is the last choice for detection. |
|
|
|
|
$os = PHP_OS; |
|
|
|
@ -6115,7 +6120,7 @@ function api_calculate_image_size( |
|
|
|
|
$target_height |
|
|
|
|
) { |
|
|
|
|
// Only maths is here. |
|
|
|
|
$result = array('width' => $image_width, 'height' => $image_height); |
|
|
|
|
$result = ['width' => $image_width, 'height' => $image_height]; |
|
|
|
|
if ($image_width <= 0 || $image_height <= 0) { |
|
|
|
|
return $result; |
|
|
|
|
} |
|
|
|
@ -6145,7 +6150,7 @@ function api_calculate_image_size( |
|
|
|
|
*/ |
|
|
|
|
function api_get_tools_lists($my_tool = null) |
|
|
|
|
{ |
|
|
|
|
$tools_list = array( |
|
|
|
|
$tools_list = [ |
|
|
|
|
TOOL_DOCUMENT, |
|
|
|
|
TOOL_THUMBNAIL, |
|
|
|
|
TOOL_HOTPOTATOES, |
|
|
|
@ -6182,7 +6187,7 @@ function api_get_tools_lists($my_tool = null) |
|
|
|
|
TOOL_NOTEBOOK, |
|
|
|
|
TOOL_ATTENDANCE, |
|
|
|
|
TOOL_COURSE_PROGRESS, |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
if (empty($my_tool)) { |
|
|
|
|
return $tools_list; |
|
|
|
|
} |
|
|
|
@ -6199,7 +6204,6 @@ function api_check_term_condition($userId) |
|
|
|
|
if (api_get_setting('allow_terms_conditions') == 'true') { |
|
|
|
|
// Check if exists terms and conditions |
|
|
|
|
if (LegalManager::count() == 0) { |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -6348,7 +6352,7 @@ function api_protect_global_admin_script() |
|
|
|
|
*/ |
|
|
|
|
function api_get_template($path_type = 'rel') |
|
|
|
|
{ |
|
|
|
|
$path_types = array('rel', 'abs'); |
|
|
|
|
$path_types = ['rel', 'abs']; |
|
|
|
|
$template_path = ''; |
|
|
|
|
if (in_array($path_type, $path_types)) { |
|
|
|
|
if ($path_type == 'rel') { |
|
|
|
@ -6558,7 +6562,7 @@ function api_browser_support($format = '') |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} elseif ($format == "check_browser") { |
|
|
|
|
$array_check_browser = array($current_browser, $current_majorver); |
|
|
|
|
$array_check_browser = [$current_browser, $current_majorver]; |
|
|
|
|
return $array_check_browser; |
|
|
|
|
} else { |
|
|
|
|
$result[$format] = false; |
|
|
|
@ -6673,7 +6677,7 @@ function api_get_jquery_ui_js($include_jqgrid = false) |
|
|
|
|
|
|
|
|
|
function api_get_jqgrid_js() |
|
|
|
|
{ |
|
|
|
|
return api_get_jquery_libraries_js(array('jqgrid')); |
|
|
|
|
return api_get_jquery_libraries_js(['jqgrid']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -6695,9 +6699,9 @@ function api_get_jquery_libraries_js($libraries) |
|
|
|
|
$platform_isocode = strtolower(api_get_language_isocode()); |
|
|
|
|
|
|
|
|
|
//languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n |
|
|
|
|
$jqgrid_langs = array( |
|
|
|
|
$jqgrid_langs = [ |
|
|
|
|
'bg', 'bg1251', 'cat', 'cn', 'cs', 'da', 'de', 'el', 'en', 'es', 'fa', 'fi', 'fr', 'gl', 'he', 'hu', 'is', 'it', 'ja', 'nl', 'no', 'pl', 'pt-br', 'pt', 'ro', 'ru', 'sk', 'sr', 'sv', 'tr', 'ua' |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if (in_array($platform_isocode, $jqgrid_langs)) { |
|
|
|
|
$languaje = $platform_isocode; |
|
|
|
@ -6710,7 +6714,6 @@ function api_get_jquery_libraries_js($libraries) |
|
|
|
|
|
|
|
|
|
//Document multiple upload funcionality |
|
|
|
|
if (in_array('jquery-upload', $libraries)) { |
|
|
|
|
|
|
|
|
|
$js .= api_get_asset('blueimp-load-image/js/load-image.all.min.js'); |
|
|
|
|
$js .= api_get_asset('blueimp-canvas-to-blob/js/canvas-to-blob.min.js'); |
|
|
|
|
$js .= api_get_asset('jquery-file-upload/js/jquery.iframe-transport.js'); |
|
|
|
@ -6731,9 +6734,9 @@ function api_get_jquery_libraries_js($libraries) |
|
|
|
|
$platform_isocode = strtolower(api_get_language_isocode()); |
|
|
|
|
|
|
|
|
|
// languages supported by jqgrid see files in main/inc/lib/javascript/jqgrid/js/i18n |
|
|
|
|
$datapicker_langs = array( |
|
|
|
|
$datapicker_langs = [ |
|
|
|
|
'af', 'ar', 'ar-DZ', 'az', 'bg', 'bs', 'ca', 'cs', 'cy-GB', 'da', 'de', 'el', 'en-AU', 'en-GB', 'en-NZ', 'eo', 'es', 'et', 'eu', 'fa', 'fi', 'fo', 'fr', 'fr-CH', 'gl', 'he', 'hi', 'hr', 'hu', 'hy', 'id', 'is', 'it', 'ja', 'ka', 'kk', 'km', 'ko', 'lb', 'lt', 'lv', 'mk', 'ml', 'ms', 'nl', 'nl-BE', 'no', 'pl', 'pt', 'pt-BR', 'rm', 'ro', 'ru', 'sk', 'sl', 'sq', 'sr', 'sr-SR', 'sv', 'ta', 'th', 'tj', 'tr', 'uk', 'vi', 'zh-CN', 'zh-HK', 'zh-TW' |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
if (in_array($platform_isocode, $datapicker_langs)) { |
|
|
|
|
$languaje = $platform_isocode; |
|
|
|
|
} |
|
|
|
@ -6930,7 +6933,7 @@ function api_check_archive_dir() |
|
|
|
|
*/ |
|
|
|
|
function api_get_locked_settings() |
|
|
|
|
{ |
|
|
|
|
return array( |
|
|
|
|
return [ |
|
|
|
|
'server_type', |
|
|
|
|
'permanently_remove_deleted_files', |
|
|
|
|
'account_valid_duration', |
|
|
|
@ -6960,7 +6963,7 @@ function api_get_locked_settings() |
|
|
|
|
'languagePriority4', |
|
|
|
|
'login_is_email', |
|
|
|
|
'chamilo_database_version' |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -6997,7 +7000,9 @@ function api_get_real_ip() |
|
|
|
|
} |
|
|
|
|
$ip = trim($ip1); |
|
|
|
|
} |
|
|
|
|
if (!empty($debug)) error_log('Real IP: '.$ip); |
|
|
|
|
if (!empty($debug)) { |
|
|
|
|
error_log('Real IP: '.$ip); |
|
|
|
|
} |
|
|
|
|
return $ip; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -7021,7 +7026,7 @@ function api_check_ip_in_range($ip, $range) |
|
|
|
|
if (strpos($range, ',') !== false) { |
|
|
|
|
$ranges = explode(',', $range); |
|
|
|
|
} else { |
|
|
|
|
$ranges = array($range); |
|
|
|
|
$ranges = [$range]; |
|
|
|
|
} |
|
|
|
|
foreach ($ranges as $range) { |
|
|
|
|
$range = trim($range); |
|
|
|
@ -7035,7 +7040,7 @@ function api_check_ip_in_range($ip, $range) |
|
|
|
|
continue; //otherwise, get to the next range |
|
|
|
|
} |
|
|
|
|
// the range contains a "/", so analyse completely |
|
|
|
|
list ($net, $mask) = explode("/", $range); |
|
|
|
|
list($net, $mask) = explode("/", $range); |
|
|
|
|
|
|
|
|
|
$ip_net = ip2long($net); |
|
|
|
|
// mask binary magic |
|
|
|
@ -7052,7 +7057,7 @@ function api_check_ip_in_range($ip, $range) |
|
|
|
|
|
|
|
|
|
function api_check_user_access_to_legal($course_visibility) |
|
|
|
|
{ |
|
|
|
|
$course_visibility_list = array(COURSE_VISIBILITY_OPEN_WORLD, COURSE_VISIBILITY_OPEN_PLATFORM); |
|
|
|
|
$course_visibility_list = [COURSE_VISIBILITY_OPEN_WORLD, COURSE_VISIBILITY_OPEN_PLATFORM]; |
|
|
|
|
return in_array($course_visibility, $course_visibility_list) || api_is_drh(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -7679,7 +7684,7 @@ function api_can_login_as($loginAsUserId, $userId = null) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$userInfo = api_get_user_info($userId); |
|
|
|
|
$isDrh = function() use($loginAsUserId) { |
|
|
|
|
$isDrh = function () use ($loginAsUserId) { |
|
|
|
|
if (api_is_drh()) { |
|
|
|
|
if (api_drh_can_access_all_session_content()) { |
|
|
|
|
$users = SessionManager::getAllUsersFromCoursesFromAllSessionFromStatus( |
|
|
|
@ -7890,7 +7895,7 @@ function api_get_configuration_value($variable) |
|
|
|
|
function api_get_supported_image_extensions($supportVectors = true) |
|
|
|
|
{ |
|
|
|
|
// jpg can also be called jpeg, jpe, jfif and jif. See https://en.wikipedia.org/wiki/JPEG#JPEG_filename_extensions |
|
|
|
|
$supportedImageExtensions = array('jpg', 'jpeg', 'png', 'gif', 'jpe', 'jfif', 'jif'); |
|
|
|
|
$supportedImageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'jpe', 'jfif', 'jif']; |
|
|
|
|
if ($supportVectors) { |
|
|
|
|
array_push($supportedImageExtensions, 'svg'); |
|
|
|
|
} |
|
|
|
@ -7908,7 +7913,8 @@ function api_get_supported_image_extensions($supportVectors = true) |
|
|
|
|
* @param bool $listCampus Whether we authorize |
|
|
|
|
* @todo the $_settings should be reloaded here. => write api function for this and use this in global.inc.php also. |
|
|
|
|
*/ |
|
|
|
|
function api_register_campus($listCampus = true) { |
|
|
|
|
function api_register_campus($listCampus = true) |
|
|
|
|
{ |
|
|
|
|
$tbl_settings = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT); |
|
|
|
|
|
|
|
|
|
$sql = "UPDATE $tbl_settings SET selected_value='true' WHERE variable='registered'"; |
|
|
|
@ -7953,7 +7959,6 @@ function api_is_excluded_user_type($checkDB = false, $userId = 0) |
|
|
|
|
|
|
|
|
|
switch ($userInfo['status']) { |
|
|
|
|
case INVITEE: |
|
|
|
|
//no break; |
|
|
|
|
case ANONYMOUS: |
|
|
|
|
return true; |
|
|
|
|
default: |
|
|
|
@ -7978,10 +7983,10 @@ function api_is_excluded_user_type($checkDB = false, $userId = 0) |
|
|
|
|
*/ |
|
|
|
|
function api_get_users_status_ignored_in_reports($format = 'array') |
|
|
|
|
{ |
|
|
|
|
$excludedTypes = array( |
|
|
|
|
$excludedTypes = [ |
|
|
|
|
INVITEE, |
|
|
|
|
ANONYMOUS |
|
|
|
|
); |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
if ($format == 'string') { |
|
|
|
|
return implode(', ', $excludedTypes); |
|
|
|
|