|
@@ -2512,62 +2512,6 @@ class UserManager
|
|
|
return $fields;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Build a list of extra file already uploaded in $user_folder/{$extra_field}/.
|
|
|
- *
|
|
|
- * @param $user_id
|
|
|
- * @param $extra_field
|
|
|
- * @param bool $force
|
|
|
- * @param bool $showDelete
|
|
|
- *
|
|
|
- * @return bool|string
|
|
|
- */
|
|
|
- public static function build_user_extra_file_list(
|
|
|
- $user_id,
|
|
|
- $extra_field,
|
|
|
- $force = false,
|
|
|
- $showDelete = false
|
|
|
- ) {
|
|
|
- if (!$force && !empty($_POST['remove_'.$extra_field])) {
|
|
|
- return true; // postpone reading from the filesystem
|
|
|
- }
|
|
|
-
|
|
|
- $extra_files = self::get_user_extra_files($user_id, $extra_field);
|
|
|
- if (empty($extra_files)) {
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- $path_info = self::get_user_picture_path_by_id($user_id, 'web');
|
|
|
- $path = $path_info['dir'];
|
|
|
- $del_image = Display::returnIconPath('delete.png');
|
|
|
-
|
|
|
- $del_text = get_lang('Delete');
|
|
|
- $extra_file_list = '';
|
|
|
- if (count($extra_files) > 0) {
|
|
|
- $extra_file_list = '<div class="files-production"><ul id="productions">';
|
|
|
- foreach ($extra_files as $file) {
|
|
|
- $filename = substr($file, strlen($extra_field) + 1);
|
|
|
- $extra_file_list .= '<li>'.Display::return_icon('archive.png').
|
|
|
- '<a href="'.$path.$extra_field.'/'.urlencode($filename).'" target="_blank">
|
|
|
- '.htmlentities($filename).
|
|
|
- '</a> ';
|
|
|
- if ($showDelete) {
|
|
|
- $extra_file_list .= '<input
|
|
|
- style="width:16px;"
|
|
|
- type="image"
|
|
|
- name="remove_extra_'.$extra_field.'['.urlencode($file).']"
|
|
|
- src="'.$del_image.'"
|
|
|
- alt="'.$del_text.'"
|
|
|
- title="'.$del_text.' '.htmlentities($filename).'"
|
|
|
- onclick="javascript: return confirmation(\''.htmlentities($filename).'\');" /></li>';
|
|
|
- }
|
|
|
- }
|
|
|
- $extra_file_list .= '</ul></div>';
|
|
|
- }
|
|
|
-
|
|
|
- return $extra_file_list;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get valid filenames in $user_folder/{$extra_field}/.
|
|
|
*
|
|
@@ -2610,33 +2554,6 @@ class UserManager
|
|
|
return $files; // can be an empty array
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Remove an {$extra_file} from the user folder $user_folder/{$extra_field}/.
|
|
|
- *
|
|
|
- * @param int $user_id
|
|
|
- * @param string $extra_field
|
|
|
- * @param string $extra_file
|
|
|
- *
|
|
|
- * @return bool
|
|
|
- */
|
|
|
- public static function remove_user_extra_file($user_id, $extra_field, $extra_file)
|
|
|
- {
|
|
|
- $extra_file = Security::filter_filename($extra_file);
|
|
|
- $path_info = self::get_user_picture_path_by_id($user_id, 'system');
|
|
|
- if (strpos($extra_file, $extra_field) !== false) {
|
|
|
- $path_extra_file = $path_info['dir'].$extra_file;
|
|
|
- } else {
|
|
|
- $path_extra_file = $path_info['dir'].$extra_field.'/'.$extra_file;
|
|
|
- }
|
|
|
- if (is_file($path_extra_file)) {
|
|
|
- unlink($path_extra_file);
|
|
|
-
|
|
|
- return true;
|
|
|
- }
|
|
|
-
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Creates a new extra field.
|
|
|
*
|
|
@@ -2880,18 +2797,6 @@ class UserManager
|
|
|
return $extraField->get_handler_field_info_by_tags($variable);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param string $type
|
|
|
- *
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public static function get_all_extra_field_by_type($type)
|
|
|
- {
|
|
|
- $extraField = new ExtraField('user');
|
|
|
-
|
|
|
- return $extraField->get_all_extra_field_by_type($type);
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get all the extra field information of a certain field (also the options).
|
|
|
*
|
|
@@ -5418,42 +5323,6 @@ class UserManager
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Gets the user path of user certificated.
|
|
|
- *
|
|
|
- * @param int The user id
|
|
|
- *
|
|
|
- * @return array containing path_certificate and cat_id
|
|
|
- */
|
|
|
- public static function get_user_path_certificate($user_id)
|
|
|
- {
|
|
|
- $my_certificate = [];
|
|
|
- $table_certificate = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CERTIFICATE);
|
|
|
- $table_gradebook_category = Database::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY);
|
|
|
-
|
|
|
- $session_id = api_get_session_id();
|
|
|
- $user_id = (int) $user_id;
|
|
|
- if ($session_id == 0 || is_null($session_id)) {
|
|
|
- $sql_session = 'AND (session_id='.intval($session_id).' OR isnull(session_id)) ';
|
|
|
- } elseif ($session_id > 0) {
|
|
|
- $sql_session = 'AND session_id='.intval($session_id);
|
|
|
- } else {
|
|
|
- $sql_session = '';
|
|
|
- }
|
|
|
- $sql = "SELECT tc.path_certificate,tc.cat_id,tgc.course_code,tgc.name
|
|
|
- FROM $table_certificate tc, $table_gradebook_category tgc
|
|
|
- WHERE tgc.id = tc.cat_id AND tc.user_id = $user_id
|
|
|
- ORDER BY tc.date_certificate DESC
|
|
|
- LIMIT 5";
|
|
|
-
|
|
|
- $rs = Database::query($sql);
|
|
|
- while ($row = Database::fetch_array($rs)) {
|
|
|
- $my_certificate[] = $row;
|
|
|
- }
|
|
|
-
|
|
|
- return $my_certificate;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* This function check if the user is a coach inside session course.
|
|
|
*
|
|
@@ -5515,32 +5384,6 @@ class UserManager
|
|
|
return $icon_link;
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Returns an array of the different types of user extra fields [id => title translation].
|
|
|
- *
|
|
|
- * @return array
|
|
|
- */
|
|
|
- public static function get_user_field_types()
|
|
|
- {
|
|
|
- $types = [];
|
|
|
- $types[self::USER_FIELD_TYPE_TEXT] = get_lang('FieldTypeText');
|
|
|
- $types[self::USER_FIELD_TYPE_TEXTAREA] = get_lang('FieldTypeTextarea');
|
|
|
- $types[self::USER_FIELD_TYPE_RADIO] = get_lang('FieldTypeRadio');
|
|
|
- $types[self::USER_FIELD_TYPE_SELECT] = get_lang('FieldTypeSelect');
|
|
|
- $types[self::USER_FIELD_TYPE_SELECT_MULTIPLE] = get_lang('FieldTypeSelectMultiple');
|
|
|
- $types[self::USER_FIELD_TYPE_DATE] = get_lang('FieldTypeDate');
|
|
|
- $types[self::USER_FIELD_TYPE_DATETIME] = get_lang('FieldTypeDatetime');
|
|
|
- $types[self::USER_FIELD_TYPE_DOUBLE_SELECT] = get_lang('FieldTypeDoubleSelect');
|
|
|
- $types[self::USER_FIELD_TYPE_DIVIDER] = get_lang('FieldTypeDivider');
|
|
|
- $types[self::USER_FIELD_TYPE_TAG] = get_lang('FieldTypeTag');
|
|
|
- $types[self::USER_FIELD_TYPE_TIMEZONE] = get_lang('FieldTypeTimezone');
|
|
|
- $types[self::USER_FIELD_TYPE_SOCIAL_PROFILE] = get_lang('FieldTypeSocialProfile');
|
|
|
- $types[self::USER_FIELD_TYPE_FILE] = get_lang('FieldTypeFile');
|
|
|
- $types[self::USER_FIELD_TYPE_MOBILE_PHONE_NUMBER] = get_lang('FieldTypeMobilePhoneNumber');
|
|
|
-
|
|
|
- return $types;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param User $user
|
|
|
*/
|
|
@@ -5739,34 +5582,6 @@ class UserManager
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Get the teacher (users with COURSEMANGER status) list.
|
|
|
- *
|
|
|
- * @return array The list
|
|
|
- */
|
|
|
- public static function getTeachersList()
|
|
|
- {
|
|
|
- $userTable = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
- $resultData = Database::select(
|
|
|
- 'user_id, lastname, firstname, username',
|
|
|
- $userTable,
|
|
|
- [
|
|
|
- 'where' => [
|
|
|
- 'status = ?' => COURSEMANAGER,
|
|
|
- ],
|
|
|
- ]
|
|
|
- );
|
|
|
-
|
|
|
- foreach ($resultData as &$teacherData) {
|
|
|
- $teacherData['completeName'] = api_get_person_name(
|
|
|
- $teacherData['firstname'],
|
|
|
- $teacherData['lastname']
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
- return $resultData;
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @return array
|
|
|
*/
|
|
@@ -5962,21 +5777,6 @@ class UserManager
|
|
|
return get_lang('Anonymous');
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Displays the name of the user and makes the link to the user profile.
|
|
|
- *
|
|
|
- * @param $userInfo
|
|
|
- *
|
|
|
- * @return string
|
|
|
- */
|
|
|
- public static function getUserProfileLinkWithPicture($userInfo)
|
|
|
- {
|
|
|
- return Display::url(
|
|
|
- Display::img($userInfo['avatar']),
|
|
|
- $userInfo['profile_url']
|
|
|
- );
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* Get users whose name matches $firstname and $lastname.
|
|
|
*
|
|
@@ -6532,19 +6332,6 @@ SQL;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @return int
|
|
|
- */
|
|
|
- public static function getCountActiveUsers()
|
|
|
- {
|
|
|
- $table = Database::get_main_table(TABLE_MAIN_USER);
|
|
|
- $sql = "SELECT count(id) count FROM $table WHERE active = 1 AND status <> ".ANONYMOUS;
|
|
|
- $result = Database::query($sql);
|
|
|
- $row = Database::fetch_array($result);
|
|
|
-
|
|
|
- return (int) $row['count'];
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* @param array $userInfo
|
|
|
* @param int $searchYear
|