Example #1
0
 public function sendFriends()
 {
     Phpfox::isUser(true);
     if (Mail_Service_Process::instance()->add($this->get('val'))) {
         $this->setMessage(Phpfox::getPhrase('share.message_successfully_sent'));
     }
 }
Example #2
0
 /**
  * Controller
  */
 public function process()
 {
     $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     $aMail = Mail_Service_Mail::instance()->getMail($this->request()->getInt('id'));
     if (!isset($aMail['mail_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
     }
     $bCanView = false;
     if ($aMail['viewer_user_id'] == Phpfox::getUserId() || $aMail['owner_user_id'] == Phpfox::getUserId()) {
         $bCanView = true;
     }
     if ($bCanView === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
     }
     if ($aVals = $this->request()->getArray('val')) {
         if ($oValid->isValid($aVals)) {
             $aVals['to'] = $aMail['owner_user_id'];
             if ($iNewId = Mail_Service_Process::instance()->add($aVals)) {
                 $this->url()->send('mail.view', array('id' => $iNewId));
             }
         }
     }
     if ($aMail['viewer_user_id'] == Phpfox::getUserId()) {
         Mail_Service_Process::instance()->toggleView($aMail['mail_id'], false);
     }
     $this->template()->assign(array('bMobileInboxIsActive' => true, 'aMail' => $aMail));
 }
Example #3
0
 public function post($id)
 {
     $this->auth();
     $this->requires(['message']);
     \Mail_Service_Process::instance()->add(['thread_id' => $id, 'message' => $this->request->get('message')]);
     $thread = new Thread\Object(\Mail_Service_Mail::instance()->getThreadedMail($id, 0, true));
     return $thread;
 }
Example #4
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     if (!Phpfox::getParam('mail.threaded_mail_conversation')) {
         $this->url()->send('mail');
     }
     $aVals = $this->request()->get('val');
     if ($aVals && ($iNewId = Mail_Service_Process::instance()->add($aVals))) {
         list($aCon, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iNewId);
         $aMessages = array_reverse($aMessages);
         Phpfox_Template::instance()->assign(array('aMail' => $aMessages[0], 'aCon' => $aCon, 'bIsLastMessage' => true))->getTemplate('mail.block.entry');
         $content = ob_get_contents();
         ob_clean();
         return ['append' => ['to' => '#mail_threaded_new_message', 'with' => $content]];
     }
     $iThreadId = $this->request()->getInt('id');
     list($aThread, $aMessages) = Mail_Service_Mail::instance()->getThreadedMail($iThreadId);
     if ($aThread === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_find_a_conversation_history_with_this_user'));
     }
     $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aThread['user_is_archive']) {
         $this->request()->set('view', 'trash');
     }
     Mail_Service_Mail::instance()->buildMenu();
     Mail_Service_Process::instance()->threadIsRead($aThread['thread_id']);
     $iUserCnt = 0;
     $sUsers = '';
     $bCanViewThread = false;
     foreach ($aThread['users'] as $aUser) {
         if ($aUser['user_id'] == Phpfox::getUserId()) {
             $bCanViewThread = true;
         }
         if ($aUser['user_id'] == Phpfox::getUserId()) {
             continue;
         }
         $iUserCnt++;
         if ($iUserCnt == count($aThread['users']) - 1 && count($aThread['users']) - 1 > 1) {
             $sUsers .= ' & ';
         } else {
             if ($iUserCnt != '1') {
                 $sUsers .= ', ';
             }
         }
         $sUsers .= $aUser['full_name'];
     }
     if (!$bCanViewThread) {
         return Phpfox_Error::display('Unable to view this thread.');
     } else {
         $this->template()->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setBreadcrumb($sUsers, $this->url()->makeUrl('mail.thread', array('id' => $iThreadId)), true);
     }
     $this->template()->setTitle($sUsers)->setTitle(Phpfox::getPhrase('mail.mail'))->setHeader('cache', array('mail.js' => 'module_mail', 'jquery/plugin/jquery.scrollTo.js' => 'static_script'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(false), 'aMessages' => $aMessages, 'aThread' => $aThread, 'sCurrentPageCnt' => $this->request()->getInt('page', 0) + 1));
     $this->setParam('attachment_share', array('type' => 'mail', 'id' => 'js_form_mail'));
     $this->setParam('global_moderation', array('name' => 'mail', 'ajax' => 'mail.mailThreadAction', 'custom_fields' => '<div><input type="hidden" name="forward_thread_id" value="' . $aThread['thread_id'] . '" id="js_forward_thread_id" /></div>', 'menu' => array(array('phrase' => Phpfox::getPhrase('mail.forward'), 'action' => 'forward'))));
 }
Example #5
0
 public function move($mFolder, $aIds)
 {
     foreach ($aIds as $iId) {
         if ($mFolder == 'trash') {
             Mail_Service_Process::instance()->delete($iId);
             continue;
         } else {
             $aUpdate = array('viewer_folder_id' => (int) $mFolder, 'viewer_type_id' => '0');
         }
         $this->database()->update(Phpfox::getT('mail'), $aUpdate, 'mail_id = ' . (int) $iId);
     }
     ($sPlugin = Phpfox_Plugin::get('mail.service_folder_process_move')) ? eval($sPlugin) : false;
     return true;
 }
