예제 #1
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $errors = array();
         $id = SJB_Request::getInt('id', 0, 'GET');
         $action = SJB_Request::getVar('action', '', 'GET');
         if ($id > 0) {
             // read message
             if (SJB_PrivateMessage::isMyMessage($id)) {
                 if ($action == 'delete') {
                     SJB_PrivateMessage::delete(array($id));
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                 }
                 $message = SJB_PrivateMessage::readMessage($id);
                 SJB_Authorization::updateCurrentUserSession();
                 $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser();
                 $current_user_info['logged_in'] = true;
                 $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']);
                 SJB_System::setCurrentUserInfo($current_user_info);
                 $tp->assign('message', $message);
                 $tp->assign('include', 'message_detail.tpl');
             } else {
                 $errors['NOT_EXISTS_MESSAGE'] = 1;
             }
         }
         $tp->assign('errors', $errors);
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
         $tp->display('main.tpl');
     } else {
         $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis()));
         $tp->display('../users/login.tpl');
     }
 }
예제 #2
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid', 0, SJB_Request::METHOD_GET));
     $user_id = $user['sid'];
     if (SJB_Request::getVar('pm_action', '', SJB_Request::METHOD_POST) == 'delete') {
         $checked = SJB_Request::getVar('pm_check', array(), SJB_Request::METHOD_POST);
         SJB_PrivateMessage::delete($checked);
     }
     $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET));
     $per_page = 10;
     $total = SJB_PrivateMessage::getTotalOutbox($user_id);
     $max_pages = ceil($total / $per_page);
     if ($max_pages == 0) {
         $max_pages = 1;
     }
     if ($max_pages < $page) {
         SJB_HelperFunctions::redirect("?user_sid={$user_id}&page={$max_pages}");
     }
     $navigate = SJB_PrivateMessage::getNavigate($page, $total, $per_page);
     $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $per_page);
     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']);
     SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']);
     $tp->assign("user_group_info", $userGroupInfo);
     $tp->assign('username', $user['username']);
     $tp->assign('user_sid', $user_id);
     $tp->assign('message', $list);
     $tp->assign('navigate', $navigate);
     $tp->assign('page', $page);
     $tp->display('pm_outbox.tpl');
 }
예제 #3
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         if (SJB_Request::getVar('pm_action', '', SJB_Request::METHOD_POST) == 'delete') {
             $checked = SJB_Request::getVar('pm_check', array(), SJB_Request::METHOD_POST);
             SJB_PrivateMessage::delete($checked);
         }
         $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET));
         $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10);
         $total = SJB_PrivateMessage::getTotalOutbox($user_id);
         $totalPages = ceil($total / $messagesPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $list = SJB_PrivateMessage::getListOutbox($user_id, $page, $messagesPerPage);
         $tp->assign('message_list', $list);
         $tp->assign('messagesPerPage', $messagesPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('include', 'list_outbox.tpl');
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
     }
     $tp->display('main.tpl');
 }
예제 #4
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $unread = SJB_PrivateMessage::getCountUnreadMessages($user_id);
         $tp->assign('unread', $unread);
         $tp->assign('include', '');
     }
     $tp->display('main.tpl');
 }
 public function execute()
 {
     $current_user_info = array('logged_in' => false);
     if (SJB_UserManager::isUserLoggedIn()) {
         SJB_Authorization::updateCurrentUserSession();
         $current_user_info = SJB_UserManager::createTemplateStructureForCurrentUser();
         $current_user_info['logged_in'] = true;
         $current_user_info['new_messages'] = SJB_PrivateMessage::getCountUnreadMessages($current_user_info['id']);
     } else {
         // social plugin
         $userGroups = SJB_UserGroupManager::getAllUserGroupsInfo();
         SJB_System::setCurrentUserGroupsInfo($userGroups);
         SJB_Event::dispatch('Login_Plugin');
     }
     SJB_System::setCurrentUserInfo($current_user_info);
 }
