/** * @Route("/{username}") * @Method({"GET"}) */ public function indexAction($username) { $userId = \UserManager::get_user_id_from_username($username); $userInfo = api_get_user_info($userId); $this->getTemplate()->assign('user', $userInfo); $this->getTemplate()->assign('form_send_message', \MessageManager::generate_message_form('send_message')); $this->getTemplate()->assign('form_send_invitation', \MessageManager::generate_invitation_form('send_invitation')); $response = $this->getTemplate()->renderTemplate($this->getTemplatePath() . 'profile.tpl'); return new Response($response, 200, array()); }
/** * Get the list of new messages for a user * @param string $username The username * @param int $lastId The id of the last received message * @return array the new message list */ public function getNewMessages($username, $lastId = 0) { $messages = array(); $userInfo = api_get_user_info_from_username($username); $userId = $userInfo['user_id']; $lastMessages = MessageManager::getMessagesFromLastReceivedMessage($userId, $lastId); foreach ($lastMessages as $message) { $hasAttachments = MessageManager::hasAttachments($message['id']); $messages[] = array('id' => $message['id'], 'title' => $message['title'], 'sender' => array('id' => $message['user_id'], 'lastname' => $message['lastname'], 'firstname' => $message['firstname'], 'completeName' => api_get_person_name($message['firstname'], $message['lastname'])), 'sendDate' => $message['send_date'], 'content' => $message['content'], 'hasAttachments' => $hasAttachments, 'platform' => array('website' => api_get_path(WEB_PATH), 'messagingTool' => api_get_path(WEB_PATH) . 'main/messages/inbox.php')); } return $messages; }
public static function echoAll() { if (count(self::$errors)) { echo '<ul class="log_list_errors">'; MessageManager::echoAllErrors('<li>', '</li>'); echo '</ul>'; } if (count(self::$warnings)) { echo '<ul class="log_list_warnings">'; MessageManager::echoAllWarnings('<li>', '</li>'); echo '</ul>'; } if (count(self::$msgs)) { echo '<ul class="log_list_messages">'; MessageManager::echoAllMessages('<li>', '</li>'); echo '</ul>'; } }
} if (!empty($user_info['teach'])) { $more_info .= '<div class="social-actions-message"><strong>' . get_lang('MyTeach') . '</strong></div>'; $more_info .= '<div class="social-profile-extended">' . $user_info['teach'] . '</div>'; $more_info .= '<br />'; } $socialRightInformation .= SocialManager::social_wrapper_div($more_info, 4); } } $tpl = new Template(get_lang('Social')); // Block Avatar Social SocialManager::setSocialUserBlock($tpl, $user_id, 'shared_profile'); $tpl->assign('social_friend_block', $friend_html); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_wall_block', $social_wall_block); $tpl->assign('social_post_wall_block', $social_post_wall_block); $tpl->assign('social_extra_info_block', $social_extra_info_block); $tpl->assign('social_course_block', $social_course_block); $tpl->assign('social_group_info_block', $social_group_info_block); $tpl->assign('social_rss_block', $social_rss_block); $tpl->assign('social_skill_block', SocialManager::getSkillBlock($my_user_id)); $tpl->assign('sessionList', $social_session_block); $tpl->assign('social_right_information', $socialRightInformation); $tpl->assign('social_auto_extend_link', $socialAutoExtendLink); $formModalTpl = new Template(); $formModalTpl->assign('messageForm', MessageManager::generate_message_form('send_message')); $formModalTpl->assign('invitationForm', MessageManager::generate_invitation_form('send_invitation')); $formModals = $formModalTpl->fetch('default/social/form_modals.tpl'); $tpl->assign('formModals', $formModals); $social_layout = $tpl->get_template('social/profile.tpl'); $tpl->display($social_layout);
$social_avatar_block = SocialManager::show_social_avatar_block( 'member_list', $group_id ); $social_menu_block = SocialManager::show_social_menu('member_list', $group_id); if (!empty($show_message)) { $social_right_content .= Display::return_message( $show_message, 'confirmation' ); } $social_right_content .= MessageManager::display_message_for_group( $group_id, $topic_id, $is_member, $message_id ); $social_right_content = '<div class="span9">' . $social_right_content . '</div>'; $tpl = new Template($tool_name); $tpl->set_help('Groups'); $tpl->assign('social_avatar_block', $social_avatar_block); $tpl->assign('social_menu_block', $social_menu_block); $tpl->assign('social_right_content', $social_right_content); $tpl->assign('actions', $actions); $tpl->assign('message', $show_message); $tpl->assign('content', $content); $social_layout = $tpl->get_template('layout/social_layout.tpl');
Database::query($sql); if (isset($_POST['send_notification'])) { //@todo move this somewhere else $subject = get_lang('ExamSheetVCC'); $message = '<p>' . get_lang('DearStudentEmailIntroduction') . '</p><p>' . get_lang('AttemptVCC'); $message .= '<h3>' . get_lang('CourseName') . '</h3><p>' . Security::remove_XSS($course_info['name']) . ''; $message .= '<h3>' . get_lang('Exercise') . '</h3><p>' . Security::remove_XSS($test); //Only for exercises not in a LP if ($lp_id == 0) { $message .= '<p>' . get_lang('ClickLinkToViewComment') . ' <a href="#url#">#url#</a><br />'; } $message .= '<p>' . get_lang('Regards') . '</p>'; $message .= $from_name; $message = str_replace("#test#", Security::remove_XSS($test), $message); $message = str_replace("#url#", $url, $message); MessageManager::send_message_simple($student_id, $subject, $message, api_get_user_id()); if ($allowCoachFeedbackExercises) { Display::addFlash(Display::return_message(get_lang('MessageSent'))); header('Location: ' . api_get_path(WEB_PATH)); exit; } } //Updating LP score here if (in_array($origin, array('tracking_course', 'user_course', 'correct_exercise_in_lp'))) { $sql = "UPDATE {$TBL_LP_ITEM_VIEW} SET score = '" . floatval($tot) . "'\n WHERE c_id = " . $course_id . " AND id = " . $lp_item_view_id; Database::query($sql); if ($origin == 'tracking_course') { //Redirect to the course detail in lp header('location: exercise.php?course=' . Security::remove_XSS($_GET['course'])); exit; } else {
$user_list = isset($_POST['invitation']) ? $_POST['invitation'] : null; $group_id = intval($_POST['id']); if (!is_array($user_list)) { $user_list = array(); } if ($form_sent == 1) { // invite this users $result = $usergroup->add_users_to_groups($user_list, array($group_id), GROUP_USER_PERMISSION_PENDING_INVITATION); $title = get_lang('YouAreInvitedToGroup') . ' ' . $group_info['name']; $content = get_lang('YouAreInvitedToGroupContent') . ' ' . $group_info['name'] . ' <br />'; $content .= get_lang('ToSubscribeClickInTheLinkBelow') . ' <br />'; $content .= '<a href="' . api_get_path(WEB_CODE_PATH) . 'social/invitations.php?accept=' . $group_id . '">' . get_lang('Subscribe') . '</a>'; if (is_array($user_list) && count($user_list) > 0) { //send invitation message foreach ($user_list as $user_id) { $result = MessageManager::send_message($user_id, $title, $content); } Display::addFlash(Display::return_message(get_lang('InvitationSent'))); } header('Location: ' . api_get_self() . '?id=' . $group_id); exit; } } $nosessionUsersList = $sessionUsersList = array(); $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username'; $friends = SocialManager::get_friends(api_get_user_id()); $suggest_friends = false; $Users = array(); if (!$friends) { $suggest_friends = true; } else {
/** * Subscribes users (students) to the given session and optionally (default) unsubscribes previous users * @author Carlos Vargas from existing code * @param integer Session ID * @param array List of user IDs * @param bool Whether to unsubscribe existing users (true, default) or not (false) * @return void Nothing, or false on error **/ public static function suscribe_users_to_session($id_session, $user_list, $session_visibility = SESSION_VISIBLE_READ_ONLY, $empty_users = true, $send_email = false) { if ($id_session != strval(intval($id_session))) { return false; } foreach ($user_list as $intUser) { if ($intUser != strval(intval($intUser))) { return false; } } $tbl_session_rel_course = Database::get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_rel_course_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER); $tbl_session_rel_user = Database::get_main_table(TABLE_MAIN_SESSION_USER); $tbl_session = Database::get_main_table(TABLE_MAIN_SESSION); $session_info = api_get_session_info($id_session); if ($session_info) { $session_name = $session_info['name']; } else { return false; } //from function parameter if (empty($session_visibility)) { $session_visibility = $session_info['visibility']; //loaded from DB //default status loaded if empty if (empty($session_visibility)) { $session_visibility = SESSION_VISIBLE_READ_ONLY; } // by default readonly 1 } else { if (!in_array($session_visibility, array(SESSION_VISIBLE_READ_ONLY, SESSION_VISIBLE, SESSION_INVISIBLE))) { $session_visibility = SESSION_VISIBLE_READ_ONLY; } } $sql = "SELECT id_user FROM {$tbl_session_rel_course_rel_user} WHERE id_session = '{$id_session}' AND status = 0"; $result = Database::query($sql); $existingUsers = array(); while ($row = Database::fetch_array($result)) { $existingUsers[] = $row['id_user']; } $sql = "SELECT c_id FROM {$tbl_session_rel_course} WHERE id_session = '{$id_session}'"; $result = Database::query($sql); $course_list = array(); while ($row = Database::fetch_array($result)) { $course_list[] = $row['c_id']; } if ($send_email) { //sending emails only if (is_array($user_list) && count($user_list) > 0) { foreach ($user_list as $user_id) { if (!in_array($user_id, $existingUsers)) { $subject = '[' . get_setting('siteName') . '] ' . get_lang('YourReg') . ' ' . get_setting('siteName'); $user_info = api_get_user_info($user_id); $content = get_lang('Dear') . " " . stripslashes($user_info['complete_name']) . ",\n\n" . sprintf(get_lang('YouAreRegisterToSessionX'), $session_name) . " \n\n" . get_lang('Address') . " " . api_get_setting('siteName') . " " . get_lang('Is') . " : " . api_get_path(WEB_PATH) . "\n\n" . get_lang('Problem') . "\n\n" . get_lang('Formula') . ",\n\n" . get_setting('administratorName') . " " . get_setting('administratorSurname') . "\n" . get_lang('Manager') . " " . get_setting('siteName') . "\nT. " . get_setting('administratorTelephone') . "\n" . get_lang('Email') . " : " . get_setting('emailAdministrator'); MessageManager::send_message($user_id, $subject, $content, array(), array(), null, null, null, null, null); } } } } foreach ($course_list as $courseId) { // for each course in the session $nbr_users = 0; $courseId = Database::escape_string($courseId); // delete existing users if ($empty_users) { foreach ($existingUsers as $existing_user) { if (!in_array($existing_user, $user_list)) { $sql = "DELETE FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND c_id ='{$courseId}' AND id_user='******' AND status = 0"; $result = Database::query($sql); if (Database::affected_rows($result)) { $nbr_users--; } } } } //Replace with this new function // // insert new users into session_rel_course_rel_user and ignore if they already exist foreach ($user_list as $enreg_user) { if (!in_array($enreg_user, $existingUsers)) { $enreg_user = Database::escape_string($enreg_user); $insert_sql = "INSERT IGNORE INTO {$tbl_session_rel_course_rel_user}(id_session, c_id, id_user, visibility, status) VALUES('{$id_session}','{$courseId}','{$enreg_user}','{$session_visibility}', '0')"; $result = Database::query($insert_sql); if (Database::affected_rows($result)) { $nbr_users++; } } } // count users in this session-course relation $sql = "SELECT COUNT(id_user) as nbUsers FROM {$tbl_session_rel_course_rel_user} WHERE id_session='{$id_session}' AND c_id ='{$courseId}' AND status<>2"; $rs = Database::query($sql); list($nbr_users) = Database::fetch_array($rs); // update the session-course relation to add the users total $update_sql = "UPDATE {$tbl_session_rel_course} SET nbr_users = {$nbr_users} WHERE id_session='{$id_session}' AND c_id ='{$courseId}'"; Database::query($update_sql); } // Delete users from the session if ($empty_users === true) { Database::query("DELETE FROM {$tbl_session_rel_user} WHERE id_session = {$id_session} AND relation_type<>" . SESSION_RELATION_TYPE_RRHH . ""); } // Insert missing users into session $nbr_users = 0; foreach ($user_list as $enreg_user) { $enreg_user = Database::escape_string($enreg_user); $insert_sql = "INSERT IGNORE INTO {$tbl_session_rel_user} (id_session, id_user) VALUES ('{$id_session}', '{$enreg_user}')"; Database::query($insert_sql); //Reset moved_to just in case $update_sql = "UPDATE {$tbl_session_rel_user} SET moved_to = 0, moved_status = 0, moved_at ='0000-00-00 00:00:00'\n WHERE id_session = {$id_session} AND id_user = {$enreg_user}"; Database::query($update_sql); $nbr_users++; } // update number of users in the session $nbr_users = count($user_list); if ($empty_users) { // update number of users in the session $update_sql = "UPDATE {$tbl_session} SET nbr_users = {$nbr_users} WHERE id='{$id_session}' "; Database::query($update_sql); } else { $update_sql = "UPDATE {$tbl_session} SET nbr_users = nbr_users + {$nbr_users} WHERE id='{$id_session}' "; Database::query($update_sql); } }
function send_notification_for_oral_questions($question_list_answers, $origin, $exe_id) { if (api_get_course_setting('email_alert_manager_on_new_quiz') != 1) { 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 = api_get_user_info(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 = get_lang('OralQuestionsAttempted') . '<br /><br /> ' . get_lang('AttemptDetails') . ' : <br /><br />' . '<table>' . '<tr>' . '<td><em>' . get_lang('CourseName') . '</em></td>' . '<td> <b>#course#</b></td>' . '</tr>' . '<tr>' . '<td>' . get_lang('TestAttempted') . '</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 .= '<br /><a href="#url#">' . get_lang('ClickToCommentAndGiveFeedback') . '</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::getTeacherListFromCourse($course_info['real_id']); } if (!empty($teachers)) { foreach ($teachers as $user_id => $teacher_data) { MessageManager::send_message_simple($user_id, $subject, $mail_content); } } } }
echo ' $("#send_message_link").on("click", function() { var url = "' . $ajax_url . '?a=send_message&user_id=' . $user_info['user_id'] . '"; var params = $("#send_message").serialize(); $.ajax({ url: url+"&"+params, success:function(data) { $("#subject_id").val(""); $("#content_id").val(""); $("#send_message").html(data); $("#send_message_link").hide(); } }); });'; echo '</script>'; echo MessageManager::generate_message_form('send_message', array(), 'block'); echo ' <div class="row"> <div class="col-sm-10 col-sm-offset-2"> <a class="btn btn-primary" id="send_message_link"> <em class="fa fa-envelope"></em> ' . get_lang('Send') . ' </a> </div> </div> '; } break; case 'user_id_exists': if (api_is_anonymous()) { echo ''; } else {
/** * Send emails to users. * @param bool $sendToUsersInSession * @param bool $sendToDrhUsers send a copy of the message to the DRH users * related to the main user */ public function send($sendToUsersInSession = false, $sendToDrhUsers = false) { $sender = $this->sender(); $subject = $this->subject(); // Send email one by one to avoid antispam $users = $this->sent_to(); foreach ($users as $user) { $message = $this->message($user['user_id']); MessageManager::send_message_simple($user['user_id'], $subject, $message, $sender['user_id'], $sendToDrhUsers, true); } if ($sendToUsersInSession) { $sessionList = SessionManager::get_session_by_course($this->course['real_id']); if (!empty($sessionList)) { foreach ($sessionList as $sessionInfo) { $sessionId = $sessionInfo['id']; $message = $this->message(null, $sessionId); $userList = CourseManager::get_user_list_from_course_code($this->course['code'], $sessionId); if (!empty($userList)) { foreach ($userList as $user) { MessageManager::send_message_simple($user['user_id'], $subject, $message, $sender['user_id'], false, true); } } } } } $this->log_mail_sent(); }
} $actionsRight = $form->returnForm(); $social_right_content .= Display::toolbarAction('toolbar', [$actionsLeft, $actionsRight]); } //MAIN CONTENT if (!isset($_GET['del_msg'])) { $social_right_content .= MessageManager::inbox_display(); } else { $num_msg = intval($_POST['total']); for ($i = 0; $i < $num_msg; $i++) { if ($_POST[$i]) { //the user_id was necesarry to delete a message?? Display::addFlash(MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_POST['_' . $i])); } } $social_right_content .= MessageManager::inbox_display(); } if (api_get_setting('social.allow_social_tool') == 'true') { $social_right_content .= '</div>'; } $tpl = \Chamilo\CoreBundle\Framework\Container::getTwig(); // Block Social Avatar SocialManager::setSocialUserBlock($tpl, api_get_user_id(), 'messages'); if (api_get_setting('social.allow_social_tool') == 'true') { $tpl->addGlobal('social_menu_block', $social_menu_block); $tpl->addGlobal('social_right_content', $social_right_content); echo $tpl->render('@template_style/social/inbox.html.twig'); } else { $content = $social_right_content; echo $actions; echo $content;
public function process($parameters) { //iba prihlaseny uzivatelia $this->checkUser(); $userManager = new UserManager(); $messageManager = new MessageManager(); $loggedUser = $userManager->returnUser(); //ak je zadane URL pre vytvorenie novej spravy if (!empty($parameters[0]) && $parameters[0] == 'vytvorit') { $users = $userManager->returnUsers(); //vytvorenie zdroja pre automaticke doplnovanie uzivatelov v poli 'prijemca' $autocompleteSource = ''; foreach ($users as $user) { $autocompleteSource = $autocompleteSource . "'" . $user['name'] . "'" . ', '; } $autocompleteSource = rtrim($autocompleteSource, ", "); $this->data['autocompleteSource'] = $autocompleteSource; //ak bol zadany prijemca v URL if (!empty($parameters[1])) { $this->data['recipient_url'] = strip_tags($parameters[1]); } else { $this->data['recipient_url'] = ''; } $this->head['title'] = 'Nová správa'; $this->view = 'messageForm'; } //ak je zadane URL na odstranenie spravy if (!empty($parameters[1]) && $parameters[1] == 'odstranit') { $message = $messageManager->returnMessage($parameters[0]); if ($message) { $messageManager->deleteMessage($parameters[0], $loggedUser); $this->createMessage('Správa bola odstránená', 'success'); $this->redirect('panel'); } else { $this->redirect('chyba'); } } //ak je zadane URL na zobrazenie spravy if (!empty($parameters[1]) && $parameters[1] == 'zobrazit') { $message = $messageManager->returnMessage($parameters[0]); //ak sprava existuje a otvara ju prijimatel, alebo odosielatel if ($message && ($message['sender'] == $loggedUser['name'] || $message['recipient'] == $loggedUser['name'])) { //pri prvom otvoreni, oznac spravu ako precitanu if ($message['unread'] == 1 && $message['recipient'] == $loggedUser['name']) { $messageManager->readMessage($message['message_id']); } $this->head['title'] = 'Správa - ' . $message['subject']; $this->data['message'] = $message; $this->view = 'message'; } else { $this->redirect('chyba'); } } //ak bol odoslany formular pre odoslanie spravy if ($_POST) { $sender = $userManager->returnUser(); $recipient = strip_tags($_POST['recipient']); $subject = htmlspecialchars($_POST['subject']); $message = htmlspecialchars($_POST['message']); try { $recipient = $userManager->returnUserInfo($recipient); if (!$recipient) { throw new UserError('Užívateľ neexistuje'); } if ($sender['name'] == $recipient['name']) { throw new UserError('Nemôžete poslať správu sám sebe'); } //odoslanie spravy do databazy $messageManager->sendMessage($sender['name'], $recipient['name'], $subject, $message); $this->createMessage('Vaša správa bola úspešne odoslaná', 'success'); $this->redirect('panel'); } catch (UserError $error) { $this->createMessage($error->getMessage(), 'warning'); } } //zadane URL bez parametrov if (empty($parameters)) { $this->redirect('chyba'); } }
/** * Get all the users who need to receive a notification of a new post (those subscribed to * the forum or the thread) * * @param integer $forum_id the id of the forum * @param integer $thread_id the id of the thread * @param integer $post_id the id of the post * @return bool * * @author Patrick Cool <*****@*****.**>, Ghent University, Belgium * @version May 2008, dokeos 1.8.5 * @since May 2008, dokeos 1.8.5 */ function send_notifications($forum_id = 0, $thread_id = 0, $post_id = 0) { $_course = api_get_course_info(); // The content of the mail $thread_link = api_get_path(WEB_CODE_PATH) . 'forum/viewthread.php?' . api_get_cidreq() . '&forum=' . $forum_id . '&thread=' . $thread_id; // Users who subscribed to the forum if ($forum_id != 0) { $users_to_be_notified_by_forum = get_notifications('forum', $forum_id); } else { return false; } $current_thread = get_thread_information($thread_id); $current_forum = get_forum_information($current_thread['forum_id']); $subject = get_lang('NewForumPost') . ' - ' . $_course['official_code'] . ' - ' . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title']; // User who subscribed to the thread if ($thread_id != 0) { $users_to_be_notified_by_thread = get_notifications('thread', $thread_id); } // Merging the two $users_to_be_notified = array_merge($users_to_be_notified_by_forum, $users_to_be_notified_by_thread); $sender_id = api_get_user_id(); if (is_array($users_to_be_notified)) { foreach ($users_to_be_notified as $value) { $user_info = api_get_user_info($value['user_id']); $email_body = get_lang('Dear') . ' ' . api_get_person_name($user_info['firstname'], $user_info['lastname'], null, PERSON_NAME_EMAIL_ADDRESS) . ", <br />\n\r"; $email_body .= get_lang('NewForumPost') . ": " . $current_forum['forum_title'] . ' - ' . $current_thread['thread_title'] . " <br />\n"; $email_body .= get_lang('Course') . ': ' . $_course['name'] . ' - [' . $_course['official_code'] . "] <br />\n"; $email_body .= get_lang('YouWantedToStayInformed') . "<br />\n"; $email_body .= get_lang('ThreadCanBeFoundHere') . ': <br /> <a href="' . $thread_link . '">' . $thread_link . "</a>\n"; MessageManager::send_message_simple($value['user_id'], $subject, $email_body, $sender_id); } } }
function updateUserTexture($srvid, $uid, $newTexture) { try { if (is_string($newTexture)) { // conversation string -> byte array (PHP5) $newTexture = str_split($newTexture); } $this->getServer($srvid)->setTexture($uid, $newTexture); return true; } catch (Murmur_InvalidTextureException $exc) { MessageManager::addError(tr('error_invalidTexture')); return false; } }
$emailbody = get_lang('ApprovalForNewAccount', null, $values['language']) . "\n"; $emailbody .= get_lang('UserName', null, $values['language']) . ': ' . $values['username'] . "\n"; if (api_is_western_name_order()) { $emailbody .= get_lang('FirstName', null, $values['language']) . ': ' . $values['firstname'] . "\n"; $emailbody .= get_lang('LastName', null, $values['language']) . ': ' . $values['lastname'] . "\n"; } else { $emailbody .= get_lang('LastName', null, $values['language']) . ': ' . $values['lastname'] . "\n"; $emailbody .= get_lang('FirstName', null, $values['language']) . ': ' . $values['firstname'] . "\n"; } $emailbody .= get_lang('Email', null, $values['language']) . ': ' . $values['email'] . "\n"; $emailbody .= get_lang('Status', null, $values['language']) . ': ' . $values['status'] . "\n\n"; $url_edit = Display::url(api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user_id, api_get_path(WEB_CODE_PATH) . 'admin/user_edit.php?user_id=' . $user_id); $emailbody .= get_lang('ManageUser', null, $values['language']) . ": {$url_edit}"; $admins = UserManager::get_all_administrators(); foreach ($admins as $admin_info) { MessageManager::send_message($admin_info['user_id'], $emailsubject, $emailbody, null, null, null, null, null, null, $user_id); } // 3. exit the page unset($user_id); Display::display_header($tool_name); echo Display::page_header($tool_name); echo $content; Display::display_footer(); exit; } } } // Terms & Conditions if (api_get_setting('registration.allow_terms_conditions') == 'true') { // Update the terms & conditions. if (isset($values['legal_accept_type'])) {
/** * Send the invitation by mail. * * @param int invitedUser - the userId (course user) or emailaddress of additional user * $param string $invitation_code - the unique invitation code for the URL * @return void */ public static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text) { $_user = api_get_user_info(); $_course = api_get_course_info(); // Replacing the **link** part with a valid link for the user $survey_link = api_get_path(WEB_CODE_PATH) . 'survey/fillsurvey.php?course=' . $_course['code'] . '&invitationcode=' . $invitation_code; $text_link = '<a href="' . $survey_link . '">' . get_lang('ClickHereToAnswerTheSurvey') . "</a><br />\r\n<br />\r\n" . get_lang('OrCopyPasteTheFollowingUrl') . " <br />\r\n " . $survey_link; $replace_count = 0; $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count); if ($replace_count < 1) { $full_invitation_text = $full_invitation_text . "<br />\r\n<br />\r\n" . $text_link; } // Sending the mail $sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); $sender_email = $_user['mail']; $sender_user_id = api_get_user_id(); $replyto = array(); if (api_get_setting('survey.survey_email_sender_noreply') == 'noreply') { $noreply = api_get_setting('mail.noreply_email_address'); if (!empty($noreply)) { $replyto['Reply-to'] = $noreply; $sender_name = $noreply; $sender_email = $noreply; $sender_user_id = null; } } // Optionally: finding the e-mail of the course user if (is_numeric($invitedUser)) { $table_user = Database::get_main_table(TABLE_MAIN_USER); $sql = "SELECT firstname, lastname, email FROM {$table_user}\n WHERE user_id='" . Database::escape_string($invitedUser) . "'"; $result = Database::query($sql); $row = Database::fetch_array($result); $recipient_email = $row['email']; $recipient_name = api_get_person_name($row['firstname'], $row['lastname'], null, PERSON_NAME_EMAIL_ADDRESS); MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, [], [], null, null, null, null, $sender_user_id); } else { /** @todo check if the address is a valid email */ $recipient_email = $invitedUser; @api_mail_html($recipient_name, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email, $replyto); } }
if (isset($_POST['email'])) { ServerInterface::getInstance()->updateUserEmail($_SESSION['serverid'], $_SESSION['userid'], $_POST['email']); } // remove texture if (isset($_GET['remove_texture'])) { try { ServerInterface::getInstance()->updateUserTexture($_SESSION['serverid'], $_SESSION['userid'], array()); } catch (Murmur_InvalidTextureException $exc) { MessageManager::addWarning(tr('profile_removetexturefailed')); } } // new texture //TODO reimplement setting texture if (isset($_FILES['texture'])) { if (!file_exists($_FILES['texture']['tmp_name'])) { MessageManager::addWarning(tr('profile_texture_notempfile')); } else { $imgData = file_get_contents($_FILES['texture']['tmp_name']); ServerInterface::getInstance()->updateUserTexture($_SESSION['serverid'], $_SESSION['userid'], $imgData); } } } ?> <div id="content"> <h1><?php echo TranslationManager::getText('profile_head'); ?> </h1> <form action="?page=profile&action=doedit" method="post" style="width:420px;"<?php if (isset($_GET['action']) && $_GET['action'] == 'edit_texture') { echo ' enctype="multipart/form-data"';
/** * @return string */ static function outbox_display() { $social_link = false; if (isset($_REQUEST['f']) && $_REQUEST['f'] == 'social') { $social_link = 'f=social'; } $success = get_lang('SelectedMessagesDeleted') . ' </b><br /><a href="outbox.php?' . $social_link . '">' . get_lang('BackToOutbox') . '</a>'; $html = null; if (isset($_REQUEST['action'])) { switch ($_REQUEST['action']) { case 'delete': $number_of_selected_messages = count($_POST['id']); if ($number_of_selected_messages != 0) { foreach ($_POST['id'] as $index => $message_id) { MessageManager::delete_message_by_user_receiver(api_get_user_id(), $message_id); } } $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false); break; case 'deleteone': MessageManager::delete_message_by_user_receiver(api_get_user_id(), $_GET['id']); $html .= Display::return_message(api_xml_http_response_encode($success), 'normal', false); $html .= '<br/>'; break; } } // display sortable table with messages of the current user $table = new SortableTable('message_outbox', array('MessageManager', 'get_number_of_messages_sent'), array('MessageManager', 'get_message_data_sent'), 3, 20, 'DESC'); $parameters['f'] = isset($_GET['f']) && $_GET['f'] == 'social' ? 'social' : null; $table->set_additional_parameters($parameters); $table->set_header(0, '', false, array('style' => 'width:15px;')); $table->set_header(1, get_lang('Messages'), false); $table->set_header(2, get_lang('Date'), true, array('style' => 'width:160px;')); $table->set_header(3, get_lang('Modify'), false, array('style' => 'width:70px;')); $table->set_form_actions(array('delete' => get_lang('DeleteSelectedMessages'))); $html .= $table->return_table(); return $html; }
$my_group_role, array( GROUP_USER_PERMISSION_PENDING_INVITATION_SENT_BY_USER, GROUP_USER_PERMISSION_PENDING_INVITATION ) ) ) { $social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id( ) . '">' . get_lang('JoinGroup') . '</a>'; } elseif ($my_group_role == GROUP_USER_PERMISSION_PENDING_INVITATION) { $social_right_content .= '<a class="btn" href="groups.php?id=' . $group_id . '&action=join&u=' . api_get_user_id( ) . '">' . get_lang('YouHaveBeenInvitedJoinNow') . '</a>'; } $social_right_content .= '<br /><br />'; } $content = MessageManager::display_messages_for_group($group_id); if ($is_group_member) { if (empty($content)) { $create_thread_link = '<a href="' . api_get_path( WEB_CODE_PATH ) . 'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend=' . api_get_user_id( ) . '&group_id=' . $group_id . '&action=add_message_group" class="ajax btn" title="' . get_lang( 'ComposeMessage' ) . '">' . get_lang('YouShouldCreateATopic') . '</a></li>'; } else { $create_thread_link = '<a href="' . api_get_path( WEB_CODE_PATH ) . 'social/message_for_group_form.inc.php?view_panel=1&height=400&width=610&&user_friend=' . api_get_user_id( ) . '&group_id=' . $group_id . '&action=add_message_group" class="ajax btn" title="' . get_lang( 'ComposeMessage' ) . '">' . get_lang('NewTopic') . '</a>';
/** * Send a system announcement by e-mail to all teachers/students depending on parameters * @param string Title * @param string Content * @param int Whether to send to all teachers (1) or not (0) * @param int Whether to send to all students (1) or not (0) * @param string Language (optional, considered for all languages if left empty) * @return bool True if the message was sent or there was no destination matching. False on database or e-mail sending error. */ public static function send_system_announcement_by_email($title, $content, $teacher, $student, $language = null, $sendEmailTest = false) { global $charset; $title = api_html_entity_decode(stripslashes($title), ENT_QUOTES, $charset); $content = api_html_entity_decode(stripslashes(str_replace(array('\\r\\n', '\\n', '\\r'), '', $content)), ENT_QUOTES, $charset); if ($sendEmailTest) { MessageManager::send_message_simple(api_get_user_id(), $title, $content); return true; } $user_table = Database::get_main_table(TABLE_MAIN_USER); if (api_is_multiple_url_enabled()) { $current_access_url_id = api_get_current_access_url_id(); $url_rel_user = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_USER); $url_condition = " INNER JOIN {$url_rel_user} uu ON uu.user_id = u.user_id "; } if ($teacher != 0 and $student == 0) { $sql = "SELECT DISTINCT u.user_id FROM {$user_table} u {$url_condition} WHERE status = '1' "; } if ($teacher == 0 and $student != 0) { $sql = "SELECT DISTINCT u.user_id FROM {$user_table} u {$url_condition} WHERE status = '5' "; } if ($teacher != 0 and $student != 0) { $sql = "SELECT DISTINCT u.user_id FROM {$user_table} u {$url_condition} WHERE 1 = 1 "; } if (!empty($language)) { //special condition because language was already treated for SQL insert before $sql .= " AND language = '" . Database::escape_string($language) . "' "; } if (api_is_multiple_url_enabled()) { $sql .= " AND access_url_id = '" . $current_access_url_id . "' "; } // Sent to active users. $sql .= " AND email <>'' AND active = 1 "; if ((empty($teacher) or $teacher == '0') and (empty($student) or $student == '0')) { return true; } $result = Database::query($sql); if ($result === false) { return false; } $message_sent = false; while ($row = Database::fetch_array($result, 'ASSOC')) { MessageManager::send_message_simple($row['user_id'], $title, $content); $message_sent = true; } return $message_sent; //true if at least one e-mail was sent }
/** * Send the invitation by mail. * * @param invitedUser - the userId (course user) or emailaddress of additional user * $param $invitation_code - the unique invitation code for the URL * @return void */ static function send_invitation_mail($invitedUser, $invitation_code, $invitation_title, $invitation_text) { global $_user, $_course, $_configuration; $portal_url = api_get_path(WEB_CODE_PATH); if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url = api_get_access_url($access_url_id); $portal_url = $url['url']; } } // Replacing the **link** part with a valid link for the user $survey_link = api_get_path(WEB_CODE_PATH) . 'survey/fillsurvey.php?course=' . $_course['code'] . '&invitationcode=' . $invitation_code; $text_link = '<a href="' . $survey_link . '">' . get_lang('ClickHereToAnswerTheSurvey') . "</a><br />\r\n<br />\r\n" . get_lang('OrCopyPasteTheFollowingUrl') . " <br />\r\n " . $survey_link; $replace_count = 0; $full_invitation_text = api_str_ireplace('**link**', $text_link, $invitation_text, $replace_count); if ($replace_count < 1) { $full_invitation_text = $full_invitation_text . "<br />\r\n<br />\r\n" . $text_link; } // Sending the mail $sender_name = api_get_person_name($_user['firstName'], $_user['lastName'], null, PERSON_NAME_EMAIL_ADDRESS); $sender_email = $_user['mail']; $sender_user_id = api_get_user_id(); $replyto = array(); if (api_get_setting('survey_email_sender_noreply') == 'noreply') { $noReply = api_get_setting('noreply_email_address'); if (!empty($noReply)) { $sender_name = $noReply; $sender_email = $noReply; $sender_user_id = null; } } // Optionally: finding the e-mail of the user if (is_numeric($invitedUser)) { MessageManager::send_message($invitedUser, $invitation_title, $full_invitation_text, null, null, null, null, null, null, $sender_user_id); } else { /** @todo check if the address is a valid email */ $recipient_email = $invitedUser; @api_mail_html(null, $recipient_email, $invitation_title, $full_invitation_text, $sender_name, $sender_email); } }
/* For licensing terms, see /license.txt */ /** * Responses to AJAX calls */ //require_once '../global.inc.php'; $action = $_GET['a']; switch ($action) { case 'send_message': $subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null; $messageContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null; if (empty($subject) || empty($messageContent)) { echo Display::display_error_message(get_lang('ErrorSendingMessage')); exit; } $result = MessageManager::send_message($_REQUEST['user_id'], $subject, $messageContent); if ($result) { echo Display::display_confirmation_message(get_lang('MessageHasBeenSent')); } else { echo Display::display_error_message(get_lang('ErrorSendingMessage')); } break; case 'send_invitation': $subject = isset($_REQUEST['subject']) ? trim($_REQUEST['subject']) : null; $invitationContent = isset($_REQUEST['content']) ? trim($_REQUEST['content']) : null; SocialManager::send_invitation_friend_user($_REQUEST['user_id'], $subject, $invitationContent); break; case 'find_users': if (api_is_anonymous()) { echo ''; break;
error_reporting(E_ALL); } // Check for running Ice with Murmur try { ServerInterface::getInstance(); } catch (Ice_UnknownLocalException $ex) { MessageManager::addError(tr('error_noIce')); MessageManager::echoAll(); exit; } if (isset($_GET['ajax'])) { require_once MUMPHPI_MAINDIR . '/ajax/' . MUMPHPI_SECTION . '.ajax.php'; if (is_callable('Ajax_' . MUMPHPI_SECTION . '::' . $_GET['ajax'])) { eval('Ajax_' . MUMPHPI_SECTION . '::' . $_GET['ajax'] . '();'); } MessageManager::echoAll(); exit; } $serverId = isset($_GET['serverId']) ? intval($_GET['serverId']) : 1; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title><?php echo SettingsManager::getInstance()->getSiteTitle(); ?> </title> <meta name="description" content="<?php echo SettingsManager::getInstance()->getSiteDescription();
/** * Set header parameters */ private function set_header_parameters() { global $httpHeadXtra, $_course, $interbreadcrumb, $language_file, $noPHP_SELF, $_configuration, $this_section; $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as & $thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('online.png')); $this->assign('offline_button',Display::return_icon('offline.png')); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('Institution'); $title_list[] = api_get_setting('siteName'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $this->set_css_files(); $this->set_js_files(); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="'.$host.'">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-'.$this_section); $favico = '<link rel="shortcut icon" href="'.api_get_path(WEB_PATH).'favicon.ico" type="image/x-icon" />'; if (isset($_configuration['multiple_access_urls']) && $_configuration['multiple_access_urls']) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $clean_url = replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH).'home/'.$clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_PATH).'home/'.$clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep.'favicon.ico')) { $favico = '<link rel="shortcut icon" href="'.$homep.'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->set_help(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="'.api_get_path(WEB_IMG_PATH).'bug.large.png" style="vertical-align: middle;" alt="'.get_lang('ReportABug').'" title="'.get_lang( 'ReportABug' ).'"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); //Preparing values for the menu //Logout link if (isset($_configuration['hide_logout_button']) && $_configuration['hide_logout_button'] == 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH).'index.php?logout=logout&uid='.api_get_user_id()); } //Profile link if (api_get_setting('allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH).'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH).'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH).'messages/inbox.php'; $message_link = '<a href="'.api_get_path(WEB_CODE_PATH).'messages/inbox.php">'.get_lang('Inbox').'</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('Institution'); $portal_name = empty($institution) ? api_get_setting('siteName') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); //Setting notifications $count_unread_message = 0; if (api_get_setting('allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id( api_get_user_id() ); $group_pending_invitations = GroupPortalManager::get_groups_by_user( api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false ); $group_pending_invitations = 0; if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval( $count_unread_message ); } $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) : null); $this->assign('user_notifications', $total_invitations); //Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); //if ($this->show_header == 1) { header('Content-Type: text/html; charset='.api_get_system_encoding()); header( 'X-Powered-By: '.$_configuration['software_name'].' '.substr($_configuration['system_version'], 0, 1) ); //} }
break; case -1: MessageManager::addWarning(tr('login_wronglogininformation')); break; default: // login success $_SESSION['serverid'] = $_POST['serverid']; $_SESSION['userid'] = $tmpUid; $_SESSION['userLoggedIn'] = true; echo '<script type="text/javascript">location.replace("?page=profile")</script>'; echo tr('login_success'); break; } } else { // missing mandatory data MessageManager::addError(tr('login_missing_data')); } } else { // no login-action, thus show login form ?> <div id="content"> <h1><?php echo tr('login_head'); ?> </h1> <form action="./?page=login&action=dologin" method="post" style="width:400px;"> <table class="fullwidth"> <tr> <td class="formitemname"><?php echo tr('server');
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']) && $_GET['f'] == 'social' ? 'social' : null; $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->addText('id_text_name', get_lang('SendMessageTo'), true, array('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->addLabel(get_lang('SendMessageTo'), $sent_to); } if (empty($default['users'])) { //fb select $form->addElement('select_ajax', 'users', get_lang('SendMessageTo'), array(), ['multiple' => 'multiple', 'url' => api_get_path(WEB_AJAX_PATH) . 'message.ajax.php?a=find_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->addText('title', get_lang('Subject'), true); $form->addHtmlEditor('content', get_lang('Message'), false, false, array('ToolbarSet' => 'Messages', 'Width' => '100%', '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 = api_get_user_info($message_reply_info['user_sender_id']); $default['content'] = '<p><br/></p>' . sprintf(get_lang('XWroteY'), $user_reply_info['complete_name'], Security::filter_terms($message_reply_info['content'])); } if (empty($group_id)) { $form->addElement('label', '', '<div id="filepaths" class="form-group"> <div id="filepath_1"> <label>' . get_lang('FilesAttachment') . '</label> <input type="file" name="attach_1"/> <label>' . get_lang('Description') . '</label> <input id="file-descrtiption" type="text" name="legend[]" class="form-control"/> </div> </div>'); $form->addElement('label', '', '<span id="link-more-attach"><a href="javascript://" onclick="return add_image_form()">' . get_lang('AddOneMoreFile') . '</a></span> (' . sprintf(get_lang('MaximunFileSizeX'), format_file_size(api_get_setting('message.message_max_upload_filesize'))) . ')'); } $form->addButtonSend(get_lang('SendMessage'), 'compose'); $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 = isset($default['parent_id']) ? $default['parent_id'] : null; 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); if ($res) { $html .= MessageManager::display_success_message($user); } } } 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->returnForm(); } return $html; }
/** * Get admin object by (account-)name. * @param $username account name * @return array admin object or null */ public function getAdminByName($username) { if (file_exists($this->filepath_admins)) { $fd = fopen($this->filepath_admins, 'r') or MessageManager::addError('could not open ' . self::$filename_admins . ' file'); while ($line = fgets($fd)) { $admin = $this->createAdminFromString($line); if ($admin['name'] == $username) { fclose($fd); return $admin; } } } return null; }
/** * @param string $uniqueId * @param int $userId * @param int $courseId * @param int $sessionId */ public function sendMailLink($uniqueId, $userId, $courseId, $sessionId) { $courseInfo = api_get_course_info_by_id($courseId); $courseCode = $courseInfo['code']; $url = api_get_path(WEB_CODE_PATH) . 'course_info/legal.php?web_agreement_link=' . $uniqueId . '&course_code=' . Security::remove_XSS($courseCode) . '&session_id=' . $sessionId; $courseUrl = Display::url($url, $url); $sessionInfo = api_get_session_info($sessionId); $sesstionTitle = null; if (!empty($sessionInfo)) { $sesstionTitle = ' (' . $sessionInfo['name'] . ')'; } $courseTitle = $courseInfo['title'] . $sesstionTitle; $subject = $this->get_lang("MailAgreement"); $message = sprintf($this->get_lang("MailAgreementWasSentWithClickX"), $courseTitle, $courseUrl); MessageManager::send_message_simple($userId, $subject, $message); }
/** * Set header parameters * @param bool $sendHeaders send headers */ private function set_header_parameters($sendHeaders) { global $httpHeadXtra, $interbreadcrumb, $language_file, $_configuration, $this_section; $_course = api_get_course_info(); $help = $this->help; $nameTools = $this->title; $navigation = return_navigation_array(); $this->menu_navigation = $navigation['menu_navigation']; $this->assign('system_charset', api_get_system_encoding()); if (isset($httpHeadXtra) && $httpHeadXtra) { foreach ($httpHeadXtra as &$thisHttpHead) { header($thisHttpHead); } } $this->assign('online_button', Display::return_icon('statusonline.png', null, null, ICON_SIZE_ATOM)); $this->assign('offline_button', Display::return_icon('statusoffline.png', null, null, ICON_SIZE_ATOM)); // Get language iso-code for this page - ignore errors $this->assign('document_language', api_get_language_isocode()); $course_title = isset($_course['name']) ? $_course['name'] : null; $title_list = array(); $title_list[] = api_get_setting('platform.institution'); $title_list[] = api_get_setting('platform.site_name'); if (!empty($course_title)) { $title_list[] = $course_title; } if ($nameTools != '') { $title_list[] = $nameTools; } $title_string = ''; for ($i = 0; $i < count($title_list); $i++) { $title_string .= $title_list[$i]; if (isset($title_list[$i + 1])) { $item = trim($title_list[$i + 1]); if (!empty($item)) { $title_string .= ' - '; } } } $this->assign('title_string', $title_string); //Setting the theme and CSS files $css = $this->setCssFiles(); $this->set_js_files(); $this->setCssCustomFiles($css); //$this->set_js_files_post(); $browser = api_browser_support('check_browser'); if ($browser[0] == 'Internet Explorer' && $browser[1] >= '11') { $browser_head = '<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE9" />'; $this->assign('browser_specific_head', $browser_head); } // Implementation of prefetch. // See http://cdn.chamilo.org/main/img/online.png for details $prefetch = ''; if (!empty($_configuration['cdn_enable'])) { $prefetch .= '<meta http-equiv="x-dns-prefetch-control" content="on">'; foreach ($_configuration['cdn'] as $host => $exts) { $prefetch .= '<link rel="dns-prefetch" href="' . $host . '">'; } } $this->assign('prefetch', $prefetch); $this->assign('text_direction', api_get_text_direction()); $this->assign('section_name', 'section-' . $this_section); //Defaul root chamilo favicon $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_PATH) . 'favicon.ico" type="image/x-icon" />'; //Added to verify if in the current Chamilo Theme exist a favicon $favicoThemeUrl = api_get_path(SYS_CSS_PATH) . 'themes/' . $this->theme . '/images/'; //If exist pick the current chamilo theme favicon if (is_file($favicoThemeUrl . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . api_get_path(WEB_CSS_PATH) . 'themes/' . $this->theme . '/images/favicon.ico" type="image/x-icon" />'; } if (api_is_multiple_url_enabled()) { $access_url_id = api_get_current_access_url_id(); if ($access_url_id != -1) { $url_info = api_get_access_url($access_url_id); $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url'])); $clean_url = api_replace_dangerous_char($url); $clean_url = str_replace('/', '-', $clean_url); $clean_url .= '/'; $homep = api_get_path(REL_PATH) . 'home/' . $clean_url; //homep for Home Path $icon_real_homep = api_get_path(SYS_APP_PATH) . 'home/' . $clean_url; //we create the new dir for the new sites if (is_file($icon_real_homep . 'favicon.ico')) { $favico = '<link rel="shortcut icon" href="' . $homep . 'favicon.ico" type="image/x-icon" />'; } } } $this->assign('favico', $favico); $this->setHelp(); //@todo move this in the template $bug_notification_link = ''; if (api_get_setting('show_link_bug_notification') == 'true' && $this->user_is_logged_in) { $bug_notification_link = '<li class="report"> <a href="http://support.chamilo.org/projects/chamilo-18/wiki/How_to_report_bugs" target="_blank"> <img src="' . api_get_path(WEB_IMG_PATH) . 'bug.large.png" style="vertical-align: middle;" alt="' . get_lang('ReportABug') . '" title="' . get_lang('ReportABug') . '"/></a> </li>'; } $this->assign('bug_notification_link', $bug_notification_link); $notification = return_notification_menu(); $this->assign('notification_menu', $notification); $resize = ''; if (api_get_setting('accessibility_font_resize') == 'true') { $resize .= '<div class="resize_font">'; $resize .= '<div class="btn-group">'; $resize .= '<a title="' . get_lang('DecreaseFontSize') . '" href="#" class="decrease_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('ResetFontSize') . '" href="#" class="reset_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '<a title="' . get_lang('IncreaseFontSize') . '" href="#" class="increase_font btn btn-default"><em class="fa fa-font"></em></a>'; $resize .= '</div>'; $resize .= '</div>'; } $this->assign('accessibility', $resize); // Preparing values for the menu // Logout link $hideLogout = api_get_setting('hide_logout_button'); if ($hideLogout === 'true') { $this->assign('logout_link', null); } else { $this->assign('logout_link', api_get_path(WEB_PATH) . 'index.php?logout=logout&uid=' . api_get_user_id()); } //Profile link if (api_get_setting('social.allow_social_tool') == 'true') { $profile_url = api_get_path(WEB_CODE_PATH) . 'social/home.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } else { $profile_url = api_get_path(WEB_CODE_PATH) . 'auth/profile.php'; $profile_link = Display::url(get_lang('Profile'), $profile_url); } $this->assign('profile_link', $profile_link); $this->assign('profile_url', $profile_url); //Message link $message_link = null; $message_url = null; if (api_get_setting('message.allow_message_tool') == 'true') { $message_url = api_get_path(WEB_CODE_PATH) . 'messages/inbox.php'; $message_link = '<a href="' . api_get_path(WEB_CODE_PATH) . 'messages/inbox.php">' . get_lang('Inbox') . '</a>'; } $this->assign('message_link', $message_link); $this->assign('message_url', $message_url); $institution = api_get_setting('platform.institution'); $portal_name = empty($institution) ? api_get_setting('platform.site_name') : $institution; $this->assign('portal_name', $portal_name); //Menu $menu = return_menu(); $this->assign('menu', $menu); // Setting notifications $count_unread_message = 0; if (api_get_setting('message.allow_message_tool') == 'true') { // get count unread message and total invitations $count_unread_message = MessageManager::get_number_of_messages(true); } $total_invitations = 0; if (api_get_setting('social.allow_social_tool') == 'true') { $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); $usergroup = new UserGroup(); $group_pending_invitations = $usergroup->get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION, false); if (!empty($group_pending_invitations)) { $group_pending_invitations = count($group_pending_invitations); } else { $group_pending_invitations = 0; } $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); } $total_invitations = !empty($total_invitations) ? Display::badge($total_invitations) : null; $this->assign('user_notifications', $total_invitations); // Block Breadcrumb $breadcrumb = return_breadcrumb($interbreadcrumb, $language_file, $nameTools); $this->assign('breadcrumb', $breadcrumb); //Extra content $extra_header = null; if (!api_is_platform_admin()) { $extra_header = trim(api_get_setting('header_extra_content')); } $this->assign('header_extra_content', $extra_header); if ($sendHeaders) { header('Content-Type: text/html; charset=' . api_get_system_encoding()); header('X-Powered-By: ' . $_configuration['software_name'] . ' ' . substr($_configuration['system_version'], 0, 1)); } $socialMeta = ''; $metaTitle = api_get_setting('meta_title'); if (!empty($metaTitle)) { $socialMeta .= '<meta name="twitter:card" content="summary" />' . "\n"; $socialMeta .= '<meta property="og:title" content="' . $metaTitle . '" />' . "\n"; $socialMeta .= '<meta property="og:url" content="' . api_get_path(WEB_PATH) . '" />' . "\n"; $metaDescription = api_get_setting('meta_description'); if (!empty($metaDescription)) { $socialMeta .= '<meta property="og:description" content="' . $metaDescription . '" />' . "\n"; } $metaSite = api_get_setting('meta_twitter_site'); if (!empty($metaSite)) { $socialMeta .= '<meta name="twitter:site" content="' . $metaSite . '" />' . "\n"; $metaCreator = api_get_setting('meta_twitter_creator'); if (!empty($metaCreator)) { $socialMeta .= '<meta name="twitter:creator" content="' . $metaCreator . '" />' . "\n"; } } $metaImage = api_get_setting('meta_image_path'); if (!empty($metaImage)) { if (is_file(api_get_path(SYS_PATH) . $metaImage)) { $path = api_get_path(WEB_PATH) . $metaImage; $socialMeta .= '<meta property="og:image" content="' . $path . '" />' . "\n"; } } } $this->assign('social_meta', $socialMeta); }