Example #6
0
 public function add()
 {
     /*
     @title 
     @info Compose a new message.
     @method POST
     @extra user_id=#{User ID#|int|yes}&subject=#{Subject|string|yes}&message=#{Message|string|yes}
     @return id=#{Mail ID#|int}&permalink=#{URL to message|string}
     */
     $aVals = array('to' => array($this->_oApi->get('user_id')), 'subject' => $this->_oApi->get('subject'), 'message' => $this->_oApi->get('message'));
     if (($aIds = Mail_Service_Process::instance()->add($aVals)) !== false) {
         $aReturn = array('id' => Phpfox::getParam('mail.threaded_mail_conversation') ? $aIds : $aIds[0], 'permalink' => Phpfox::getParam('mail.threaded_mail_conversation') ? Phpfox_Url::instance()->makeUrl('mail.thread', array('id' => $aIds)) : Phpfox_Url::instance()->makeUrl('mail.view.' . $aIds[0]));
         return $aReturn;
     }
 }
 /**
  * Controller
  */
 public function process()
 {
     $bFriendIsSelected = false;
     if ($iUserId = $this->request()->getInt('to')) {
         $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField());
         if (isset($aUser['user_id'])) {
             //if (!Phpfox::getService('user.privacy')->hasAccess($aUser['user_id'], 'mail.send_message'))
             if (!Mail_Service_Mail::instance()->canMessageUser($aUser['user_id'])) {
                 return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_send_a_private_message_to_this_user_at_the_moment'));
             }
             $bFriendIsSelected = true;
             $this->template()->assign('aUser', $aUser);
         }
     }
     if (Phpfox::getParam('mail.spam_check_messages') && Phpfox::isSpammer()) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.currently_your_account_is_marked_as_a_spammer'));
     }
     $aValidation = array('subject' => Phpfox::getPhrase('mail.provide_subject_for_your_message'), 'message' => Phpfox::getPhrase('mail.provide_message'));
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->getArray('val')) {
         // Lets make sure they are actually trying to send someone a message.
         if ((!isset($aVals['to']) || isset($aVals['to']) && !count($aVals['to'])) && (!isset($aVals['copy_to_self']) || $aVals['copy_to_self'] != 1)) {
             Phpfox_Error::set(Phpfox::getPhrase('mail.select_a_member_to_send_a_message_to'));
         }
         if ($oValid->isValid($aVals)) {
             if (Phpfox::getParam('mail.mail_hash_check')) {
                 Phpfox::getLib('spam.hash', array('table' => 'mail_hash', 'total' => Phpfox::getParam('mail.total_mail_messages_to_check'), 'time' => Phpfox::getParam('mail.total_minutes_to_wait_for_pm'), 'content' => $aVals['message']))->isSpam();
             }
             if (Phpfox::getParam('mail.spam_check_messages')) {
                 if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['message']))))) {
                     Phpfox_Error::set(Phpfox::getPhrase('mail.this_message_feels_like_spam_try_again'));
                 }
             }
             if (Phpfox_Error::isPassed()) {
                 $aIds = Mail_Service_Process::instance()->add($aVals);
                 $this->url()->send('mail.view', array('id' => $aIds[0]));
             }
         }
     }
     $this->template()->assign(array('bMobileInboxIsActive' => true, 'bFriendIsSelected' => $bFriendIsSelected, 'aMobileSubMenus' => array($this->url()->makeUrl('mail') => Phpfox::getPhrase('mail.mobile_messages'), $this->url()->makeUrl('mail', 'sent') => Phpfox::getPhrase('mail.sent'), $this->url()->makeUrl('mail', 'compose') => Phpfox::getPhrase('mail.compose')), 'sActiveMobileSubMenu' => $this->url()->makeUrl('mail', 'compose')));
 }
Example #8
0
 /**
  * Action to take when user cancelled their account
  * @param int $iUser
  */
 public function onDeleteUser($iUser)
 {
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         $this->database()->delete(Phpfox::getT('mail_thread_text'), 'user_id = ' . $iUser);
         $this->database()->delete(Phpfox::getT('mail_thread_user'), 'user_id = ' . $iUser);
     }
     // get all the mail in this user's inbox
     $aMails = $this->database()->select('mail_id, owner_user_id, viewer_user_id')->from($this->_sTable)->where('owner_user_id = ' . (int) $iUser . ' OR viewer_user_id = ' . (int) $iUser)->execute('getSlaveRows');
     foreach ($aMails as $aMail) {
         if (Phpfox::getParam('mail.delete_sent_when_account_cancel')) {
             // if that setting is enabled then we can do a hard delete:
             $this->database()->delete($this->_sTable, 'mail_id = ' . $aMail['mail_id']);
             $this->database()->delete(Phpfox::getT('mail_text'), 'mail_id = ' . $aMail['mail_id']);
             // soft delete
             //Mail_Service_Process::instance()->delete($aMail['mail_id'], true);
         } else {
             $bSent = $aMail['owner_user_id'] == $iUser;
             Mail_Service_Process::instance()->delete($aMail['mail_id'], $bSent);
         }
     }
     $this->database()->delete(Phpfox::getT('mail_folder'), 'user_id = ' . (int) $iUser);
 }