예제 #6
0
파일: pm.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid'));
     $user_id = $user['sid'];
     $total_in = SJB_PrivateMessage::getTotalInbox($user_id);
     $total_out = SJB_PrivateMessage::getTotalOutbox($user_id);
     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']);
     SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']);
     $tp->assign('username', $user['username']);
     $tp->assign("user_group_info", $userGroupInfo);
     $tp->assign('user_sid', $user_id);
     $tp->assign('total_in', $total_in);
     $tp->assign('total_out', $total_out);
     $tp->display('main.tpl');
 }
예제 #7
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $userSID = SJB_UserManager::getCurrentUserSID();
         $action = SJB_Request::getVar('pm_action', null);
         if ($action) {
             $checked = SJB_Request::getVar('pm_check', array(), 'POST');
             switch ($action) {
                 case 'delete':
                     SJB_PrivateMessage::deleteContact($userSID, $checked);
                     break;
                 case 'save_contact':
                     $error = '';
                     $contactSID = SJB_Request::getInt('user_id', 0);
                     SJB_PrivateMessage::saveContact($userSID, $contactSID, $error);
                     $tp->assign('error', $error);
                     $tp->display('contact_save.tpl');
                     return true;
                     break;
                 default:
                     break;
             }
         }
         $page = SJB_Request::getInt('page', 1, 'GET');
         $contactsPerPage = SJB_Request::getInt('contactsPerPage', 10);
         SJB_PrivateMessage::deleteNonexistentContacts($userSID);
         $total = SJB_PrivateMessage::getTotalContacts($userSID);
         $totalPages = ceil($total / $contactsPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $tp->assign('message_list', SJB_PrivateMessage::getContacts($userSID, $page, $contactsPerPage));
         $tp->assign('contactsPerPage', $contactsPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('include', 'contacts.tpl');
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($userSID));
     }
     $tp->display('main.tpl');
 }
예제 #8
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $action = SJB_Request::getVar('pm_action', SJB_Request::METHOD_POST, false);
         if ($action) {
             $checked = SJB_Request::getVar('pm_check', SJB_Request::METHOD_POST, array());
             switch ($action) {
                 case 'mark':
                     SJB_PrivateMessage::markAsRead($checked);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                     break;
                 case 'delete':
                     SJB_PrivateMessage::delete($checked);
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                     break;
                 default:
                     break;
             }
         }
         $page = SJB_Request::getInt('page', 1, 'GET');
         $messagesPerPage = SJB_Request::getInt('messagesPerPage', 10);
         $total = SJB_PrivateMessage::getTotalInbox($user_id);
         $totalPages = ceil($total / $messagesPerPage);
         if ($totalPages == 0) {
             $totalPages = 1;
         }
         if (empty($page) || $page <= 0) {
             $page = 1;
         }
         if ($totalPages < $page) {
             SJB_HelperFunctions::redirect("?page={$totalPages}");
         }
         $tp->assign('message_list', SJB_PrivateMessage::getListInbox($user_id, $page, $messagesPerPage));
         $tp->assign('include', 'list_inbox.tpl');
         $tp->assign('messagesPerPage', $messagesPerPage);
         $tp->assign('page', $page);
         $tp->assign('totalPages', $totalPages);
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
     }
     $tp->display('main.tpl');
 }
예제 #9
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = null;
     if (SJB_UserManager::isUserLoggedIn()) {
         $userSID = SJB_UserManager::getCurrentUserSID();
         $contactSID = 0;
         $errors = array();
         if (isset($_REQUEST['passed_parameters_via_uri'])) {
             $passed_parameters_via_uri = SJB_UrlParamProvider::getParams();
             $contactSID = SJB_Array::get($passed_parameters_via_uri, 0);
         }
         if (!$contactSID) {
             $errors['UNDEFINED_CONTACT_ID'] = 1;
         } else {
             $contactInfo = SJB_PrivateMessage::getContactInfo($userSID, $contactSID);
             if (!$contactInfo) {
                 $errors['WRONG_CONTACT_ID_SPECIFIED'] = 1;
             } else {
                 $action = SJB_Request::getVar('action');
                 switch ($action) {
                     case 'save':
                         $note = SJB_Request::getVar('note');
                         $result = SJB_PrivateMessage::saveContactNote($userSID, $contactSID, $note);
                         if ($result) {
                             $tp->assign('noteSaved', true);
                         }
                         break;
                     default:
                         break;
                 }
             }
             $tp->assign('contactInfo', $contactInfo);
         }
         $tp->assign('errors', $errors);
     }
     if ($action) {
         $tp->assign('action', $action);
         $tp->display('notes.tpl');
     } else {
         $tp->display('contact.tpl');
     }
 }
