/** * Returns the message for the specified items id. */ public function getEmailMessage($groupwareEmailItemsId, $userId) { $groupwareEmailItemsId = (int) $groupwareEmailItemsId; if ($groupwareEmailItemsId <= 0) { return 0; } $adapter = Conjoon_Db_Table::getDefaultAdapter(); $select = $adapter->select()->from(array('items' => Conjoon_Db_Table::getTablePrefix() . 'groupware_email_items'), array('id', 'cc', 'bcc', 'reply_to', 'to', 'subject', 'from', 'date', 'content_text_plain AS body', '(1) AS is_plain_text', 'groupware_email_folders_id'))->join(array('folders_users' => Conjoon_Db_Table::getTablePrefix() . 'groupware_email_folders_users'), '`folders_users`.`groupware_email_folders_id` = `items`.`groupware_email_folders_id` ' . ' AND ' . $adapter->quoteInto('`folders_users`.`users_id`=?', $userId, 'INTEGER') . ' AND ' . $adapter->quoteInto('`folders_users`.`relationship`=?', 'owner', 'STRING'), array())->joinLeft(array('flag' => Conjoon_Db_Table::getTablePrefix() . 'groupware_email_items_flags'), '`flag`.`groupware_email_items_id` = `items`.`id`' . ' AND ' . $adapter->quoteInto('`flag`.`user_id`=?', $userId, 'INTEGER'), array('is_spam'))->where('items.id=?', $groupwareEmailItemsId); $row = $adapter->fetchRow($select); if (!$row) { return null; } /** * @see Conjoon_Modules_Groupware_Email_Folder_Model_Folder */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Model/Folder.php'; $folderModel = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); // unique id. Underscore needed since this wil automatically get // camelized later on $row['u_id'] = $row['id']; $row['path'] = $folderModel->getPathForFolderId($row['groupware_email_folders_id']); return $row; }
/** * Returns all email accounts for the specified user-id. * Note, that the field 'user_id' won't be available in the returned * array. * * @param int $id The id of the user to get the email accounts for * * @return Zend_Db_Table_Rowset */ public function getAccountsForUser($id) { $id = (int) $id; if ($id <= 0) { return array(); } $rows = $this->fetchAll($this->select()->where('user_id=?', $id)->where('is_deleted=?', false)->order('is_standard DESC')); $rows = $rows->toArray(); $adapter = $this->getDefaultAdapter(); /** * @see Conjoon_Modules_Groupware_Email_Folder_Model_Folder */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Model/Folder.php'; $folderModel = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); foreach ($rows as &$row) { // add information related to the accounts root folder here $row['localRootMailFolder'] = array(); $rootId = $folderModel->getAccountsRootOrRootFolderId($row['id'], $id); if ($rootId) { $row['localRootMailFolder'] = $folderModel->getFolderBaseData($rootId); if ($row['localRootMailFolder']) { $row['localRootMailFolder'] = $row['localRootMailFolder']->toArray(); } } $mappings = $adapter->fetchAll($adapter->select()->from(array('mappings' => self::getTablePrefix() . 'groupware_email_imap_mapping'), array('id', 'type', 'globalName' => 'global_name'))->where('mappings.groupware_email_accounts_id=?', $row['id'])); $row['folderMappings'] = $mappings; } return $rows; }
/** * This action will update email accounts according to the POST params * that come along with the request. * Depending of the current context the action was called, the format of the * POST params will differ: For json, it will be an array holding json-encoded parameters. * Despite all different formats the POST params may come in, each request sends * values for 'updated' and 'deleted' accounts: 'deleted' as an array, holding all * ids that should become deleted, and 'updated' an array holding information about * the records that get edited, represented by specific associative array, representing * the fields of the record. * The view will await values assigned to 'updated_failed' and 'deleted_failed', whereas * 'deleted_failed' is an array containing all ids that couldn't be deleted, and * 'updated_failed' an array containing the records (in associative array notation) * that could not be updated. * * Note: If any error in the user-input was detected, no update-action will happen, but * deltes may already have been submitted to the underlying datastore. * The first error found in the passed data will be returned as an error of the type * Conjoon_Error_Form, containing the fields that where errorneous. * */ public function updateEmailAccountsAction() { require_once 'Conjoon/Modules/Groupware/Email/Account/Filter/Account.php'; require_once 'Conjoon/Util/Array.php'; require_once 'Conjoon/Modules/Groupware/Email/Account/Model/Account.php'; $toDelete = array(); $toUpdate = array(); $deletedFailed = array(); $updatedFailed = array(); $model = new Conjoon_Modules_Groupware_Email_Account_Model_Account(); $data = array(); $error = null; if ($this->_helper->conjoonContext()->getCurrentContext() == self::CONTEXT_JSON) { require_once 'Zend/Json.php'; $toDelete = Zend_Json::decode($_POST['deleted'], Zend_Json::TYPE_ARRAY); $toUpdate = Zend_Json::decode($_POST['updated'], Zend_Json::TYPE_ARRAY); } $numToUpdate = count($toUpdate); $numToDelete = count($toDelete); if ($numToUpdate != 0 || $numToDelete != 0) { /** * @see Conjoon_Builder_Factory */ require_once 'Conjoon/Builder/Factory.php'; Conjoon_Builder_Factory::getBuilder(Conjoon_Keys::CACHE_EMAIL_ACCOUNTS, Zend_Registry::get(Conjoon_Keys::REGISTRY_CONFIG_OBJECT)->toArray())->cleanCacheForTags(array('userId' => Zend_Registry::get(Conjoon_Keys::REGISTRY_AUTH_OBJECT)->getIdentity()->getId())); } $userId = $this->_helper->registryAccess()->getUserId(); for ($i = 0; $i < $numToDelete; $i++) { $affected = $model->deleteAccount($toDelete[$i], $userId); if ($affected == 0) { $deletedFailed[] = $toDelete[$i]; } } $folderMappingData = array(); for ($i = 0; $i < $numToUpdate; $i++) { $_ = $toUpdate[$i]; $folderMappingData[$toUpdate[$i]['id']] = $toUpdate[$i]['folderMappings']; $filter = new Conjoon_Modules_Groupware_Email_Account_Filter_Account($_, Conjoon_Filter_Input::CONTEXT_UPDATE); try { $data[$i] = $filter->getProcessedData(); Conjoon_Util_Array::underscoreKeys($data[$i]); } catch (Zend_Filter_Exception $e) { require_once 'Conjoon/Error.php'; $error = Conjoon_Error::fromFilter($filter, $e); $this->view->success = false; $this->view->updatedFailed = array($_['id']); $this->view->deletedFailed = $deletedFailed; $this->view->error = $error->getDto(); return; } } $createdLocalRootMailFolders = array(); $removedLocalRootMailFolders = array(); /** * @see Conjoon_BeanContext_Decorator */ require_once 'Conjoon/BeanContext/Decorator.php'; $decoratedFolderModel = new Conjoon_BeanContext_Decorator('Conjoon_Modules_Groupware_Email_Folder_Model_Folder', null, false); $decoratedAccountModel = new Conjoon_BeanContext_Decorator('Conjoon_Modules_Groupware_Email_Account_Model_Account'); /** * @see Conjoon_Modules_Groupware_Email_Folder_Model_Folder */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Model/Folder.php'; $folderModel = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); /** * @see Conjoon_Modules_Groupware_Email_Folder_Model_FoldersAccounts */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Model/FoldersAccounts.php'; $foldersAccounts = new Conjoon_Modules_Groupware_Email_Folder_Model_FoldersAccounts(); for ($i = 0, $len = count($data); $i < $len; $i++) { $id = $data[$i]['id']; unset($data[$i]['id']); // check here for duplicates $duplicates = $model->getAccountWithNameForUser($data[$i]['name'], $userId); $affected = 0; if (!empty($duplicates)) { for ($a = 0, $lena = count($duplicates); $a < $lena; $a++) { if ($duplicates[$a]['id'] != $id) { $affected = -1; break; } } } if ($affected != -1) { $affected = $model->updateAccount($id, $data[$i]); $entityManager = Zend_Registry::get(Conjoon_Keys::DOCTRINE_ENTITY_MANAGER); // update folderMappings if (isset($folderMappingData[$id])) { $fmRep = $entityManager->getRepository('\\Conjoon\\Data\\Entity\\Mail\\DefaultFolderMappingEntity'); for ($u = 0, $lenu = count($folderMappingData[$id]); $u < $lenu; $u++) { if (isset($folderMappingData[$id][$u]['id']) && empty($folderMappingData[$id][$u]['path'])) { $updEnt = $fmRep->findById($folderMappingData[$id][$u]['id']); $updEnt->setGlobalName(""); $fmRep->register($updEnt); } else { if (isset($folderMappingData[$id][$u]['id']) && !empty($folderMappingData[$id][$u]['path'])) { /** * @see \Conjoon\Data\Entity\Mail\DefaultFolderMappingEntity */ require_once 'Conjoon/Data/Entity/Mail/DefaultFolderMappingEntity.php'; /** * @see Conjoon_Modules_Groupware_Email_ImapHelper */ require_once 'Conjoon/Modules/Groupware/Email/ImapHelper.php'; $accDto = $decoratedAccountModel->getAccountAsDto($id, $userId); $delim = Conjoon_Modules_Groupware_Email_ImapHelper::getFolderDelimiterForImapAccount($accDto); $p = $folderMappingData[$id][$u]['path']; array_shift($p); array_shift($p); $globalName = implode($delim, $p); $updEnt = $fmRep->findById($folderMappingData[$id][$u]['id']); $updEnt->setGlobalName($globalName); $fmRep->register($updEnt); continue; } } } $fmRep->flush(); } // take care of folder heirarchies if ($affected != -1) { /** * @todo Facade */ $hasSeparateFolderHierarchy = array_key_exists('has_separate_folder_hierarchy', $data[$i]) ? (bool) (int) $data[$i]['has_separate_folder_hierarchy'] : null; // get org protocol of account so it cannot be changed from // the outside $orgAccount = $model->getAccount($id, $userId); $orgProtocol = $orgAccount['protocol']; if ($hasSeparateFolderHierarchy !== null && strtolower($orgProtocol) !== 'imap') { // the original folder ids, before remapping occures $oldAccountFolderIds = $foldersAccounts->getFolderIdsForAccountId($id); // read out folder base data of folder for associated account $rootFolderBaseData = $decoratedFolderModel->getAnyRootMailFolderBaseDataAsDto($id, $userId); if (!$rootFolderBaseData) { throw new RuntimeException("No root folder base data available."); } if (!$hasSeparateFolderHierarchy) { // do nothing if type is already accounts_root and // separateFolderHierarchy = false is submitted; // but if the type is root and the folderHierarchy // (i.e. "root) should be removed, // we need to switch from root to accounts_root if ($rootFolderBaseData->type == 'root') { // check first if accounts_root exist! $accountsRootFolderId = $folderModel->getAccountsRootMailFolderBaseData($userId); // accounts root not yet existing if (!$accountsRootFolderId) { $folderModel->createFolderBaseHierarchyAndMapAccountIdForUserId($id, $userId); } else { $newFolderIds = $folderModel->getFoldersForAccountsRoot($userId); // accounts root already existing. // remove the root and remap to accounts_root foreach ($oldAccountFolderIds as $oldFolderId) { $folderModel->deleteFolder($oldFolderId, $userId, false); } $removedLocalRootMailFolders[$id] = $rootFolderBaseData; $foldersAccounts->mapFolderIdsToAccountId($newFolderIds, $id); } $createdLocalRootMailFolders[$id] = $decoratedFolderModel->getAnyRootMailFolderBaseDataAsDto($id, $userId); } } else { // do nothing if the type is already root which means // there already exists a separate folder hierarchy // if the type is accounts_root, we need to switch // to a root hierarchy if ($rootFolderBaseData->type == 'accounts_root') { // remove old mappings $foldersAccounts->deleteForAccountId($id); $folderModel->createFolderHierarchyAndMapAccountIdForUserId($id, $userId, $data[$i]['name']); $createdLocalRootMailFolders[$id] = $decoratedFolderModel->getAnyRootMailFolderBaseDataAsDto($id, $userId); } } } } } if ($affected == -1) { $updatedFailed[] = $id; } } $this->view->success = empty($updatedFailed) ? true : false; $this->view->updatedFailed = $updatedFailed; $this->view->deletedFailed = $deletedFailed; $this->view->error = null; $this->view->createdLocalRootMailFolders = $createdLocalRootMailFolders; $this->view->removedLocalRootMailFolders = $removedLocalRootMailFolders; }
/** * Saves a sent email into the database. * * @param Conjoon_Modules_Groupware_Email_Draft $message * @param Conjoon_Modules_Groupware_Email_Account $account * @param integer $userId * @param Conjoon_Mail_Sent $mailSent * @param string $type * @param integer $referencesId The id of the email that was refernced sending this * message. This argument will only be taken into account if $type euqals to * reply or reply_all * @param array $postedAttachments * @param array $removeAttachmentIds * * @return array the data from groupware_email_item associated with * the newly saved entry */ public function saveSentEmail(Conjoon_Modules_Groupware_Email_Draft $message, Conjoon_Modules_Groupware_Email_Account $account, $userId, Conjoon_Mail_Sent $mailSent, $type = "", $referencesId = -1, $postedAttachments = array(), $removeAttachmentIds = array()) { $mail = $mailSent->getMailObject(); $userId = (int) $userId; $accountId = (int) $account->getId(); $messageId = (int) $message->getId(); $referenceId = $referencesId <= 0 ? 0 : $referencesId; if ($userId <= 0 || $accountId <= 0) { return array(); } $referencesModel = new Conjoon_Modules_Groupware_Email_Item_Model_References(); $emailRecipientsFilter = new Conjoon_Filter_EmailRecipients(); $emailRecipientsToStringFilter = new Conjoon_Filter_EmailRecipientsToString(); $outboxModel = new Conjoon_Modules_Groupware_Email_Item_Model_Outbox(); $folderModel = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); // first check the folder type of the email $folderId = $message->getGroupwareEmailFoldersId(); $messageType = 'scratch'; // negative/0, means the message was created from draft if ($folderId <= 0) { $messageType = 'scratch'; } else { // anything else needs the meta info type fetched out of the folder model $metaInfo = $folderModel->getMetaInfo($folderId); switch ($metaInfo) { case Conjoon_Modules_Groupware_Email_Folder_Model_Folder::META_INFO_OUTBOX: $messageType = 'outbox'; break; case Conjoon_Modules_Groupware_Email_Folder_Model_Folder::META_INFO_DRAFT: $messageType = 'draft'; break; // anything else is probably a reply or forward to an existing message in any other // folder // anything else is probably a reply or forward to an existing message in any other // folder default: $messageType = 'scratch'; break; } } // adjust the message type depending on the type if ($type == 'reply' || $type == 'reply_all' || $type == 'forward') { $messageType = 'scratch'; } // prefill update/insert arrays $sentFolderId = $folderModel->getSentFolder($accountId, $userId); $date = new Zend_Date($mail->getDate(), Zend_Date::RFC_2822); $replyTo = (string) $mail->getReplyTo(); $to = $message->getTo(); $cc = $message->getCc(); $bcc = $message->getBcc(); $fromAddress = new Conjoon_Modules_Groupware_Email_Address(array($account->getAddress(), $account->getUserName())); $toString = array(); foreach ($to as $recipient) { $toString[] = $recipient->__toString(); } $toString = implode(', ', $toString); $ccString = array(); foreach ($cc as $recipient) { $ccString[] = $recipient->__toString(); } $ccString = implode(', ', $ccString); $bccString = array(); foreach ($bcc as $recipient) { $bccString[] = $recipient->__toString(); } $bccString = implode(', ', $bccString); $outboxUpdate = array('sent_timestamp' => time(), 'raw_header' => $mailSent->getSentHeaderText(), 'raw_body' => $mailSent->getSentBodyText(), 'groupware_email_accounts_id' => $message->getGroupwareEmailAccountsId()); /** * @see Conjoon_Filter_DateToUtc */ require_once 'Conjoon/Filter/DateToUtc.php'; $filterToUtc = new Conjoon_Filter_DateToUtc(); $itemUpdate = array('reply_to' => $replyTo, 'from' => $fromAddress->__toString(), 'recipients' => $emailRecipientsToStringFilter->filter($emailRecipientsFilter->filter(array($toString, $ccString, $bccString))), 'sender' => $emailRecipientsToStringFilter->filter($emailRecipientsFilter->filter(array($fromAddress->__toString()))), 'groupware_email_folders_id' => $sentFolderId, 'date' => $filterToUtc->filter($date->get(Zend_Date::ISO_8601))); switch ($messageType) { // if the message was sent from an opened draft or from the outbox, // we simply can create a new entry in the tables, // as if it was created from scratch // if, however, the email was sent from drafts, a user might have updated // the addresses, the subject, the email text and the attachments. // those fields have to be updated in the datastorage as well case 'draft': Conjoon_Util_Array::apply($itemUpdate, array('subject' => $message->getSubject(), 'to' => $toString, 'cc' => $ccString, 'bcc' => $bccString, 'content_text_plain' => $message->getContentTextPlain(), 'content_text_html' => $message->getContentTextHtml())); $this->saveAttachmentsForDraft($message, $postedAttachments, $removeAttachmentIds); // most simple: mesageType is outbox which means we have simply to update a few fields // most simple: mesageType is outbox which means we have simply to update a few fields case 'outbox': if ($messageId <= 0 || $sentFolderId == 0) { return array(); } // the message might have referenced an item when it was created. // look up entry in reference table and set this to is_pending = false $referencesWhere = $referencesModel->getAdapter()->quoteInto('groupware_email_items_id = ?', $messageId) . ' AND ' . $referencesModel->getAdapter()->quoteInto('user_id = ?', $userId); $referencesModel->update(array('is_pending' => 0), $referencesWhere); $outboxWhere = $outboxModel->getAdapter()->quoteInto('groupware_email_items_id = ?', $messageId); $outboxModel->update($outboxUpdate, $outboxWhere); $itemWhere = $this->getAdapter()->quoteInto('id = ?', $messageId); $this->update($itemUpdate, $itemWhere); return $this->getItemForUser($messageId, $userId); break; // if the message was created from scratch, i.e. has no id and no folderId, // save a fresh row into the tables groupware_email_items_id, groupware_email_items_flags, // groupware_email_items_outbox // if the message was created from scratch, i.e. has no id and no folderId, // save a fresh row into the tables groupware_email_items_id, groupware_email_items_flags, // groupware_email_items_outbox case 'scratch': Conjoon_Util_Array::apply($itemUpdate, array('subject' => $message->getSubject(), 'to' => $toString, 'cc' => $ccString, 'bcc' => $bccString, 'in_reply_to' => $message->getInReplyTo(), 'references' => $message->getReferences(), 'content_text_plain' => $message->getContentTextPlain(), 'content_text_html' => $message->getContentTextHtml())); $messageId = (int) $this->insert($itemUpdate); if ($messageId <= 0) { return array(); } $flagModel = new Conjoon_Modules_Groupware_Email_Item_Model_Flag(); $referenceType = ''; if (($type == Conjoon_Modules_Groupware_Email_Keys::REFERENCE_TYPE_REPLY || $type == Conjoon_Modules_Groupware_Email_Keys::REFERENCE_TYPE_REPLY_ALL || $type == Conjoon_Modules_Groupware_Email_Keys::REFERENCE_TYPE_FORWARD) && $referenceId != 0) { $referenceType = $type; $referenceUpdate = array('groupware_email_items_id' => $messageId, 'user_id' => $userId, 'reference_items_id' => $referenceId, 'reference_type' => $referenceType); $referencesModel->insert($referenceUpdate); } $flagUpdate = array('groupware_email_items_id' => $messageId, 'user_id' => $userId, 'is_read' => 1, 'is_spam' => 0, 'is_deleted' => 0); $flagModel->insert($flagUpdate); Conjoon_Util_Array::apply($outboxUpdate, array('groupware_email_items_id' => $messageId)); $outboxModel->insert($outboxUpdate); $message->setId($messageId); $this->saveAttachmentsForDraft($message, $postedAttachments, $removeAttachmentIds); return $this->getItemForUser($messageId, $userId); break; } return null; }
/** * Returns the email items based on the passed POST-parameters to the client. * Possible POST parameters are: * * start - the index in the datastore from where to read the first record * limit - the number of records to return * dir - the sort direction, either ASC or DESC * sort - the field to sort. Fields are based upon the properties of the * Conjoon_Modules_Groupware_Email_ItemDto-class and have to be substituted * to their appropriate representatives in the underlying datamodel. * groupwareEmailFoldersId - the id of the folder, for which the items should be loaded. * if this parameter is missing, all emails from all accounts * will be fetched * minDate - this argument is optional - if passed, all emails with a fetched_timestamp * equal to or greater than minDate will be fetched * * * The assigned view variables are: * * items - an array with objects of Conjoon_Modules_Groupware_Email_ItemDto * totalCount - the total count of records available for the requested folder * for this user, or the total count of latest emails for the * user since minDate * version - the version property for Ext.ux.grid.BufferedStore * pendingItems - if a folder id other than 0 was supplied, the number of * pending items will be read out and assigned to this view-variable * */ public function getEmailItemsAction() { require_once 'Conjoon/Modules/Groupware/Email/Item/Filter/Request.php'; require_once 'Conjoon/Util/Array.php'; require_once 'Conjoon/Keys.php'; $auth = Zend_Registry::get(Conjoon_Keys::REGISTRY_AUTH_OBJECT); $userId = $auth->getIdentity()->getId(); $CONTEXT_REQUEST_LATEST = Conjoon_Modules_Groupware_Email_Item_Filter_Request::CONTEXT_REQUEST_LATEST; $CONTEXT_REQUEST = Conjoon_Modules_Groupware_Email_Item_Filter_Request::CONTEXT_REQUEST; if (isset($_POST['minDate']) && !isset($_POST['groupwareEmailFoldersId'])) { $context = $CONTEXT_REQUEST_LATEST; } else { $context = $CONTEXT_REQUEST; } $itemRequestFilter = new Conjoon_Modules_Groupware_Email_Item_Filter_Request($_POST, $context); try { $filteredData = $itemRequestFilter->getProcessedData(); } catch (Zend_Filter_Exception $e) { $this->view->success = true; $this->view->error = null; $this->view->items = array(); $this->view->version = 1; $this->view->totalCount = 0; return; } $sortInfo = array('sort' => $filteredData['sort'], 'dir' => $filteredData['dir'], 'limit' => $filteredData['limit'], 'start' => $filteredData['start']); require_once 'Conjoon/BeanContext/Decorator.php'; require_once 'Conjoon/Modules/Groupware/Email/Item/Filter/ItemResponse.php'; $itemResponseFilter = new Conjoon_Modules_Groupware_Email_Item_Filter_ItemResponse(array(), Conjoon_Filter_Input::CONTEXT_RESPONSE); $pendingItems = -1; if ($context == $CONTEXT_REQUEST) { // check if folder is remote folder /** * @see Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser */ require_once 'Conjoon/Text/Parser/Mail/MailboxFolderPathJsonParser.php'; $parser = new Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser(); $pathInfo = $parser->parse($filteredData['path']); /** * @see Conjoon_Modules_Groupware_Email_Folder_Facade */ require_once 'Conjoon/Modules/Groupware/Email/Folder/Facade.php'; $facade = Conjoon_Modules_Groupware_Email_Folder_Facade::getInstance(); if ($facade->isRemoteFolder((int) $pathInfo['rootId'])) { /** * @see Conjoon_Modules_Groupware_Email_Item_ItemListRequestFacade */ require_once 'Conjoon/Modules/Groupware/Email/Item/ItemListRequestFacade.php'; $listFacade = Conjoon_Modules_Groupware_Email_Item_ItemListRequestFacade::getInstance(); $itemData = $listFacade->getEmailItemList($pathInfo, $userId, $sortInfo, true); $this->view->success = true; $this->view->error = null; $this->view->items = $itemData['items']; $this->view->version = 1; $this->view->totalCount = $itemData['totalCount']; $this->view->pendingItems = $itemData['pendingItems']; return; } // get the number of emails currently available for this folder // and this user require_once 'Conjoon/Modules/Groupware/Email/Item/Model/Item.php'; require_once 'Conjoon/Modules/Groupware/Email/Folder/Model/Folder.php'; $folderModel = new Conjoon_Modules_Groupware_Email_Folder_Model_Folder(); $itemModel = new Conjoon_Modules_Groupware_Email_Item_Model_Item(); $totalCount = $folderModel->getItemCountForFolderAndUser($filteredData['groupwareEmailFoldersId'], $userId); if ($totalCount == 0) { $this->view->success = true; $this->view->error = null; $this->view->items = array(); $this->view->version = 1; $this->view->totalCount = 0; $this->view->pendingItems = 0; return; } $decoratedModel = new Conjoon_BeanContext_Decorator($itemModel, $itemResponseFilter); $rows = $decoratedModel->getEmailItemsForAsDto($userId, $filteredData['groupwareEmailFoldersId'], $sortInfo); $pendingItems = $folderModel->getPendingCountForFolderAndUser($filteredData['groupwareEmailFoldersId'], $userId); } else { if ($context == $CONTEXT_REQUEST_LATEST) { require_once 'Conjoon/BeanContext/Decorator.php'; require_once 'Conjoon/Modules/Groupware/Email/Item/Filter/ItemResponse.php'; require_once 'Conjoon/Modules/Groupware/Email/Item/Model/Inbox.php'; $itemInboxModel = new Conjoon_Modules_Groupware_Email_Item_Model_Inbox(); $totalCount = $itemInboxModel->getLatestItemCount($userId, $filteredData['minDate']); if ($totalCount == 0) { $this->view->success = true; $this->view->error = null; $this->view->items = array(); $this->view->version = 1; $this->view->totalCount = 0; return; } $decoratedModel = new Conjoon_BeanContext_Decorator($itemInboxModel, $itemResponseFilter); $rows = $decoratedModel->getLatestEmailItemsForAsDto($userId, $filteredData['minDate'], $sortInfo); } } $this->view->success = true; $this->view->error = null; $this->view->items = $rows; $this->view->pendingItems = $pendingItems; $this->view->version = 1; $this->view->totalCount = $totalCount; }