Example #9
0
 public function process()
 {
     Phpfox::getUserParam('mail.can_read_private_messages', true);
     if ($iDeleteId = $this->request()->getInt('delete')) {
         if (Mail_Service_Process::instance()->adminDelete($iDeleteId)) {
             $this->url()->send('admincp.mail.private', null, Phpfox::getPhrase('mail.message_successfully_deleted'));
         }
     }
     $aPages = array(12, 15, 18, 21);
     $aDisplays = array();
     foreach ($aPages as $iPageCnt) {
         $aDisplays[$iPageCnt] = Phpfox::getPhrase('core.per_page', array('total' => $iPageCnt));
     }
     $aUserGroups = array();
     foreach (Phpfox::getService('user.group')->get() as $aUserGroup) {
         $aUserGroups[$aUserGroup['user_group_id']] = $aUserGroup['title'];
     }
     $aAge = array();
     for ($i = 18; $i <= 68; $i++) {
         $aAge[$i] = $i;
     }
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         $aOptions = array('1' => array(Phpfox::getPhrase('mail.text'), "AND mt.text LIKE '%[VALUE]%'"));
     } else {
         $aOptions = array('1' => array(Phpfox::getPhrase('mail.subject_amp_text'), "AND (m.subject LIKE '%[VALUE]%' OR mt.text_parsed LIKE '%[VALUE]%')"), '2' => array(Phpfox::getPhrase('mail.subject'), "AND m.subject LIKE '%[VALUE]%'"), '3' => array(Phpfox::getPhrase('mail.text'), "AND mt.text LIKE '%[VALUE]%'"));
     }
     $iDay = date('d');
     $iMonth = date('m');
     $iYear = date('Y');
     $aFilters = array('display' => array('type' => 'select', 'options' => $aDisplays, 'default' => '12'), 'sort' => array('type' => 'select', 'options' => array(), 'default' => 'time_updated', 'alias' => 'm'), 'sort_by' => array('type' => 'select', 'options' => array('DESC' => Phpfox::getPhrase('core.descending'), 'ASC' => Phpfox::getPhrase('core.ascending')), 'default' => 'DESC'), 'keyword' => array('type' => 'input:text', 'size' => 20), 'type' => array('type' => 'input:radio', 'default_view' => '1', 'prefix' => '<div>', 'suffix' => '</div>', 'options' => $aOptions, 'depend' => 'keyword'), 'group' => array('type' => 'select', 'options' => $aUserGroups, 'add_any' => true, 'search' => 'AND sender.user_group_id = \'[VALUE]\''), 'status' => array('type' => 'select', 'options' => array('1' => Phpfox::getPhrase('mail.all_members'), '2' => Phpfox::getPhrase('mail.featured_members')), 'default_view' => '1', 'search' => 'FEATURED_[VALUE]'), 'view' => array('type' => 'input:radio', 'options' => array('online' => Phpfox::getPhrase('mail.online'), 'updated' => Phpfox::getPhrase('mail.updated'))), 'show' => array('type' => 'select', 'options' => array('1' => Phpfox::getPhrase('mail.name_and_photo_only'), '2' => Phpfox::getPhrase('mail.name_photo_and_users_details')), 'default_view' => Phpfox::getParam('user.user_browse_display_results_default') == 'name_photo_detail' ? '2' : '1'), 'sender' => array('type' => 'input:text', 'size' => 20, 'search' => 'SENDER=\'[VALUE]\''), 'receiver' => array('type' => 'input:text', 'size' => 20, 'search' => 'RECEIVER=\'[VALUE]\''));
     $oFilter = Phpfox_Search::instance()->set(array('type' => 'browse', 'filters' => $aFilters, 'search' => 'keyword'));
     $iPage = $this->request()->getInt('page', 1);
     define('PHPFOX_IS_PRIVATE_MAIL', true);
     list($aMessages, $iCnt) = Mail_Service_Mail::instance()->getPrivate($oFilter->getConditions(), 10, $oFilter->getSort(), $iPage);
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => 10, 'count' => $oFilter->getSearchTotal($iCnt)));
     $this->template()->setTitle(Phpfox::getPhrase('mail.private_messages'))->setHeader('cache', array('mail.css' => 'style_css'))->setBreadCrumb(Phpfox::getPhrase('mail.private_messages'))->setBreadcrumb(Phpfox::getPhrase('mail.view_private_messages'), null, true)->assign(array('aMessages' => $aMessages));
 }
