|
@@ -352,7 +352,6 @@ define('USER_RELATION_TYPE_BOSS', 8);
|
|
|
|
|
|
// Gradebook link constants
|
|
|
// Please do not change existing values, they are used in the database !
|
|
|
-
|
|
|
define('GRADEBOOK_ITEM_LIMIT', 1000);
|
|
|
|
|
|
define('LINK_EXERCISE', 1);
|
|
@@ -434,7 +433,6 @@ define('GROUP_TITLE_LENGTH', 50);
|
|
|
|
|
|
// Exercise
|
|
|
// @todo move into a class
|
|
|
-
|
|
|
define('ALL_ON_ONE_PAGE', 1);
|
|
|
define('ONE_PER_PAGE', 2);
|
|
|
|
|
@@ -607,11 +605,10 @@ define('RESOURCE_ATTENDANCE', 'attendance');
|
|
|
define('RESOURCE_WORK', 'work');
|
|
|
define('RESOURCE_SESSION_COURSE', 'session_course');
|
|
|
define('RESOURCE_GRADEBOOK', 'gradebook');
|
|
|
-
|
|
|
define('ADD_THEMATIC_PLAN', 6);
|
|
|
|
|
|
// Make sure the CHAMILO_LOAD_WYSIWYG constant is defined
|
|
|
-define('MAX_ONLINE_USERS', 8);
|
|
|
+define('MAX_ONLINE_USERS', 12);
|
|
|
|
|
|
// Make sure the CHAMILO_LOAD_WYSIWYG constant is defined
|
|
|
// To remove CKeditor libs from HTML, set this constant to true before loading
|
|
@@ -711,7 +708,6 @@ function api_get_path($path = '', $configuration = [])
|
|
|
}
|
|
|
|
|
|
$paths = [];
|
|
|
-
|
|
|
// Initialise cache with default values.
|
|
|
if (!array_key_exists($root_web, $paths)) {
|
|
|
$paths[$root_web] = array(
|
|
@@ -892,7 +888,6 @@ function api_get_path($path = '', $configuration = [])
|
|
|
return $path;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Gets a modified version of the path for the CDN, if defined in
|
|
|
* configuration.php
|
|
@@ -1036,7 +1031,6 @@ function api_valid_email($address)
|
|
|
return filter_var($address, FILTER_VALIDATE_EMAIL);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/* PROTECTION FUNCTIONS
|
|
|
Use these functions to protect your scripts. */
|
|
|
|
|
@@ -2288,6 +2282,7 @@ function api_get_session_condition(
|
|
|
* if (api_get_setting('show_navigation_menu') == true) //INCORRECT
|
|
|
* @param string $variable The variable name
|
|
|
* @param string $key The subkey (sub-variable) if any. Defaults to NULL
|
|
|
+ * @return string
|
|
|
* @author René Haentjens
|
|
|
* @author Bart Mollet
|
|
|
*/
|
|
@@ -2376,23 +2371,24 @@ function api_get_self() {
|
|
|
|
|
|
/**
|
|
|
* Checks whether current user is a platform administrator
|
|
|
- * @param boolean Whether session admins should be considered admins or not
|
|
|
- * @param boolean Whether HR directors should be considered admins or not
|
|
|
+ * @param boolean $allowSessionAdmins Whether session admins should be considered admins or not
|
|
|
+ * @param boolean $allowDrh Whether HR directors should be considered admins or not
|
|
|
* @return boolean True if the user has platform admin rights,
|
|
|
* false otherwise.
|
|
|
* @see usermanager::is_admin(user_id) for a user-id specific function
|
|
|
*/
|
|
|
-function api_is_platform_admin($allow_sessions_admins = false, $allow_drh = false)
|
|
|
+function api_is_platform_admin($allowSessionAdmins = false, $allowDrh = false)
|
|
|
{
|
|
|
- if (isset($_SESSION['is_platformAdmin']) && $_SESSION['is_platformAdmin']) {
|
|
|
+ $isAdmin = Session::read('is_platformAdmin');
|
|
|
+ if ($isAdmin) {
|
|
|
return true;
|
|
|
}
|
|
|
- $_user = api_get_user_info();
|
|
|
+ $user = api_get_user_info();
|
|
|
return
|
|
|
- isset($_user['status']) &&
|
|
|
+ isset($user['status']) &&
|
|
|
(
|
|
|
- ($allow_sessions_admins && $_user['status'] == SESSIONADMIN) ||
|
|
|
- ($allow_drh && $_user['status'] == DRH)
|
|
|
+ ($allowSessionAdmins && $user['status'] == SESSIONADMIN) ||
|
|
|
+ ($allowDrh && $user['status'] == DRH)
|
|
|
);
|
|
|
}
|
|
|
|
|
@@ -2489,95 +2485,6 @@ function api_is_course_tutor() {
|
|
|
return Session::read('is_courseTutor');
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @param int $user_id
|
|
|
- *
|
|
|
- * @return array
|
|
|
- */
|
|
|
-function api_get_user_platform_status($user_id = null) {
|
|
|
- $status = array();
|
|
|
- $user_id = intval($user_id);
|
|
|
- if (empty($user_id)) {
|
|
|
- $user_id = api_get_user_id();
|
|
|
- }
|
|
|
-
|
|
|
- if (empty($user_id)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- $group_id = api_get_group_id();
|
|
|
- $course_id = api_get_course_int_id();
|
|
|
- $course_code= api_get_course_id();
|
|
|
- $session_id = api_get_session_id();
|
|
|
-
|
|
|
- //Group (in course)
|
|
|
- if ($group_id && $course_id) {
|
|
|
- $group_status = array();
|
|
|
- $groupInfo = GroupManager::get_group_properties($group_id);
|
|
|
- $is_subscribed = GroupManager::is_subscribed($user_id, $groupInfo['iid']);
|
|
|
- if ($is_subscribed) {
|
|
|
- $group_status = array('id'=> $group_id , 'status' => 'student');
|
|
|
- $is_tutor = GroupManager::is_tutor_of_group($user_id, $groupInfo['iid']);
|
|
|
- if ($is_tutor) {
|
|
|
- $group_status['status'] = 'tutor';
|
|
|
- } else {
|
|
|
- $group_status['status'] = 'student';
|
|
|
- }
|
|
|
- }
|
|
|
- $status['group'] = $group_status;
|
|
|
- }
|
|
|
-
|
|
|
- //Session
|
|
|
- if ($session_id && $course_id) {
|
|
|
- $session_status = array('id' => $session_id, 'course_id' => $course_id);
|
|
|
- $session_user_status = SessionManager::get_user_status_in_course_session(
|
|
|
- $user_id,
|
|
|
- $course_id,
|
|
|
- $session_id
|
|
|
- );
|
|
|
-
|
|
|
- switch ($session_user_status) {
|
|
|
- case 0:
|
|
|
- $session_status['status'] = 'student';
|
|
|
- break;
|
|
|
- case 2:
|
|
|
- $session_status['status'] = 'coach';
|
|
|
- break;
|
|
|
- }
|
|
|
- $is_general_coach = SessionManager::user_is_general_coach($user_id, $session_id);
|
|
|
- if ($is_general_coach) {
|
|
|
- $session_status['status'] = 'general_coach';
|
|
|
- }
|
|
|
- $status['session'] = $session_status;
|
|
|
-
|
|
|
- } elseif($course_id) {
|
|
|
- //Course
|
|
|
- $course_status = array();
|
|
|
- if ($course_id) {
|
|
|
- $user_course_status = CourseManager::get_user_in_course_status($user_id, $course_code);
|
|
|
-
|
|
|
- if ($user_course_status) {
|
|
|
- $course_status = array('id'=> $course_id);
|
|
|
- switch($user_course_status) {
|
|
|
- case 1:
|
|
|
- $course_status['status'] = 'teacher';
|
|
|
- break;
|
|
|
- case 5:
|
|
|
- $course_status['status'] = 'student';
|
|
|
- //check if tutor
|
|
|
- $tutor_course_status = CourseManager::get_tutor_in_course_status($user_id, $course_id);
|
|
|
- if ($tutor_course_status) {
|
|
|
- $course_status['status'] = 'tutor';
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- $status['course'] = $course_status;
|
|
|
- }
|
|
|
-
|
|
|
- return $status;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @param int $user_id
|
|
|
* @param int $courseId
|
|
@@ -2698,8 +2605,8 @@ function api_is_student()
|
|
|
{
|
|
|
$user = api_get_user_info();
|
|
|
return isset($user['status']) && $user['status'] == STUDENT;
|
|
|
-
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* Checks whether the current user has the status 'teacher'
|
|
|
* @return boolean True if current user is a human resources manager
|
|
@@ -2752,9 +2659,6 @@ function api_is_session_in_category($session_id, $category_name)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/* DISPLAY OPTIONS
|
|
|
- student view, title, message boxes,... */
|
|
|
-
|
|
|
/**
|
|
|
* Displays the title of a tool.
|
|
|
* Normal use: parameter is a string:
|
|
@@ -2892,8 +2796,12 @@ function api_display_tool_view_option() {
|
|
|
* @return boolean true: the user has the rights to edit, false: he does not
|
|
|
*/
|
|
|
|
|
|
-function api_is_allowed_to_edit($tutor = false, $coach = false, $session_coach = false, $check_student_view = true)
|
|
|
-{
|
|
|
+function api_is_allowed_to_edit(
|
|
|
+ $tutor = false,
|
|
|
+ $coach = false,
|
|
|
+ $session_coach = false,
|
|
|
+ $check_student_view = true
|
|
|
+) {
|
|
|
$my_session_id = api_get_session_id();
|
|
|
$is_allowed_coach_to_edit = api_is_coach(null, null, $check_student_view);
|
|
|
$session_visibility = api_get_session_visibility($my_session_id);
|
|
@@ -3373,8 +3281,6 @@ function api_not_allowed($print_headers = false, $message = null)
|
|
|
if ($casEnabled) {
|
|
|
$msg .= "</div>";
|
|
|
}
|
|
|
-
|
|
|
- //$msg .= '<hr/><p style="text-align:center"><a href="'.$home_url.'">'.get_lang('ReturnToCourseHomepage').'</a></p>';
|
|
|
} else {
|
|
|
// we were not in a course, return to home page
|
|
|
$msg = Display::return_message(
|
|
@@ -3389,11 +3295,6 @@ function api_not_allowed($print_headers = false, $message = null)
|
|
|
exit;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-/* WHAT'S NEW
|
|
|
- functions for the what's new icons
|
|
|
- in the user course list */
|
|
|
-
|
|
|
/**
|
|
|
* Gets a UNIX timestamp from a database (MySQL) datetime format string
|
|
|
* @param $last_post_datetime standard output date in a sql query
|
|
@@ -3409,16 +3310,6 @@ function convert_sql_date($last_post_datetime) {
|
|
|
return mktime((int)$hour, (int)$min, (int)$sec, (int)$month, (int)$day, (int)$year);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Gets a database (MySQL) datetime format string from a UNIX timestamp
|
|
|
- * @param int UNIX timestamp, as generated by the time() function. Will be generated if parameter not provided
|
|
|
- * @return string MySQL datetime format, like '2009-01-30 12:23:34'
|
|
|
- */
|
|
|
-function api_get_datetime($time = null) {
|
|
|
- if (!isset($time)) { $time = time(); }
|
|
|
- return date('Y-m-d H:i:s', $time);
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Gets item visibility from the item_property table
|
|
|
*
|
|
@@ -4152,9 +4043,7 @@ function api_display_language_form($hide_if_no_choice = false)
|
|
|
|
|
|
$original_languages = $language_list['name'];
|
|
|
$folder = $language_list['folder']; // This line is probably no longer needed.
|
|
|
- $html = '
|
|
|
- <script type="text/javascript">
|
|
|
- <!--
|
|
|
+ $html = '<script>
|
|
|
$(document).ready(function() {
|
|
|
$("#language_list").change(function() {
|
|
|
jumpMenu("parent",this,0);
|
|
@@ -4165,7 +4054,6 @@ function api_display_language_form($hide_if_no_choice = false)
|
|
|
eval(targ+".location=\'"+selObj.options[selObj.selectedIndex].value+"\'");
|
|
|
if (restore) selObj.selectedIndex=0;
|
|
|
}
|
|
|
- //-->
|
|
|
</script>';
|
|
|
$html .= '<form id="lang_form" name="lang_form" method="post" action="'.api_get_self().'">';
|
|
|
$html .= '<label style="display: none;" for="language_list">' . get_lang('Language') . '</label>';
|
|
@@ -4195,7 +4083,8 @@ function api_display_language_form($hide_if_no_choice = false)
|
|
|
*/
|
|
|
function api_get_languages() {
|
|
|
$tbl_language = Database::get_main_table(TABLE_MAIN_LANGUAGE);
|
|
|
- $sql = "SELECT * FROM $tbl_language WHERE available='1' ORDER BY original_name ASC";
|
|
|
+ $sql = "SELECT * FROM $tbl_language WHERE available='1'
|
|
|
+ ORDER BY original_name ASC";
|
|
|
$result = Database::query($sql);
|
|
|
$language_list = array();
|
|
|
while ($row = Database::fetch_array($result)) {
|
|
@@ -4530,6 +4419,7 @@ function api_get_permissions_for_new_files() {
|
|
|
if (!isset($permissions)) {
|
|
|
$permissions = trim(api_get_setting('permissions_for_new_files'));
|
|
|
// The default value 0666 is according to that in the platform administration panel after fresh system installation.
|
|
|
+ // administration panel after fresh system installation.
|
|
|
$permissions = octdec(!empty($permissions) ? $permissions : '0666');
|
|
|
}
|
|
|
return $permissions;
|
|
@@ -4832,7 +4722,7 @@ function api_chmod_R($path, $filemode) {
|
|
|
* @return
|
|
|
* The info array.
|
|
|
*/
|
|
|
-function parse_info_file($filename) {
|
|
|
+function api_parse_info_file($filename) {
|
|
|
$info = array();
|
|
|
|
|
|
if (!file_exists($filename)) {
|
|
@@ -4893,7 +4783,6 @@ function parse_info_file($filename) {
|
|
|
return $info;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Gets Chamilo version from the configuration files
|
|
|
* @return string A string of type "1.8.4", or an empty string if the version could not be found
|
|
@@ -5225,34 +5114,6 @@ function api_get_access_url($id, $returnDefault = true)
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Adds an access URL into the database
|
|
|
- * @param string URL
|
|
|
- * @param string Description
|
|
|
- * @param int Active (1= active, 0=disabled)
|
|
|
- * @return int The new database id, or the existing database id if this url already exists
|
|
|
- */
|
|
|
-function api_add_access_url($u, $d = '', $a = 1) {
|
|
|
- $t_au = Database::get_main_table(TABLE_MAIN_ACCESS_URL);
|
|
|
- $u = Database::escape_string($u);
|
|
|
- $d = Database::escape_string($d);
|
|
|
- $a = (int) $a;
|
|
|
- $sql = "SELECT id FROM $t_au WHERE url LIKE '$u'";
|
|
|
- $res = Database::query($sql);
|
|
|
- if ($res === false) {
|
|
|
- // Problem querying the database - return false.
|
|
|
- return false;
|
|
|
- }
|
|
|
- if (Database::num_rows($res) > 0) {
|
|
|
- return Database::result($res, 0, 'id');
|
|
|
- }
|
|
|
- $ui = api_get_user_id();
|
|
|
-
|
|
|
- $sql = "INSERT INTO $t_au (url,description,active,created_by,tms) VALUES ('$u','$d',$a,$ui,'')";
|
|
|
- $res = Database::query($sql);
|
|
|
- return ($res === false) ? false : Database::insert_id();
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Gets all the current settings for a specific access url
|
|
|
* @param string The category, if any, that we want to get
|
|
@@ -5290,65 +5151,6 @@ function & api_get_settings($cat = null, $ordering = 'list', $access_url = 1, $u
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Gets the distinct settings categories
|
|
|
- * @param array Array of strings giving the categories we want to excluded
|
|
|
- * @param int Access URL. Optional. Defaults to 1
|
|
|
- * @return array A list of categories
|
|
|
- */
|
|
|
-function & api_get_settings_categories($exceptions = array(), $access_url = 1) {
|
|
|
- $access_url = (int) $access_url;
|
|
|
- $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
|
|
|
- $list = "'".implode("','",$exceptions)."'";
|
|
|
- $sql = "SELECT DISTINCT category FROM $t_cs WHERE category is NOT NULL ";
|
|
|
- if ($list != "'',''" && $list != "''" && !empty($list)) {
|
|
|
- $sql .= " AND category NOT IN ($list) ";
|
|
|
- }
|
|
|
- $result = Database::store_result(Database::query($sql));
|
|
|
- return $result;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Deletes a setting
|
|
|
- * @param string Variable
|
|
|
- * @param string Subkey
|
|
|
- * @param int Access URL
|
|
|
- * @return boolean False on failure, true on success
|
|
|
- */
|
|
|
-
|
|
|
-function api_delete_setting($v, $s = null, $a = 1) {
|
|
|
- if (empty($v)) { return false; }
|
|
|
- $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
|
|
|
- $v = Database::escape_string($v);
|
|
|
- $a = (int) $a;
|
|
|
- if (empty($a)) { $a = 1; }
|
|
|
- if (!empty($s)) {
|
|
|
- $s = Database::escape_string($s);
|
|
|
- $sql = "DELETE FROM $t_cs WHERE variable = '$v' AND subkey = '$s' AND access_url = $a";
|
|
|
- $r = Database::query($sql);
|
|
|
- return $r;
|
|
|
- }
|
|
|
- $sql = "DELETE FROM $t_cs WHERE variable = '$v' AND access_url = $a";
|
|
|
- $r = Database::query($sql);
|
|
|
- return $r;
|
|
|
-}
|
|
|
-
|
|
|
-/**
|
|
|
- * Deletes all the settings from one category
|
|
|
- * @param string Subkey
|
|
|
- * @param int Access URL
|
|
|
- * @return boolean False on failure, true on success
|
|
|
- */
|
|
|
-function api_delete_category_settings_by_subkey($subkey, $access_url_id = 1) {
|
|
|
- if (empty($subkey)) { return false; }
|
|
|
- $t_cs = Database::get_main_table(TABLE_MAIN_SETTINGS_CURRENT);
|
|
|
- $subkey = Database::escape_string($subkey);
|
|
|
- $access_url_id = intval($access_url_id);
|
|
|
- $sql = "DELETE FROM $t_cs WHERE subkey = '$subkey' AND access_url = $access_url_id";
|
|
|
- $r = Database::query($sql);
|
|
|
- return $r;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Sets a platform configuration setting to a given value
|
|
|
* @param string The value we want to record
|
|
@@ -5781,23 +5583,6 @@ function api_get_status_of_user_in_course($user_id, $courseId)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Checks whether the curent user is in a course or not.
|
|
|
- *
|
|
|
- * @param string The course code - optional (takes it from session if not given)
|
|
|
- * @return boolean
|
|
|
- * @author Yannick Warnier <yannick.warnier@beeznest.com>
|
|
|
- */
|
|
|
-function api_is_in_course($course_code = null) {
|
|
|
- if (isset($_SESSION['_course']['sysCode'])) {
|
|
|
- if (!empty($course_code)) {
|
|
|
- return $course_code == $_SESSION['_course']['sysCode'];
|
|
|
- }
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Checks whether the curent user is in a group or not.
|
|
|
*
|
|
@@ -5832,7 +5617,6 @@ function api_is_in_group($groupIdParam = null, $courseCodeParam = null)
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Checks whether a secret key is valid
|
|
|
* @param string $original_key_secret - secret key from (webservice) client
|
|
@@ -6064,18 +5848,6 @@ function api_get_tool_information_by_name($name) {
|
|
|
return Database::fetch_array($rs, 'ASSOC');
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * @deprecated use api_trunc_str() instead.
|
|
|
- */
|
|
|
-function shorten($input, $length = 15, $encoding = null) {
|
|
|
- $length = intval($length);
|
|
|
- if (!$length) {
|
|
|
- $length = 15;
|
|
|
- }
|
|
|
- return api_trunc_str($input, $length, '...', false, $encoding);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* Function used to protect a "global" admin script.
|
|
|
* The function blocks access when the user has no global platform admin rights.
|
|
@@ -6206,8 +5978,7 @@ function api_get_template($path_type = 'rel') {
|
|
|
* @return bool or return text array if $format=check_browser
|
|
|
* @author Juan Carlos Raña Trabado
|
|
|
*/
|
|
|
-
|
|
|
-function api_browser_support($format = "")
|
|
|
+function api_browser_support($format = '')
|
|
|
{
|
|
|
$browser = new Browser();
|
|
|
$current_browser = $browser->getBrowser();
|
|
@@ -6457,7 +6228,6 @@ function api_get_jqgrid_js() {
|
|
|
return api_get_jquery_libraries_js(array('jqgrid'));
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* Returns the jquery library js and css headers
|
|
|
*
|
|
@@ -7010,36 +6780,6 @@ function api_detect_user_roles($user_id, $courseId, $session_id = 0)
|
|
|
return $user_roles;
|
|
|
}
|
|
|
|
|
|
-function api_get_roles_to_string($roles) {
|
|
|
- $role_names = array();
|
|
|
- if (!empty($roles)) {
|
|
|
- foreach ($roles as $role) {
|
|
|
- $role_names[] = get_status_from_code($role);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!empty($role_names)) {
|
|
|
- return implode(', ', $role_names);
|
|
|
- }
|
|
|
- return null;
|
|
|
-}
|
|
|
-
|
|
|
-function role_actions() {
|
|
|
- return array(
|
|
|
- 'course' => array(
|
|
|
- 'create',
|
|
|
- 'read',
|
|
|
- 'edit',
|
|
|
- 'delete'
|
|
|
- ),
|
|
|
- 'admin' => array(
|
|
|
- 'create',
|
|
|
- 'read',
|
|
|
- 'edit',
|
|
|
- 'delete'
|
|
|
- )
|
|
|
- );
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @param int $courseId
|
|
|
* @param int $session_id
|
|
@@ -7161,12 +6901,6 @@ function api_set_settings_and_plugins() {
|
|
|
$_SESSION['_plugins'] = $_plugins;
|
|
|
}
|
|
|
|
|
|
-function api_set_setting_last_update()
|
|
|
-{
|
|
|
- // Saving latest refresh.
|
|
|
- api_set_setting('settings_latest_update', api_get_utc_datetime());
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Tries to set memory limit, if authorized and new limit is higher than current
|
|
|
* @param string New memory limit
|
|
@@ -7228,16 +6962,17 @@ function api_get_bytes_memory_limit($mem){
|
|
|
/**
|
|
|
* Finds all the information about a user from username instead of user id
|
|
|
*
|
|
|
+ * @param string $officialCode
|
|
|
* @return array $user_info user_id, lastname, firstname, username, email, ...
|
|
|
* @author Yannick Warnier <yannick.warnier@beeznest.com>
|
|
|
*/
|
|
|
-function api_get_user_info_from_official_code($official_code = '')
|
|
|
+function api_get_user_info_from_official_code($officialCode)
|
|
|
{
|
|
|
- if (empty($official_code)) {
|
|
|
+ if (empty($officialCode)) {
|
|
|
return false;
|
|
|
}
|
|
|
$sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_USER)."
|
|
|
- WHERE official_code ='".Database::escape_string($official_code)."'";
|
|
|
+ WHERE official_code ='".Database::escape_string($officialCode)."'";
|
|
|
$result = Database::query($sql);
|
|
|
if (Database::num_rows($result) > 0) {
|
|
|
$result_array = Database::fetch_array($result);
|
|
@@ -7355,20 +7090,6 @@ function api_get_password_checker_js($usernameInputId, $passwordInputId)
|
|
|
return $js;
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Gets an array with "easy" passwords
|
|
|
- * @return array
|
|
|
- */
|
|
|
-function api_get_easy_password_list()
|
|
|
-{
|
|
|
- $passwordList = array('123', '1234', '123456', 'admin', 'user', 'student', 'teacher');
|
|
|
- $file = api_get_path(CONFIGURATION_PATH).'easy_password_list.php';
|
|
|
- if (file_exists($file)) {
|
|
|
- $passwordList = require_once $file;
|
|
|
- }
|
|
|
- return $passwordList;
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* @param string $username
|
|
|
* create an user extra field called 'captcha_blocked_until_date'
|
|
@@ -7466,9 +7187,9 @@ function api_remove_tags_with_space($in_html, $in_double_quote_replace = true) {
|
|
|
*/
|
|
|
function api_drh_can_access_all_session_content()
|
|
|
{
|
|
|
- $a = api_get_setting('drh_can_access_all_session_content');
|
|
|
+ $value = api_get_setting('drh_can_access_all_session_content');
|
|
|
|
|
|
- return $a === 'true';
|
|
|
+ return $value === 'true';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -7486,8 +7207,8 @@ function api_get_default_tool_setting($tool, $setting, $defaultValue)
|
|
|
) {
|
|
|
return $_configuration[$tool]['default_settings'][$setting];
|
|
|
}
|
|
|
- return $defaultValue;
|
|
|
|
|
|
+ return $defaultValue;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -7557,30 +7278,6 @@ function api_is_allowed_in_course()
|
|
|
return Session::read('is_allowed_in_course');
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * Show a string in
|
|
|
- * @param string $string Some string to dump, removing tabs, spaces,
|
|
|
- * newlines, etc (usually most useful for SQL queries)
|
|
|
- * @param int $dump Set to 1 to use print_r()
|
|
|
- */
|
|
|
-function api_error_log($string, $dump = 0)
|
|
|
-{
|
|
|
- // Clean query
|
|
|
- $bt = debug_backtrace();
|
|
|
- $caller = array_shift($bt);;
|
|
|
- if ($dump == 1) {
|
|
|
- $string = print_r($string, 1);
|
|
|
- } else {
|
|
|
- $string = str_replace(array("\r", "\n", "\t", "\10"), '', $string);
|
|
|
- $string = str_replace(' ',' ', $string);
|
|
|
- }
|
|
|
-
|
|
|
- error_log("-------------------------------------");
|
|
|
- error_log($string);
|
|
|
- error_log("File: ".$caller['file']." +".$caller['line']);
|
|
|
- error_log("-------------------------------------");
|
|
|
-}
|
|
|
-
|
|
|
/**
|
|
|
* Set the cookie to go directly to the course code $in_firstpage
|
|
|
* after login
|
|
@@ -7588,7 +7285,7 @@ function api_error_log($string, $dump = 0)
|
|
|
*/
|
|
|
function api_set_firstpage_parameter($in_firstpage)
|
|
|
{
|
|
|
- setcookie("GotoCourse", $in_firstpage);
|
|
|
+ setcookie('GotoCourse', $in_firstpage);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -7597,7 +7294,7 @@ function api_set_firstpage_parameter($in_firstpage)
|
|
|
*/
|
|
|
function api_delete_firstpage_parameter()
|
|
|
{
|
|
|
- setcookie("GotoCourse", "", time() - 3600);
|
|
|
+ setcookie('GotoCourse', '', time() - 3600);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -7643,7 +7340,8 @@ function api_get_protocol()
|
|
|
* @param string $in_text
|
|
|
* @return string
|
|
|
*/
|
|
|
-function convert_double_quote_to_single($in_text) {
|
|
|
+function convert_double_quote_to_single($in_text)
|
|
|
+{
|
|
|
return api_preg_replace('/"/', "''", $in_text);
|
|
|
}
|
|
|
|
|
@@ -7659,7 +7357,7 @@ function api_get_origin()
|
|
|
return $_REQUEST['origin'] === 'learnpath' ? 'learnpath' : '';
|
|
|
}
|
|
|
|
|
|
- return null;
|
|
|
+ return '';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -7814,7 +7512,7 @@ function api_get_users_status_ignored_in_reports($format = 'array')
|
|
|
*/
|
|
|
function api_set_site_use_cookie_warning_cookie()
|
|
|
{
|
|
|
- setcookie("ChamiloUsesCookies", "ok", time()+31556926);
|
|
|
+ setcookie('ChamiloUsesCookies', 'ok', time()+31556926);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -8027,15 +7725,6 @@ function api_mail_html(
|
|
|
}
|
|
|
$o++;
|
|
|
}
|
|
|
-// } elseif (is_array($_FILES)) {
|
|
|
-// $data_file = $_FILES;
|
|
|
-// $o = 0;
|
|
|
-// foreach ($data_file as $file_attach) {
|
|
|
-// if (!empty($file_attach['tmp_name']) && !empty($file_attach['name'])) {
|
|
|
-// $mail->AddAttachment($file_attach['tmp_name'], $file_attach['name']);
|
|
|
-// }
|
|
|
-// $o++;
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
// Only valid addresses are accepted.
|
|
@@ -8194,7 +7883,8 @@ function api_protect_limit_for_session_admin()
|
|
|
}
|
|
|
|
|
|
function api_is_student_view_active() {
|
|
|
- return (isset($_SESSION['studentview']) && $_SESSION['studentview'] == "studentview");
|
|
|
+ $studentView = Session::read('studentview');
|
|
|
+ return $studentView == 'studentview';
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -8252,4 +7942,4 @@ function api_remove_uploaded_file($type, $file)
|
|
|
function api_student_boss_access_to_course_and_session()
|
|
|
{
|
|
|
return true;
|
|
|
-}
|
|
|
+}
|