function search_users($needle, $type) { global $_configuration, $tbl_access_url_rel_user, $tbl_user, $user_anonymous, $current_user_id, $user_id; $xajax_response = new XajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $assigned_users_to_hrm = UserManager::get_users_followed_by_drh($user_id); $assigned_users_id = array_keys($assigned_users_to_hrm); $without_assigned_users = ''; if (count($assigned_users_id) > 0) { $without_assigned_users = " AND user.user_id NOT IN(" . implode(',', $assigned_users_id) . ")"; } if ($_configuration['multiple_access_urls']) { $sql = "SELECT user.user_id, username, lastname, firstname FROM {$tbl_user} user LEFT JOIN {$tbl_access_url_rel_user} au ON (au.user_id = user.user_id)\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user.user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users} AND access_url_id = " . api_get_current_access_url_id() . ""; } else { $sql = "SELECT user_id, username, lastname, firstname FROM {$tbl_user} user\n\t\t\tWHERE " . (api_sort_by_first_name() ? 'firstname' : 'lastname') . " LIKE '{$needle}%' AND status NOT IN(" . DRH . ", " . SESSIONADMIN . ") AND user_id NOT IN ({$user_anonymous}, {$current_user_id}, {$user_id}) {$without_assigned_users}"; } $rs = Database::query($sql); $return .= '<select id="origin" name="NoAssignedUsersList[]" multiple="multiple" size="20" style="width:340px;">'; while ($user = Database::fetch_array($rs)) { $person_name = api_get_person_name($user['firstname'], $user['lastname']); $return .= '<option value="' . $user['user_id'] . '" title="' . htmlspecialchars($person_name, ENT_QUOTES) . '">' . $person_name . ' (' . $user['username'] . ')</option>'; } $return .= '</select>'; $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return)); } return $xajax_response; }
/** * Search users by username, firstname or lastname, based on the given * search string * @param string Search string * @param int Deprecated param * @return string Xajax response block * @assert () === false */ public static function search_users($needle, $id) { global $tbl_user, $tbl_access_url_rel_user; $xajax_response = new XajaxResponse(); $return = ''; if (!empty($needle)) { // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $needle = Database::escape_string($needle); // search users where username or firstname or lastname begins likes $needle $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $sql = 'SELECT u.user_id, username, lastname, firstname FROM ' . $tbl_user . ' u ' . ' WHERE (username LIKE "' . $needle . '%" ' . ' OR firstname LIKE "' . $needle . '%" ' . ' OR lastname LIKE "' . $needle . '%") ' . $order_clause . ' LIMIT 11'; $rs = Database::query($sql); $i = 0; while ($user = Database::fetch_array($rs)) { $i++; if ($i <= 10) { $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\'' . addslashes($user['user_id']) . '\',\'' . api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])) . ' (' . addslashes($user['username']) . ')' . '\')">' . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')</a><br />'; } else { $return .= '...<br />'; } } } $xajax_response->addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return)); return $xajax_response; }
/** * Constructor (generates a connection to the API) * @param string Clockworksms API key required to use the plugin * @return void */ public function __construct($apiKey = null) { $plugin = ClockworksmsPlugin::create(); $clockWorkSMSPlugin = $plugin->get('tool_enable'); if (empty($apiKey)) { $clockWorkSMSApiKey = $plugin->get('api_key'); } else { $clockWorkSMSApiKey = $apiKey; } $this->table = Database::get_main_table('user_field_values'); if ($clockWorkSMSPlugin == true) { $this->apiKey = $clockWorkSMSApiKey; // Setting Clockworksms api if (!defined('CONFIG_SECURITY_API_KEY')) { define('CONFIG_SECURITY_API_KEY', $this->apiKey); } $trimmedApiKey = trim(CONFIG_SECURITY_API_KEY); if (!empty($trimmedApiKey)) { $this->api = new Clockwork(CONFIG_SECURITY_API_KEY); } else { $this->api = new Clockwork(' '); $recipient_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $email_form = api_get_setting('emailAdministrator'); $emailsubject = 'Clockworksms error'; $emailbody = 'Key cannot be blank'; $sender_name = $recipient_name; $email_admin = $email_form; api_mail_html($recipient_name, $email_form, $emailsubject, $emailbody, $sender_name, $email_admin); } $this->plugin_enabled = true; } }
function mdo_generate_default_xml_metadata() { global $iso639_2_code, $ieee_xml; $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); if ($xhtDoc->htt_error) { give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); } $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); if ($xhtDoc->xht_xmldoc->error) { give_up($xhtDoc->xht_xmldoc->error); } $xhtDoc->xht_param['siteUri'] = make_uri(); $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Link.' . $this->mdo_id; // 2005-05-30: path->sysCode $xhtDoc->xht_param['location'] = $this->mdo_url . ''; $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : get_lang('MdTitle'); if ($d = $this->mdo_description) { if ($keywords = $this->_find_keywords($d)) { $d = array_pop($keywords); } $xhtDoc->xht_param['description'] = $d; } else { $xhtDoc->xht_param['description'] = get_lang('MdDescription'); } $xhtDoc->xht_param['coverage'] = $this->mdo_category_title ? $this->mdo_category_title : get_lang('MdCoverage'); if (isset($_user)) { $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n"; } $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); $xhtDoc->xht_param['format'] = ''; $xhtDoc->xht_param['size'] = '0'; if (count($keywords)) { $xd = new xmddoc(explode("\n", $mdt = $xhtDoc->xht_fill_template('XML'))); if ($xd->error) { return $mdt; } // and worry later $this->_add_keywords($xd, $keywords); return $xd->xmd_xml(); } return $xhtDoc->xht_fill_template('XML'); }
function search_coachs($needle) { $tbl_user = Database::get_main_table(TABLE_MAIN_USER); $xajax_response = new xajaxResponse(); $return = ''; if (!empty($needle)) { $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; // search users where username or firstname or lastname begins likes $needle $sql = 'SELECT username, lastname, firstname FROM ' . $tbl_user . ' user WHERE (username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%" OR lastname LIKE "' . $needle . '%") AND status=1' . $order_clause . ' LIMIT 10'; if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $sql = 'SELECT username, lastname, firstname FROM ' . $tbl_user . ' user INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = ' . $access_url_id . ' AND ( username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%" OR lastname LIKE "' . $needle . '%" ) AND status=1' . $order_clause . ' LIMIT 10'; } } $rs = Database::query($sql); while ($user = Database::fetch_array($rs)) { $return .= '<a href="javascript: void(0);" onclick="javascript: fill_coach_field(\'' . $user['username'] . '\')">' . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')</a><br />'; } } $xajax_response->addAssign('ajax_list_coachs', 'innerHTML', api_utf8_encode($return)); return $xajax_response; }
/** * Get document information */ private function get_information($course_id, $doc_id) { $course_information = api_get_course_info($course_id); $course_id = $course_information['real_id']; $course_path = $course_information['path']; if (!empty($course_information)) { $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY); $doc_table = Database::get_course_table(TABLE_DOCUMENT); $doc_id = Database::escape_string($doc_id); $sql = "SELECT * FROM {$doc_table}\n WHERE {$doc_table}.id = {$doc_id} AND c_id = {$course_id}\n LIMIT 1"; $dk_result = Database::query($sql); $sql = "SELECT insert_user_id FROM {$item_property_table}\n WHERE ref = {$doc_id} AND tool = '" . TOOL_DOCUMENT . "' AND c_id = {$course_id}\n LIMIT 1"; $name = ''; if ($row = Database::fetch_array($dk_result)) { $name = $row['title']; $url = api_get_path(WEB_PATH) . 'courses/%s/document%s'; $url = sprintf($url, $course_path, $row['path']); // Get the image path $icon = FileManager::choose_image(basename($row['path'])); $thumbnail = api_get_path(WEB_IMG_PATH) . $icon; $image = $thumbnail; //FIXME: use big images // get author $author = ''; $item_result = Database::query($sql); if ($row = Database::fetch_array($item_result)) { $user_data = api_get_user_info($row['insert_user_id']); $author = api_get_person_name($user_data['firstName'], $user_data['lastName']); } } return array($thumbnail, $image, $name, $author, $url); // FIXME: is it posible to get an author here? } else { return array(); } }
function mdo_generate_default_xml_metadata() { global $iso639_2_code, $ieee_xml; $xhtDoc = new xhtdoc($ieee_xml); $_user = api_get_user_info(); if ($xhtDoc->htt_error) { give_up('IEEE XML (metadata/md_funcs): ' . $xhtDoc->htt_error); } $xhtDoc->xht_get_lang = 'get_lang'; $xhtDoc->xht_xmldoc = new xmddoc(''); if ($xhtDoc->xht_xmldoc->error) { give_up($xhtDoc->xht_xmldoc->error); } $xhtDoc->xht_param['siteUri'] = make_uri(); $xhtDoc->xht_param['entry'] = $this->mdo_course['sysCode'] . '.Document.' . $this->mdo_id; // 2005-05-30: path->sysCode $xhtDoc->xht_param['location'] = api_get_path(WEB_PATH) . 'main/metadata/openobject.php?cidReq=' . urlencode($this->mdo_course['sysCode']) . '&eid=' . urlencode($this->mdo_eid); $xhtDoc->xht_param['mdlang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['lang'] = strtolower($iso639_2_code); $xhtDoc->xht_param['title'] = $this->mdo_title ? $this->mdo_title : ($this->mdo_path ? $this->mdo_path : get_lang('MdTitle', '')); $xhtDoc->xht_param['description'] = $this->mdo_comment ? $this->mdo_comment : get_lang('MdDescription', ''); $xhtDoc->xht_param['coverage'] = get_lang('MdCoverage', ''); if (isset($_user)) { $xhtDoc->xht_param['author'] = "BEGIN:VCARD\\nFN:" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\\nEMAIL:" . $_user['mail'] . "\\nEND:VCARD\\n"; } $xhtDoc->xht_param['dateTime'] = date('Y-m-d'); if ($this->mdo_filetype == 'folder') { $format = "inode/directory"; } else { require_once api_get_path(LIBRARY_PATH) . 'document.lib.php'; $format = DocumentManager::file_get_mime_type($this->mdo_path); } $xhtDoc->xht_param['format'] = $format; $xhtDoc->xht_param['size'] = ($s = filesize(get_course_path() . $this->mdo_course['path'] . '/document' . $this->mdo_path)) ? $s : '0'; return $xhtDoc->xht_fill_template('XML'); }
$count_pending_invitations = count($pending_invitations); } if (!empty($production_list) || !empty($file_list) || $count_pending_invitations > 0) { //Pending invitations if (!isset($_GET['u']) || isset($_GET['u']) && $_GET['u'] == api_get_user_id()) { if ($count_pending_invitations > 0) { $invitations = '<div><h3>' . get_lang('PendingInvitations') . '</h3></div>'; for ($i = 0; $i < $count_pending_invitations; $i++) { $user_invitation_id = $pending_invitations[$i]['user_sender_id']; $invitations .= '<div id="dpending_' . $user_invitation_id . '" class="friend_invitations">'; $invitations .= '<div style="float:left;width:60px;" >'; $invitations .= '<img style="margin-bottom:5px;"' . ' src="' . $list_get_path_web[$i]['dir'] . '/' . $list_get_path_web[$i]['file'] . '"' . ' width="60px">'; $invitations .= '</div>'; $invitations .= '<div style="padding-left:70px;">'; $user_invitation_info = api_get_user_info($user_invitation_id); $invitations .= '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php' . '?u=' . $user_invitation_id . '">' . api_get_person_name($user_invitation_info['firstname'], $user_invitation_info['lastname']) . '</a>'; $invitations .= '<br />'; $invitations .= Security::remove_XSS(cut($pending_invitations[$i]['content'], 50), STUDENT, true); $invitations .= '<br />'; $invitations .= '<a id="btn_accepted_' . $user_invitation_id . '"' . ' class="btn btn-default" onclick="register_friend(this)" href="javascript:void(0)">' . get_lang('SocialAddToFriends') . '</a>'; $invitations .= '<div id="id_response"></div>'; $invitations .= '</div>'; $invitations .= '</div>'; } $socialRightInformation .= SocialManager::social_wrapper_div($invitations, 4); } } // Productions $production_list = UserManager::build_production_list($user_id); $product_content = ''; if (!empty($production_list)) {
$possible_users = array(); $userGroup = new UserGroup(); if (!empty($complete_user_list)) { usort($complete_user_list, 'sort_users'); foreach ($complete_user_list as $index => $user) { $officialCode = !empty($user['official_code']) ? ' - ' . $user['official_code'] : null; $groups = $userGroup->getUserGroupListByUser($user['user_id']); $groupNameListToString = ''; if (!empty($groups)) { $groupNameList = array_column($groups, 'name'); $groupNameListToString = ' - [' . implode(', ', $groupNameList) . ']'; } $name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')' . $officialCode; if ($orderUserListByOfficialCode === 'true') { $officialCode = !empty($user['official_code']) ? $user['official_code'] . " - " : '? - '; $name = $officialCode . " " . api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')'; } $possible_users[$user['user_id']] = $name . $groupNameListToString; } } // Group members $group_member_list = GroupManager::get_subscribed_users($current_group['id']); $selected_users = array(); if (!empty($group_member_list)) { foreach ($group_member_list as $index => $user) { $selected_users[] = $user['user_id']; } } $group_members_element = $form->addElement('advmultiselect', 'group_members', get_lang('GroupMembers'), $possible_users, 'style="width: 280px;"'); $form->addFormRule('check_group_members'); // submit button
?> </option> <?php foreach ($coaches as $enreg) { ?> <option value="<?php echo $enreg['user_id']; ?> " <?php if (is_array($arr_infos) && in_array($enreg['user_id'], $arr_infos)) { echo 'selected="selected"'; } ?> > <?php echo api_get_person_name($enreg['firstname'], $enreg['lastname']) . ' (' . $enreg['username'] . ')'; ?> </option> <?php } unset($coaches); ?> </select> <div class="control"> <button class="btn btn-success" type="submit" name="name" value="<?php echo get_lang('AssignCoach'); ?> "> <em class="fa fa-plus"></em> <?php echo get_lang('AssignCoach');
?> </th> <th width="160px"><?php echo get_lang('Date'); ?> </th> </tr> <?php $sql = "SELECT *, quiz_question.question, firstname, lastname\n FROM {$TBL_TRACK_ATTEMPT_RECORDING} t, {$TBL_USER}, {$TBL_EXERCICES_QUESTION} quiz_question\n\t\tWHERE quiz_question.id = question_id AND\n user_id = author AND\n exe_id = '" . (int) $_GET['exe_id'] . "'\n ORDER BY position"; $query = Database::query($sql); while ($row = Database::fetch_array($query)) { echo '<tr'; if ($i % 2 == 0) { echo 'class="row_odd"'; } else { echo 'class="row_even"'; } echo '>'; echo '<td>' . $row['question'] . '</td>'; echo '<td>' . $row['marks'] . '</td>'; if (!empty($row['teacher_comment'])) { echo '<td>' . $row['teacher_comment'] . '</td>'; } else { echo '<td>' . get_lang('WithoutComment') . '</td>'; } echo '<td>' . (empty($row['firstname']) && empty($row['lastname']) ? '<i>' . get_lang('OriginalValue') . '</i>' : api_get_person_name($row['firstname'], $row['lastname'])) . '</td>'; echo '<td>' . api_convert_and_format_date($row['insert_date'], DATE_TIME_FORMAT_LONG) . '</td>'; echo '</tr>'; } echo '</table>'; Display::display_footer();
$url = api_get_self() . '?action=delete_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode; echo Display::url(get_lang('DeleteAllCertificates'), $url, array('class' => 'btn btn-default')); $hideCertificateExport = api_get_setting('hide_certificate_export_link'); if (count($certificate_list) > 0 && $hideCertificateExport !== 'true') { $url = api_get_self() . '?action=export_all_certificates' . '&' . api_get_cidReq() . '&cat_id=' . $cat_id . '&filter=' . $filterOfficialCode; echo Display::url(get_lang('ExportAllCertificatesToPDF'), $url, array('class' => 'btn btn-default')); } echo '</div>'; echo $filterForm; if (count($certificate_list) == 0) { echo Display::display_warning_message(get_lang('NoResultsAvailable')); } else { echo '<br /><br /><table class="data_table">'; foreach ($certificate_list as $index => $value) { echo '<tr> <td width="100%" class="actions">' . get_lang('Student') . ' : ' . api_get_person_name($value['firstname'], $value['lastname']) . ' (' . $value['username'] . ')</td>'; echo '</tr>'; echo '<tr><td> <table class="data_table">'; $list_certificate = GradebookUtils::get_list_gradebook_certificates_by_user_id($value['user_id'], $cat_id); foreach ($list_certificate as $value_certificate) { echo '<tr>'; echo '<td width="50%">' . get_lang('Score') . ' : ' . $value_certificate['score_certificate'] . '</td>'; echo '<td width="30%">' . get_lang('Date') . ' : ' . api_convert_and_format_date($value_certificate['created_at']) . '</td>'; echo '<td width="20%">'; $url = api_get_path(WEB_PATH) . 'certificates/index.php?id=' . $value_certificate['id']; $certificates = Display::url(get_lang('Certificate'), $url, array('target' => '_blank', 'class' => 'btn btn-default')); echo $certificates; echo '<a onclick="return confirmation();" href="gradebook_display_certificate.php?sec_token=' . $token . '&cidReq=' . $course_code . '&action=delete&cat_id=' . $cat_id . '&certificate_id=' . $value_certificate['id'] . '"> ' . Display::return_icon('delete.png', get_lang('Delete')) . ' </a>';
function WSCreateCourseByTitle($params) { global $firstExpirationDelay, $_configuration; if (!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } $table_course = Database::get_main_table(TABLE_MAIN_COURSE); $courses_params = $params['courses']; $results = array(); $orig_course_id_value = array(); foreach ($courses_params as $course_param) { $title = $course_param['title']; $category_code = 'LANG'; // TODO: A hard-coded value. $wanted_code = ''; $tutor_firstname = api_get_setting('administratorName'); $tutor_lastname = api_get_setting('administratorSurname'); $course_language = 'spanish'; // TODO: Incorrect default value, it should 'english'. if (!empty($course_param['course_language'])) { $course_language = $course_param['course_language']; } $tutor_name = api_get_person_name($tutor_firstname, $tutor_lastname, null, null, $course_language); if (!empty($course_param['tutor_name'])) { $tutor_name = $course_param['tutor_name']; } $original_course_id_name = $course_param['original_course_id_name']; $original_course_id_value = $course_param['original_course_id_value']; $orig_course_id_value[] = $course_param['original_course_id_value']; $extra_list = $course_param['extra']; // Ensure the database prefix + database name do not get over 40 characters $maxlength = 40; if (empty($wanted_code)) { $wanted_code = CourseManager::generate_course_code(substr($title, 0, $maxlength)); } $courseInfo = CourseManager::getCourseInfoFromOriginalId($original_course_id_value, $original_course_id_name); if (!empty($courseInfo)) { if ($courseInfo['visibility'] != 0) { $sql = "UPDATE {$table_course} SET\n course_language='" . Database::escape_string($course_language) . "',\n title='" . Database::escape_string($title) . "',\n category_code='" . Database::escape_string($category_code) . "',\n tutor_name='" . Database::escape_string($tutor_name) . "',\n visual_code='" . Database::escape_string($wanted_code) . "',\n visibility = '3'\n WHERE id ='" . $courseInfo['real_id'] . "'"; Database::query($sql); $results[] = $courseInfo['real_id']; continue; } else { $results[] = 0; continue; } } // Set default values. if (isset($_user['language']) && $_user['language'] != '') { $values['course_language'] = $_user['language']; } else { $values['course_language'] = api_get_setting('platformLanguage'); } $values['tutor_name'] = api_get_person_name($_user['firstName'], $_user['lastName'], null, null, $values['course_language']); $keys = AddCourse::define_course_keys($wanted_code, '', $_configuration['db_prefix']); $sql_check = sprintf('SELECT * FROM ' . $table_course . ' WHERE visual_code = "%s"', Database::escape_string($wanted_code)); $result_check = Database::query($sql_check); // I don't know why this api function doesn't work... if (Database::num_rows($result_check) < 1) { $params = array(); $params['title'] = $title; $params['wanted_code'] = $wanted_code; $params['category_code'] = $category_code; $params['tutor_name'] = $tutor_name; $params['course_language'] = $course_language; $params['user_id'] = api_get_user_id(); //$params['visibility'] = $visibility; $course_info = CourseManager::create_course($params); if (!empty($course_info)) { $course_code = $course_info['code']; // Save new fieldlabel into course_field table. CourseManager::create_course_extra_field($original_course_id_name, 1, $original_course_id_name, ''); // Save the external system's id into user_field_value table. CourseManager::update_course_extra_field_value($course_code, $original_course_id_name, $original_course_id_value); if (is_array($extra_list) && count($extra_list) > 0) { foreach ($extra_list as $extra) { $extra_field_name = $extra['field_name']; $extra_field_value = $extra['field_value']; // Save new fieldlabel into course_field table. CourseManager::create_course_extra_field($extra_field_name, 1, $extra_field_name, ''); // Save the external system's id into course_field_value table. CourseManager::update_course_extra_field_value($course_code, $extra_field_name, $extra_field_value); } } } $results[] = $course_code; continue; } else { $results[] = 0; continue; } } // end principal foreach $count_results = count($results); $output = array(); for ($i = 0; $i < $count_results; $i++) { $output[] = array('original_course_id_value' => $orig_course_id_value[$i], 'result' => $results[$i]); } return $output; }
$newPost = $iconEmpty; } } $html .= '<div class="col-md-6">'; $html .= '<div class="row">'; $html .= '<div class="col-md-2">'; $html .= Display::return_icon('post-forum.png', get_lang('Forum'), null, ICON_SIZE_SMALL); $html .= ' ' . $number_threads . '<br>' . $newPost . '</div>'; $html .= '<div class="col-md-6">'; // The last post in the forum. if ($forum['last_poster_name'] != '') { $name = $forum['last_poster_name']; $poster_id = 0; $username = ""; } else { $name = api_get_person_name($forum['last_poster_firstname'], $forum['last_poster_lastname']); $poster_id = $forum['last_poster_id']; $userinfo = api_get_user_info($poster_id); $username = sprintf(get_lang('LoginX'), $userinfo['username']); } if (!empty($forum['last_post_id'])) { $html .= Display::return_icon('post-item.png', null, null, ICON_SIZE_TINY) . ' ' . api_convert_and_format_date($forum['last_post_date']) . '<br /> ' . get_lang('By') . ' ' . display_user_link($poster_id, $name, '', $username); } $html .= '</div>'; $html .= '<div class="col-md-4">'; if (api_is_allowed_to_edit(false, true) && !($forum['session_id'] == 0 && intval($sessionId) != 0)) { $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=edit&content=forum&id=' . $forum['forum_id'] . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= '<a href="' . api_get_self() . '?' . api_get_cidreq() . '&action=delete&content=forum&id=' . $forum['forum_id'] . "\" onclick=\"javascript:if(!confirm('" . addslashes(api_htmlentities(get_lang('DeleteForum'), ENT_QUOTES)) . "')) return false;\">" . Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL) . '</a>'; $html .= return_visible_invisible_icon('forum', $forum['forum_id'], $forum['visibility']); $html .= return_lock_unlock_icon('forum', $forum['forum_id'], $forum['locked']); $html .= return_up_down_icon('forum', $forum['forum_id'], $forumsInCategory);
if ($affected_rows) { $msg = get_lang('AssignedSessionsHaveBeenUpdatedSuccessfully'); } } // display header Display::display_header($tool_name); // actions echo '<div class="actions">'; if ($user_info['status'] != SESSIONADMIN) { echo '<span style="float: right;margin:0px;padding:0px;"> <a href="dashboard_add_users_to_user.php?user='******'">' . Display::return_icon('add_user_big.gif', get_lang('AssignUsers'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AssignUsers') . '</a> <a href="dashboard_add_courses_to_user.php?user='******'">' . Display::return_icon('course_add.gif', get_lang('AssignCourses'), array('style' => 'vertical-align:middle')) . ' ' . get_lang('AssignCourses') . '</a> </span>'; } echo '</div>'; echo Display::page_header(sprintf(get_lang('AssignSessionsToX'), api_get_person_name($user_info['firstname'], $user_info['lastname']))); $assigned_sessions_to_hrm = SessionManager::get_sessions_followed_by_drh($user_id); $assigned_sessions_id = array_keys($assigned_sessions_to_hrm); $without_assigned_sessions = ''; if (count($assigned_sessions_id) > 0) { $without_assigned_sessions = " AND s.id NOT IN(" . implode(',', $assigned_sessions_id) . ")"; } $needle = '%'; if (isset($_POST['firstLetterSession'])) { $needle = Database::escape_string($_POST['firstLetterSession']); $needle = "{$needle}%"; } if ($_configuration['multiple_access_urls']) { $sql = " SELECT s.id, s.name FROM {$tbl_session} s LEFT JOIN {$tbl_session_rel_access_url} a ON (s.id = a.session_id)\n\t\t\t\tWHERE s.name LIKE '{$needle}%' {$without_assigned_sessions} AND access_url_id = " . api_get_current_access_url_id() . "\n ORDER BY s.name"; } else { $sql = " SELECT s.id, s.name FROM {$tbl_session} s\n\t\t\t\tWHERE s.name LIKE '{$needle}%' {$without_assigned_sessions}\n ORDER BY s.name\n ";
//filtered by post-condition $id = intval($_GET['exeid']); $track_exercise_info = ExerciseLib::get_exercise_track_exercise_info($id); if (empty($track_exercise_info)) { api_not_allowed(); } $test = $track_exercise_info['title']; $student_id = $track_exercise_info['exe_user_id']; $session_id = $track_exercise_info['session_id']; $lp_id = $track_exercise_info['orig_lp_id']; //$lp_item_id = $track_exercise_info['orig_lp_item_id']; $lp_item_view_id = $track_exercise_info['orig_lp_item_view_id']; $course_info = api_get_course_info(); // Teacher data $teacher_info = api_get_user_info(api_get_user_id()); $from_name = api_get_person_name($teacher_info['firstname'], $teacher_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $url = api_get_path(WEB_CODE_PATH) . 'exercice/result.php?id=' . $track_exercise_info['exe_id'] . '&' . api_get_cidreq() . '&show_headers=1&id_session=' . $session_id; $my_post_info = array(); $post_content_id = array(); $comments_exist = false; foreach ($_POST as $key_index => $key_value) { $my_post_info = explode('_', $key_index); $post_content_id[] = $my_post_info[1]; if ($my_post_info[0] == 'comments') { $comments_exist = true; } } $loop_in_track = $comments_exist === true ? count($_POST) / 2 : count($_POST); $array_content_id_exe = array(); if ($comments_exist === true) { $array_content_id_exe = array_slice($post_content_id, $loop_in_track);
if(lesson_status != '') { result=lesson_status; } else{ result='not attempted'; } break; case 'cmi.core.student_id' : result='<?php echo $_user['user_id']; ?> '; break; case 'cmi.core.student_name' : <?php $who = addslashes(api_get_person_name($_user['firstName'], $_user['lastName'])); echo "result='{$who}';"; ?> break; case 'cmi.core.lesson_location' : result=''; break; case 'cmi.core.total_time' : result=total_time; break; case 'cmi.core.score._children' : result='raw,min,max'; break; case 'cmi.core.score.raw' : result=score; break;
$friend_group_id = ''; if (isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['id'] == $group_id) { $friend_group_id = $group_id; } if (!isset($group_friend_list[$group_id]) || isset($group_friend_list[$group_id]) && $group_friend_list[$group_id]['relation_type'] == '') { $Users[$friend['friend_user_id']] = array('user_id' => $friend['friend_user_id'], 'firstname' => $friend['firstName'], 'lastname' => $friend['lastName'], 'username' => $friend['username'], 'group_id' => $friend_group_id); } } else { $Users[$friend['friend_user_id']] = array('user_id' => $friend['friend_user_id'], 'firstname' => $friend['firstName'], 'lastname' => $friend['lastName'], 'username' => $friend['username'], 'group_id' => null); } } } if (is_array($Users) && count($Users) > 0) { foreach ($Users as $user) { if ($user['group_id'] != $group_id) { $nosessionUsersList[$user['user_id']] = api_get_person_name($user['firstname'], $user['lastname']); } } } $social_left_content = SocialManager::show_social_menu('invite_friends', $group_id); $social_right_content = '<h2>' . Security::remove_XSS($group_info['name'], STUDENT, true) . '</h2>'; if (count($nosessionUsersList) == 0) { $friends = SocialManager::get_friends(api_get_user_id()); if ($friends == 0) { $social_right_content .= get_lang('YouNeedToHaveFriendsInYourSocialNetwork'); } else { $social_right_content .= get_lang('YouAlreadyInviteAllYourContacts'); } $social_right_content .= '<div>'; $social_right_content .= '<a href="search.php">' . get_lang('TryAndFindSomeFriends') . '</a>'; $social_right_content .= '</div>';
/** * Get actual array data * @return array 2-dimensional array - each array contains the elements: * 0: user id * 1: user lastname * 2: user firstname * 3+: evaluation/link scores */ public function get_data($users_sorting = 0, $users_start = 0, $users_count = null, $items_start = 0, $items_count = null, $ignore_score_color = false, $show_all = false) { // do some checks on users/items counts, redefine if invalid values if (!isset($users_count)) { $users_count = count($this->users) - $users_start; } if ($users_count < 0) { $users_count = 0; } if (!isset($items_count)) { $items_count = count($this->evals) + count($this->links) - $items_start; } if ($items_count < 0) { $items_count = 0; } // copy users to a new array that we will sort // TODO - needed ? $userTable = array(); foreach ($this->users as $user) { $userTable[] = $user; } // sort users array if ($users_sorting & self::FVDG_SORT_LASTNAME) { usort($userTable, array('FlatViewDataGenerator', 'sort_by_last_name')); } elseif ($users_sorting & self::FVDG_SORT_FIRSTNAME) { usort($userTable, array('FlatViewDataGenerator', 'sort_by_first_name')); } if ($users_sorting & self::FVDG_SORT_DESC) { $userTable = array_reverse($userTable); } // select the requested users $selected_users = array_slice($userTable, $users_start, $users_count); // generate actual data array $scoredisplay = ScoreDisplay::instance(); $data = array(); $displaytype = SCORE_DIV; if ($ignore_score_color) { $displaytype |= SCORE_IGNORE_SPLIT; } //@todo move these in a function $sum_categories_weight_array = array(); $mainCategoryId = null; $mainCourseCategory = $this->getMainCourseCategory(); if (!empty($mainCourseCategory)) { $mainCategoryId = $mainCourseCategory->get_id(); } if (isset($this->category) && !empty($this->category)) { $categories = Category::load(null, null, null, $this->category->get_id()); if (!empty($categories)) { foreach ($categories as $category) { $sum_categories_weight_array[$category->get_id()] = $category->get_weight(); } } else { $sum_categories_weight_array[$this->category->get_id()] = $this->category->get_weight(); } } $parent_id = $this->category->get_parent_id(); if ($parent_id == 0 or $this->params['only_subcat'] == $this->category->get_id()) { $main_weight = $this->category->get_weight(); $grade_model_id = $this->category->get_grade_model_id(); } else { $main_cat = Category::load($parent_id, null, null); $main_weight = $main_cat[0]->get_weight(); $grade_model_id = $main_cat[0]->get_grade_model_id(); } $use_grade_model = true; if (empty($grade_model_id) || $grade_model_id == -1) { $use_grade_model = false; } $export_to_pdf = false; if (isset($this->params['export_pdf']) && $this->params['export_pdf']) { $export_to_pdf = true; } foreach ($selected_users as $user) { $row = array(); if ($export_to_pdf) { $row['user_id'] = $user_id = $user[0]; //user id } else { $row[] = $user_id = $user[0]; //user id } if (isset($this->params['show_official_code']) && $this->params['show_official_code']) { if ($export_to_pdf) { $row['official_code'] = $user[4]; //official code } else { $row[] = $user[4]; //official code } } if (isset($this->params['join_firstname_lastname']) && $this->params['join_firstname_lastname']) { if ($export_to_pdf) { $row['name'] = api_get_person_name($user[3], $user[2]); //last name } else { $row[] = api_get_person_name($user[3], $user[2]); //last name } } else { if ($export_to_pdf) { if (api_is_western_name_order()) { $row['firstname'] = $user[3]; $row['lastname'] = $user[2]; } else { $row['lastname'] = $user[2]; $row['firstname'] = $user[3]; } } else { if (api_is_western_name_order()) { $row[] = $user[3]; //first name $row[] = $user[2]; //last name } else { $row[] = $user[2]; //last name $row[] = $user[3]; //first name } } } $item_value = 0; $item_value_total = 0; $item_total = 0; $convert_using_the_global_weight = true; $course_code = api_get_course_id(); $session_id = api_get_session_id(); $allcat = $this->category->get_subcategories(null, $course_code, $session_id, 'ORDER BY id'); $evaluationsAdded = array(); if ($parent_id == 0 && !empty($allcat)) { foreach ($allcat as $sub_cat) { $score = $sub_cat->calc_score($user_id); $real_score = $score; $divide = $score[1] == 0 ? 1 : $score[1]; $sub_cat_percentage = $sum_categories_weight_array[$sub_cat->get_id()]; $item_value = $score[0] / $divide * $main_weight; //Fixing total when using one or multiple gradebooks $percentage = $sub_cat->get_weight() / $sub_cat_percentage * $sub_cat_percentage / $this->category->get_weight(); $item_value = $percentage * $item_value; $item_total += $sub_cat->get_weight(); /* if ($convert_using_the_global_weight) { $score[0] = $score[0]/$main_weight*$sub_cat->get_weight(); $score[1] = $main_weight ; } */ if (api_get_setting('gradebook_show_percentage_in_reports') == 'false') { //if (true) { $real_score = $scoredisplay->display_score($real_score, SCORE_SIMPLE); $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($real_score, $temp_score); } else { $real_score = $scoredisplay->display_score($real_score, SCORE_DIV_PERCENT, SCORE_ONLY_SCORE); $temp_score = $scoredisplay->display_score($score, SCORE_DIV_SIMPLE_WITH_CUSTOM); $temp_score = Display::tip($temp_score, $real_score); } if (!isset($this->params['only_total_category']) || isset($this->params['only_total_category']) && $this->params['only_total_category'] == false) { if (!$show_all) { $row[] = $temp_score . ' '; } else { $row[] = $temp_score; } } $item_value_total += $item_value; } if ($convert_using_the_global_weight) { //$item_total = $main_weight; } } else { $result = $this->parseEvaluations($user_id, $sum_categories_weight_array, $items_count, $items_start, $show_all, $row); $item_total += $result['item_total']; $item_value_total += $result['item_value_total']; $evaluationsAdded = $result['evaluations_added']; $item_total = $main_weight; } // All evaluations $result = $this->parseEvaluations($user_id, $sum_categories_weight_array, $items_count, $items_start, $show_all, $row, $mainCategoryId, $evaluationsAdded); $item_total += $result['item_total']; $item_value_total += $result['item_value_total']; $total_score = array($item_value_total, $item_total); if (!$show_all) { if ($export_to_pdf) { $row['total'] = $scoredisplay->display_score($total_score); } else { $row[] = $scoredisplay->display_score($total_score); } } else { if ($export_to_pdf) { $row['total'] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS); } else { $row[] = $scoredisplay->display_score($total_score, SCORE_DIV_SIMPLE_WITH_CUSTOM_LETTERS); } } unset($score); $data[] = $row; } return $data; }
} } } elseif (api_get_setting('social.allow_social_tool') == 'false' && api_get_setting('message.allow_message_tool') == 'true') { if (api_get_setting('message.allow_send_message_to_all_platform_users') == 'true') { $sql = "SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n FROM {$tbl_user} u LEFT JOIN {$tbl_access_url_rel_user} r ON u.user_id = r.user_id\n WHERE\n u.status <> 6 AND\n u.user_id <> {$user_id} AND\n r.access_url_id = {$access_url_id}\n {$likeCondition} "; } else { $time_limit = api_get_setting('display.time_limit_whosonline'); $online_time = time() - $time_limit * 60; $limit_date = api_get_utc_datetime($online_time); $sql = "SELECT SELECT DISTINCT u.user_id as id, u.firstname, u.lastname, u.email\n FROM {$tbl_my_user} u INNER JOIN {$track_online_table} t\n ON u.user_id=t.login_user_id\n WHERE login_date >= '" . $limit_date . "' AND\n {$likeCondition}"; } } $sql .= ' LIMIT 20'; $result = Database::query($sql); $showEmail = api_get_setting('display.show_email_addresses'); $return = array(); if (Database::num_rows($result) > 0) { while ($row = Database::fetch_array($result, 'ASSOC')) { $name = api_get_person_name($row['firstname'], $row['lastname']); if ($showEmail == 'true') { $name .= ' (' . $row['email'] . ')'; } $return['items'][] = array('text' => $name, 'id' => $row['id']); } } echo json_encode($return); break; default: echo ''; } exit;
while ($ar['id'] != '') { $lp_title = stripslashes($ar['name']); //echo "<a href='".api_get_self()."?view=".$view."&scormcontopen=".$ar['id']."' class='specialLink'>$lp_title</a>"; if ($ar['id'] == $scormcontopen) { //have to list the students here $contentId = $ar['id']; $sql2 = "SELECT u.user_id, u.lastname, u.firstname " . "FROM {$tbl_learnpath_view} sd " . "INNER JOIN {$table_user} u " . "ON u.user_id = sd.user_id " . "WHERE sd.c_id = {$course_id} AND sd.lp_id={$contentId} group by u.user_id"; //error_log($sql2,0); $result2 = Database::query($sql2); if (Database::num_rows($result2) > 0) { $ar2 = Database::fetch_array($result2); while ($ar2 != '') { if (isset($_REQUEST["scormstudentopen"]) && $ar2['user_id'] == $scormstudentopen) { $line .= $ar['id'] . " " . $ar2['user_id'] . " " . api_get_person_name($ar2['firstname'], $ar2['lastname']); } else { $line .= $ar['id'] . " " . $ar2['user_id'] . " " . api_get_person_name($ar2['firstname'], $ar2['lastname']); } if ($ar2['user_id'] == $scormstudentopen) { //have to list the student's results $studentId = $ar2['user_id']; $sql3 = "SELECT iv.status, iv.score, i.title, iv.total_time " . "FROM {$tbl_learnpath_item} i " . "INNER JOIN {$tbl_learnpath_item_view} iv ON i.id=iv.lp_item_id " . "INNER JOIN {$tbl_learnpath_view} v ON iv.lp_view_id=v.id " . "WHERE \ti.c_id = {$course_id} AND\n \t\tiv.c_id = {$course_id} AND\n \t\tv.c_id = {$course_id} AND\n \t\t\t\tv.user_id={$studentId} and v.lp_id={$contentId} ORDER BY v.id, i.id"; $result3 = Database::query($sql3); $ar3 = Database::fetch_array($result3); $title_line .= get_lang('ScormTitleColumn') . ";" . get_lang('ScormStatusColumn') . ";" . get_lang('ScormScoreColumn') . ";" . get_lang('ScormTimeColumn'); while ($ar3['status'] != '') { require_once '../newscorm/learnpathItem.class.php'; $time = learnpathItem::getScormTimeFromParameter('php', $ar3['total_time']); $line .= $title . ";" . $ar3['status'] . ";" . $ar3['score'] . ";" . $time; $ar3 = Database::fetch_array($result3); } }
} if ($row['thread_sticky'] == 1) { echo Display::return_icon('exclamation.gif'); } echo '</td>'; echo '<td>'; echo '<a href="viewthread.php?' . api_get_cidreq() . '&forum=' . Security::remove_XSS($my_forum) . '&origin=' . $origin . '&thread=' . $row['thread_id'] . $origin_string . '&search=' . Security::remove_XSS(urlencode($my_search)) . '" ' . class_visible_invisible($row['visibility']) . '>' . prepare4display($row['thread_title']) . '</a></td>'; echo '<td>' . $row['thread_replies'] . '</td>'; echo '<td>' . $row['thread_views'] . '</td>'; // display the author name $tab_poster_info = api_get_user_info($row['user_id']); $poster_username = sprintf(get_lang('LoginX'), $tab_poster_info['username']); if ($origin != 'learnpath') { echo '<td>' . display_user_link($row['user_id'], api_get_person_name($row['firstname'], $row['lastname']), '', $poster_username) . '</td>'; } else { echo '<td>' . Display::tag('span', api_get_person_name($row['firstname'], $row['lastname']), array("title" => api_htmlentities($poster_username, ENT_QUOTES))) . '</td>'; } $last_post_info = get_last_post_by_thread($row['c_id'], $row['thread_id'], $row['forum_id'], is_allowed_to_edit()); $last_post = null; if ($last_post_info) { $poster_info = api_get_user_info($last_post_info['poster_id']); $post_date = api_convert_and_format_date($last_post_info['post_date']); $last_post = $post_date . ' ' . get_lang('By') . ' ' . display_user_link($last_post_info['poster_id'], $poster_info['complete_name'], '', $poster_info['username']); } /* if ($row['last_poster_user_id'] == '0') { $name = $row['poster_name']; $last_poster_username = ""; } else { $name = api_get_person_name($row['last_poster_firstname'], $row['last_poster_lastname']); $tab_last_poster_info = api_get_user_info($row['last_poster_user_id']);
/** * Set footer parameters */ private function set_footer_parameters() { global $_configuration; //Show admin data //$this->assign('show_administrator_data', api_get_setting('show_administrator_data')); if (api_get_setting('show_administrator_data') == 'true') { //Administrator name $administrator_data = get_lang('Manager').' : '.Display::encrypted_mailto_link( api_get_setting('emailAdministrator'), api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')) ); $this->assign('administrator_name', $administrator_data); } //Loading footer extra content if (!api_is_platform_admin()) { $extra_footer = trim(api_get_setting('footer_extra_content')); if (!empty($extra_footer)) { $this->assign('footer_extra_content', $extra_footer); } } //Tutor name if (api_get_setting('show_tutor_data') == 'true') { // Course manager $id_course = api_get_course_id(); $id_session = api_get_session_id(); if (isset($id_course) && $id_course != -1) { $tutor_data = ''; if ($id_session != 0) { $coachs_email = CourseManager::get_email_of_tutor_to_session($id_session, $id_course); $email_link = array(); foreach ($coachs_email as $coach) { $email_link[] = Display::encrypted_mailto_link($coach['email'], $coach['complete_name']); } if (count($coachs_email) > 1) { $tutor_data .= get_lang('Coachs').' : '; $tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR); } elseif (count($coachs_email) == 1) { $tutor_data .= get_lang('Coach').' : '; $tutor_data .= array_to_string($email_link, CourseManager::USER_SEPARATOR); } elseif (count($coachs_email) == 0) { $tutor_data .= ''; } } $this->assign('session_teachers', $tutor_data); } } if (api_get_setting('show_teacher_data') == 'true') { // course manager $id_course = api_get_course_id(); if (isset($id_course) && $id_course != -1) { $teacher_data = ''; $mail = CourseManager::get_emails_of_tutors_to_course($id_course); if (!empty($mail)) { $teachers_parsed = array(); foreach ($mail as $value) { foreach ($value as $email => $name) { $teachers_parsed[] = Display::encrypted_mailto_link($email, $name); } } $label = get_lang('Teacher'); if (count($mail) > 1) { $label = get_lang('Teachers'); } $teacher_data .= $label.' : '.array_to_string($teachers_parsed, CourseManager::USER_SEPARATOR); } $this->assign('teachers', $teacher_data); } } /* $stats = ''; $this->assign('execution_stats', $stats); */ }
/** * @param array $group_list * @param int $category_id */ static function process_groups($group_list, $category_id = null) { global $origin, $charset; $category_id = intval($category_id); $totalRegistered = 0; $group_data = array(); $user_info = api_get_user_info(); $session_id = api_get_session_id(); $user_id = $user_info['user_id']; $orig = isset($origin) ? $origin : null; foreach ($group_list as $this_group) { // Validation when belongs to a session $session_img = api_get_session_image($this_group['session_id'], $user_info['status']); // All the tutors of this group $tutorsids_of_group = self::get_subscribed_tutors($this_group['id'], true); // Create a new table-row $row = array(); // Checkbox if (api_is_allowed_to_edit(false, true) && count($group_list) > 1) { $row[] = $this_group['id']; } // Group name if ((api_is_allowed_to_edit(false, true) || in_array($user_id, $tutorsids_of_group) || $this_group['is_member'] || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_FORUM) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_DOCUMENTS) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_CALENDAR) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_ANNOUNCEMENT) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WORK) || self::user_has_access($user_id, $this_group['id'], self::GROUP_TOOL_WIKI)) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $group_name = '<a href="group_space.php?cidReq=' . api_get_course_id() . '&origin=' . $orig . '&gidReq=' . $this_group['id'] . '">' . Security::remove_XSS($this_group['name']) . '</a> '; if (!empty($user_id) && !empty($this_group['id_tutor']) && $user_id == $this_group['id_tutor']) { $group_name .= Display::label(get_lang('OneMyGroups'), 'success'); } elseif ($this_group['is_member']) { $group_name .= Display::label(get_lang('MyGroup'), 'success'); } if (api_is_allowed_to_edit() && !empty($this_group['session_name'])) { $group_name .= ' (' . $this_group['session_name'] . ')'; } $group_name .= $session_img; $row[] = $group_name . '<br />' . stripslashes(trim($this_group['description'])); } else { $row[] = $this_group['name'] . '<br />' . stripslashes(trim($this_group['description'])); } // Tutor name $tutor_info = null; if (count($tutorsids_of_group) > 0) { foreach ($tutorsids_of_group as $tutor_id) { $tutor = api_get_user_info($tutor_id); $username = api_htmlentities(sprintf(get_lang('LoginX'), $tutor['username']), ENT_QUOTES); if (api_get_setting('show_email_addresses') == 'true') { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { if (api_is_allowed_to_edit()) { $tutor_info .= Display::tag('span', Display::encrypted_mailto_link($tutor['mail'], api_get_person_name($tutor['firstName'], $tutor['lastName'])), array('title' => $username)) . ', '; } else { $tutor_info .= Display::tag('span', api_get_person_name($tutor['firstName'], $tutor['lastName']), array('title' => $username)) . ', '; } } } } $tutor_info = api_substr($tutor_info, 0, api_strlen($tutor_info) - 2); $row[] = $tutor_info; // Max number of members in group $max_members = $this_group['maximum_number_of_members'] == self::MEMBER_PER_GROUP_NO_LIMIT ? ' ' : ' / ' . $this_group['maximum_number_of_members']; // Number of members in group $row[] = $this_group['number_of_members'] . $max_members; // Self-registration / unregistration if (!api_is_allowed_to_edit(false, true)) { if (self::is_self_registration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_reg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfRegInf') . '</a>'; } elseif (self::is_self_unregistration_allowed($user_id, $this_group['id'])) { $row[] = '<a class = "btn" href="group.php?' . api_get_cidreq() . '&category=' . $category_id . '&action=self_unreg&group_id=' . $this_group['id'] . '" onclick="javascript:if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "'" . ')) return false;">' . get_lang('GroupSelfUnRegInf') . '</a>'; } else { $row[] = '-'; } } $url = api_get_path(WEB_CODE_PATH) . 'group/'; // Edit-links if (api_is_allowed_to_edit(false, true) && !(api_is_course_coach() && intval($this_group['session_id']) != $session_id)) { $edit_actions = '<a href="' . $url . 'settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('EditGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'member_settings.php?' . api_get_cidreq(true, false) . '&gidReq=' . $this_group['id'] . '" title="' . get_lang('GroupMembers') . '">' . Display::return_icon('user.png', get_lang('GroupMembers'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . $url . 'group_overview.php?action=export&type=xls&' . api_get_cidreq(true, false) . '&id=' . $this_group['id'] . '" title="' . get_lang('ExportUsers') . '">' . Display::return_icon('export_excel.png', get_lang('Export'), '', ICON_SIZE_SMALL) . '</a> '; /*$edit_actions .= '<a href="'.api_get_self().'?'.api_get_cidreq(true, false).'&category='.$category_id.'&action=empty_one&id='.$this_group['id'].'" onclick="javascript: if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;" title="'.get_lang('EmptyGroup').'">'. Display::return_icon('clean.png',get_lang('EmptyGroup'),'',ICON_SIZE_SMALL).'</a> ';*/ $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=fill_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('FillGroup') . '">' . Display::return_icon('fill.png', get_lang('FillGroup'), '', ICON_SIZE_SMALL) . '</a> '; $edit_actions .= '<a href="' . api_get_self() . '?' . api_get_cidreq(true, false) . '&category=' . $category_id . '&action=delete_one&id=' . $this_group['id'] . '" onclick="javascript: if(!confirm(' . "'" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES)) . "'" . ')) return false;" title="' . get_lang('Delete') . '">' . Display::return_icon('delete.png', get_lang('Delete'), '', ICON_SIZE_SMALL) . '</a> '; $row[] = $edit_actions; } if (!empty($this_group['nbMember'])) { $totalRegistered = $totalRegistered + $this_group['nbMember']; } $group_data[] = $row; } // end loop $table = new SortableTableFromArrayConfig($group_data, 1, 20, 'group_category_' . $category_id); $table->set_additional_parameters(array('category' => $category_id)); $column = 0; if (api_is_allowed_to_edit(false, true) and count($group_list) > 1) { $table->set_header($column++, '', false); } $table->set_header($column++, get_lang('Groups')); $table->set_header($column++, get_lang('GroupTutor')); $table->set_header($column++, get_lang('Registered'), false); if (!api_is_allowed_to_edit(false, true)) { // If self-registration allowed $table->set_header($column++, get_lang('GroupSelfRegistration'), false); } if (api_is_allowed_to_edit(false, true)) { // Only for course administrator $table->set_header($column++, get_lang('Modify'), false); $form_actions = array(); $form_actions['fill_selected'] = get_lang('FillGroup'); $form_actions['empty_selected'] = get_lang('EmptyGroup'); $form_actions['delete_selected'] = get_lang('Delete'); if (count($group_list) > 1) { $table->set_form_actions($form_actions, 'group'); } } $table->display(); }
/** * Asks the author (through e-mail) for additional information about the given course request. * @param int/string $id The database primary id of the given request. * @return bool Returns TRUE on success or FALSE on failure. */ public static function ask_for_additional_info($id) { $id = (int) $id; // Retrieve request's data $course_request_info = self::get_course_request_info($id); if (!is_array($course_request_info)) { return false; } $user_id = intval($course_request_info['user_id']); if ($user_id <= 0) { return false; } $user_info = api_get_user_info($user_id); if (!is_array($user_info)) { return false; } $code = $course_request_info['code']; $info = intval($course_request_info['info']); // Error is to be returned on a repeated attempt for asking additional information. if (!empty($info)) { return false; } // E-mail notification. // E-mail language: The platform language seems to be the best choice. $email_language = api_get_setting('platformLanguage'); $email_subject = sprintf(get_lang('CourseRequestAskInfoEmailSubject', null, $email_language), '[' . api_get_setting('siteName') . ']', $code); $email_body = get_lang('Dear', null, $email_language) . ' '; $email_body .= api_get_person_name($user_info['firstname'], $user_info['lastname'], null, null, $email_language) . ",\n\n"; $email_body .= sprintf(get_lang('CourseRequestAskInfoEmailText', null, $email_language), $code) . "\n"; $email_body .= "\n" . get_lang('Formula', null, $email_language) . "\n"; $email_body .= api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname')) . "\n"; $email_body .= get_lang('Manager', null, $email_language) . ' ' . api_get_setting('siteName') . "\n"; $email_body .= get_lang('Phone', null, $email_language) . ': ' . api_get_setting('administratorTelephone') . "\n"; $email_body .= get_lang('Email', null, $email_language) . ': ' . api_get_setting('emailAdministrator') . "\n"; $email_body .= "\n" . get_lang('CourseRequestLegalNote', null, $email_language) . "\n"; $sender_name = api_get_person_name(api_get_setting('administratorName'), api_get_setting('administratorSurname'), null, PERSON_NAME_EMAIL_ADDRESS); $sender_email = api_get_setting('emailAdministrator'); $recipient_name = api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); $recipient_email = $user_info['mail']; $extra_headers = 'Bcc: ' . $sender_email; $additionalParameters = array('smsType' => SmsPlugin::COURSE_OPENING_REQUEST_CODE, 'userId' => $user_id, 'courseCode' => $code); $result = api_mail_html($recipient_name, $recipient_email, $email_subject, $email_body, $sender_name, $sender_email, null, null, null, $additionalParameters); if (!$result) { return false; } // Marking the fact that additional information about the request has been asked. $sql = "UPDATE " . Database::get_main_table(TABLE_MAIN_COURSE_REQUEST) . "\n SET info = 1 WHERE id = " . $id; $result = Database::query($sql) !== false; return $result; }
} } $inserted_in_course = array(); if (strcmp($file_type, 'csv') === 0) { updateUsers($users_to_insert); } if (count($errors) > 0) { $see_message_import = get_lang('FileImportedJustUsersThatAreNotRegistered'); } else { $see_message_import = get_lang('FileImported'); } if (count($errors) != 0) { $warning_message = '<ul>'; foreach ($errors as $index => $error_user) { $warning_message .= '<li><b>' . $error_user['error'] . '</b>: '; $warning_message .= '<strong>' . $error_user['UserName'] . '</strong> (' . api_get_person_name($error_user['FirstName'], $error_user['LastName']) . ')'; $warning_message .= '</li>'; } $warning_message .= '</ul>'; } // if the warning message is too long then we display the warning message trough a session if ($error_kind_file) { Display::addFlash(Display::return_message(get_lang('YouMustImportAFileAccordingToSelectedOption'))); } else { Display::addFlash(Display::return_message($see_message_import)); header('Location: ' . api_get_path(WEB_CODE_PATH) . 'admin/user_list.php?&sec_token=' . $tok); exit; } } Display::display_header($tool_name); $form = new FormValidator('user_update_import', 'post', api_get_self());
<td width="40%" align="center"> <select name="UserList[]" multiple="multiple" size="20" style="width:300px;"> <?php foreach ($db_users as $user) { ?> <option value="<?php echo $user['user_id']; ?> " <?php if (in_array($user['user_id'], $users)) { echo 'selected="selected"'; } ?> > <?php $userName = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ')'; if ($showOfficialCode) { $officialCode = !empty($user['official_code']) ? $user['official_code'] . ' - ' : '? - '; $userName = $officialCode . $userName; } echo $userName; ?> </option> <?php } ?> </select> </td> <td width="20%" valign="middle" align="center"> <button type="submit" class="add" value="<?php echo get_lang('AddToThatCourse');
public function get_students_content_html_for_drh() { $attendance = new Attendance(); $students = $this->students; $content = '<div style="margin:5px;">'; $content .= '<h3><font color="#000">' . get_lang('YourStudents') . '</font></h3>'; $students_table = null; if (count($students) > 0) { $students_table .= '<table class="data_table">'; $students_table .= '<tr> <th>' . get_lang('User') . '</th> <th>' . get_lang('AttendancesFaults') . '</th> <th>' . get_lang('Evaluations') . '</th> </tr>'; $i = 1; foreach ($students as $student) { $student_id = $student['user_id']; $firstname = $student['firstname']; $lastname = $student['lastname']; $username = $student['username']; // get average of faults in attendances by student $results_faults_avg = $attendance->get_faults_average_inside_courses($student_id); if (!empty($results_faults_avg)) { $attendances_faults_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . $results_faults_avg['faults'] . '/' . $results_faults_avg['total'] . ' (' . $results_faults_avg['porcent'] . '%)</a>'; } else { $attendances_faults_avg = '0%'; } $courses_by_user = CourseManager::get_courses_list_by_user_id($student_id, true); $evaluations_avg = 0; $score = $weight = 0; foreach ($courses_by_user as $course) { $course_code = $course['code']; $cats = Category::load(null, null, $course_code, null, null, null, false); $scoretotal = array(); if (isset($cats) && isset($cats[0])) { $scoretotal = $cats[0]->calc_score($student_id, $course_code); } if (!empty($scoretotal)) { $score += $scoretotal[0]; $weight += $scoretotal[1]; } } if (!empty($weight)) { $evaluations_avg = '<a title="' . get_lang('GoToStudentDetails') . '" href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/myStudents.php?student=' . $student_id . '">' . round($score, 2) . '/' . round($weight, 2) . '(' . round($score / $weight * 100, 2) . ' %)</a>'; } if ($i % 2 == 0) { $class_tr = 'row_odd'; } else { $class_tr = 'row_even'; } $students_table .= '<tr class="' . $class_tr . '"> <td>' . api_get_person_name($firstname, $lastname) . ' (' . $username . ')</td> <td>' . $attendances_faults_avg . '</td> <td>' . $evaluations_avg . '</td> </tr>'; $i++; } $students_table .= '</table>'; } else { $students_table .= get_lang('ThereIsNoInformationAboutYourStudents'); } $content .= $students_table; if (count($students) > 0) { $content .= '<div style="text-align:right;margin-top:10px;"> <a href="' . api_get_path(WEB_CODE_PATH) . 'mySpace/index.php?view=admin&display=yourstudents">' . get_lang('SeeMore') . '</a> </div>'; } $content .= '</div>'; return $content; }
/** * Count the number of friends for social network users */ static function get_friends() { $user_friend_table = Database::get_main_table(TABLE_MAIN_USER_REL_USER); $user_table = Database::get_main_table(TABLE_MAIN_USER); $access_url_rel_user_table = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $current_url_id = api_get_current_access_url_id(); if (api_is_multiple_url_enabled()) { $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend " . "FROM " . $access_url_rel_user_table . " as url, " . $user_friend_table . " uf " . "LEFT JOIN " . $user_table . " u ON uf.user_id = u.user_id " . "WHERE uf.relation_type <> '" . USER_RELATION_TYPE_RRHH . "' AND uf.user_id = url.user_id AND access_url_id='" . $current_url_id . "' " . "GROUP BY uf.user_id ORDER BY count_friend DESC "; } else { $sql = "SELECT lastname, firstname, username, COUNT(friend_user_id) AS count_friend " . "FROM " . $user_friend_table . " uf " . "LEFT JOIN " . $user_table . " u ON uf.user_id = u.user_id " . "WHERE uf.relation_type <> '" . USER_RELATION_TYPE_RRHH . "' " . "GROUP BY uf.user_id ORDER BY count_friend DESC "; } $res = Database::query($sql); $list_friends = array(); while ($friends = Database::fetch_array($res)) { $users = api_get_person_name($friends['firstname'], $friends['lastname']) . '<br />(' . $friends['username'] . ')'; $list_friends[$users] = $friends['count_friend']; } return $list_friends; }
function search_users($needle, $type) { global $tbl_user, $tbl_session_rel_user, $id_session; $xajax_response = new XajaxResponse(); $return = ''; if (!empty($needle) && !empty($type)) { //normal behaviour if ($type == 'any_session' && $needle == 'false') { $type = 'multiple'; $needle = ''; } // xajax send utf8 datas... datas in db can be non-utf8 datas $charset = api_get_system_encoding(); $needle = Database::escape_string($needle); $needle = api_convert_encoding($needle, $charset, 'utf-8'); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $cond_user_id = ''; //Only for single & multiple if (in_array($type, array('single', 'multiple'))) { if (!empty($id_session)) { $id_session = intval($id_session); // check id_user from session_rel_user table $sql = 'SELECT id_user FROM ' . $tbl_session_rel_user . ' WHERE id_session ="' . $id_session . '" AND relation_type<>' . SESSION_RELATION_TYPE_RRHH . ' '; $res = Database::query($sql); $user_ids = array(); if (Database::num_rows($res) > 0) { while ($row = Database::fetch_row($res)) { $user_ids[] = (int) $row[0]; } } if (count($user_ids) > 0) { $cond_user_id = ' AND user.user_id NOT IN(' . implode(",", $user_ids) . ')'; } } } switch ($type) { case 'single': // search users where username or firstname or lastname begins likes $needle $sql = 'SELECT user.user_id, username, lastname, firstname, official_code FROM ' . $tbl_user . ' user WHERE (username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%" OR lastname LIKE "' . $needle . '%") AND user.status<>6 AND user.status<>' . DRH . '' . $order_clause . ' LIMIT 11'; break; case 'multiple': $sql = 'SELECT user.user_id, username, lastname, firstname, official_code FROM ' . $tbl_user . ' user WHERE ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user.status<>' . DRH . ' AND user.status<>6 ' . $cond_user_id . $order_clause; break; case 'any_session': $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code FROM ' . $tbl_user . ' user LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s ON (s.id_user = user.user_id) WHERE s.id_user IS null AND user.status<>' . DRH . ' AND user.status<>6 ' . $cond_user_id . $order_clause; break; } if (api_is_multiple_url_enabled()) { $tbl_user_rel_access_url = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { switch ($type) { case 'single': $sql = 'SELECT user.user_id, username, lastname, firstname, official_code FROM ' . $tbl_user . ' user INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = ' . $access_url_id . ' AND (username LIKE "' . $needle . '%" OR firstname LIKE "' . $needle . '%" OR lastname LIKE "' . $needle . '%") AND user.status<>6 AND user.status<>' . DRH . ' ' . $order_clause . ' LIMIT 11'; break; case 'multiple': $sql = 'SELECT user.user_id, username, lastname, firstname , official_code FROM ' . $tbl_user . ' user INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = ' . $access_url_id . ' AND ' . (api_sort_by_first_name() ? 'firstname' : 'lastname') . ' LIKE "' . $needle . '%" AND user.status<>' . DRH . ' AND user.status<>6 ' . $cond_user_id . $order_clause; break; case 'any_session': $sql = 'SELECT DISTINCT user.user_id, username, lastname, firstname, official_code FROM ' . $tbl_user . ' user LEFT OUTER JOIN ' . $tbl_session_rel_user . ' s ON (s.id_user = user.user_id) INNER JOIN ' . $tbl_user_rel_access_url . ' url_user ON (url_user.user_id=user.user_id) WHERE access_url_id = ' . $access_url_id . ' AND s.id_user IS null AND user.status<>' . DRH . ' AND user.status<>6 ' . $cond_user_id . $order_clause; break; } } } $rs = Database::query($sql); $i = 0; if ($type == 'single') { while ($user = Database::fetch_array($rs)) { $i++; if ($i <= 10) { $person_name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ' . $user['official_code']; $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_session(\'' . $user['user_id'] . '\',\'' . $person_name . ' ' . '\')">' . $person_name . ' </a><br />'; } else { $return .= '...<br />'; } } $xajax_response->addAssign('ajax_list_users_single', 'innerHTML', api_utf8_encode($return)); } else { global $nosessionUsersList; $return .= '<select id="origin_users" name="nosessionUsersList[]" multiple="multiple" size="15" style="width:360px;">'; while ($user = Database::fetch_array($rs)) { $person_name = api_get_person_name($user['firstname'], $user['lastname']) . ' (' . $user['username'] . ') ' . $user['official_code']; $return .= '<option value="' . $user['user_id'] . '">' . $person_name . ' </option>'; } $return .= '</select>'; $xajax_response->addAssign('ajax_list_users_multiple', 'innerHTML', api_utf8_encode($return)); } } return $xajax_response; }