Example #10
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     $bIsInLegacyView = false;
     if (Phpfox::getParam('mail.threaded_mail_conversation') && $this->request()->get('legacy')) {
         Phpfox::getLib('setting')->setParam('mail.threaded_mail_conversation', false);
         $bIsInLegacyView = true;
     }
     $this->setParam('bIsInLegacyView', $bIsInLegacyView);
     if ($aItemModerate = $this->request()->get('item_moderate')) {
         $sFile = Mail_Service_Mail::instance()->getThreadsForExport($aItemModerate);
         Phpfox_File::instance()->forceDownload($sFile, 'mail.xml');
     }
     $iPage = $this->request()->getInt('page');
     $iPageSize = 10;
     $bIsSentbox = $this->request()->get('view') == 'sent' ? true : false;
     $bIsTrash = $this->request()->get('view') == 'trash' ? true : false;
     $iPrivateBox = $this->request()->get('view') == 'box' ? $this->request()->getInt('id') : false;
     $bIs = $this->getParam('bIsSentbox');
     if ($this->request()->get('action') == 'archive') {
         Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 1);
         $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.message_successfully_archived'));
     }
     if ($this->request()->get('action') == 'forcedelete') {
         Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 2);
         $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.conversation_successfully_deleted'));
     }
     if ($this->request()->get('action') == 'unarchive') {
         Mail_Service_Process::instance()->archiveThread($this->request()->getInt('id'), 0);
         $this->url()->send('mail', null, Phpfox::getPhrase('mail.message_successfully_unarchived'));
     }
     if ($this->request()->get('action') == 'delete') {
         $iMailId = $this->request()->getInt('id');
         if (!is_int($iMailId) || empty($iMailId)) {
             Phpfox_Error::set(Phpfox::getPhrase('mail.no_mail_specified'));
         } else {
             $bTrash = $this->getParam('bIsTrash');
             if (!isset($bTrash) || !is_bool($bTrash)) {
                 $bIsTrash = Mail_Service_Mail::instance()->isDeleted($iMailId);
             }
             if ($bIsTrash) {
                 if (Mail_Service_Process::instance()->deleteTrash($iMailId)) {
                     $this->url()->send('mail.trash', null, Phpfox::getPhrase('mail.mail_deleted_successfully'));
                 } else {
                     Phpfox_Error::set(Phpfox::getPhrase('mail.mail_could_not_be_deleted'));
                 }
             } else {
                 $bIsSent = $this->getParam('bIsSentbox');
                 if (!isset($bIsSent) || !is_bool($bIsSent)) {
                     $bIsSentbox = Mail_Service_Mail::instance()->isSent($iMailId);
                 }
                 if (Mail_Service_Process::instance()->delete($iMailId, $bIsSentbox)) {
                     $this->url()->send($bIsSentbox == true ? 'mail.sentbox' : 'mail', null, Phpfox::getPhrase('mail.mail_deleted_successfully'));
                 } else {
                     Phpfox_Error::set(Phpfox::getPhrase('mail.mail_could_not_be_deleted'));
                 }
             }
         }
     }
     if (($aVals = $this->request()->getArray('val')) && isset($aVals['action'])) {
         if (isset($aVals['id'])) {
             //make sure there is at least one selected
             $oMailProcess = Mail_Service_Process::instance();
             switch ($aVals['action']) {
                 case 'unread':
                 case 'read':
                     foreach ($aVals['id'] as $iId) {
                         $oMailProcess->toggleView($iId, $aVals['action'] == 'unread' ? true : false);
                     }
                     $sMessage = Phpfox::getPhrase('mail.messages_updated');
                     break;
                 case 'delete':
                     if (isset($aVals['select']) && $aVals['select'] == 'every') {
                         $aMail = Mail_Service_Mail::instance()->getAllMailFromFolder(Phpfox::getUserId(), (int) $aVals['folder'], $bIsSentbox, $bIsTrash);
                         $aVals['id'] = $aMail;
                     }
                     foreach ($aVals['id'] as $iId) {
                         $bIsTrash ? $oMailProcess->deleteTrash($iId) : $oMailProcess->delete($iId, $bIsSentbox);
                     }
                     $sMessage = Phpfox::getPhrase('mail.messages_deleted');
                     break;
                 case 'undelete':
                     foreach ($aVals['id'] as $iId) {
                         $oMailProcess->undelete($iId);
                     }
                     $sMessage = Phpfox::getPhrase('mail.messages_updated');
                     break;
             }
         } else {
             // didnt select any message
             $sMessage = Phpfox::getPhrase('mail.error_you_did_not_select_any_message');
         }
         // define the mail box that the user was looking at
         $mSend = null;
         if ($bIsSentbox) {
             $mSend = array('sentbox');
         } elseif ($bIsTrash) {
             $mSend = array('trash');
         } elseif ($iPrivateBox) {
             $mSend = array('box', 'id' => $iPrivateBox);
         }
         // send the user to that folder with the message
         $this->url()->send('mail', $mSend, $sMessage);
     }
     $this->search()->set(array('type' => 'mail', 'field' => 'mail.mail_id', 'search_tool' => array('table_alias' => 'm', 'search' => array('action' => $this->url()->makeUrl('mail', array('view' => $this->request()->get('view'), 'id' => $this->request()->get('id'))), 'default_value' => Phpfox::getPhrase('mail.search_messages'), 'name' => 'search', 'field' => array('m.subject', 'm.preview')), 'sort' => array('latest' => array('m.time_stamp', Phpfox::getPhrase('mail.latest')), 'most-viewed' => array('m.viewer_is_new', Phpfox::getPhrase('mail.unread_first'))), 'show' => array(10, 15, 20))));
     $iPageSize = $this->search()->getDisplay();
     $aFolders = Phpfox::getService('mail.folder')->get();
     $sUrl = '';
     $sFolder = '';
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         if ($bIsTrash) {
             $sUrl = $this->url()->makeUrl('mail.trash');
             $this->search()->setCondition('AND m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.is_archive = 1');
         } else {
             if ($bIsSentbox) {
                 $sUrl = $this->url()->makeUrl('mail.sentbox');
             } else {
                 $sUrl = $this->url()->makeUrl('mail');
             }
             $this->search()->setCondition('AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.is_archive = 0');
         }
     } else {
         if ($bIsTrash) {
             $sFolder = Phpfox::getPhrase('mail.trash');
             $sUrl = $this->url()->makeUrl('mail.trash');
             $this->search()->setCondition('AND (m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 1) OR (m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 1)');
             // $this->search()->setCondition('AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 1');
         } elseif ($iPrivateBox) {
             if (isset($aFolders[$iPrivateBox])) {
                 $sFolder = $aFolders[$iPrivateBox]['name'];
                 $sUrl = $this->url()->makeUrl('mail.box', array('id' => (int) $iPrivateBox));
                 $this->search()->setCondition('AND m.viewer_folder_id = ' . (int) $iPrivateBox . ' AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0');
             } else {
                 $this->url()->send('mail', null, Phpfox::getPhrase('mail.mail_folder_does_not_exist'));
             }
         } else {
             if ($bIsSentbox) {
                 $sFolder = Phpfox::getPhrase('mail.sent_messages');
                 $sUrl = $this->url()->makeUrl('mail.sentbox');
                 $this->search()->setCondition('AND m.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 0');
             } else {
                 $sFolder = Phpfox::getPhrase('mail.inbox');
                 $sUrl = $this->url()->makeUrl('mail');
                 $this->search()->setCondition('AND m.viewer_folder_id = 0 AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0');
             }
         }
     }
     list($iCnt, $aRows, $aInputs) = Mail_Service_Mail::instance()->get($this->search()->getConditions(), $this->search()->getSort(), $this->search()->getPage(), $iPageSize, $bIsSentbox, $bIsTrash);
     Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt));
     Mail_Service_Mail::instance()->buildMenu();
     $aActions = array();
     $aActions[] = array('phrase' => Phpfox::getPhrase('mail.delete'), 'action' => 'delete');
     if (!$bIsSentbox && !$bIsInLegacyView) {
         $aActions[] = array('phrase' => Phpfox::getPhrase('mail.move'), 'action' => 'move');
     }
     $aModeration = array('name' => 'mail', 'ajax' => 'mail.moderation', 'menu' => $aActions);
     if ($bIsSentbox) {
         $aModeration['custom_fields'] = '<div><input type="hidden" name="sent" value="1" /></div>';
     } elseif ($bIsTrash) {
         $aModeration['custom_fields'] = '<div><input type="hidden" name="trash" value="1" /></div>';
     }
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         $aModeration['ajax'] = 'mail.archive';
         $aMenuOptions = array();
         if ($bIsTrash) {
             $aMenuOptions = array('phrase' => Phpfox::getPhrase('mail.un_archive'), 'action' => 'un-archive');
         } else {
             $aMenuOptions = array('phrase' => Phpfox::getPhrase('mail.archive'), 'action' => 'archive');
         }
         $aModeration['menu'] = array($aMenuOptions, array('phrase' => Phpfox::getPhrase('mail.export'), 'action' => 'export'));
     }
     $this->setParam('global_moderation', $aModeration);
     if (empty($sFolder)) {
         $sFolder = Phpfox::getPhrase('mail.mail');
     }
     $iMailSpaceUsed = 0;
     if (!Phpfox::getUserParam('mail.override_mail_box_limit') && Phpfox::getParam('mail.enable_mail_box_warning')) {
         $iMailSpaceUsed = Mail_Service_Mail::instance()->getSpaceUsed(Phpfox::getUserId());
         if ($iMailSpaceUsed > 100) {
             $iMailSpaceUsed = 100;
         }
     }
     $this->template()->setTitle($sFolder)->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setPhrase(array('mail.add_new_folder', 'mail.adding_new_folder', 'mail.view_folders', 'mail.edit_folders', 'mail.you_will_delete_every_message_in_this_folder', 'mail.updating'))->setHeader('cache', array('jquery/plugin/jquery.highlightFade.js' => 'static_script', 'quick_edit.js' => 'static_script', 'selector.js' => 'static_script', 'mail.js' => 'module_mail', 'pager.css' => 'style_css', 'mail.css' => 'style_css'))->assign(array('aMails' => $aRows, 'bIsSentbox' => $bIsSentbox, 'bIsTrash' => $bIsTrash, 'aInputs' => $aInputs, 'aFolders' => $aFolders, 'iMailSpaceUsed' => $iMailSpaceUsed, 'iMessageAge' => Phpfox::getParam('mail.message_age_to_delete'), 'sUrl' => $sUrl, 'iFolder' => isset($aFolders[$iPrivateBox]['folder_id']) ? $aFolders[$iPrivateBox]['folder_id'] : 0, 'iTotalMessages' => $iCnt, 'sSiteName' => Phpfox::getParam('core.site_title'), 'bIsInLegacyView' => $bIsInLegacyView));
 }
