/** * Controller */ public function process() { $aCond = array(); $iPage = $this->request()->getInt('page'); $iPageSize = 10; $bIsSentbox = $this->request()->get('req2') == 'sent' ? true : false; $bIsSearch = false; if ($bIsSentbox) { $aCond[] = 'm.owner_user_id = ' . Phpfox::getUserId() . ' AND m.owner_type_id = 0'; } else { $aCond[] = 'm.viewer_folder_id = 0 AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.viewer_type_id = 0'; } if (($sSearch = $this->request()->get('search')) || $this->request()->get('search-query')) { if ($this->request()->get('search-query')) { $sSearch = Phpfox::getLib('session')->get('mfsearch'); } $bIsSearch = true; $aCond[] = "AND (m.subject LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%' OR m.preview LIKE '%" . Phpfox_Database::instance()->escape($sSearch) . "%')"; $this->url()->setParam('search-query', 'true'); Phpfox::getLib('session')->set('mfsearch', $sSearch); } if ($bIsSearch == false) { Phpfox::getLib('session')->remove('mfsearch'); } list($iCnt, $aMessages, $aInputs) = Mail_Service_Mail::instance()->get($aCond, 'm.time_updated DESC', $iPage, $iPageSize, $bIsSentbox); Phpfox_Pager::instance()->set(array('page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt)); $this->template()->assign(array('bMobileInboxIsActive' => true, 'aMessages' => $aMessages, 'bIsSearch' => $bIsSearch, 'bIsSentbox' => $bIsSentbox, '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', $this->request()->get('req2') == '' ? null : $this->request()->get('req2')))); }
/** * 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)); }
/** * Controller */ public function process() { $aMessages = Mail_Service_Mail::instance()->getLatest(); foreach ($aMessages as $iKey => $aMessage) { $aMessages[$iKey]['preview'] = strip_tags(str_replace(array('<', '>'), array('<', '> '), $aMessage['preview'])); } $this->template()->assign(array('aMessages' => $aMessages)); }
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; }
public function process() { Phpfox::isUser(true); $iPageSize = 30; $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(30)))); $this->search()->setCondition('AND m.viewer_user_id = ' . Phpfox::getUserId() . ' AND m.is_archive = 0'); list($iCnt, $aMessages, $aInputs) = Mail_Service_Mail::instance()->get($this->search()->getConditions(), $this->search()->getSort(), $this->search()->getPage(), $iPageSize); $this->template()->assign(array('aMessages' => $aMessages)); }
/** * 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')))); }
/** * Controller */ public function process() { $aMessage = Mail_Service_Mail::instance()->getMail($this->request()->getInt('id')); if (!Phpfox::getParam('mail.threaded_mail_conversation') && !isset($aMessage['mail_id']) || Phpfox::getParam('mail.threaded_mail_conversation') && !count($aMessage)) { return Phpfox_Error::display(Phpfox::getPhrase('mail.message_not_found')); } if (Phpfox::getParam('mail.threaded_mail_conversation')) { $this->template()->setHeader(array('mail.css' => 'style_css')); } $this->template()->setTitle(Phpfox::getPhrase('mail.viewing_private_message'))->setBreadCrumb(Phpfox::getPhrase('mail.private_messages'), $this->url()->makeUrl('admincp.mail.private'))->setBreadcrumb(Phpfox::getPhrase('mail.viewing_private_message'), null, true)->assign(array('aMessage' => $aMessage)); }
public function addThreadMail() { $aVals = $this->get('val'); if ($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'); $this->call('$(\'.mail_thread_holder\').removeClass(\'is_last_message\');'); $this->append('#mail_threaded_new_message', $this->getContent(false)); $this->call("\$.scrollTo('.is_last_message:first');"); $this->call("\$('.mail_thread_form_holder').addClass('not_fixed');"); } }
public function get($id = null) { if ($id) { $message = $this->db->select('t.*, ' . \Phpfox::getUserField())->from(':mail_thread_text', 't')->join(':user', 'u', 'u.user_id = t.user_id')->where(['t.message_id' => $id])->get(); $object = new Message\Thread\Object($message); } else { $this->auth(); $object = []; list($total, $messages, $inputs) = \Mail_Service_Mail::instance()->get(); foreach ($messages as $message) { $object[] = new Message\Object($message); } } return $object; }
/** * Controller */ public function process() { $iId = $this->request()->get('id'); $aMessage = Mail_Service_Mail::instance()->getMail($iId); if (!Phpfox::getParam('mail.threaded_mail_conversation')) { // calculate the "best" dimensions possible: //die(d($aMessage, true)); if (strpos($aMessage['text'], '<br />') !== false) { $iWidth = strlen($aMessage['text']) / substr_count($aMessage['text'], '<br />') * 9 > 800 ? 800 : strlen($aMessage['text']) / substr_count($aMessage['text'], '<br />') * 9; $iHeight = strlen($aMessage['text']) / substr_count($aMessage['text'], '<br />') * 5 > 600 ? 600 : strlen($aMessage['text']) / substr_count($aMessage['text'], '<br />') * 5; } else { // guess... $iWidth = strlen($aMessage['text']) * 8 > 600 ? 600 : (strlen($aMessage['text']) * 4 < 300 ? 300 : strlen($aMessage['text']) * 4); $iHeight = $iWidth; } } //)), Phpfox::getPhrase('mail.read_private_message'), $iWidth, $iHeight); $this->template()->assign(array('aMessage' => $aMessage)); return 'block'; }
/** * 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'))); }
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)); }
/** * 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)); }
/** * Sends the birthday congratulation * @param int $iUser * @param string $sMessage * @param int| $iEgift egift_id or 0 * @return int|boolean int if fCost > 0, boolean otherwise */ public function sendCongrats($iUser, $sMessage, $iEgift = 0, $fCost = 0) { $iUser = (int) $iUser; if ($iUser < 1) { return false; } /* Lets skip sending a notification until the user has paid if its a charged gift*/ if ($fCost > 0) { // Notification.process::add checks for this before adding it. define('SKIP_NOTIFICATION', true); // this is checked in the mail lib define('PHPFOX_SKIP_MAIL', true); } /* Always send the message but need to alter the mail display routine to just * display messages that have been paid */ $aMail = array('to' => $iUser, 'subject' => Phpfox::getPhrase('friend.happy_birthday')); $iBirthdayId = Mail_Service_Mail::instance()->add($aMail); /* if its free then send the notification and mail*/ if ($fCost != 0 && $iEgift > 0) { /* Create an invoice*/ $iInvoice = $this->database()->insert(Phpfox::getT('egift_invoice'), array('user_from' => Phpfox::getUserId(), 'user_to' => $iUser, 'egift_id' => $iEgift, 'birthday_id' => $iBirthdayId, 'currency_id' => Phpfox::getService('user')->getCurrency(), 'price' => $fCost, 'time_stamp_created' => PHPFOX_TIME, 'status' => 'pending')); return $iInvoice; } return true; }
/** * This function checks if the current user is either the sender or the receiver of iMailId * Used to validate who can download attachments * @param int $iMailId * @return bool */ public function attachmentControl($iMailId) { if (Phpfox::getParam('mail.threaded_mail_conversation')) { $iThreadId = (int) $this->database()->select('thread_id')->from(Phpfox::getT('mail_thread_text'))->where('message_id = ' . (int) $iMailId)->execute('getSlaveField'); if ($iThreadId <= 0) { return false; } $iUserCheck = (int) $this->database()->select('COUNT(*)')->from(Phpfox::getT('mail_thread_user'))->where('thread_id = ' . (int) $iThreadId . ' AND user_id = ' . (int) Phpfox::getUserId())->execute('getSlaveField'); return $iUserCheck > 0 ? true : false; } $aMail = Mail_Service_Mail::instance()->getMail($iMailId); return $aMail['owner_user_id'] == Phpfox::getUserId() || $aMail['viewer_user_id'] == Phpfox::getUserId(); }
public function delete($iId, $bSent = false) { $aMail = Mail_Service_Mail::instance()->getMail($iId); if ($aMail['viewer_user_id'] == $aMail['owner_user_id']) { $this->database()->update($this->_sTable, array($bSent === false ? 'owner_type_id' : 'viewer_type_id' => 1), 'mail_id = ' . (int) $iId . ' AND ' . ($bSent === false ? 'viewer_user_id' : 'owner_user_id') . ' = ' . Phpfox::getUserId()); } $this->database()->update($this->_sTable, array($bSent === false ? 'viewer_type_id' : 'owner_type_id' => 1), 'mail_id = ' . (int) $iId . ' AND ' . ($bSent === false ? 'viewer_user_id' : 'owner_user_id') . ' = ' . Phpfox::getUserId()); ($sPlugin = Phpfox_Plugin::get('mail.service_process_delete')) ? eval($sPlugin) : false; return true; }
/** * Controller */ public function process() { $iPage = $this->getParam('page', 0); $iPageSize = 36; $bIsOnline = false; $oDb = Phpfox_Database::instance(); $aParams = array(); $aConditions = array(); $iListId = 0; $aConditions[] = 'AND friend.is_page = 0'; if ($this->getParam('type') != 'mail') { $aConditions[] = 'AND friend.user_id = ' . Phpfox::getUserId(); } if ($sFind = $this->getParam('find')) { $aConditions[] = 'AND (u.full_name LIKE \'%' . $oDb->escape($sFind) . '%\' OR (u.email LIKE \'%' . $oDb->escape($sFind) . '@%\' OR u.email = \'' . $oDb->escape($sFind) . '\'))'; } $aLetters = array(Phpfox::getPhrase('friend.all'), '#', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); if (($sLetter = $this->getParam('letter')) && in_array($sLetter, $aLetters) && strtolower($sLetter) != 'all') { if ($sLetter == '#') { $sSubCondition = ''; for ($i = 0; $i <= 9; $i++) { $sSubCondition .= "OR u.full_name LIKE '" . Phpfox_Database::instance()->escape($i) . "%' "; } $sSubCondition = ltrim($sSubCondition, 'OR '); $aConditions[] = 'AND (' . $sSubCondition . ')'; } else { $aConditions[] = "AND u.full_name LIKE '" . Phpfox_Database::instance()->escape($sLetter) . "%'"; } $aParams['letter'] = $sLetter; } if ($sView = $this->getParam('view')) { switch ($sView) { case 'top': $aConditions[] = 'AND is_top_friend = 1'; break; case 'online': $bIsOnline = true; break; case 'all': break; default: if ((int) $sView > 0 && ($aList = Phpfox::getService('friend.list')->getList($sView, Phpfox::getUserId())) && isset($aList['list_id'])) { $iListId = (int) $aList['list_id']; } break; } } if ($this->getParam('type') == 'mail') { $aConditions[] = 'AND u.user_id != ' . Phpfox::getUserId(); list($iCnt, $aFriends) = Phpfox::getService('user.browse')->conditions($aConditions)->sort('u.full_name ASC')->page($iPage)->limit($iPageSize)->get(); if (Phpfox::getParam('mail.disallow_select_of_recipients')) { $oMail = Mail_Service_Mail::instance(); foreach ($aFriends as $iKey => $aFriend) { if (!$oMail->canMessageUser($aFriend['user_id'])) { $aFriends[$iKey]['canMessageUser'] = false; } } } } else { list($iCnt, $aFriends) = Friend_Service_Friend::instance()->get($aConditions, 'u.full_name ASC', $iPage, $iPageSize, true, true, $bIsOnline, null, false, $iListId); } ($sPlugin = Phpfox_Plugin::get('friend.component_block_search_get')) ? eval($sPlugin) : false; $aParams['input'] = $this->getParam('input'); $aParams['friend_item_id'] = $this->getParam('friend_item_id'); $aParams['friend_module_id'] = $this->getParam('friend_module_id'); $aParams['type'] = $this->getParam('type'); Phpfox_Pager::instance()->set(array('ajax' => 'friend.searchAjax', 'page' => $iPage, 'size' => $iPageSize, 'count' => $iCnt, 'aParams' => $aParams)); $sFriendModuleId = $this->getParam('friend_module_id', ''); $this->template()->assign(array('aFriends' => $aFriends, 'aLetters' => $aLetters, 'sView' => $sView, 'sActualLetter' => $sLetter, 'sPrivacyInputName' => $this->getParam('input'), 'aLists' => Phpfox::getService('friend.list')->get(), 'bSearch' => $this->getParam('search'), 'bIsForShare' => $this->getParam('friend_share', false), 'sFriendItemId' => (int) $this->getParam('friend_item_id', '0'), 'sFriendModuleId' => $sFriendModuleId, 'sFriendType' => $this->getParam('type'))); ($sPlugin = Phpfox_Plugin::get('friend.component_block_search_process')) ? eval($sPlugin) : false; }
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')); }
/** * 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')); }
public function buildMenu() { // Add a hook with return here if (Phpfox::getParam('mail.show_core_mail_folders_item_count') && Phpfox::getUserParam('mail.show_core_mail_folders_item_count')) { $aCountFolders = Mail_Service_Mail::instance()->getDefaultFoldersCount(Phpfox::getUserId()); } $aFilterMenu = array(Phpfox::getPhrase('mail.inbox') . (isset($aCountFolders['iCountInbox']) ? ' (' . $aCountFolders['iCountInbox'] . ')' : '') => '', Phpfox::getPhrase('mail.sent_messages') . (isset($aCountFolders['iCountSentbox']) ? ' (' . $aCountFolders['iCountSentbox'] . ')' : '') => 'sent', (Phpfox::getParam('mail.threaded_mail_conversation') ? Phpfox::getPhrase('mail.archive') : Phpfox::getPhrase('mail.trash')) . (isset($aCountFolders['iCountDeleted']) ? ' (' . $aCountFolders['iCountDeleted'] . ')' : '') => 'trash'); if (!Phpfox::getParam('mail.threaded_mail_conversation')) { $aFilterMenu[] = true; $aFolders = Phpfox::getService('mail.folder')->get(); foreach ($aFolders as $aFolder) { $aFilterMenu[$aFolder['name']] = 'mail.view_box.id_' . $aFolder['folder_id']; } } if (Phpfox::getParam('mail.threaded_mail_conversation')) { $iLegacyCount = Mail_Service_Mail::instance()->getLegacyCount(); $aFilterMenu[] = true; $aFilterMenu[Phpfox::getPhrase('mail.legacy_inbox') . ' <span class="invited">' . $iLegacyCount . '</span>'] = 'mail.legacy_1'; } Phpfox_Template::instance()->buildSectionMenu('mail', $aFilterMenu); }
public function get() { /* @title @info Get all the messages of the user that is logged in. @method GET @extra @return id=#{Message ID#|int}&subject=#{Subject|string}&preview=#{Preview of the message|string}&from=#{From|string}&from_url=#{Profile link of the person who sent the message|string}&permalink=#{Link to the message|string}&new=#{Check to see if the message is read or not. <b>True</b> is a new message|bool} */ $iUserId = Phpfox::getUserId(); $aCond = array(); if (Phpfox::getParam('mail.threaded_mail_conversation')) { $aCond[] = 'AND m.viewer_user_id = ' . $iUserId . ' AND m.is_archive = 0'; } else { $aCond[] = 'AND m.viewer_folder_id = 0 AND m.viewer_user_id = ' . $iUserId . ' AND m.viewer_type_id = 0'; } $aMessages = array(); list($iTotal, $aMessageRows, $aTotals) = Mail_Service_Mail::instance()->get($aCond); foreach ($aMessageRows as $iKey => $aMessageRow) { $aMessages[$iKey] = array('id' => Phpfox::getParam('mail.threaded_mail_conversation') ? $aMessageRow['thread_id'] : $aMessageRow['mail_id'], 'subject' => Phpfox::getParam('mail.threaded_mail_conversation') ? '' : $aMessageRow['subject'], 'preview' => $aMessageRow['preview'], 'from' => $aMessageRow['full_name'], 'from_url' => Phpfox_Url::instance()->makeUrl($aMessageRow['user_name']), 'permalink' => Phpfox::getParam('mail.threaded_mail_conversation') ? Phpfox_Url::instance()->makeUrl('mail.thread', array('id' => $aMessageRow['thread_id'])) : Phpfox_Url::instance()->makeUrl('mail.view.' . $aMessageRow['mail_id']), 'new' => $aMessageRow['viewer_is_new'] ? true : false); if (Phpfox::getParam('mail.threaded_mail_conversation')) { unset($aMessages[$iKey]['subject']); } } return $aMessages; }