本文整理汇总了PHP中UserManager::get_extra_fields方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::get_extra_fields方法的具体用法?PHP UserManager::get_extra_fields怎么用?PHP UserManager::get_extra_fields使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::get_extra_fields方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
}
$result = CourseManager::get_user_list_from_course_code(null, null, "LIMIT {$start}, {$limit}", null, null, null, true, true, array('ruc'), $courseCodeList, $userIdList, null, $sessionIdList);
$new_result = array();
if (!empty($result)) {
foreach ($result as $row) {
$row['training_hours'] = api_time_to_hms($row['training_hours']);
$row['average_hours_per_user'] = api_time_to_hms($row['average_hours_per_user']);
$new_result[] = $row;
}
$result = $new_result;
}
break;
case 'get_user_course_report':
$columns = array('course', 'user', 'email', 'time', 'certificate', 'progress_100', 'progress');
$column_names = array(get_lang('Course'), get_lang('User'), get_lang('Email'), get_lang('ManHours'), get_lang('CertificateGenerated'), get_lang('Approved'), get_lang('CourseAdvance'));
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
if (!empty($extra_fields)) {
foreach ($extra_fields as $extra) {
$columns[] = $extra['1'];
$column_names[] = $extra['3'];
}
}
if (api_is_student_boss()) {
$columns[] = 'group';
$column_names[] = get_lang('Group');
}
if (!in_array($sidx, array('title'))) {
$sidx = 'title';
}
if (api_is_student_boss() && empty($userIdList)) {
$result = [];
示例2: set_extra_fields_in_form
/**
* @param FormValidator $form
* @param $extra_data
* @param $form_name
* @param bool $admin_permissions
* @param null $user_id
* @deprecated
* @return array
*/
static function set_extra_fields_in_form($form, $extra_data, $admin_permissions = false, $user_id = null)
{
$user_id = intval($user_id);
// EXTRA FIELDS
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
$jquery_ready_content = null;
foreach ($extra as $field_details) {
if (!$admin_permissions) {
if ($field_details[6] == 0) {
continue;
}
}
switch ($field_details[2]) {
case ExtraField::FIELD_TYPE_TEXT:
$form->addElement('text', 'extra_' . $field_details[1], $field_details[3], array('size' => 40));
$form->applyFilter('extra_' . $field_details[1], 'stripslashes');
$form->applyFilter('extra_' . $field_details[1], 'trim');
$form->applyFilter('extra_' . $field_details[1], 'html_filter');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_TEXTAREA:
$form->addHtmlEditor('extra_' . $field_details[1], $field_details[3], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
$form->applyFilter('extra_' . $field_details[1], 'stripslashes');
$form->applyFilter('extra_' . $field_details[1], 'trim');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_RADIO:
$group = array();
foreach ($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
$group[] = $form->createElement('radio', 'extra_' . $field_details[1], $option_details[1], $option_details[2] . '<br />', $option_details[1]);
}
$form->addGroup($group, 'extra_' . $field_details[1], $field_details[3], '');
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT:
$get_lang_variables = false;
if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
$get_lang_variables = true;
}
$options = array();
foreach ($field_details[9] as $option_id => $option_details) {
if ($get_lang_variables) {
$options[$option_details[1]] = get_lang($option_details[2]);
} else {
$options[$option_details[1]] = $option_details[2];
}
}
if ($get_lang_variables) {
$field_details[3] = get_lang($field_details[3]);
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('id' => 'extra_' . $field_details[1]));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$options = array();
foreach ($field_details[9] as $option_id => $option_details) {
$options[$option_details[1]] = $option_details[2];
}
$form->addElement('select', 'extra_' . $field_details[1], $field_details[3], $options, array('multiple' => 'multiple'));
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
break;
case ExtraField::FIELD_TYPE_DATE:
$form->addDatePicker('extra_' . $field_details[1], $field_details[3]);
$defaults['extra_' . $field_details[1]] = date('Y-m-d 12:00:00');
$form->setDefaults($defaults);
if (!$admin_permissions) {
if ($field_details[7] == 0) {
$form->freeze('extra_' . $field_details[1]);
}
}
//.........这里部分代码省略.........
示例3: display_additional_profile_fields
public static function display_additional_profile_fields()
{
// getting all the extra profile fields that are defined by the platform administrator
$extra_fields = UserManager::get_extra_fields(0, 50, 5, 'ASC');
// creating the form
$return = '<form action="courseLog.php" method="get" name="additional_profile_field_form" id="additional_profile_field_form">';
// the select field with the additional user profile fields (= this is where we select the field of which we want to see
// the information the users have entered or selected.
$return .= '<select name="additional_profile_field">';
$return .= '<option value="-">' . get_lang('SelectFieldToAdd') . '</option>';
$extra_fields_to_show = 0;
foreach ($extra_fields as $key => $field) {
// show only extra fields that are visible + and can be filtered, added by J.Montoya
if ($field[6] == 1 && $field[8] == 1) {
if (isset($_GET['additional_profile_field']) && $field[0] == $_GET['additional_profile_field']) {
$selected = 'selected="selected"';
} else {
$selected = '';
}
$extra_fields_to_show++;
$return .= '<option value="' . $field[0] . '" ' . $selected . '>' . $field[3] . '</option>';
}
}
$return .= '</select>';
// the form elements for the $_GET parameters (because the form is passed through GET
foreach ($_GET as $key => $value) {
if ($key != 'additional_profile_field') {
$return .= '<input type="hidden" name="' . Security::remove_XSS($key) . '" value="' . Security::remove_XSS($value) . '" />';
}
}
// the submit button
$return .= '<button class="save" type="submit">' . get_lang('AddAdditionalProfileField') . '</button>';
$return .= '</form>';
if ($extra_fields_to_show > 0) {
return $return;
} else {
return '';
}
}
示例4: make_field_list
/**
* Creates a multi array with the user fields that we can show. We look the visibility with the api_get_setting function
* The username is always NOT able to change it.
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification
* @return array[value_name][name]
* array[value_name][visibilty]
*/
static function make_field_list()
{
// LAST NAME and FIRST NAME
$field_list_array = array();
$field_list_array['lastname']['name'] = get_lang('LastName');
$field_list_array['firstname']['name'] = get_lang('FirstName');
if (api_get_setting('profile', 'name') != 'true') {
$field_list_array['firstname']['visibility'] = 0;
$field_list_array['lastname']['visibility'] = 0;
} else {
$field_list_array['firstname']['visibility'] = 1;
$field_list_array['lastname']['visibility'] = 1;
}
$field_list_array['username']['name'] = get_lang('Username');
$field_list_array['username']['visibility'] = 0;
// OFFICIAL CODE
$field_list_array['official_code']['name'] = get_lang('OfficialCode');
if (api_get_setting('profile', 'officialcode') != 'true') {
$field_list_array['official_code']['visibility'] = 1;
} else {
$field_list_array['official_code']['visibility'] = 0;
}
// EMAIL
$field_list_array['email']['name'] = get_lang('Email');
if (api_get_setting('profile', 'email') != 'true') {
$field_list_array['email']['visibility'] = 1;
} else {
$field_list_array['email']['visibility'] = 0;
}
// PHONE
$field_list_array['phone']['name'] = get_lang('Phone');
if (api_get_setting('profile', 'phone') != 'true') {
$field_list_array['phone']['visibility'] = 0;
} else {
$field_list_array['phone']['visibility'] = 1;
}
// LANGUAGE
$field_list_array['language']['name'] = get_lang('Language');
if (api_get_setting('profile', 'language') != 'true') {
$field_list_array['language']['visibility'] = 0;
} else {
$field_list_array['language']['visibility'] = 1;
}
// EXTRA FIELDS
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
foreach ($extra as $id => $field_details) {
if ($field_details[6] == 0) {
continue;
}
switch ($field_details[2]) {
case UserManager::USER_FIELD_TYPE_TEXT:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_TEXTAREA:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_RADIO:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_SELECT:
$get_lang_variables = false;
if (in_array($field_details[1], array('mail_notify_message', 'mail_notify_invitation', 'mail_notify_group_message'))) {
$get_lang_variables = true;
}
if ($get_lang_variables) {
$field_list_array['extra_' . $field_details[1]]['name'] = get_lang($field_details[3]);
} else {
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
}
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_SELECT_MULTIPLE:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
//.........这里部分代码省略.........
示例5: set_extra_fields_in_form
/**
* @param FormValidator $form
* @param array $extraData
* @param string $form_name
* @param bool $admin_permissions
* @param int $user_id
* @param array $extra
* @param int $itemId
*
* @return array
*/
public function set_extra_fields_in_form($form, $extraData, $form_name, $admin_permissions = false, $user_id = null, $extra = array(), $itemId = null)
{
$user_id = intval($user_id);
$type = $this->type;
// User extra fields
if ($type == 'user') {
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC', true, null, true);
}
$jquery_ready_content = null;
if (!empty($extra)) {
foreach ($extra as $field_details) {
// Getting default value id if is set
$defaultValueId = null;
if (isset($field_details['options']) && !empty($field_details['options'])) {
$valueToFind = null;
if (isset($field_details['field_default_value'])) {
$valueToFind = $field_details['field_default_value'];
}
// If a value is found we override the default value
if (isset($extraData['extra_' . $field_details['field_variable']])) {
$valueToFind = $extraData['extra_' . $field_details['field_variable']];
}
foreach ($field_details['options'] as $option) {
if ($option['option_value'] == $valueToFind) {
$defaultValueId = $option['id'];
}
}
}
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
continue;
}
}
switch ($field_details['field_type']) {
case ExtraField::FIELD_TYPE_TEXT:
$form->addElement('text', 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], array('class' => 'span4'));
$form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_' . $field_details['field_variable'], 'trim');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_TEXTAREA:
$form->add_html_editor('extra_' . $field_details['field_variable'], $field_details['field_display_text'], false, false, array('ToolbarSet' => 'Profile', 'Width' => '100%', 'Height' => '130'));
$form->applyFilter('extra_' . $field_details['field_variable'], 'stripslashes');
$form->applyFilter('extra_' . $field_details['field_variable'], 'trim');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_RADIO:
$group = array();
if (isset($field_details['options']) && !empty($field_details['options'])) {
foreach ($field_details['options'] as $option_details) {
$options[$option_details['option_value']] = $option_details['option_display_text'];
$group[] = $form->createElement('radio', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']);
}
}
$form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], '');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_CHECKBOX:
$group = array();
if (isset($field_details['options']) && !empty($field_details['options'])) {
foreach ($field_details['options'] as $option_details) {
$options[$option_details['option_value']] = $option_details['option_display_text'];
$group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], $option_details['option_value'], $option_details['option_display_text'] . '<br />', $option_details['option_value']);
}
} else {
// We assume that is a switch on/off with 1 and 0 as values
$group[] = $form->createElement('checkbox', 'extra_' . $field_details['field_variable'], null, 'Yes <br />', null);
}
$form->addGroup($group, 'extra_' . $field_details['field_variable'], $field_details['field_display_text'], '');
if (!$admin_permissions) {
if ($field_details['field_visible'] == 0) {
$form->freeze('extra_' . $field_details['field_variable']);
}
}
break;
case ExtraField::FIELD_TYPE_SELECT:
$get_lang_variables = false;
//.........这里部分代码省略.........
示例6: make_field_list
/**
* Creates a multi array with the user fields that we can show. We look the visibility with the api_get_setting function
* The username is always NOT able to change it.
* @author Julio Montoya Armas <gugli100@gmail.com>, Chamilo: Personality Test modification
* @return array[value_name][name]
* array[value_name][visibilty]
*/
static function make_field_list()
{
// LAST NAME and FIRST NAME
$field_list_array = array();
$field_list_array['lastname']['name'] = get_lang('Lastname');
$field_list_array['firstname']['name'] = get_lang('Firstname');
if (api_get_setting('profile', 'name') != 'true') {
$field_list_array['firstname']['visibility'] = 0;
$field_list_array['lastname']['visibility'] = 0;
} else {
$field_list_array['firstname']['visibility'] = 1;
$field_list_array['lastname']['visibility'] = 1;
}
$field_list_array['username']['name'] = get_lang('Username');
$field_list_array['username']['visibility'] = 0;
// OFFICIAL CODE
$field_list_array['official_code']['name'] = get_lang('OfficialCode');
if (api_get_setting('profile', 'officialcode') != 'true') {
$field_list_array['official_code']['visibility'] = 1;
} else {
$field_list_array['official_code']['visibility'] = 0;
}
// EMAIL
$field_list_array['email']['name'] = get_lang('Email');
if (api_get_setting('profile', 'email') != 'true') {
$field_list_array['email']['visibility'] = 1;
} else {
$field_list_array['email']['visibility'] = 0;
}
// OPENID URL
//$field_list_array[] = 'openid_authentication';
/*
if (is_profile_editable() && api_get_setting('openid_authentication') == 'true') {
$form->addElement('text', 'openid', get_lang('OpenIDURL'), array('size' => 40));
if (api_get_setting('profile', 'openid') != 'true') {
$form->freeze('openid');
}
$form->applyFilter('openid', 'trim');
//if (api_get_setting('registration', 'openid') == 'true')
// $form->addRule('openid', get_lang('ThisFieldIsRequired'), 'required');
}*/
// PHONE
$field_list_array['phone']['name'] = get_lang('Phone');
if (api_get_setting('profile', 'phone') != 'true') {
$field_list_array['phone']['visibility'] = 0;
} else {
$field_list_array['phone']['visibility'] = 1;
}
// LANGUAGE
$field_list_array['language']['name'] = get_lang('Language');
if (api_get_setting('profile', 'language') != 'true') {
$field_list_array['language']['visibility'] = 0;
} else {
$field_list_array['language']['visibility'] = 1;
}
// EXTRA FIELDS
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
$extra_data = UserManager::get_extra_user_data(api_get_user_id(), true);
foreach ($extra as $id => $field_details) {
if ($field_details[6] == 0) {
continue;
}
switch ($field_details[2]) {
case UserManager::USER_FIELD_TYPE_TEXT:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_TEXTAREA:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_RADIO:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
}
break;
case UserManager::USER_FIELD_TYPE_SELECT:
$field_list_array['extra_' . $field_details[1]]['name'] = $field_details[3];
if ($field_details[7] == 0) {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 0;
} else {
$field_list_array['extra_' . $field_details[1]]['visibility'] = 1;
//.........这里部分代码省略.........
示例7: display_extra_profile_fields_filter
/**
* This function displays a dropdown list with all the additional user profile fields defined by the platform administrator in
* platform administration > profiling. Only the fields that have predefined fields are usefull for such a filter.
*
*/
function display_extra_profile_fields_filter($type)
{
// getting all the additional user profile fields
$extra = UserManager::get_extra_fields(0, 50, 5, 'ASC');
$return = '<option value="">' . get_lang('SelectFilter') . '</option>';
// looping through the additional user profile fields
foreach ($extra as $id => $field_details) {
// $field_details[2] contains the type of the additional user profile field
switch ($field_details[2]) {
// text fields cannot be used as a filter
case ExtraField::FIELD_TYPE_TEXT:
break;
// text area fields cannot be used as a filter
// text area fields cannot be used as a filter
case ExtraField::FIELD_TYPE_TEXTAREA:
break;
case ExtraField::FIELD_TYPE_RADIO:
case ExtraField::FIELD_TYPE_SELECT:
case ExtraField::FIELD_TYPE_SELECT_MULTIPLE:
$return .= '<optgroup label="' . $field_details[3] . '">';
foreach ($field_details[9] as $option_id => $option_details) {
if ($_GET['subscribe_user_filter_value'] == $field_details[0] . '*' . $option_details[1]) {
$selected = 'selected="selected"';
} else {
$selected = false;
}
$return .= '<option value="' . $field_details[0] . '*' . $option_details[1] . '" ' . $selected . '>' . $option_details[2] . '</option>';
}
$return .= '</optgroup>';
break;
}
}
echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="' . api_get_self() . '?api_get_cidreq" style="float:left;">';
echo ' <input type="hidden" name="type" id="type" value="' . $type . '" />';
echo '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">' . $return . '</select>';
echo '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">' . get_lang('Filter') . '</button>';
echo '</form>';
}
示例8: exportCompleteReportXLS
/**
* Exports the complete report as an XLS file
* @return boolean False on error
*/
public function exportCompleteReportXLS($document_path = '', $user_id = null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null)
{
global $charset;
$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_' . date('YmdGis') . '.xls';
if (!empty($user_id)) {
$filename = 'exercise_results_user_' . $user_id . '_' . date('YmdGis') . '.xls';
}
$workbook = new Spreadsheet_Excel_Writer();
$workbook->setTempDir(api_get_path(SYS_ARCHIVE_PATH));
$workbook->setVersion(8);
// BIFF8
$workbook->send($filename);
$worksheet =& $workbook->addWorksheet('Report ' . date('YmdGis'));
$worksheet->setInputEncoding(api_get_system_encoding());
$line = 0;
$column = 0;
//skip the first column (row titles)
// check if exists column 'user'
$with_column_user = false;
foreach ($this->results as $result) {
if (!empty($result['last_name']) && !empty($result['first_name'])) {
$with_column_user = true;
break;
}
}
if ($with_column_user) {
$worksheet->write($line, $column, get_lang('Email'));
$column++;
if (api_is_western_name_order()) {
$worksheet->write($line, $column, get_lang('FirstName'));
$column++;
$worksheet->write($line, $column, get_lang('LastName'));
$column++;
} else {
$worksheet->write($line, $column, get_lang('LastName'));
$column++;
$worksheet->write($line, $column, get_lang('FirstName'));
$column++;
}
}
if ($export_user_fields) {
//show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
//show the fields names for user fields
foreach ($extra_user_fields as $field) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
$column++;
}
}
$worksheet->write($line, $column, get_lang('Title'));
$column++;
$worksheet->write($line, $column, get_lang('StartDate'));
$column++;
$worksheet->write($line, $column, get_lang('EndDate'));
$column++;
$worksheet->write($line, $column, get_lang('Duration') . ' (' . get_lang('MinMinutes') . ')');
$column++;
$worksheet->write($line, $column, get_lang('Score'));
$column++;
$worksheet->write($line, $column, get_lang('Total'));
$column++;
$worksheet->write($line, $column, get_lang('Status'));
$line++;
foreach ($this->results as $row) {
$column = 0;
if ($with_column_user) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
$column++;
if (api_is_western_name_order()) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
} else {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
}
}
if ($export_user_fields) {
//show user fields data, if any, for this user
$user_fields_values = UserManager::get_extra_user_data($row['user_id'], false, false, false, true);
foreach ($user_fields_values as $value) {
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($value), ENT_QUOTES, $charset));
$column++;
}
}
$worksheet->write($line, $column, api_html_entity_decode(strip_tags($row['title']), ENT_QUOTES, $charset));
$column++;
$worksheet->write($line, $column, $row['start_date']);
$column++;
$worksheet->write($line, $column, $row['end_date']);
$column++;
$worksheet->write($line, $column, $row['duration']);
//.........这里部分代码省略.........
示例9: get_user_list_from_course_code
//.........这里部分代码省略.........
(field_id = ' . $extraFieldInfo['id'] . ' OR field_id IS NULL)
)';
$extraFieldWasAdded = true;
}
}
}
$sql .= ' WHERE ' . $filter_by_status_condition . ' ' . implode(' OR ', $where);
if ($multiple_access_url) {
$current_access_url_id = api_get_current_access_url_id();
$sql .= " AND (access_url_id = {$current_access_url_id} ) ";
}
if ($return_count && $resumed_report && $extraFieldWasAdded) {
$sql .= ' AND field_id IS NOT NULL GROUP BY value ';
}
if (!empty($courseCodeList)) {
$courseCodeList = array_map(array('Database', 'escape_string'), $courseCodeList);
$courseCodeList = implode('","', $courseCodeList);
if (empty($sessionIdList)) {
$sql .= ' AND course.code IN ("' . $courseCodeList . '")';
}
}
if (!empty($userIdList)) {
$userIdList = array_map('intval', $userIdList);
$userIdList = implode('","', $userIdList);
$sql .= ' AND user.user_id IN ("' . $userIdList . '")';
}
if (isset($filterByActive)) {
$filterByActive = intval($filterByActive);
$sql .= ' AND user.active = ' . $filterByActive;
}
$sql .= ' ' . $order_by . ' ' . $limit;
$rs = Database::query($sql);
$users = array();
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
$counter = 1;
$count_rows = Database::num_rows($rs);
if ($return_count && $resumed_report) {
return $count_rows;
}
$table_user_field_value = Database::get_main_table(TABLE_EXTRA_FIELD_VALUES);
$tableExtraField = Database::get_main_table(TABLE_EXTRA_FIELD);
if ($count_rows) {
while ($user = Database::fetch_array($rs)) {
if ($return_count) {
return $user['count'];
}
$report_info = array();
$user_info = $user;
$user_info['status'] = $user['status'];
if (isset($user['is_tutor'])) {
$user_info['is_tutor'] = $user['is_tutor'];
}
if (!empty($session_id)) {
$user_info['status_session'] = $user['status_session'];
}
$sessionId = isset($user['session_id']) ? $user['session_id'] : 0;
$course_code = isset($user['code']) ? $user['code'] : null;
if ($add_reports) {
if ($resumed_report) {
$extra = array();
if (!empty($extra_fields)) {
foreach ($extra_fields as $extra) {
if (in_array($extra['1'], $extra_field)) {
$user_data = UserManager::get_extra_user_data_by_field($user['user_id'], $extra['1']);
break;
}
示例10: export_tracking_user_overview
/**
* This function exports the table that we see in display_tracking_user_overview()
*
* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University, Belgium
* @version Dokeos 1.8.6
* @since October 2008
*/
public static function export_tracking_user_overview()
{
// database table definitions
$tbl_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$is_western_name_order = api_is_western_name_order(PERSON_NAME_DATA_EXPORT);
$sort_by_first_name = api_sort_by_first_name();
// the values of the sortable table
if ($_GET['tracking_user_overview_page_nr']) {
$from = $_GET['tracking_user_overview_page_nr'];
} else {
$from = 0;
}
if ($_GET['tracking_user_overview_column']) {
$orderby = $_GET['tracking_user_overview_column'];
} else {
$orderby = 0;
}
if ($is_western_name_order != api_is_western_name_order() && ($orderby == 1 || $orderby == 2)) {
// Swapping the sorting column if name order for export is different than the common name order.
$orderby = 3 - $orderby;
}
if ($_GET['tracking_user_overview_direction']) {
$direction = $_GET['tracking_user_overview_direction'];
} else {
$direction = 'ASC';
}
$user_data = MySpace::get_user_data_tracking_overview($from, 1000, $orderby, $direction);
// the first line of the csv file with the column headers
$csv_row = array();
$csv_row[] = get_lang('OfficialCode');
if ($is_western_name_order) {
$csv_row[] = get_lang('FirstName', '');
$csv_row[] = get_lang('LastName', '');
} else {
$csv_row[] = get_lang('LastName', '');
$csv_row[] = get_lang('FirstName', '');
}
$csv_row[] = get_lang('LoginName');
$csv_row[] = get_lang('CourseCode');
// the additional user defined fields (only those that were selected to be exported)
$fields = UserManager::get_extra_fields(0, 50, 5, 'ASC');
if (is_array($_SESSION['additional_export_fields'])) {
foreach ($_SESSION['additional_export_fields'] as $key => $extra_field_export) {
$csv_row[] = $fields[$extra_field_export][3];
$field_names_to_be_exported[] = 'extra_' . $fields[$extra_field_export][1];
}
}
$csv_row[] = get_lang('AvgTimeSpentInTheCourse', '');
$csv_row[] = get_lang('AvgStudentsProgress', '');
$csv_row[] = get_lang('AvgCourseScore', '');
$csv_row[] = get_lang('AvgExercisesScore', '');
$csv_row[] = get_lang('AvgMessages', '');
$csv_row[] = get_lang('AvgAssignments', '');
$csv_row[] = get_lang('TotalExercisesScoreObtained', '');
$csv_row[] = get_lang('TotalExercisesScorePossible', '');
$csv_row[] = get_lang('TotalExercisesAnswered', '');
$csv_row[] = get_lang('TotalExercisesScorePercentage', '');
$csv_row[] = get_lang('FirstLogin', '');
$csv_row[] = get_lang('LatestLogin', '');
$csv_content[] = $csv_row;
// the other lines (the data)
foreach ($user_data as $key => $user) {
// getting all the courses of the user
$sql = "SELECT * FROM {$tbl_course_user}\n WHERE user_id = '" . intval($user[4]) . "' AND relation_type<>" . COURSE_RELATION_TYPE_RRHH . " ";
$result = Database::query($sql);
while ($row = Database::fetch_row($result)) {
$courseInfo = api_get_course_info($row['course_code']);
$courseId = $courseInfo['real_id'];
$csv_row = array();
// user official code
$csv_row[] = $user[0];
// user first|last name
$csv_row[] = $user[1];
// user last|first name
$csv_row[] = $user[2];
// user login name
$csv_row[] = $user[3];
// course code
$csv_row[] = $row[0];
// the additional defined user fields
$extra_fields = MySpace::get_user_overview_export_extra_fields($user[4]);
if (is_array($field_names_to_be_exported)) {
foreach ($field_names_to_be_exported as $key => $extra_field_export) {
$csv_row[] = $extra_fields[$extra_field_export];
}
}
// time spent in the course
$csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId));
// student progress in course
$csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2);
// student score
$csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2);
// student tes score
//.........这里部分代码省略.........
示例11: get_extra_fields
function get_extra_fields($f, $n, $o, $d)
{
return UserManager::get_extra_fields($f, $n, $o, $d);
}
示例12: get_user_list_from_course_code
/**
* Return user info array of all users registered in the specified course
* This only returns the users that are registered in this actual course, not linked courses.
*
* @param string $course_code the code of the course
* @param boolean $with_session determines if the course is used in a session or not
* @param integer $session_id the id of the session
* @param string $limit the LIMIT statement of the sql statement
* @param string $order_by the field to order the users by. Valid values are 'lastname', 'firstname', 'username', 'email', 'official_code' OR a part of a SQL statement that starts with ORDER BY ...
* @param int if using the session_id: 0 or 2 (student, coach), if using session_id = 0 STUDENT or COURSEMANAGER
* @return array
*/
public static function get_user_list_from_course_code($course_code = null, $session_id = 0, $limit = null, $order_by = null, $filter_by_status = null, $return_count = null, $add_reports = false, $resumed_report = false, $extra_field = null)
{
// variable initialisation
$session_id = intval($session_id);
$course_code = Database::escape_string($course_code);
$where = array();
// if the $order_by does not contain 'ORDER BY' we have to check if it is a valid field that can be sorted on
if (!strstr($order_by, 'ORDER BY')) {
//if (!empty($order_by) AND in_array($order_by, array('lastname', 'firstname', 'username', 'email', 'official_code'))) {
if (!empty($order_by)) {
$order_by = 'ORDER BY ' . $order_by;
} else {
$order_by = '';
}
}
$courseInfo = api_get_course_info($course_code);
$courseId = null;
if ($courseInfo) {
$courseId = $courseInfo['real_id'];
}
$filter_by_status_condition = null;
if (!empty($session_id) && !empty($courseId)) {
$sql = 'SELECT DISTINCT user.user_id, session_course_user.status as status_session, user.* ';
$sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user ';
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER) . ' as session_course_user
ON user.user_id = session_course_user.id_user
AND session_course_user.c_id="' . $courseId . '"
AND session_course_user.id_session = ' . $session_id;
$where[] = ' session_course_user.c_id IS NOT NULL ';
// 2 = coach
// 0 = student
if (isset($filter_by_status)) {
$filter_by_status = intval($filter_by_status);
$filter_by_status_condition = " session_course_user.status = {$filter_by_status} AND ";
}
} else {
if ($return_count) {
$sql = " SELECT COUNT(*) as count";
if ($resumed_report) {
//$sql = " SELECT count(field_id) ";
}
} else {
if (empty($course_code)) {
$sql = 'SELECT DISTINCT course.title, course.code, course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* ';
} else {
$sql = 'SELECT DISTINCT course_rel_user.status as status_rel, user.user_id, course_rel_user.role, course_rel_user.tutor_id, user.* ';
}
}
$sql .= ' FROM ' . Database::get_main_table(TABLE_MAIN_USER) . ' as user ';
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_COURSE_USER) . ' as course_rel_user
ON user.user_id = course_rel_user.user_id AND
course_rel_user.relation_type <> ' . COURSE_RELATION_TYPE_RRHH;
if (!empty($courseInfo)) {
$sql .= " AND course_rel_user.c_id = " . $courseId;
} else {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE);
$sql .= " INNER JOIN {$course_table} course ON course_rel_user.c_id = course.id";
}
$where[] = ' course_rel_user.c_id IS NOT NULL ';
if (isset($filter_by_status) && $filter_by_status != '') {
$filter_by_status = intval($filter_by_status);
$filter_by_status_condition = " course_rel_user.status = {$filter_by_status} AND ";
}
}
$multiple_access_url = api_get_multiple_access_url();
if ($multiple_access_url) {
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER) . ' au ON (au.user_id = user.user_id) ';
}
if ($return_count && $resumed_report) {
$extra_field_info = UserManager::get_extra_field_information_by_name($extra_field);
$sql .= ' LEFT JOIN ' . Database::get_main_table(TABLE_MAIN_USER_FIELD_VALUES) . ' as ufv ON (user.user_id = ufv.user_id AND (field_id = ' . $extra_field_info['id'] . ' OR field_id IS NULL ) )';
}
$sql .= ' WHERE ' . $filter_by_status_condition . ' ' . implode(' OR ', $where);
if ($multiple_access_url) {
$current_access_url_id = api_get_current_access_url_id();
$sql .= " AND (access_url_id = {$current_access_url_id} ) ";
}
if ($return_count && $resumed_report) {
$sql .= ' AND field_id IS NOT NULL GROUP BY field_value ';
}
$sql .= ' ' . $order_by . ' ' . $limit;
$rs = Database::query($sql);
$users = array();
if ($add_reports) {
$extra_fields = UserManager::get_extra_fields(0, 100, null, null, true, true);
}
$counter = 1;
$count_rows = Database::num_rows($rs);
//.........这里部分代码省略.........
示例13: indexAction
//.........这里部分代码省略.........
case 'get_work_user_list':
require_once api_get_path(SYS_CODE_PATH) . 'work/work.lib.php';
$work_id = $request->get('work_id');
//$_REQUEST['work_id'];
$count = get_count_work($work_id);
break;
case 'get_exercise_results':
$exercise_id = $request->get('exerciseId');
//$_REQUEST['exerciseId'];
$filter_by_user = $request->get('filter_by_user');
if (isset($filter_by_user) && !empty($filter_by_user)) {
$filter_user = intval($filter_by_user);
if ($where_condition == "") {
$where_condition .= " te.exe_user_id = '{$filter_user}'";
} else {
$where_condition .= " AND te.exe_user_id = '{$filter_user}'";
}
}
$count = \ExerciseLib::get_count_exam_results($exercise_id, $where_condition);
break;
case 'get_hotpotatoes_exercise_results':
$hotpot_path = $request->get('path');
//$_REQUEST['path'];
$count = \ExerciseLib::get_count_exam_hotpotatoes_results($hotpot_path);
break;
case 'get_sessions':
$list_type = $request->get('list_type');
if ($list_type == 'simple' || empty($list_type)) {
$count = \SessionManager::get_sessions_admin(array('where' => $where_condition, 'extra' => $extra_fields), true);
} else {
$count = \SessionManager::get_count_admin_complete(array('where' => $where_condition, 'extra' => $extra_fields));
}
break;
case 'get_extra_fields':
$obj = new \ExtraField($type);
$count = $obj->get_count();
break;
case 'get_extra_field_options':
$field_id = $request->get('field_id');
$obj = new \ExtraFieldOption($type);
$count = $obj->get_count_by_field_id($field_id);
break;
case 'get_timelines':
$obj = new \Timeline();
$count = $obj->get_count();
break;
case 'get_gradebooks':
$obj = new \Gradebook();
$count = $obj->get_count();
break;
case 'get_event_email_template':
$obj = new \EventEmailTemplate();
$count = $obj->get_count();
break;
case 'get_careers':
$obj = new \Career();
$count = $obj->get_count();
break;
case 'get_promotions':
$obj = new \Promotion();
$count = $obj->get_count();
break;
case 'get_grade_models':
$obj = new \GradeModel();
$count = $obj->get_count();
break;
示例14: exportCompleteReportXLS
/**
* Exports the complete report as an XLS file
* @return boolean False on error
*/
public function exportCompleteReportXLS($document_path = '', $user_id = null, $export_user_fields = false, $export_filter = 0, $exercise_id = 0, $hotpotato_name = null)
{
global $charset;
$this->getExercisesReporting($document_path, $user_id, $export_filter, $exercise_id, $hotpotato_name);
$filename = 'exercise_results_' . api_get_local_time() . '.xls';
if (!empty($user_id)) {
$filename = 'exercise_results_user_' . $user_id . '_' . api_get_local_time() . '.xls';
}
$spreadsheet = new PHPExcel();
$spreadsheet->setActiveSheetIndex(0);
$worksheet = $spreadsheet->getActiveSheet();
$line = 0;
$column = 0;
//skip the first column (row titles)
// check if exists column 'user'
$with_column_user = false;
foreach ($this->results as $result) {
if (!empty($result['last_name']) && !empty($result['first_name'])) {
$with_column_user = true;
break;
}
}
$officialCodeInList = api_get_setting('exercise.show_official_code_exercise_result_list');
if ($with_column_user) {
if (api_is_western_name_order()) {
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName'));
$column++;
} else {
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('LastName'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('FirstName'));
$column++;
}
if ($officialCodeInList === 'true') {
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('OfficialCode'));
$column++;
}
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Email'));
$column++;
}
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Groups'));
$column++;
if ($export_user_fields) {
//show user fields section with a big th colspan that spans over all fields
$extra_user_fields = UserManager::get_extra_fields(0, 1000, 5, 'ASC', false, 1);
//show the fields names for user fields
foreach ($extra_user_fields as $field) {
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($field[3]), ENT_QUOTES, $charset));
$column++;
}
}
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Title'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('StartDate'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('EndDate'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Duration') . ' (' . get_lang('MinMinutes') . ')');
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Score'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Total'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('Status'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('ToolLearnpath'));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, get_lang('UserIsCurrentlySubscribed'));
$line++;
foreach ($this->results as $row) {
$column = 0;
if ($with_column_user) {
if (api_is_western_name_order()) {
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
} else {
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['last_name']), ENT_QUOTES, $charset));
$column++;
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['first_name']), ENT_QUOTES, $charset));
$column++;
}
if ($officialCodeInList === 'true') {
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['official_code']), ENT_QUOTES, $charset));
$column++;
}
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags($row['email']), ENT_QUOTES, $charset));
$column++;
}
$worksheet->SetCellValueByColumnAndRow($line, $column, api_html_entity_decode(strip_tags(implode(", ", GroupManager::get_user_group_name($row['user_id']))), ENT_QUOTES, $charset));
$column++;
if ($export_user_fields) {
//show user fields data, if any, for this user
//.........这里部分代码省略.........
示例15: xml_set_character_data_handler
xml_set_character_data_handler($parser, 'character_data');
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
xml_parser_free($parser);
return $users;
}
$this_section = SECTION_PLATFORM_ADMIN;
api_protect_admin_script(true, null, 'login');
$defined_auth_sources[] = PLATFORM_AUTH_SOURCE;
if (isset($extAuthSource) && is_array($extAuthSource)) {
$defined_auth_sources = array_merge($defined_auth_sources, array_keys($extAuthSource));
}
$tool_name = get_lang('ImportUserListXMLCSV');
$interbreadcrumb[] = array('url' => Container::getRouter()->generate('administration'), "name" => get_lang('PlatformAdmin'));
set_time_limit(0);
$extra_fields = UserManager::get_extra_fields(0, 0, 5, 'ASC', true);
$user_id_error = array();
$error_message = '';
if (isset($_POST['formSent']) && $_POST['formSent'] and $_FILES['import_file']['size'] !== 0) {
$file_type = 'csv';
Security::clear_token();
$tok = Security::get_token();
$allowed_file_mimetype = array('csv', 'xml');
$error_kind_file = false;
$uploadInfo = pathinfo($_FILES['import_file']['name']);
$ext_import_file = $uploadInfo['extension'];
if (in_array($ext_import_file, $allowed_file_mimetype)) {
if (strcmp($file_type, 'csv') === 0 && $ext_import_file == $allowed_file_mimetype[0]) {
$users = parse_csv_data($_FILES['import_file']['tmp_name']);
$errors = validate_data($users);
$error_kind_file = false;