예제 #10
0
파일: pm_read.php 프로젝트: Maxlander/shixi
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $action = SJB_Request::getVar('action', '', SJB_Request::METHOD_GET);
     $mess_id = intval(SJB_Request::getVar('mess', 0, SJB_Request::METHOD_GET));
     $return_to = SJB_Request::getVar('from', 'in', SJB_Request::METHOD_GET);
     $page = intval(SJB_Request::getVar('page', 1, SJB_Request::METHOD_GET));
     $user = SJB_UserManager::getUserInfoBySID(SJB_Request::getVar('user_sid'));
     $user_id = $user['sid'];
     if ($action == 'delete') {
         SJB_DB::query("DELETE FROM `private_message` WHERE `id` = '{$mess_id}'");
         $per_page = 10;
         if ($return_to == 'in') {
             $total = SJB_PrivateMessage::getTotalInbox($user_id);
         } else {
             $total = SJB_PrivateMessage::getTotalOutbox($user_id);
         }
         $max_pages = ceil($total / $per_page);
         if ($max_pages == 0) {
             $max_pages = 1;
         }
         if ($max_pages < $page) {
             $page = $max_pages;
         }
         $site_url = SJB_System::getSystemSettings('SITE_URL');
         SJB_HelperFunctions::redirect($site_url . '/private-messages/pm-' . ($return_to == 'in' ? 'inbox' : 'outbox') . "/?user_sid={$user_id}&page={$page}");
     }
     $message = SJB_PrivateMessage::ReadMessage($mess_id, true);
     $userGroupInfo = SJB_UserGroupManager::getUserGroupInfoBySID($user['user_group_sid']);
     SJB_System::setGlobalTemplateVariable('wikiExtraParam', $userGroupInfo['id']);
     $tp->assign("user_group_info", $userGroupInfo);
     $tp->assign('returt_to', $return_to);
     $tp->assign('username', $user['username']);
     $tp->assign('user_sid', $user_id);
     $tp->assign('message', $message);
     $tp->assign('page', $page);
     $tp->display('pm_read.tpl');
 }