Example #11
0
 public function markAllRead()
 {
     Mail_Service_Process::instance()->markAllRead();
     $this->call('window.location.href=window.location.href');
 }
Example #12
0
 public function process()
 {
     Phpfox::isUser(true);
     Phpfox::getUserParam('mail.can_compose_message', true);
     $bClaiming = $this->getParam('page_id') != false;
     if (Phpfox::getParam('mail.spam_check_messages') && Phpfox::isSpammer()) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.currently_your_account_is_marked_as_a_spammer'));
     }
     $aVals = $this->request()->getArray('val');
     $bIsSending = isset($aVals['sending_message']);
     $aUser = array();
     if (($iUserId = $this->request()->get('id')) || ($iUserId = $this->getParam('id'))) {
         $aUser = Phpfox::getService('user')->getUser($iUserId, Phpfox::getUserField());
         if (isset($aUser['user_id'])) {
             if ($bClaiming == false && $bIsSending != true && Mail_Service_Mail::instance()->canMessageUser($aUser['user_id']) == false) {
                 return Phpfox_Error::display(Phpfox::getPhrase('mail.unable_to_send_a_private_message_to_this_user_at_the_moment'));
             }
             $this->template()->assign('aUser', $aUser);
             if ($bClaiming) {
                 $aPage = Phpfox::getService('pages')->getPage($this->getParam('page_id'));
                 $this->template()->assign(array('iPageId' => $this->getParam('page_id'), 'aPage' => $aPage, 'sMessageClaim' => Phpfox::getPhrase('mail.page_claim_message', array('title' => $aPage['title'], 'url' => Phpfox::permalink('pages', $aPage['page_id'], $aPage['title'])))));
             }
         }
         ($sPlugin = Phpfox_Plugin::get('mail.component_controller_compose_controller_to')) ? eval($sPlugin) : false;
     }
     $bIsThreadForward = false;
     $iThreadId = 0;
     if ($iThreadId = $this->request()->getInt('forward_thread_id')) {
         $bIsThreadForward = true;
     }
     $aValidation = array('subject' => Phpfox::getPhrase('mail.provide_subject_for_your_message'), 'message' => Phpfox::getPhrase('mail.provide_message'));
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         unset($aValidation['subject']);
     }
     if (Phpfox::isModule('captcha') && Phpfox::getUserParam('mail.enable_captcha_on_mail')) {
         $aValidation['image_verification'] = Phpfox::getPhrase('captcha.complete_captcha_challenge');
     }
     ($sPlugin = Phpfox_Plugin::get('mail.component_controller_compose_controller_validation')) ? eval($sPlugin) : false;
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->getArray('val')) {
         // Lets make sure they are actually trying to send someone a message.
         if ((!isset($aVals['to']) || isset($aVals['to']) && !count($aVals['to'])) && (!isset($aVals['copy_to_self']) || $aVals['copy_to_self'] != 1)) {
             Phpfox_Error::set(Phpfox::getPhrase('mail.select_a_member_to_send_a_message_to'));
         }
         if ($oValid->isValid($aVals)) {
             if (Phpfox::getParam('mail.mail_hash_check')) {
                 Phpfox::getLib('spam.hash', array('table' => 'mail_hash', 'total' => Phpfox::getParam('mail.total_mail_messages_to_check'), 'time' => Phpfox::getParam('mail.total_minutes_to_wait_for_pm'), 'content' => $aVals['message']))->isSpam();
             }
             if (Phpfox::getParam('mail.spam_check_messages')) {
                 if (Phpfox::getLib('spam')->check(array('action' => 'isSpam', 'params' => array('module' => 'comment', 'content' => Phpfox::getLib('parse.input')->prepare($aVals['message']))))) {
                     Phpfox_Error::set(Phpfox::getPhrase('mail.this_message_feels_like_spam_try_again'));
                 }
             }
             if (Phpfox_Error::isPassed()) {
                 if ($bClaiming) {
                     $aVals['claim_page'] = true;
                 }
                 if ($aIds = Mail_Service_Process::instance()->add($aVals)) {
                     if (isset($aVals['page_id']) && !empty($aVals['page_id'])) {
                         Phpfox_Database::instance()->insert(Phpfox::getT('pages_claim'), array('status_id' => '1', 'page_id' => (int) $aVals['page_id'], 'user_id' => Phpfox::getUserId(), 'time_stamp' => PHPFOX_TIME));
                     }
                     if (PHPFOX_IS_AJAX) {
                         $this->_bReturn = true;
                         return true;
                     }
                     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
                         $this->url()->send('mail.thread', array('id' => $aIds));
                     } else {
                         if (count($aIds) > 1) {
                             $this->url()->send('mail.view', array('id' => base64_encode(serialize($aIds))));
                         } elseif (isset($aIds[0])) {
                             $this->url()->send('mail.view', array('id' => $aIds[0]));
                         }
                     }
                 } else {
                     if (PHPFOX_IS_AJAX) {
                         $this->_bReturn = false;
                         return false;
                     }
                 }
             } else {
                 if (PHPFOX_IS_AJAX) {
                     $this->_bReturn = false;
                     return false;
                 }
             }
         } else {
             if (PHPFOX_IS_AJAX) {
                 $this->_bReturn = false;
                 return false;
             }
         }
     }
     Mail_Service_Mail::instance()->buildMenu();
     if (Phpfox::isModule('friend')) {
         $this->template()->setPhrase(array('friend.loading'));
     }
     if (Phpfox::getParam('core.wysiwyg') == 'tiny_mce') {
         Phpfox::getService('tinymce')->load();
         $sTinyMceCode = str_replace('\'', '\\\'', Phpfox::getService('tinymce')->getJsCode());
         $sTinyMceCode = str_replace(array("\r\n", "\n", "\r"), '', $sTinyMceCode);
         //break here so I know where I left
         //$this->template()->assign(array('sTinyMceCode' => $sTinyMceCode));
     }
     $this->template()->setTitle(Phpfox::getPhrase('mail.compose_new_message'))->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'))->setBreadcrumb(Phpfox::getPhrase('mail.compose_new_message'), $this->url()->makeUrl('mail.compose'), true)->setPhrase(array('mail.add_new_folder', 'mail.adding_new_folder', 'mail.view_folders', 'mail.edit_folders', 'mail.you_will_delete_every_message_in_this_folder'))->setEditor()->setHeader('cache', array('switch_legend.js' => 'static_script', 'switch_menu.js' => 'static_script', 'jquery/plugin/jquery.highlightFade.js' => 'static_script', 'jquery/plugin/jquery.scrollTo.js' => 'static_script', 'mail.js' => 'module_mail', 'pager.css' => 'style_css'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'iMaxRecipients' => Phpfox::getUserParam('mail.send_message_to_max_users_each_time'), 'bIsThreadForward' => $bIsThreadForward, 'sThreadsToForward' => $this->request()->get('forwards'), 'sForwardThreadId' => $iThreadId));
     if (!Phpfox::getUserParam('mail.can_add_attachment_on_mail')) {
         $this->template()->assign('bNoAttachaFile', true);
     }
     $this->setParam('attachment_share', array('type' => 'mail', 'inline' => true, 'id' => 'js_form_mail'));
 }
