コード例 #1
0
ファイル: Account.php プロジェクト: ThorstenSuckow/conjoon
 /**
  * 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;
 }