예제 #11
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     $errors = array();
     $info = '';
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $to = SJB_Request::getVar('to');
         // POST and check for errors form_to form_subject form_message
         if (isset($_POST['form_to'])) {
             $to_user_name = SJB_Request::getVar('form_to', null, 'POST');
             $to_user_info = null;
             // trying to get user info by user id
             if (intval($to_user_name)) {
                 $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name);
             }
             /*
              * в функции compose private message функцию отправки
              * сообщения по имени пользователя оставить рабочей
              */
             if (is_null($to_user_info)) {
                 $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name);
             }
             // trying to get user info by user id
             if (intval($to_user_name)) {
                 $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name);
             }
             /*
              * в функции compose private message функцию отправки
              * сообщения по имени пользователя оставить рабочей
              */
             if (is_null($to_user_info)) {
                 $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name);
             }
             $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0;
             $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : '';
             $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : '';
             $save = isset($_POST['form_save']) ? true : false;
             if ($to_user == 0) {
                 $errors['form_to'] = 'You specified wrong username';
             }
             if (empty($subject)) {
                 $errors['form_subject'] = 'Please, enter message subject';
             }
             if (empty($message)) {
                 $errors['form_message'] = 'Please, enter message';
             }
             if (count($errors) == 0) {
                 $anonym = SJB_Request::getVar('anonym');
                 SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, false, $anonym);
                 $info = 'The message was sent successfully';
                 $to = '';
                 // save to contacts
                 if (!$anonym) {
                     SJB_PrivateMessage::saveContact($user_id, $to_user);
                     SJB_PrivateMessage::saveContact($to_user, $user_id);
                 }
             } else {
                 $tp->assign("form_to", htmlentities($to_user_name, ENT_QUOTES, "UTF-8"));
                 $tp->assign("form_subject", htmlentities($subject, ENT_QUOTES, "UTF-8"));
                 $tp->assign("form_message", $message);
                 $tp->assign("form_save", $save);
                 $tp->assign("errors", $errors);
             }
         }
         $display_to = '';
         // get display name for "Message to" field
         SJB_UserManager::getComposeDisplayName($to, $display_to);
         $tp->assign('info', $info);
         $tp->assign('to', $to);
         $tp->assign('anonym', SJB_Request::getVar('anonym'));
         $tp->assign('display_to', $display_to);
         $tp->assign('include', 'new_message.tpl');
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
         $tp->display('main.tpl');
     } else {
         $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis()));
         $tp->assign('ajaxRelocate', true);
         $tp->display('../users/login.tpl');
     }
 }
예제 #12
0
 public static function deleteNonexistentContacts($userSID)
 {
     $contacts = SJB_DB::query("SELECT `contact_sid` FROM `private_message_contacts` WHERE `user_sid` = ?n", $userSID);
     foreach ($contacts as $contactInfo) {
         $userInfo = SJB_UserManager::getUserInfoBySID($contactInfo['contact_sid']);
         if (empty($userInfo)) {
             SJB_PrivateMessage::deleteContact($userSID, $contactInfo['contact_sid']);
         }
     }
 }
예제 #13
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $errors = array();
         $info = '';
         $to = SJB_Request::getVar('to', '', 'GET');
         // POST and check for errors form_to form_subject form_message
         if (isset($_POST['act'])) {
             $to_user_name = SJB_Request::getVar('form_to', '', 'POST');
             $to_user_info = null;
             if (intval($to_user_name)) {
                 $to_user_info = SJB_UserManager::getUserInfoBySID($to_user_name);
             }
             // в функции compose private message функцию отправки
             // сообщения по имени пользователя оставить рабочей
             if (is_null($to_user_info)) {
                 $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name);
             }
             $cc = SJB_Request::getVar('cc', false);
             if ($cc !== false) {
                 if (intval($cc)) {
                     $cc_info = SJB_UserManager::getUserInfoBySID($cc);
                 }
                 // в функции compose private message функцию отправки
                 // сообщения по имени пользователя оставить рабочей
                 if (is_null($cc_info)) {
                     $cc_info = SJB_UserManager::getUserInfoByUserName($cc);
                 }
                 if (!empty($cc_info)) {
                     $cc = $cc_info['sid'];
                 }
             }
             $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0;
             $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : '';
             $message = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : '';
             $save = isset($_POST['form_save']) ? $_POST['form_save'] == 1 ? true : false : false;
             if ($to_user == 0) {
                 $errors['form_to'] = 'Please enter correct username';
             }
             if (empty($subject)) {
                 $errors['form_subject'] = 'Please, enter message subject';
             }
             if (empty($message)) {
                 $errors['form_message'] = 'Please, enter message';
             }
             if (count($errors) == 0) {
                 $anonym = SJB_Request::getVar('anonym');
                 SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $message, $save, false, $cc, $anonym);
                 // save to contacts
                 if (!$anonym) {
                     SJB_PrivateMessage::saveContact($user_id, $to_user);
                     SJB_PrivateMessage::saveContact($to_user, $user_id);
                 }
                 echo '<p class="message">' . SJB_I18N::getInstance()->gettext(null, 'The message was sent successfully') . '</p>';
                 exit;
             }
         }
         $display_to = '';
         // get display name for 'Message to' field
         SJB_UserManager::getComposeDisplayName($to, $display_to);
         $tp->assign('errors', $errors);
         $tp->assign('info', $info);
         $tp->assign('to', $to);
         $tp->assign('display_to', $display_to);
         $tp->assign('anonym', SJB_Request::getVar('anonym'));
         $tp->assign('cc', SJB_Request::getVar('cc', ''));
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
         $tp->display('new_message_ajax.tpl');
     } else {
         $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis()));
         $tp->assign('ajaxRelocate', true);
         $tp->display('../users/login.tpl');
     }
 }