Example #13
0
 /**
  * Controller
  */
 public function process()
 {
     Phpfox::isUser(true);
     $bIsSentbox = false;
     $bIsTrash = false;
     $bIsCustomFolder = false;
     $iId = $this->request()->get('id');
     if (empty($iId)) {
         $iId = $this->request()->get('req3');
     }
     $oParseOutput = Phpfox::getLib('parse.output');
     $oMail = Mail_Service_Mail::instance();
     if (!is_numeric($iId)) {
         $aIds = unserialize(base64_decode($iId));
         $sIds = '';
         foreach ($aIds as $iMassId) {
             if (empty($iMassId)) {
                 continue;
             }
             if (!is_numeric($iMassId)) {
                 continue;
             }
             $sIds .= $iMassId . ',';
         }
         list($iCnt, $aMails, $aInputs) = $oMail->get(array("m.mail_id IN(" . rtrim($sIds, ',') . ")"), 'm.time_updated DESC', 0, 20, true);
         if (isset($aMails[0])) {
             $iId = $aMails[0]['mail_id'];
         }
         $this->template()->assign(array('bMass' => true, 'aMails' => $aMails));
     }
     $aMail = $oMail->getMail($iId, true);
     ($sPlugin = Phpfox_Plugin::get('mail.component_controller_view_process_start')) ? eval($sPlugin) : false;
     if (!isset($aMail['mail_id'])) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
     }
     $bCanView = false;
     if ($aMail['viewer_user_id'] == Phpfox::getUserId() || $aMail['owner_user_id'] == Phpfox::getUserId()) {
         $bCanView = true;
     }
     if ($bCanView === false) {
         return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
     }
     if ($aMail['viewer_user_id'] == Phpfox::getUserId()) {
         Mail_Service_Process::instance()->toggleView($aMail['mail_id'], false);
     }
     $aValidation = array('message' => Phpfox::getPhrase('mail.add_reply'));
     ($sPlugin = Phpfox_Plugin::get('mail.component_controller_view_process_validation')) ? eval($sPlugin) : false;
     $oValid = Phpfox_Validator::instance()->set(array('sFormName' => 'js_form', 'aParams' => $aValidation));
     if ($aVals = $this->request()->getArray('val')) {
         if ($oValid->isValid($aVals)) {
             $aVals['to'] = $aMail['owner_user_id'];
             if ($iNewId = Mail_Service_Process::instance()->add($aVals)) {
                 $this->url()->send('mail.view', array('id' => $iNewId));
             }
         }
     }
     $sTitle = $oParseOutput->clean($aMail['subject'], 255);
     ($sPlugin = Phpfox_Plugin::get('mail.component_controller_view_process_end')) ? eval($sPlugin) : false;
     $sFolder = Phpfox::getPhrase('mail.inbox');
     $sLink = $this->url()->makeUrl('mail', array('view' => 'inbox'));
     if (isset($aMail['folder_name']['name'])) {
         $sFolder = $aMail['folder_name']['name'];
         $bIsCustomFolder = true;
         $sLink = $this->url()->makeUrl('mail', array('view' => 'box', 'id' => $aMail['folder_name']['folder_id']));
     } else {
         if ($aMail['viewer_user_id'] != Phpfox::getUserId()) {
             $sFolder = Phpfox::getPhrase('mail.sent_messages');
             $bIsSentbox = true;
             $sLink = $this->url()->makeUrl('mail', array('view' => 'sentbox'));
             if ($aMail['owner_type_id'] == 1) {
                 $sFolder = Phpfox::getPhrase('mail.trash');
                 $bIsTrash = true;
                 $bIsActualTrash = true;
                 $sLink = $this->url()->makeUrl('mail', array('view' => 'trash'));
             } elseif ($aMail['owner_type_id'] == 3) {
                 return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
             }
         } else {
             if ($aMail['viewer_type_id'] == 1) {
                 $sFolder = Phpfox::getPhrase('mail.trash');
                 $bIsTrash = true;
                 $sLink = $this->url()->makeUrl('mail', array('view' => 'trash'));
             } elseif ($aMail['viewer_type_id'] == 3) {
                 return Phpfox_Error::display(Phpfox::getPhrase('mail.invalid_message'));
             }
         }
     }
     if ($bIsSentbox && !isset($bIsActualTrash)) {
         $this->request()->set('view', 'sent');
     } elseif ($bIsTrash) {
         $this->request()->set('view', 'trash');
     }
     /*
     elseif ($bIsCustomFolder)
     {
     	$this->request()->set('view', 'box');
     	$this->request()->set('id', '2');
     }		
     */
     // check for attachments only if needed.
     if ($aMail['total_attachment'] > 0) {
         list($iCnt, $aAttachments) = Phpfox::getService('attachment')->get(array('AND attachment.item_id = ' . ($aMail['mass_id'] ? $aMail['mass_id'] : $aMail['mail_id']) . ' AND attachment.category_id = \'mail\' AND is_inline = 0'), 'attachment.attachment_id DESC', '', '', false);
         $this->template()->assign(array('aAttachments' => $aAttachments));
     }
     $this->template()->setBreadcrumb(Phpfox::getPhrase('mail.mail'), $this->url()->makeUrl('mail'));
     Mail_Service_Mail::instance()->buildMenu();
     $this->template()->setBreadcrumb($oParseOutput->split($sTitle, 50), $this->url()->makeUrl('mail.view', array('id' => $aMail['mail_id'])), true)->setTitle(Phpfox::getPhrase('mail.message') . ': ' . $sTitle)->setPhrase(array('mail.add_new_folder', 'mail.adding_new_folder', 'mail.view_folders', 'mail.edit_folders', 'mail.you_will_delete_every_message_in_this_folder'))->setEditor()->setHeader('cache', array('mail.js' => 'module_mail'))->assign(array('sCreateJs' => $oValid->createJS(), 'sGetJsForm' => $oValid->getJsForm(), 'aMail' => $aMail, 'iPrevId' => $oMail->getPrev($aMail['time_updated'], $bIsSentbox, $bIsTrash), 'iNextId' => $oMail->getNext($aMail['time_updated'], $bIsSentbox, $bIsTrash), 'sSite' => Phpfox::getParam('core.site_title')));
     $this->setParam('attachment_share', array('type' => 'mail', 'id' => 'js_form_mail'));
 }
