public function get_user_name($username, $password, $id, $field) { if($this->verifyUserPass($username, $password) == "valid") { $userInfo = UserManager::get_user_info_by_id($id); switch ($field) { case 'firstname': return $userInfo['firstname']; break; case 'lastname' : return $userInfo['lastname']; break; case 'bothfl' : return $userInfo['firstname']." ".$userInfo['lastname']; break; case 'bothlf' : return $userInfo['lastname']." ".$userInfo['firstname']; break; default : return $userInfo['firstname']; } return "0"; } return "0"; }
public function get_announcement_data($username, $password, $course_code, $announcement_id, $field) { if ($this->verifyUserPass($username, $password) == "valid") { $htmlcode = false; $user_id = UserManager::get_user_id_from_username($username); $result = self::get_announcements($username, $course_code, $announcement_id); while ($announcement = Database::fetch_array($result)) { $announcements[] = $announcement; } switch ($field) { case 'sender': $field_table = "insert_user_id"; $sender = UserManager::get_user_info_by_id($announcements[0][$field_table]); $announcements[0][$field_table] = $sender['firstname'] . " " . $sender['lastname']; break; case 'title': $htmlcode = true; $field_table = "title"; break; case 'date': $field_table = "end_date"; break; case 'content': $htmlcode = true; $field_table = "content"; $announcements[0][$field_table] = nl2br_revert($announcements[0][$field_table]); break; default: $field_table = "title"; } return htmlcode ? html_entity_decode($announcements[0][$field_table]) : $announcements[0][$field_table]; } else { return get_lang('InvalidId'); } }
function dc_check_phone_number($user) { $uInfo = UserManager::get_user_info_by_id($user['user_id']); if (empty($uInfo['phone'])) { return false; } return true; }
/** * Displays the form to register users in a blog (in a course) * The listed users are users subcribed in the course. * @author Toon Keppens * * @param Integer $blog_id * * @return Html Form with sortable table with users to subcribe in a blog, in a course. */ public static function display_form_user_subscribe($blog_id) { // Init global $_course; $is_western_name_order = api_is_western_name_order(); $currentCourse = $_course['sysCode']; $tbl_users = Database::get_main_table(TABLE_MAIN_USER); $tbl_blogs_rel_user = Database::get_course_table(TABLE_BLOGS_REL_USER); $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); echo '<legend>' . get_lang('SubscribeMembers') . '</legend>'; $course_id = api_get_course_int_id(); $properties["width"] = "100%"; // Get blog members' id. $sql = "SELECT user.user_id FROM {$tbl_users} user\n\t\t\t\tINNER JOIN {$tbl_blogs_rel_user} blogs_rel_user\n\t\t\t\tON user.user_id = blogs_rel_user.user_id\n\t\t\t\tWHERE blogs_rel_user.c_id = {$course_id} AND blogs_rel_user.blog_id = '" . intval($blog_id) . "'"; $result = Database::query($sql); $blog_member_ids = array(); while ($user = Database::fetch_array($result)) { $blog_member_ids[] = $user['user_id']; } // Set table headers $column_header[] = array('', false, ''); if ($is_western_name_order) { $column_header[] = array(get_lang('FirstName'), true, ''); $column_header[] = array(get_lang('LastName'), true, ''); } else { $column_header[] = array(get_lang('LastName'), true, ''); $column_header[] = array(get_lang('FirstName'), true, ''); } $column_header[] = array(get_lang('Email'), false, ''); $column_header[] = array(get_lang('Register'), false, ''); if (isset($_SESSION['session_id'])) { $session_id = intval($_SESSION['session_id']); } else { $session_id = 0; } $student_list = CourseManager::get_student_list_from_course_code($currentCourse, false, $session_id); $user_data = array(); // Add users that are not in this blog to the list. foreach ($student_list as $key => $user) { if (isset($user['id_user'])) { $user['user_id'] = $user['id_user']; } if (!in_array($user['user_id'], $blog_member_ids)) { $a_infosUser = UserManager::get_user_info_by_id($user['user_id']); $row = array(); $row[] = '<input type="checkbox" name="user[]" value="' . $a_infosUser['user_id'] . '" ' . ($_GET['selectall'] == "subscribe" ? ' checked="checked" ' : '') . '/>'; $username = api_htmlentities(sprintf(get_lang('LoginX'), $a_infosUser["username"]), ENT_QUOTES); if ($is_western_name_order) { $row[] = $a_infosUser["firstname"]; $row[] = Display::tag('span', $a_infosUser["lastname"], array('title' => $username)); } else { $row[] = Display::tag('span', $a_infosUser["lastname"], array('title' => $username)); $row[] = $a_infosUser["firstname"]; } $row[] = Display::icon_mailto_link($a_infosUser["email"]); //Link to register users if ($a_infosUser["user_id"] != $_SESSION['_user']['user_id']) { $row[] = "<a class=\"btn \" href=\"" . api_get_self() . "?action=manage_members&blog_id={$blog_id}&register=yes&user_id=" . $a_infosUser["user_id"] . "\">" . get_lang('Register') . "</a>"; } else { $row[] = ''; } $user_data[] = $row; } } // Display $query_vars['action'] = 'manage_members'; $query_vars['blog_id'] = $blog_id; echo '<form method="post" action="blog.php?action=manage_members&blog_id=' . $blog_id . '">'; Display::display_sortable_table($column_header, $user_data, null, null, $query_vars); $link = ''; $link .= isset($_GET['action']) ? 'action=' . Security::remove_XSS($_GET['action']) . '&' : ''; $link .= "blog_id={$blog_id}&"; echo '<a href="blog.php?' . $link . 'selectall=subscribe">' . get_lang('SelectAll') . '</a> - '; echo '<a href="blog.php?' . $link . '">' . get_lang('UnSelectAll') . '</a> '; echo get_lang('WithSelected') . ' : '; echo '<select name="action">'; echo '<option value="select_subscribe">' . get_lang('Register') . '</option>'; echo '</select>'; echo '<input type="hidden" name="register" value="true" />'; echo '<button class="save" type="submit">' . get_lang('Ok') . '</button>'; echo '</form>'; }
/** * @return array|null|string */ function store_add_dropbox() { $_course = api_get_course_info(); $_user = api_get_user_info(); $dropbox_cnf = getDropboxConf(); // Validating the form data // there are no recipients selected if (!isset($_POST['recipients']) || count($_POST['recipients']) <= 0) { return get_lang('YouMustSelectAtLeastOneDestinee'); } else { // Check if all the recipients are valid $thisIsAMailing = false; $thisIsJustUpload = false; foreach ($_POST['recipients'] as $rec) { if ($rec == 'mailing') { $thisIsAMailing = true; } elseif ($rec == 'upload') { $thisIsJustUpload = true; } elseif (strpos($rec, 'user_') === 0 && !isCourseMember(substr($rec, strlen('user_')))) { return get_lang('InvalideUserDetected'); } elseif (strpos($rec, 'group_') !== 0 && strpos($rec, 'user_') !== 0) { return get_lang('InvalideGroupDetected'); } } } // we are doing a mailing but an additional recipient is selected if ($thisIsAMailing && count($_POST['recipients']) != 1) { return get_lang('MailingSelectNoOther'); } // we are doing a just upload but an additional recipient is selected. // note: why can't this be valid? It is like sending a document to yourself AND to a different person (I do this quite often with my e-mails) if ($thisIsJustUpload && count($_POST['recipients']) != 1) { return get_lang('MailingJustUploadSelectNoOther'); } if (empty($_FILES['file']['name'])) { $error = true; return get_lang('NoFileSpecified'); } // are we overwriting a previous file or sending a new one $dropbox_overwrite = false; if (isset($_POST['cb_overwrite']) && $_POST['cb_overwrite']) { $dropbox_overwrite = true; } // doing the upload $dropbox_filename = $_FILES['file']['name']; $dropbox_filesize = $_FILES['file']['size']; $dropbox_filetype = $_FILES['file']['type']; $dropbox_filetmpname = $_FILES['file']['tmp_name']; // check if the filesize does not exceed the allowed size. if ($dropbox_filesize <= 0 || $dropbox_filesize > $dropbox_cnf['maxFilesize']) { return get_lang('DropboxFileTooBig'); // TODO: The "too big" message does not fit in the case of uploading zero-sized file. } // check if the file is actually uploaded if (!is_uploaded_file($dropbox_filetmpname)) { // check user fraud : no clean error msg. return get_lang('TheFileIsNotUploaded'); } $upload_ok = process_uploaded_file($_FILES['file'], true); if (!$upload_ok) { return null; } // Try to add an extension to the file if it hasn't got one $dropbox_filename = add_ext_on_mime($dropbox_filename, $dropbox_filetype); // Replace dangerous characters $dropbox_filename = replace_dangerous_char($dropbox_filename); // Transform any .php file in .phps fo security $dropbox_filename = php2phps($dropbox_filename); //filter extension if (!filter_extension($dropbox_filename)) { return get_lang('UplUnableToSaveFileFilteredExtension'); } // set title $dropbox_title = $dropbox_filename; // set author if (!isset($_POST['authors'])) { $_POST['authors'] = getUserNameFromId($_user['user_id']); } // note: I think we could better migrate everything from here on to separate functions: store_new_dropbox, store_new_mailing, store_just_upload if ($dropbox_overwrite) { $dropbox_person = new Dropbox_Person($_user['user_id'], api_is_course_admin(), api_is_course_tutor()); foreach ($dropbox_person->sentWork as $w) { if ($w->title == $dropbox_filename) { if ($w->recipients[0]['id'] > dropbox_cnf('mailingIdBase') xor $thisIsAMailing) { return get_lang('MailingNonMailingError'); } if ($w->recipients[0]['id'] == $_user['user_id'] xor $thisIsJustUpload) { return get_lang('MailingJustUploadSelectNoOther'); } $dropbox_filename = $w->filename; $found = true; // note: do we still need this? break; } } } else { // rename file to login_filename_uniqueId format $dropbox_filename = getLoginFromId($_user['user_id']) . "_" . $dropbox_filename . "_" . uniqid(''); } // creating the array that contains all the users who will receive the file $new_work_recipients = array(); foreach ($_POST['recipients'] as $rec) { if (strpos($rec, 'user_') === 0) { $new_work_recipients[] = substr($rec, strlen('user_')); } elseif (strpos($rec, 'group_') === 0) { $userList = GroupManager::get_subscribed_users(substr($rec, strlen('group_'))); foreach ($userList as $usr) { if (!in_array($usr['user_id'], $new_work_recipients) && $usr['user_id'] != $_user['user_id']) { $new_work_recipients[] = $usr['user_id']; } } } } @move_uploaded_file($dropbox_filetmpname, dropbox_cnf('sysPath') . '/' . $dropbox_filename); $b_send_mail = api_get_course_setting('email_alert_on_new_doc_dropbox'); if ($b_send_mail) { foreach ($new_work_recipients as $recipient_id) { $recipent_temp = UserManager::get_user_info_by_id($recipient_id); $additionalParameters = array('smsType' => ClockworksmsPlugin::NEW_FILE_SHARED_COURSE_BY, 'userId' => $recipient_id, 'courseTitle' => $_course['title'], 'userUsername' => $recipent_temp['username']); api_mail_html(api_get_person_name($recipent_temp['firstname'] . ' ' . $recipent_temp['lastname'], null, PERSON_NAME_EMAIL_ADDRESS), $recipent_temp['email'], get_lang('NewDropboxFileUploaded'), get_lang('NewDropboxFileUploadedContent') . ' ' . api_get_path(WEB_CODE_PATH) . 'dropbox/index.php?cidReq=' . $_course['sysCode'] . "\n\n" . api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS) . "\n" . get_lang('Email') . " : " . $_user['mail'], api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS), $_user['mail'], null, null, null, $additionalParameters); } } new Dropbox_SentWork($_user['user_id'], $dropbox_title, $_POST['description'], strip_tags($_POST['authors']), $dropbox_filename, $dropbox_filesize, $new_work_recipients); Security::clear_token(); return get_lang('FileUploadSucces'); }
$allowed_picture_types = array('jpg', 'jpeg', 'png', 'gif'); $form->addRule('picture', get_lang('OnlyImagesAllowed') . ' (' . implode(',', $allowed_picture_types) . ')', 'filetype', $allowed_picture_types); $form->addElement('style_submit_button', 'apply_change', get_lang('SaveSettings'), 'class="save"'); if ($form->validate()) { $user_data = $form->getSubmitValues(); // upload picture if a new one is provided if ($_FILES['picture']['size']) { if ($new_picture = UserManager::update_user_picture(api_get_user_id(), $_FILES['picture']['name'], $_FILES['picture']['tmp_name'])) { $table_user = Database::get_main_table(TABLE_MAIN_USER); $sql = "UPDATE {$table_user} SET picture_uri = '{$new_picture}' WHERE user_id = " . api_get_user_id(); $result = Database::query($sql); } } } } $user_info = UserManager::get_user_info_by_id(api_get_user_id()); $social_left_content = SocialManager::show_social_menu('home'); $usergroup = new UserGroup(); $social_right_content = '<div class="span5">'; $social_right_content .= '<div class="well_border">'; $social_right_content .= '<h3>' . get_lang('ContactInformation') . '</h3>'; $list = array(array('title' => get_lang('Name'), 'content' => api_get_person_name($user_info['firstname'], $user_info['lastname'])), array('title' => get_lang('Email'), 'content' => $user_info['email'])); // Current user information $social_right_content .= '<div>' . Display::description($list) . '</div>'; $social_right_content .= ' <div class="form-actions"> <a class="btn" href="' . api_get_path(WEB_PATH) . 'main/auth/profile.php"> ' . get_lang('EditProfile') . ' </a> </div> </div>';
/** * Returns true if authentication accepts to run otherwise returns false. * * @return boolean */ public function accept() { /** * Authentication method must be enabled */ if (!self::is_enabled()) { return false; } $token = $this->get_access_token(); if ($token->is_empty()) { return false; } $key = UserApiKeyManager::get_by_id($token->get_id()); if (empty($key)) { return false; } /** * The service corresponding to the key must be enabled. */ $service = $key['api_service']; if (!self::is_service_enabled($service)) { return false; } /** * User associated with the key must be active */ $user = UserManager::get_user_info_by_id($token->get_user_id()); if (empty($user)) { return false; } if (!$user['active']) { return false; } /** * Token must be valid. */ return $token->is_valid(); }
function WSGetUser($params) { global $debug; if ($debug) { error_log('WSGetUser'); } if ($debug) { error_log('$params: ' . print_r($params, 1)); } if (!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } $result = array(); // Get user id $user_id = UserManager::get_user_id_from_original_id($params['original_user_id_value'], $params['original_user_id_name']); $user_data = UserManager::get_user_info_by_id($user_id); if (empty($user_data)) { // If user was not found, there was a problem $result['user_id'] = ''; $result['firstname'] = ''; $result['lastname'] = ''; } else { $result['user_id'] = $user_data['user_id']; $result['firstname'] = $user_data['firstname']; $result['lastname'] = $user_data['lastname']; } return $result; }
$table->set_header(2, get_lang('FirstName'), false, 'align="center"'); $table->set_header(3, get_lang('TrainingTime'), false); $table->set_header(4, get_lang('CourseProgress'), false); $table->set_header(5, get_lang('Score'), false); $table->set_header(6, get_lang('Student_publication'), false); $table->set_header(7, get_lang('Messages'), false); $table->set_header(8, get_lang('FirstLogin'), false, 'align="center"'); $table->set_header(9, get_lang('LatestLogin'), false, 'align="center"'); $table->set_header(10, get_lang('Details'), false); if ($export_csv) { $csv_content[] = array(); } $all_datas = array(); $course_code = $_course['id']; foreach ($a_students as $student_id => $student) { $student_datas = UserManager::get_user_info_by_id($student_id); $avg_time_spent = $avg_student_score = $avg_student_progress = $total_assignments = $total_messages = 0; $nb_courses_student = 0; $avg_time_spent = Tracking::get_time_spent_on_the_course($student_id, $course_code); $avg_student_score = Tracking::get_average_test_scorm_and_lp($student_id, $course_code); $avg_student_progress = Tracking::get_avg_student_progress($student_id, $course_code); $total_assignments = Tracking::count_student_assignments($student_id, $course_code); $total_messages = Tracking::count_student_messages($student_id, $course_code); $row = array(); $row[] = $student_datas['official_code']; $row[] = $student_datas['lastname']; $row[] = $student_datas['firstname']; $row[] = api_time_to_hms($avg_time_spent); if (is_null($avg_student_score)) { $avg_student_score = 0; }
<?php /* * This file is part of the Libcast Dokeos module. * * (c) Libcast <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ // This file is not for production, only for tests and developments, // thus, we stop here. die; require_once realpath(__DIR__ . '/../inc/global.inc.php'); require_once realpath(__DIR__ . '/../inc/lib/course.lib.php'); require_once realpath(__DIR__ . '/../inc/lib/usermanager.lib.php'); error_reporting(E_ALL); ini_set('display_errors', true); $u = UserManager::get_user_info_by_id(isset($_GET['user_id']) ? $_GET['user_id'] : 4); $_SESSION['_user'] = $u; header('Location: http://scandola.univ-corse.fr/dokeos/index.php');
$url = api_get_path(WEB_PATH) . 'main/auth/conditional_login/complete_phone_number.php'; if (!isset($_SESSION['conditional_login']['uid'])) { die("Not Authorised"); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html lang="fr" xml:lang="fr" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"> </head> <body> <form id="data_completion" name="data_completion" method="post" action="<?php echo $url; ?> "> Téléphone : <input type="text" name="phone_number" /> <input type="submit" name="submit" value="Submit" /> </form> </body> </html> <?php if (isset($_POST['submit'])) { $u = UserManager::get_user_info_by_id($_SESSION['conditional_login']['uid']); $u['phone'] = $_POST['phone_number']; $password = null; // we don't want to change the password $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], $password, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], ''); if ($updated) { ConditionalLogin::login(); } }
/** * Get tickets by userId * @param $from * @param $number_of_items * @param $column * @param $direction * @param null $user_id * @return array */ public static function get_tickets_by_user_id( $from, $number_of_items, $column, $direction, $user_id = null ) { global $plugin; $table_support_category = Database::get_main_table( TABLE_TICKET_CATEGORY ); $table_support_tickets = Database::get_main_table(TABLE_TICKET_TICKET); $table_support_priority = Database::get_main_table( TABLE_TICKET_PRIORITY ); $table_support_status = Database::get_main_table(TABLE_TICKET_STATUS); $table_support_messages = Database::get_main_table( TABLE_TICKET_MESSAGE ); $table_main_user = Database::get_main_table(TABLE_MAIN_USER); $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); if (is_null($direction)) { $direction = "DESC"; } if (is_null($user_id) || $user_id == 0) { $user_id = api_get_user_id(); } $isAdmin = UserManager::is_admin($user_id); $sql = "SELECT ticket.*, ticket.ticket_id AS col0, ticket.start_date AS col1, ticket.sys_lastedit_datetime AS col2, cat.name AS col3, user.username AS col4, priority.priority AS col5, priority.priority AS col6, status.name AS col7, ticket.total_messages AS col8, msg.message AS col9, ticket.request_user AS user_id, ticket.assigned_last_user AS responsible FROM $table_support_tickets ticket, $table_support_category cat, $table_support_priority priority, $table_support_status status, $table_main_user user, $table_support_messages msg WHERE cat.category_id = ticket.category_id AND ticket.priority_id = priority.priority_id AND ticket.status_id = status.status_id AND user.user_id = ticket.request_user AND ticket.ticket_id= msg.ticket_id AND message_id=1 "; if (!$isAdmin) { $sql .= " AND request_user = '******' "; } $keyword_unread = Database::escape_string( trim($_GET['keyword_unread']) ); //Search simple if (isset($_GET['submit_simple'])) { if ($_GET['keyword'] != '') { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (ticket.ticket_code = '$keyword' OR ticket.ticket_id = '$keyword' OR user.firstname LIKE '%$keyword%' OR user.lastname LIKE '%$keyword%' OR concat(user.firstname,' ',user.lastname) LIKE '%$keyword%' OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword%' OR user.username LIKE '%$keyword%')"; } } //Search advanced if (isset($_GET['submit_advanced'])) { $keyword_category = Database::escape_string( trim($_GET['keyword_category']) ); $keyword_request_user = Database::escape_string( trim($_GET['keyword_request_user']) ); $keyword_admin = Database::escape_string( trim($_GET['keyword_admin']) ); $keyword_start_date_start = Database::escape_string( trim($_GET['keyword_start_date_start']) ); $keyword_start_date_end = Database::escape_string( trim($_GET['keyword_start_date_end']) ); $keyword_status = Database::escape_string( trim($_GET['keyword_status']) ); $keyword_source = Database::escape_string( trim($_GET['keyword_source']) ); $keyword_priority = Database::escape_string( trim($_GET['keyword_priority']) ); $keyword_range = Database::escape_string( trim($_GET['keyword_dates']) ); $keyword_course = Database::escape_string( trim($_GET['keyword_course']) ); if ($keyword_category != '') { $sql .= " AND ticket.category_id = '$keyword_category' "; } if ($keyword_request_user != '') { $sql .= " AND (ticket.request_user = '******' OR user.firstname LIKE '%$keyword_request_user%' OR user.official_code LIKE '%$keyword_request_user%' OR user.lastname LIKE '%$keyword_request_user%' OR concat(user.firstname,' ',user.lastname) LIKE '%$keyword_request_user%' OR concat(user.lastname,' ',user.firstname) LIKE '%$keyword_request_user%' OR user.username LIKE '%$keyword_request_user%') "; } if ($keyword_admin != '') { $sql .= " AND ticket.assigned_last_user = '******' "; } if ($keyword_status != '') { $sql .= " AND ticket.status_id = '$keyword_status' "; } if ($keyword_range == '' && $keyword_start_date_start != '') { $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '$keyword_start_date_start' "; } if ($keyword_range == '1' && $keyword_start_date_start != '' && $keyword_start_date_end != '') { $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '$keyword_start_date_start' AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '$keyword_start_date_end'"; } if ($keyword_priority != '') { $sql .= " AND ticket.priority_id = '$keyword_priority' "; } if ($keyword_source != '') { $sql .= " AND ticket.source = '$keyword_source' "; } if ($keyword_priority != '') { $sql .= " AND ticket.priority_id = '$keyword_priority' "; } if ($keyword_course != '') { $course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $sql .= " AND ticket.course_id IN ( "; $sql .= "SELECT id FROM $course_table WHERE (title LIKE '%$keyword_course%' OR code LIKE '%$keyword_course%' OR visual_code LIKE '%$keyword_course%' ) )"; } } if ($keyword_unread == 'yes') { $sql .= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; } else { if ($keyword_unread == 'no') { $sql .= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN ( SELECT user_id FROM $table_main_admin ) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; } } $sql .= " ORDER BY col$column $direction"; $sql .= " LIMIT $from,$number_of_items"; $result = Database::query($sql); $tickets = array(); $webPath = api_get_path(WEB_PATH); $webCodePath = api_get_path(WEB_CODE_PATH); while ($row = Database::fetch_assoc($result)) { $sql_unread = "SELECT COUNT(DISTINCT message.message_id) AS unread FROM $table_support_tickets ticket, $table_support_messages message, $table_main_user user WHERE ticket.ticket_id = message.ticket_id AND ticket.ticket_id = '{$row['col0']}' AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id "; if ($isAdmin) { $sql_unread .= " AND user.user_id NOT IN (SELECT user_id FROM $table_main_admin) AND ticket.status_id != 'REE' "; } else { $sql_unread .= " AND user.user_id IN (SELECT user_id FROM $table_main_admin) "; } $result_unread = Database::query($sql_unread); $unread = Database::fetch_object($result_unread)->unread; $userInfo = UserManager::get_user_info_by_id($row['user_id']); $hrefUser = $webPath . 'main/admin/user_information.php?user_id=' . $row['user_id']; $name = "<a href='$hrefUser'> {$userInfo['username']} </a>"; $actions = ""; if ($row['responsible'] != 0) { $row['responsible'] = api_get_user_info($row['responsible']); if (!empty($row['responsible'])) { $hrefResp = $webPath . 'main/admin/user_information.php?user_id=' . $row['responsible']['user_id']; $row['responsible'] = "<a href='$hrefResp'> {$row['responsible']['username']} </a>"; } else { $row['responsible'] = get_lang('UnknownUser'); } } else { if ($row['status_id'] != 'REE') { $row['responsible'] = '<span style="color:#ff0000;">' . $plugin->get_lang('ToBeAssigned') . '</span>'; } else { $row['responsible'] = '<span style="color:#00ff00;">' . get_lang('MessageResent') . '</span>'; } } switch ($row['source']) { case 'PRE': $img_source = 'icons/32/user.png'; break; case 'MAI': $img_source = 'icons/32/mail.png'; break; case 'TEL': $img_source = 'icons/32/event.png'; break; default: $img_source = 'icons/32/course_home.png'; break; } $row['col1'] = api_get_local_time($row['col1']); $row['col2'] = api_get_local_time($row['col2']); if ($isAdmin) { $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon( 'synthese_view.gif', get_lang('Info') ) . '</a> '; if ($row['priority_id'] == 'HGH' && $row['status_id'] != 'CLS') { $actions .= '<img src="' . $webCodePath . 'img/exclamation.png" border="0" />'; } $row['col0'] = Display::return_icon( $img_source, get_lang('Info') ) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; if ($row['col7'] == 'PENDIENTE') { $row['col7'] = '<span style="color: #f00; font-weight:bold;">' . $row['col7'] . '</span>'; } $ticket = array( $row['col0'], api_format_date($row['col1'], '%d/%m/%y - %I:%M:%S %p'), api_format_date($row['col2'], '%d/%m/%y - %I:%M:%S %p'), $row['col3'], $name, $row['responsible'], $row['col7'], $row['col8'], $actions, eregi_replace("[\n|\r|\n\r|\r\n]", ' ', strip_tags($row['col9'])) ); } else { $actions = ""; $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon( 'synthese_view.gif', get_lang('Info') ) . '</a> '; $row['col0'] = Display::return_icon( $img_source, get_lang('Info') ) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; $now = api_strtotime(api_get_utc_datetime()); $last_edit_date = api_strtotime($row['sys_lastedit_datetime']); $dif = $now - $last_edit_date; if ($dif > 172800 && $row['priority_id'] == 'NRM' && $row['status_id'] != 'CLS') { $actions .= '<a href="myticket.php?ticket_id=' . $row['ticket_id'] . '&action=alert"> <img src="' . $webPath . 'main/img/exclamation.png" border="0" /></a>'; } if ($row['priority_id'] == 'HGH') { $actions .= '<img src="' . $webCodePath . 'img/admin_star.png" border="0" />'; } $ticket = array( $row['col0'], api_format_date($row['col1'], '%d/%m/%y - %I:%M:%S %p'), api_format_date($row['col2'], '%d/%m/%y - %I:%M:%S %p'), $row['col3'], $row['col7'], $actions ); } if ($unread > 0) { $ticket['0'] = $ticket['0'] . ' (' . $unread . ')<a href="ticket_details.php?ticket_id=' . $row['ticket_id'] . '"> <img src="' . $webPath . 'main/img/message_new.png" border="0" title="' . $unread . ' ' . get_lang('Messages') . '"/> </a>'; } if ($isAdmin) { $ticket['0'] .= ' <a href="javascript:void(0)" onclick="load_history_ticket(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')"> <img onclick="load_course_list(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')" onmouseover="clear_course_list (\'div_' . $row['ticket_id'] . '\')" src="' . $webPath . 'main/img/history.gif" title="' . get_lang( 'Historial' ) . '" alt="' . get_lang('Historial') . '"/> <div class="blackboard_hide" id="div_' . $row['ticket_id'] . '"> </div> </a> '; } $tickets[] = $ticket; } return $tickets; }
public static function get_tickets_by_user_id($from, $number_of_items, $column, $direction, $user_id = null) { $table_support_category = Database::get_main_table(TABLE_SUPPORT_CATEGORY); $table_support_tickets = Database::get_main_table(TABLE_SUPPORT_TICKET); $table_support_priority = Database::get_main_table(TABLE_SUPPORT_PRIORITY); $table_support_status = Database::get_main_table(TABLE_SUPPORT_STATUS); $table_support_messages = Database::get_main_table(TABLE_SUPPORT_MESSAGE); $table_main_user = Database::get_main_table(TABLE_MAIN_USER); $table_main_admin = Database::get_main_table(TABLE_MAIN_ADMIN); if (is_null($direction)) { $direction = "DESC"; } if (is_null($user_id) || $user_id == 0) { $user_id = api_get_user_id(); } $isAdmin = UserManager::is_admin($user_id); $sql = "SELECT ticket.*, ticket.ticket_id AS col0,ticket.start_date AS col1, ticket.sys_lastedit_datetime AS col2 ,cat.name AS col3,user.username AS col4, priority.priority AS col5 ,\n\t\t\t\tpriority.priority AS col6, status.name AS col7 , ticket.total_messages AS col8, msg.message AS col9, ticket.request_user AS user_id , ticket.assigned_last_user AS responsable \n\t\t\t\tFROM " . $table_support_tickets . " ticket ," . $table_support_category . " cat , " . $table_support_priority . " priority, " . $table_support_status . " status , " . Database::get_main_table(TABLE_MAIN_USER) . " user, tck_message msg \n\t\t\t\tWHERE cat.category_id = ticket.category_id AND ticket.priority_id = priority.priority_id AND ticket.status_id = status.status_id AND user.user_id = ticket.request_user\n\t\t\t\tAND ticket.ticket_id= msg.ticket_id AND message_id=1 "; if (!$isAdmin) { $sql .= " AND request_user = '******' "; } $keyword_unread = Database::escape_string(trim($_GET['keyword_unread'])); //Search simple if (isset($_GET['submit_simple'])) { if ($_GET['keyword'] != '') { $keyword = Database::escape_string(trim($_GET['keyword'])); $sql .= " AND (ticket.ticket_code = '" . $keyword . "' OR ticket.ticket_id = '" . $keyword . "' OR user.firstname LIKE '%" . $keyword . "%' OR user.lastname LIKE '%" . $keyword . "%' OR concat(user.firstname,' ',user.lastname) LIKE '%" . $keyword . "%' OR concat(user.lastname,' ',user.firstname) LIKE '%" . $keyword . "%' OR user.username LIKE '%" . $keyword . "%') "; } } //Search advanced if (isset($_GET['submit_advanced'])) { $keyword_category = Database::escape_string(trim($_GET['keyword_category'])); $keyword_request_user = Database::escape_string(trim($_GET['keyword_request_user'])); $keyword_admin = Database::escape_string(trim($_GET['keyword_admin'])); $keyword_start_date_start = Database::escape_string(trim($_GET['keyword_start_date_start'])); $keyword_start_date_end = Database::escape_string(trim($_GET['keyword_start_date_end'])); $keyword_status = Database::escape_string(trim($_GET['keyword_status'])); $keyword_source = Database::escape_string(trim($_GET['keyword_source'])); $keyword_priority = Database::escape_string(trim($_GET['keyword_priority'])); $keyword_range = Database::escape_string(trim($_GET['keyword_dates'])); $keyword_course = Database::escape_string(trim($_GET['keyword_course'])); if ($keyword_category != '') { $sql .= " AND ticket.category_id = '{$keyword_category}' "; } if ($keyword_request_user != '') { $sql .= " AND (ticket.request_user = '******' OR user.firstname LIKE '%" . $keyword_request_user . "%' OR user.official_code LIKE '%" . $keyword_request_user . "%' OR user.lastname LIKE '%" . $keyword_request_user . "%' OR concat(user.firstname,' ',user.lastname) LIKE '%" . $keyword_request_user . "%' OR concat(user.lastname,' ',user.firstname) LIKE '%" . $keyword_request_user . "%' OR user.username LIKE '%" . $keyword_request_user . "%') "; } if ($keyword_admin != '') { $sql .= " AND ticket.assigned_last_user = '******' "; } if ($keyword_status != '') { $sql .= " AND ticket.status_id = '{$keyword_status}' "; } if ($keyword_range == '' && $keyword_start_date_start != '') { $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') = '{$keyword_start_date_start}' "; } if ($keyword_range == '1' && $keyword_start_date_start != '' && $keyword_start_date_end != '') { $sql .= " AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') >= '{$keyword_start_date_start}' AND DATE_FORMAT( ticket.start_date,'%d/%m/%Y') <= '{$keyword_start_date_end}'"; } if ($keyword_priority != '') { $sql .= " AND ticket.priority_id = '{$keyword_priority}' "; } if ($keyword_source != '') { $sql .= " AND ticket.source = '{$keyword_source}' "; } if ($keyword_priority != '') { $sql .= " AND ticket.priority_id = '{$keyword_priority}' "; } if ($keyword_course != '') { $course_table = Database::get_main_table(TABLE_MAIN_COURSE); $sql .= " AND ticket.course_id IN ( "; $sql .= "SELECT id FROM {$course_table} WHERE (title LIKE '%" . $keyword_course . "%' OR code LIKE '%" . $keyword_course . "%' OR visual_code LIKE '%" . $keyword_course . "%' )) "; } } if ($keyword_unread == 'yes') { $sql .= " AND ticket.ticket_id IN (SELECT ticket.ticket_id FROM {$table_support_tickets} ticket, {$table_support_messages} message, {$table_main_user} user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM {$table_main_admin}) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; } else { if ($keyword_unread == 'no') { $sql .= " AND ticket.ticket_id NOT IN (SELECT ticket.ticket_id FROM {$table_support_tickets} ticket, {$table_support_messages} message, {$table_main_user} user WHERE ticket.ticket_id = message.ticket_id AND message.status = 'NOL' AND message.sys_insert_user_id = user.user_id AND user.user_id NOT IN (SELECT user_id FROM {$table_main_admin}) AND ticket.status_id != 'REE' GROUP BY ticket.ticket_id)"; } } $sql .= " ORDER BY col{$column} {$direction}"; $sql .= " LIMIT {$from},{$number_of_items}"; $result = Database::query($sql); $tickets = array(); while ($row = Database::fetch_assoc($result)) { $sql_unread = "SELECT COUNT(DISTINCT message.message_id) AS unread FROM " . $table_support_tickets . " ticket, " . $table_support_messages . " message, " . $table_main_user . " user\n \t\t\tWHERE ticket.ticket_id = message.ticket_id AND ticket.ticket_id= '" . $row['col0'] . "' AND message.status='NOL' AND message.sys_insert_user_id = user.user_id "; if ($isAdmin) { $sql_unread .= " AND user.user_id NOT IN (SELECT user_id FROM {$table_main_admin}) AND ticket.status_id != 'REE' "; } else { $sql_unread .= " AND user.user_id IN (SELECT user_id FROM {$table_main_admin}) "; } $result_unread = Database::query($sql_unread); $unread = Database::fetch_object($result_unread)->unread; $userinfo = UserManager::get_user_info_by_id($row['user_id']); $name = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/user_information.php?user_id=' . $row['user_id'] . '">' . api_get_person_name($userinfo['firstname'], $userinfo['lastname']) . '</a>'; $actions = ""; /*if($row['status_id']!='CLS' && $row['status_id']!='REE'){ if( $row['responsable'] != 0 && $row['responsable'] == $user_id ){ $actions = '<a href="myticket.php?ticket_id='.$row['ticket_id'].'&action=unassign" title="desasignarme"><img src="../../../main/img/admin_star.png" border="0" /></a>'; }else{ $actions = '<a href="myticket.php?ticket_id='.$row['ticket_id'].'&action=assign" title="asignarme"><img src="../../../main/img/admin_star_na.png" border="0" /></a>'; } }*/ if ($row['responsable'] != 0) { $row['responsable'] = api_get_user_info($row['responsable']); $row['responsable'] = '<a href="' . api_get_path(WEB_PATH) . 'main/admin/user_information.php?user_id=' . $row['responsable']['user_id'] . '">' . $row['responsable']['firstname'] . ' ' . $row['responsable']['lastname'] . '</a>'; } else { if ($row['status_id'] != 'REE') { $row['responsable'] = '<span style="color:#ff0000;">Por Asignar</span>'; } else { $row['responsable'] = '<span style="color:#00ff00;">REENVIADO</span>'; } } switch ($row['source']) { case 'PRE': $img_source = '../img/icons/32/user.png'; break; case 'MAI': $img_source = '../img/icons/32/mail.png'; break; case 'TEL': $img_source = '../img/icons/32/event.png'; break; default: $img_source = '../img/icons/32/course_home.png'; break; } $row['col1'] = api_get_local_time($row['col1']); $row['col2'] = api_get_local_time($row['col2']); if ($isAdmin) { $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a> '; if ($row['priority_id'] == 'ALT' && $row['status_id'] != 'CLS') { $actions .= '<img src="../../../main/img/exclamation.png" border="0" />'; } $row['col0'] = Display::return_icon($img_source, get_lang('Info')) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; if ($row['col7'] == 'PENDIENTE') { $row['col7'] = '<span style="color: #f00; font-weight:bold;">' . $row['col7'] . '</span>'; } //programa: $userinfo['extra']['programa'] $ticket = array($row['col0'], api_format_date($row['col1'], '%d/%m/%y - %I:%M:%S %p'), api_format_date($row['col2'], '%d/%m/%y - %I:%M:%S %p'), $row['col3'], $name, $row['responsable'], $row['col7'], $row['col8'], $actions, eregi_replace("[\n|\r|\n\r|\r\n]", ' ', strip_tags($row['col9']))); } else { $actions = ""; $actions .= '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . Display::return_icon('synthese_view.gif', get_lang('Info')) . '</a> '; $row['col0'] = Display::return_icon($img_source, get_lang('Info')) . '<a href="ticket_details.php?ticket_id=' . $row['col0'] . '">' . $row['ticket_code'] . '</a>'; $now = api_strtotime(api_get_utc_datetime()); $last_edit_date = api_strtotime($row['sys_lastedit_datetime']); $dif = $now - $last_edit_date; if ($dif > 172800 && $row['priority_id'] == 'NRM' && $row['status_id'] != 'CLS') { $actions .= '<a href="myticket.php?ticket_id=' . $row['ticket_id'] . '&action=alert"><img src="../../../main/img/exclamation.png" border="0" /></a>'; } if ($row['priority_id'] == 'ALT') { $actions .= '<img src="../../../main/img/admin_star.png" border="0" />'; } $ticket = array($row['col0'], api_format_date($row['col1'], '%d/%m/%y - %I:%M:%S %p'), api_format_date($row['col2'], '%d/%m/%y - %I:%M:%S %p'), $row['col3'], $row['col7'], $actions); } if ($unread > 0) { $ticket['0'] = $ticket['0'] . ' (' . $unread . ')<a href="ticket_details.php?ticket_id=' . $row['ticket_id'] . '"><img src="../../../main/img/message_new.png" border="0" title="' . $unread . ' Nuevo(s) Mensajes"/></a>'; } if ($isAdmin) { $ticket['0'] .= ' <a href="javascript:void(0)" onclick="load_history_ticket(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')"> <img onclick="load_course_list(\'div_' . $row['ticket_id'] . '\',' . $row['ticket_id'] . ')" onmouseover="clear_course_list (\'div_' . $row['ticket_id'] . '\')" src="../../../main/img/history.gif" title="' . get_lang('Historial') . '" alt="' . get_lang('Historial') . '"/> <div class="blackboard_hide" id="div_' . $row['ticket_id'] . '"> </div> </a> '; } $tickets[] = $ticket; } return $tickets; }
function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 2) { return null; } // Email configuration settings $courseCode = api_get_course_id(); $course_info = api_get_course_info($courseCode); $url_email = api_get_path(WEB_CODE_PATH) . 'exercice/exercise_show.php?' . api_get_cidreq() . '&id_session=' . api_get_session_id() . '&id=' . $exe_id . '&action=qualify'; $user_info = UserManager::get_user_info_by_id(api_get_user_id()); $oral_question_list = null; foreach ($question_list_answers as $item) { $question = $item['question']; $answer = $item['answer']; $answer_type = $item['answer_type']; if (!empty($question) && !empty($answer) && $answer_type == ORAL_EXPRESSION) { $oral_question_list .= '<br /><table width="730" height="136" border="0" cellpadding="3" cellspacing="3"><tr> <td width="220" valign="top" bgcolor="#E5EDF8"> ' . get_lang('Question') . '</td> <td width="473" valign="top" bgcolor="#F3F3F3">' . $question . '</td> </tr> <tr> <td width="220" valign="top" bgcolor="#E5EDF8"> ' . get_lang('Answer') . '</td> <td valign="top" bgcolor="#F3F3F3">' . $answer . '</td> </tr></table>'; } } if (!empty($oral_question_list)) { $msg = '<p>' . get_lang('OralQuestionsAttempted') . ' :</p> <p>' . get_lang('AttemptDetails') . ' : </p> <table class="data_table"> <tr> <td><h3>' . get_lang('CourseName') . '</h3></td> <td><h3>#course#</h3></td> </tr> <tr> <td>' . get_lang('TestAttempted') . '</span></td> <td>#exercise#</td> </tr> <tr> <td>' . get_lang('StudentName') . '</td> <td>#firstName# #lastName#</td> </tr> <tr> <td>' . get_lang('StudentEmail') . '</td> <td>#mail#</td> </tr> </table>'; $msg .= '<br />' . sprintf(get_lang('OralQuestionsAttemptedAreX'), $oral_question_list) . '<br />'; $msg1 = str_replace("#exercise#", $this->exercise, $msg); $msg = str_replace("#firstName#", $user_info['firstname'], $msg1); $msg1 = str_replace("#lastName#", $user_info['lastname'], $msg); $msg = str_replace("#mail#", $user_info['email'], $msg1); $msg = str_replace("#course#", $course_info['name'], $msg1); if ($origin != 'learnpath') { $msg .= get_lang('ClickToCommentAndGiveFeedback') . ', <br /> <a href="#url#">#url#</a>'; } $msg1 = str_replace("#url#", $url_email, $msg); $mail_content = $msg1; $subject = get_lang('OralQuestionsAttempted'); if (api_get_session_id()) { $teachers = CourseManager::get_coach_list_from_course_code($courseCode, api_get_session_id()); } else { $teachers = CourseManager::get_teacher_list_from_course_code($courseCode); } if (!empty($teachers)) { foreach ($teachers as $user_id => $teacher_data) { MessageManager::send_message_simple($user_id, $subject, $mail_content); } } } }
<?php /* * This file is part of the Libcast Dokeos module. * * (c) Libcast <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ require_once realpath(__DIR__ . '/../inc/global.inc.php'); require_once realpath(__DIR__ . '/../inc/lib/usermanager.lib.php'); require_once realpath(__DIR__ . '/../inc/lib/course.lib.php'); if (!($userId = strtolower(htmlspecialchars($_GET['id'])))) { return; } if (!($user = UserManager::get_user_info_by_id($userId))) { return; } $libcast->synchronizeUser($user);
public function get_forum_thread_data($username, $password, $course_code, $thread_id, $field) { if ($this->verifyUserPass($username, $password) == "valid") { $course_db = CourseManager::get_course_information($course_code); $table_item_property = Database::get_course_table(TABLE_ITEM_PROPERTY, $course_db['db_name']); $table_threads = Database::get_course_table(TABLE_FORUM_THREAD, $course_db['db_name']); $sql = "SELECT * FROM " . $table_threads . " threads, " . $table_item_property . " item_properties\n WHERE item_properties.tool='" . TOOL_FORUM_THREAD . "'\n AND item_properties.ref='" . Database::escape_string($thread_id) . "'\n AND threads.thread_id='" . Database::escape_string($thread_id) . "'"; $result = Database::query($sql); $thread_info = Database::fetch_array($result); switch ($field) { case 'title': $htmlcode = true; $field_table = "thread_title"; break; case 'date': $field_table = "thread_date"; break; case 'sender': $field_table = "insert_user_id"; break; case 'sender_name': $user_id = $thread_info[insert_user_id]; $user_info = UserManager::get_user_info_by_id($user_id); return $user_info['firstname']; break; default: $field_table = "title"; } return $thread_info[$field_table]; } else { return get_lang('InvalidId'); } }
WHERE id=' . $le_session_id; $rs = api_sql_query($sql, __FILE__, __LINE__); $session_name = Database::result($rs, 0, 'name'); $session_coach_id = intval(Database::result($rs, 0, 'id_coach')); // get coach of the course in the session $sql = 'SELECT id_coach FROM ' . $tbl_session_course . ' WHERE id_session=' . $le_session_id . ' AND course_code = "' . Database::escape_string($_GET['course']) . '"'; $rs = api_sql_query($sql, __FILE__, __LINE__); $session_course_coach_id = intval(Database::result($rs, 0, 0)); if ($session_course_coach_id != 0) { $coach_infos = UserManager::get_user_info_by_id($session_course_coach_id); $a_infosCours['tutor_name'] = $coach_infos['firstname'] . ' ' . $coach_infos['lastname']; } else { if ($session_coach_id != 0) { $coach_infos = UserManager::get_user_info_by_id($session_coach_id); $a_infosCours['tutor_name'] = $coach_infos['firstname'] . ' ' . $coach_infos['lastname']; } } } } } // end if(api_get_setting('use_session_mode')=='true') $date_start = ''; if (!empty($a_infosCours['date_start'])) { $a_date_start = explode('-', $a_infosCours['date_start']); $date_start = $a_date_start[2] . '/' . $a_date_start[1] . '/' . $a_date_start[0]; } $date_end = ''; if (!empty($a_infosCours['date_end'])) { $a_date_end = explode('-', $a_infosCours['date_end']);
if (api_get_setting('show_users_folders') == 'false' && ($document_data['path'] == '/shared_folder' || strstr($document_data['path'], 'shared_folder_session_'))) { continue; } //Admin setting for Hide/Show Default folders to all users if (api_get_setting('show_default_folders') == 'false' && ($document_data['path'] == '/images' || $document_data['path'] == '/flash' || $document_data['path'] == '/audio' || $document_data['path'] == '/video')) { continue; } //Admin setting for Hide/Show chat history folder if (api_get_setting('show_chat_folder') == 'false' && $document_data['path'] == '/chat_files') { continue; } // Show the owner of the file only in groups $user_link = ''; if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') { if (!empty($document_data['insert_user_id'])) { $user_info = UserManager::get_user_info_by_id($document_data['insert_user_id']); $user_name = api_get_person_name($user_info['firstname'], $user_info['lastname']); $user_link = '<div class="document_owner">' . get_lang('Owner') . ': ' . display_user_link_document($document_data['insert_user_id'], $user_name) . '</div>'; } } // Icons (clickable) $row[] = create_document_link($document_data, true, $count, $is_visible); $path_info = pathinfo($document_data['path']); if (isset($path_info['extension']) && in_array($path_info['extension'], array('ogg', 'mp3', 'wav'))) { $count++; } // Validacion when belongs to a session $session_img = api_get_session_image($document_data['session_id'], $_user['status']); // Document title with link $row[] = create_document_link($document_data, false, null, $is_visible) . $session_img . '<br />' . $invisibility_span_open . '<i>' . nl2br(htmlspecialchars($document_data['comment'], ENT_QUOTES, $charset)) . '</i>' . $invisibility_span_close . $user_link; // Comments => display comment under the document name
function manage_form($default, $select_from_user_list = null, $sent_to = null) { $group_id = isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : null; $message_id = isset($_GET['message_id']) ? intval($_GET['message_id']) : null; $param_f = isset($_GET['f']) ? Security::remove_XSS($_GET['f']) : ''; $form = new FormValidator('compose_message', null, api_get_self() . '?f=' . $param_f, null, array('enctype' => 'multipart/form-data')); if (empty($group_id)) { if (isset($select_from_user_list)) { $form->add_textfield('id_text_name', get_lang('SendMessageTo'), true, array('class' => 'span4', 'id' => 'id_text_name', 'onkeyup' => 'send_request_and_search()', 'autocomplete' => 'off')); $form->addRule('id_text_name', get_lang('ThisFieldIsRequired'), 'required'); $form->addElement('html', '<div id="id_div_search" style="padding:0px" class="message-select-box" > </div>'); $form->addElement('hidden', 'user_list', 0, array('id' => 'user_list')); } else { if (!empty($sent_to)) { $form->addElement('html', $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select', 'users', get_lang('SendMessageTo'), array(), array('id' => 'users')); } else { $form->addElement('hidden', 'hidden_user', $default['users'][0], array('id' => 'hidden_user')); } } } else { $usergroup = new UserGroup(); $group_info = $usergroup->get($group_id); $form->addElement('label', get_lang('ToGroup'), api_xml_http_response_encode($group_info['name'])); $form->addElement('hidden', 'group_id', $group_id); $form->addElement('hidden', 'parent_id', $message_id); } $form->add_textfield('title', get_lang('Subject'), true, array('class' => 'span4')); $form->add_html_editor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '95%', 'Height' => '250')); if (isset($_GET['re_id'])) { $message_reply_info = MessageManager::get_message_by_id($_GET['re_id']); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_reply_info['title']; $form->addElement('hidden', 're_id', intval($_GET['re_id'])); $form->addElement('hidden', 'save_form', 'save_form'); //adding reply mail $user_reply_info = UserManager::get_user_info_by_id($message_reply_info['user_sender_id']); $default['content'] = '<br />' . sprintf(get_lang('XWroteY'), api_get_person_name($user_reply_info['firstname'], $user_reply_info['lastname']), Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('advanced_settings', get_lang('FilesAttachment') . '<span id="filepaths"> <div id="filepath_1"> <input type="file" name="attach_1"/><br /> ' . get_lang('Description') . ' <input type="text" name="legend[]" /><br /><br /> </div> </span>'); $form->addElement('advanced_settings', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), Text::format_file_size(api_get_setting('message_max_upload_filesize'))) . ')'); } $form->addElement('style_submit_button', 'compose', api_xml_http_response_encode(get_lang('SendMessage')), 'class="save"'); $form->setRequiredNote('<span class="form_required">*</span> <small>' . get_lang('ThisFieldIsRequired') . '</small>'); if (!empty($group_id) && !empty($message_id)) { $message_info = MessageManager::get_message_by_id($message_id); $default['title'] = get_lang('MailSubjectReplyShort') . " " . $message_info['title']; } $form->setDefaults($default); $html = ''; if ($form->validate()) { $check = Security::check_token('post'); if ($check) { $user_list = $default['users']; $file_comments = $_POST['legend']; $title = $default['title']; $content = $default['content']; $group_id = isset($default['group_id']) ? $default['group_id'] : null; $parent_id = $default['parent_id']; if (is_array($user_list) && count($user_list) > 0) { //all is well, send the message foreach ($user_list as $user) { $res = MessageManager::send_message($user, $title, $content, $_FILES, $file_comments, $group_id, $parent_id, null, null, api_get_user_id()); if ($res) { if (is_string($res)) { $html .= Display::return_message($res, 'error'); } else { $user_info = api_get_user_info($user); $html .= Display::return_message(get_lang('MessageSentTo') . " <b>" . $user_info['complete_name'] . "</b>", 'confirmation', false); } } } } else { Display::display_error_message('ErrorSendingMessage'); } } Security::clear_token(); } else { $token = Security::get_token(); $form->addElement('hidden', 'sec_token'); $form->setConstants(array('sec_token' => $token)); $html .= $form->return_form(); } return $html; }
/** * Displays messages of a group with nested view * @param $group_id * @param $topic_id * @param $is_member * @param $message_id * @return string */ public static function display_message_for_group($group_id, $topic_id, $is_member, $message_id) { global $my_group_role; $main_message = self::get_message_by_id($topic_id); if (empty($main_message)) { return false; } $rows = self::get_messages_by_group_by_message($group_id, $topic_id); $rows = self::calculate_children($rows, $topic_id); $current_user_id = api_get_user_id(); $items_per_page = 50; $query_vars = array('id' => $group_id, 'topic_id' => $topic_id, 'topics_page_nr' => 0); // Main message $user_link = ''; $links = ''; $main_content = ''; $items_page_nr = null; $html = ''; $delete_button = ''; if (api_is_platform_admin()) { $delete_button = Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), 'group_topics.php?action=delete&id=' . $group_id . '&topic_id=' . $topic_id); } $html .= Display::page_subheader(Security::remove_XSS($main_message['title'] . $delete_button, STUDENT, true)); $user_sender_info = UserManager::get_user_info_by_id($main_message['user_sender_id']); $files_attachments = self::get_links_message_attachment_files($main_message['id']); $name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']); $topic_page_nr = isset($_GET['topics_page_nr']) ? intval($_GET['topics_page_nr']) : null; $links .= '<div id="message-reply-link">'; if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $main_message['user_sender_id'] == $current_user_id) { $links .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend=' . $current_user_id . '&group_id=' . $group_id . '&message_id=' . $main_message['id'] . '&action=edit_message_group&anchor_topic=topic_' . $main_message['id'] . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $main_message['id'] . '" class="group_message_popup" title="' . get_lang('Edit') . '">'; $links .= Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; } $links .= ' <a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend=' . api_get_user_id() . '&group_id=' . $group_id . '&message_id=' . $main_message['id'] . '&action=reply_message_group&anchor_topic=topic_' . $main_message['id'] . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $main_message['id'] . '" class="group_message_popup" title="' . get_lang('Reply') . '">'; $links .= Display::return_icon('talk.png', get_lang('Reply')) . '</a>'; $links .= '</div>'; $image_path = UserManager::get_user_picture_path_by_id($main_message['user_sender_id'], 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; $main_content .= '<div class="message-group-author"><img src="' . $image_repository . $existing_image . '" alt="' . $name . '" width="32" height="32" title="' . $name . '" /></div>'; $user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $main_message['user_sender_id'] . '">' . $name . ' </a>'; $date = ''; if ($main_message['send_date'] != $main_message['update_date']) { if (!empty($main_message['update_date']) && $main_message['update_date'] != '0000-00-00 00:00:00') { $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($main_message['update_date']) . '</div>'; } } else { $date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($main_message['send_date']) . '</div>'; } $attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>'; $main_content .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . $main_message['content'] . $attachment . '</div>'; $main_content = Security::remove_XSS($main_content, STUDENT, true); $html .= Display::div(Display::div(Display::div($main_content, array('class' => 'group_social_sub_item', 'style' => 'background-color:#fff;')), array('class' => 'group_social_item')), array('class' => 'group_social_grid')); $topic_id = $main_message['id']; if (is_array($rows) && count($rows) > 0) { $topics = $rows; $array_html_items = array(); foreach ($topics as $index => $topic) { if (empty($topic['id'])) { continue; } $items_page_nr = isset($_GET['items_' . $topic['id'] . '_page_nr']) ? intval($_GET['items_' . $topic['id'] . '_page_nr']) : null; $user_link = ''; $links = ''; $html_items = ''; $user_sender_info = UserManager::get_user_info_by_id($topic['user_sender_id']); $files_attachments = self::get_links_message_attachment_files($topic['id']); $name = api_get_person_name($user_sender_info['firstname'], $user_sender_info['lastname']); $links .= '<div id="message-reply-link">'; if ($my_group_role == GROUP_USER_PERMISSION_ADMIN || $my_group_role == GROUP_USER_PERMISSION_MODERATOR || $topic['user_sender_id'] == $current_user_id) { $links .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend=' . $current_user_id . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=edit_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="group_message_popup" title="' . get_lang('Edit') . '">' . Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL) . '</a>'; } $links .= ' <a href="' . api_get_path(WEB_CODE_PATH) . 'social/message_for_group_form.inc.php?view_panel=1&height=390&width=610&&user_friend=' . api_get_user_id() . '&group_id=' . $group_id . '&message_id=' . $topic['id'] . '&action=reply_message_group&anchor_topic=topic_' . $topic_id . '&topics_page_nr=' . $topic_page_nr . '&items_page_nr=' . $items_page_nr . '&topic_id=' . $topic_id . '" class="group_message_popup" title="' . get_lang('Reply') . '">'; $links .= Display::return_icon('talk.png', get_lang('Reply')) . '</a>'; $links .= '</div>'; $image_path = UserManager::get_user_picture_path_by_id($topic['user_sender_id'], 'web', false, true); $image_repository = $image_path['dir']; $existing_image = $image_path['file']; $html_items .= '<div class="message-group-author"><img src="' . $image_repository . $existing_image . '" alt="' . $name . '" width="32" height="32" title="' . $name . '" /></div>'; $user_link = '<a href="' . api_get_path(WEB_PATH) . 'main/social/profile.php?u=' . $topic['user_sender_id'] . '">' . $name . ' </a>'; $date = ''; if ($topic['send_date'] != $topic['update_date']) { if (!empty($topic['update_date']) && $topic['update_date'] != '0000-00-00 00:00:00') { $date = '<div class="message-group-date"> ' . get_lang('LastUpdate') . ' ' . date_to_str_ago($topic['update_date']) . '</div>'; } } else { $date = '<div class="message-group-date"> ' . get_lang('Created') . ' ' . date_to_str_ago($topic['send_date']) . '</div>'; } $attachment = '<div class="message-attach">' . (!empty($files_attachments) ? implode('<br />', $files_attachments) : '') . '</div>'; $html_items .= '<div class="message-group-content">' . $links . $user_link . ' ' . $date . Security::remove_XSS($topic['content'], STUDENT, true) . $attachment . '</div>'; $base_padding = 20; if ($topic['indent_cnt'] == 0) { $indent = $base_padding; } else { $indent = intval($topic['indent_cnt']) * $base_padding + $base_padding; } $class = 'group_social_sub_item'; if (isset($message_id) && $message_id == $topic['id']) { $class .= ' group_social_sub_item_highlight'; } $html_items = Display::div($html_items, array('class' => $class, 'id' => 'msg_' . $topic['id'])); $html_items = Display::div($html_items, array('class' => '', 'style' => 'margin-left:' . $indent . 'px')); $array_html_items[] = array($html_items); } // grids for items with paginations $options = array('hide_navigation' => false, 'per_page' => $items_per_page); $visibility = array(true, true, true, false); $style_class = array('item' => array('class' => 'group_social_item'), 'main' => array('class' => 'group_social_grid')); if (!empty($array_html_items)) { $html .= Display::return_sortable_grid('items_' . $topic['id'], array(), $array_html_items, $options, $query_vars, null, $visibility, false, $style_class); } } return $html; }
/** * @covers UserManager::get_user_info_by_id * @depends testCreateUser */ public function testGet_user_info_by_id($user_id) { $user_info = UserManager::get_user_info_by_id($user_id); $this->assertGreaterThan(1, $user_info['user_id']); return $user_info; }
protected function format_item($item) { $result = (object) array(); $item = (object) $item; $author = (object) UserManager::get_user_info_by_id($item->lastedit_user_id); $result->title = $item->title; $result->description = $item->description; $result->description .= $result->description ? '<br/>' : ''; $result->description .= '<i>' . $item->course_title . ' > ' . $this->get_tool_lang($item->tool) . ' > ' . $item->title . '</i>'; $result->date = date('r', strtotime($item->lastedit_date)); $result->author = htmlentities($author->firstname . ' ' . $author->lastname . ' <' . $author->email . '>'); $result->author_email = $author->email; $result->tool = $item->tool; $result->course_code = $item->code; $result->course_title = $item->course_title; $result->course_description = $item->course_description; $result->course_id = $item->c_id; $tool = $item->tool; $f = array($this, "format_{$tool}"); if (is_callable($f)) { call_user_func($f, $result, $item); } return $result; }
/** * Edits user info (helper method) * * @param string User id field name. Use "chamilo_user_id" in order to use internal system id * @param string User id value * @param string First name * @param string Last name * @param int User status * @param string Login name * @param string Password. Leave blank if you don't want to update it * @param string Encrypt method * @param string User email * @param string Language. Set by default to english * @param string Phone. Set by default to an empty string * @param string Expiration date. Set to null by default * @param array Extra fields. An array with elements of the form ('field_name' => 'name_of_the_field', 'field_value' => 'value_of_the_field'). Leave empty if you don't want to update * @return mixed True if user was successfully updated, WSError otherwise */ protected function editUserHelper($user_id_field_name, $user_id_value, $firstname, $lastname, $status, $loginname, $password, $encrypt_method, $email, $language, $phone, $expiration_date, $extras) { global $api_failureList; $user_id = $this->getUserId($user_id_field_name, $user_id_value); if($user_id instanceof WSError) { return $user_id; } else { if($password == '') { $password = null; } $user_info = UserManager::get_user_info_by_id($user_id); if(count($extras) == 0) { $extras = null; } $result = UserManager::update_user($user_id, $firstname, $lastname, $loginname, $password, PLATFORM_AUTH_SOURCE, $email, $status, '', $phone, $user_info['picture_uri'], $expiration_date, $user_info['active'], null, $user_info['hr_dept_id'], $extras, $encrypt_method); if (!$result) { $failure = $api_failureList[0]; if($failure == 'encrypt_method invalid') { return new WSError(103, 'The encryption of the password is invalid'); } else { return new WSError(105, 'There was an error updating the user'); } } else { return $result; } } }
<?php //Script loaded by local.inc.php providing update user information of type external_logininfo. /* This script must not exit. */ use ChamiloSession as Session; require_once api_get_path(LIBRARY_PATH) . 'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH) . 'course.lib.php'; require_once dirname(__FILE__) . '/functions.inc.php'; //MAIN CODE //$uData variable is set in local.inc.php $user = UserManager::get_user_info_by_id($uData['user_id']); $new_user = external_get_user_info($login); $user['firstname'] = $new_user['firstname']; $user['lastname'] = $new_user['lastname']; $user['status'] = $new_user['status']; $user['admin'] = $new_user['admin']; $user['email'] = $new_user['email']; $user['username'] = $new_user['username']; $user['profile_link'] = $new_user['profile_link']; $user['worldwide_bu'] = $new_user['worldwide_bu']; $user['manager'] = $new_user['manager']; $user['country_bu'] = $new_user['country_bu']; $user['extra'] = $new_user['extra']; if ($new_user !== false) { //User can login external_update_user($user); $loginFailed = false; $_user['user_id'] = $user['user_id']; $_user['uidReset'] = true;
function WSSubscribeUserToSessionSimple($params) { global $debug; if ($debug) { error_log('WSSubscribeUserToSessionSimple with params=[' . serialize($params). ']'); } // Check security key if (!WSHelperVerifyKey($params)) { return return_error(WS_ERROR_SECRET_KEY); } // Get input parameters $session_id = intval($params['session']); // Session ID $user_id = intval($params['user_id']); // Chamilo user id // Get user id $user_data = UserManager::get_user_info_by_id($user_id); // Prepare answer $result = 0; if (empty($user_data)) { $result = "User {$user_id} does not exist"; if ($debug) { error_log($result); } return $result; } if (!empty($session_id) && is_numeric($session_id)) { $session_data = api_get_session_info($session_id); if (empty($session_data)) { $result = "Session {$session_id} does not exist."; if ($debug) { error_log($result); } } else { SessionManager::suscribe_users_to_session($session_id, array($user_id), SESSION_VISIBLE_READ_ONLY, false, false); if ($debug) error_log('User registered to the course: '.$session_id); $result = 1; } } return $result; }
unset($_SESSION['paged_questions']); unset($_SESSION['page_questions_sec']); $paged_questions_sec = array(); if (!empty($survey_data['survey_introduction'])) { echo '<div id="survey_content" class="survey_content">'.$survey_data['survey_introduction'].'</div>'; } $limit = 0; } $user_id = api_get_user_id(); if ($user_id == 0) { $user_id = $survey_invitation['user']; } $user_data = UserManager :: get_user_info_by_id($user_id); if ($survey_data['form_fields'] != '' && $survey_data['anonymous'] == 0 && is_array($user_data)) { $form_fields = explode('@', $survey_data['form_fields']); $list = array(); foreach ($form_fields as $field) { $field_value = explode(':', $field); if ($field_value[1] == 1) { if ($field_value[0] != '') { $val = api_substr($field_value[0], 8, api_strlen($field_value[0])); $list[$val] = 1; } } } // We use the same form as in auth/profile.php
/** * Update the user in chamilo database. It upgrade only info that is present in the * new_user array * * @param $new_user associative array with the value to upgrade * WARNING user_id key is MANDATORY * Possible keys are : * - firstname * - lastname * - username * - auth_source * - email * - status * - official_code * - phone * - picture_uri * - expiration_date * - active * - creator_id * - hr_dept_id * - extra : array of custom fields * - language * - courses : string of all courses code separated by '|' * - admin : boolean * @return boolean * @author ndiechburg <*****@*****.**> * */ function external_update_user($new_user) { $old_user = UserManager::get_user_info_by_id($new_user['user_id']); $u = array_merge($old_user, $new_user); $updated = UserManager::update_user($u['user_id'], $u['firstname'], $u['lastname'], $u['username'], null, $u['auth_source'], $u['email'], $u['status'], $u['official_code'], $u['phone'], $u['picture_uri'], $u['expiration_date'], $u['active'], $u['creator_id'], $u['hr_dept_id'], $u['extra'], $u['language'], ''); if (isset($u['courses']) && !empty($u['courses'])) { $autoSubscribe = explode('|', $u['courses']); foreach ($autoSubscribe as $code) { if (CourseManager::course_exists($code)) { CourseManager::subscribe_user($u['user_id'], $code); } } } // Is User Admin ? //TODO decomments and check that user_is is not already in admin table /* if (isset($u['admin']) && $u['admin']){ $table = Database::get_main_table(TABLE_MAIN_ADMIN); $res = Database::query("SELECT * from $table WHERE user_id = ".$u['user_id']); } */ }