예제 #14
0
 public function execute()
 {
     $tp = SJB_System::getTemplateProcessor();
     if (SJB_UserManager::isUserLoggedIn()) {
         $user_id = SJB_UserManager::getCurrentUserSID();
         $id = SJB_Request::getInt('id', 0, 'GET');
         if ($id > 0) {
             $errors = array();
             if (isset($_POST['form_to'])) {
                 $to_user_name = isset($_POST['form_to']) ? strip_tags($_POST['form_to']) : '';
                 $to_user_info = SJB_UserManager::getUserInfoByUserName($to_user_name);
                 $to_user = isset($to_user_info['sid']) ? $to_user_info['sid'] : 0;
                 $subject = isset($_POST['form_subject']) ? strip_tags($_POST['form_subject']) : '';
                 $text = isset($_POST['form_message']) ? SJB_PrivateMessage::cleanText($_POST['form_message']) : '';
                 $save = isset($_POST['form_save']) ? true : false;
                 $reply_id = isset($_POST['reply_id']) ? $_POST['reply_id'] : false;
                 if ($to_user == 0) {
                     $errors['form_to'] = 'You specified wrong username';
                 }
                 if (empty($subject)) {
                     $errors['form_subject'] = 'Please, enter message subject';
                 }
                 if (empty($text)) {
                     $errors['form_message'] = 'Please, enter message';
                 }
                 if (count($errors) == 0) {
                     $anonym = SJB_Request::getVar('anonym');
                     SJB_PrivateMessage::sendMessage($user_id, $to_user, $subject, $text, $save, $reply_id, false, $anonym);
                     // save to contacts
                     if (!$anonym) {
                         SJB_PrivateMessage::saveContact($user_id, $to_user);
                         SJB_PrivateMessage::saveContact($to_user, $user_id);
                     }
                     SJB_HelperFunctions::redirect(SJB_System::getSystemSettings('SITE_URL') . '/private-messages/inbox/');
                 } else {
                     $message['to_name'] = htmlentities($to_user_name, ENT_QUOTES, "UTF-8");
                     $message['subject'] = htmlentities($subject, ENT_QUOTES, "UTF-8");
                     $message['message'] = $text;
                     $tp->assign('save', $save);
                 }
             } else {
                 if (SJB_PrivateMessage::isMyMessage($id)) {
                     $message = SJB_PrivateMessage::readMessage($id);
                 } else {
                     $errors['NOT_EXISTS_MESSAGE'] = 1;
                     $message = '';
                 }
                 if ($message) {
                     $message['to_name'] = htmlentities($message['from_name'], ENT_QUOTES, "UTF-8");
                     $message['subject'] = 'RE: ' . htmlentities($message['subject'], ENT_QUOTES, "UTF-8");
                     $message['message'] = '<p>&nbsp;</p><blockquote class="pmQuote">' . $message['message'] . '</blockquote>';
                 }
                 $tp->assign('reply_id', $id);
             }
         }
         $tp->assign('errors', $errors);
         $tp->assign('include', 'reply_message.tpl');
         $tp->assign('message', $message);
         $tp->assign('unread', SJB_PrivateMessage::getCountUnreadMessages($user_id));
         $tp->display('main.tpl');
     } else {
         $tp->assign('return_url', base64_encode(SJB_Navigator::getURIThis()));
         $tp->display('../users/login.tpl');
     }
 }