Example #14
0
 /**
  * This function can probably still be improved by not adding data to the mail_text and recycle the reference to the first entry
  * @param <type> $aVals
  */
 private function _sendInternal($aVals)
 {
     $oFilter = Phpfox::getLib('parse.input');
     $aVals['subject'] = isset($aVals['subject']) ? $oFilter->clean($aVals['subject'], 255) : null;
     $aSend = array();
     $aSend['to'] = array($aVals['user_id']);
     $aSend['subject'] = $aVals['subject'];
     $aSend['message'] = $aVals['text_html'];
     $aSend['bIsNewsletter'] = true;
     Mail_Service_Process::instance()->add($aSend);
     return;
     /*$aInsert = array(
     			'parent_id' => 0,
     			'subject' => $aVals['subject'],
     			'preview' => $oFilter->clean($oFilter->prepare($aVals['text_html']), 255),
     			'owner_user_id' => 0,
     			'viewer_user_id' => $aVals['user_id'],
     			'viewer_is_new' => 1,
     			'time_stamp' => PHPFOX_TIME,
     			'time_updated' => PHPFOX_TIME,
     			'total_attachment' => 0,
     		);
     
     		$iId = $this->database()->insert(Phpfox::getT('mail'), $aInsert);
     
     		$this->database()->insert(Phpfox::getT('mail_text'), array(
     				'mail_id' => $iId,
     				'text' => $oFilter->clean($aVals['text_html']),
     				'text_parsed' => $oFilter->prepare($aVals['text_html'])
     			)
     		);
     		
     		// Send the user an email
     		$sLink = Phpfox_Url::instance()->makeUrl('mail.view', array('id' => $iId));
     		Phpfox::getLib('mail')->to($aVals['user_id'])
     			->subject(array('newsletter.site_newsletter_title', array('title' => $aVals['subject'])))
     			->message(array('newsletter.you_have_received_a_newsletter_from_title', array(
     						'title' => Phpfox::getParam('core.site_title'),
     						'link' => $sLink
     					)
     				)
     			)
     			->notification('mail.new_message')
     			->send();		*/
 }
