Esempio n. 1
0
 /**
  * Transforms an array of exceptions to an array that can be easily handled
  * by the frontend.
  * The following keys are available:
  *
  * success: always set to false
  * error  : either an array of Conjoon_ErrorDto's, or a single object of the
  *          type Conjoon_ErrorDto
  *
  * @param Array $exceptions
  *
  * @return Array
  */
 public static function transformExceptions(array $exceptions = array())
 {
     /**
      * @see Conjoon_Error
      */
     require_once 'Conjoon/Error.php';
     $exList = array();
     if (count($exceptions) > 1) {
         for ($i = 0, $len = count($exceptions); $i < $len; $i++) {
             $ex = Conjoon_Error::fromException($exceptions[$i]);
             $exList[] = $ex->getDto();
         }
     } else {
         $exception = Conjoon_Error::fromException($exceptions[0]);
         $exList = $exception->getDto();
     }
     return array('success' => false, 'error' => $exList);
 }
 /**
  * Renames the folder with the specified it to the specified value.
  * Post vars:
  * id       : the id of the folder that gets renamed
  * name     : the new name of the node
  * parentId : the id of the current parent folder
  * path     : the path of this node in the tree. This is relevant for
  * IMAP mailboxes which get renamed
  */
 public function renameFolderAction()
 {
     /**
      * @see Conjoon_Modules_Groupware_Email_Folder_Facade
      */
     require_once 'Conjoon/Modules/Groupware/Email/Folder/Facade.php';
     $facade = Conjoon_Modules_Groupware_Email_Folder_Facade::getInstance();
     /**
      * @see Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser
      */
     require_once 'Conjoon/Text/Parser/Mail/MailboxFolderPathJsonParser.php';
     $parser = new Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser();
     try {
         $pathParts = $parser->parse($this->_request->getParam('path'));
     } catch (Conjoon_Text_Parser_Exception $e) {
         /**
          * @see Conjoon_Error
          */
         require_once 'Conjoon/Error.php';
         $error = Conjoon_Error::fromException($e);
         $this->view->success = false;
         $this->view->error = $error->getDto();
         return;
     }
     $name = $this->_request->getParam('name');
     $userId = $this->_helper->registryAccess->getUserId();
     try {
         $folder = $facade->renameFolderForPathAndUserId($name, $pathParts, $userId);
         if ($folder === false) {
             /**
              * @see Conjoon_Error_Factory
              */
             require_once 'Conjoon/Error/Factory.php';
             $error = Conjoon_Error_Factory::createError("Could not rename the specified folder.", Conjoon_Error::LEVEL_WARNING)->getDto();
             $this->view->success = false;
             $this->view->error = $error;
             return;
         }
     } catch (Exception $e) {
         /**
          * @see Conjoon_Error
          */
         require_once 'Conjoon/Error.php';
         $this->view->success = true;
         $this->view->error = Conjoon_Error::fromException($e)->getDto();
         return;
     }
     $this->view->success = true;
     $this->view->error = null;
     $this->view->folder = $folder;
 }