Example #15
0
 /**
  * Action to take when user cancelled their account
  * @param int $iUser
  */
 public function onDeleteUser($iUser)
 {
     if (Phpfox::getParam('mail.threaded_mail_conversation')) {
         $aThreads = $this->database()->select('thread_id')->from(Phpfox::getT('mail_thread_user'))->where('user_id = ' . (int) $iUser)->execute('getSlaveRows');
         foreach ($aThreads as $aThread) {
             $iCount = $this->database()->select('COUNT(*)')->from(Phpfox::getT('mail_thread_user'))->where('thread_id = ' . (int) $aThread['thread_id'])->execute('getField');
             if ($iCount > 2) {
                 $this->database()->delete(Phpfox::getT('mail_thread_text'), 'user_id = ' . $iUser);
                 $this->database()->delete(Phpfox::getT('mail_thread_user'), 'user_id = ' . $iUser);
                 $aLastMess = $this->database()->select('message_id, user_id, time_stamp')->from(Phpfox::getT('mail_thread_text'))->where('thread_id = ' . (int) $aThread['thread_id'])->order('time_stamp DESC')->execute('getSlaveRow');
                 $this->database()->update(Phpfox::getT('mail_thread'), array('last_id' => $aLastMess['message_id'], 'time_stamp' => $aLastMess['time_stamp']), 'thread_id = ' . $aThread['thread_id']);
                 $this->database()->update(Phpfox::getT('mail_thread_user'), array('is_read' => 1, 'is_sent' => 1, 'is_sent_update' => 1), 'thread_id = ' . $aThread['thread_id'] . ' AND user_id = ' . $aLastMess['user_id']);
             } else {
                 $this->database()->delete(Phpfox::getT('mail_thread_text'), 'thread_id = ' . $aThread['thread_id']);
                 $this->database()->delete(Phpfox::getT('mail_thread_user'), 'thread_id = ' . $aThread['thread_id']);
             }
         }
     }
     // get all the mail in this user's inbox
     $aMails = $this->database()->select('mail_id, owner_user_id, viewer_user_id')->from($this->_sTable)->where('owner_user_id = ' . (int) $iUser . ' OR viewer_user_id = ' . (int) $iUser)->execute('getSlaveRows');
     foreach ($aMails as $aMail) {
         if (Phpfox::getParam('mail.delete_sent_when_account_cancel')) {
             // if that setting is enabled then we can do a hard delete:
             $this->database()->delete($this->_sTable, 'mail_id = ' . $aMail['mail_id']);
             $this->database()->delete(Phpfox::getT('mail_text'), 'mail_id = ' . $aMail['mail_id']);
             // soft delete
             //Mail_Service_Process::instance()->delete($aMail['mail_id'], true);
         } else {
             $bSent = $aMail['owner_user_id'] == $iUser;
             Mail_Service_Process::instance()->delete($aMail['mail_id'], $bSent);
         }
     }
     $this->database()->delete(Phpfox::getT('mail_folder'), 'user_id = ' . (int) $iUser);
 }