/**
  * Creates a new instance of this class.
  *
  * @param \Conjoon\Mail\Client\Account\AccountService $accountService
  * @param boolean $replyAll whether the patrong shpuld prepare the message
  *                to reply to all recipients
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(\Conjoon\Mail\Client\Account\AccountService $accountService, $replyAll = false)
 {
     $data = array('replyAll' => $replyAll);
     ArgumentCheck::check(array('replyAll' => array('type' => 'boolean', 'allowEmpty' => false)), $data);
     $this->replyAll = $data['replyAll'];
     $this->accountService = $accountService;
 }
 /**
  * Creates a new instance of this class.
  *
  * @param string $header
  * @param string $body
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct($header, $body)
 {
     $data = array('header' => $header, 'body' => $body);
     ArgumentCheck::check(array('header' => array('type' => 'string', 'allowEmpty' => false), 'body' => array('type' => 'string', 'allowEmpty' => true)), $data);
     $this->header = $data['header'];
     $this->body = $data['body'];
 }
 /**
  * Creates a new instance of DefaultAccountBasicService.
  *
  * @param Array $options an array with the following key/value-pairs:
  *
  */
 public function __construct(array $options)
 {
     $data = array('options' => $options);
     ArgumentCheck::check(array('options' => array('type' => 'array', 'allowEmpty' => false)), $data);
     ArgumentCheck::check(array('mailAccountRepository' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Data\\Repository\\Mail\\MailAccountRepository')), $options);
     $this->mailAccountRepository = $options['mailAccountRepository'];
 }
 /**
  * @inheritdoc
  */
 public function __construct($options)
 {
     /**
      * @see \Conjoon\Argument\ArgumentCheck
      */
     require_once 'Conjoon/Argument/ArgumentCheck.php';
     $data = array('path' => $options);
     ArgumentCheck::check(array('path' => array('type' => 'string', 'allowEmpty' => false)), $data);
     $options = $data['path'];
     /**
      * @see Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser
      */
     require_once 'Conjoon/Text/Parser/Mail/MailboxFolderPathJsonParser.php';
     $parser = new \Conjoon_Text_Parser_Mail_MailboxFolderPathJsonParser();
     try {
         $parts = $parser->parse($options);
     } catch (Conjoon_Text_Parserexception $e) {
         /**
          * @see \Conjoon\Mail\Client\Folder\FolderPathException
          */
         require_once 'Conjoon/Mail/Client/Folder/FolderPathException.php';
         throw new FolderPathException("Could not extract path info from \"{$options}\" - exception " . "triggered by previous exception", 0, $e);
     }
     $this->_path = $parts['path'];
     $this->_nodeId = $parts['nodeId'];
     $this->_rootId = $parts['rootId'];
 }
 /**
  * @inherit Conjoon_Text_Transformer::transform
  */
 public function transform($input)
 {
     $data = array('input' => $input);
     ArgumentCheck::check(array('input' => array('type' => 'string', 'allowEmpty' => true, 'strict' => true)), $data);
     $value = $data['input'];
     return preg_replace('/\\s+/', ' ', $value);
 }
 /**
  * Creates a new instance of this security service.
  *
  * @param Array $options an array of options with the following
  *              key/value-pairs:
  *              - user: The user bound to this service. An instance of
  *                \Conjoon\User\User
  *              - accountBasicService: The
  *                \Conjoon\Mail\Client\Account\AccountBasicService
  *                this service uses.
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(array $options)
 {
     $data = array('options' => $options);
     ArgumentCheck::check(array('options' => array('type' => 'array', 'allowEmpty' => false)), $data);
     ArgumentCheck::check(array('user' => array('type' => 'instanceof', 'class' => 'Conjoon\\User\\User'), 'accountBasicService' => array('type' => 'instanceof', 'class' => 'Conjoon\\Mail\\Client\\Account\\AccountBasicService')), $options);
     $this->accountBasicService = $options['accountBasicService'];
     $this->user = $options['user'];
 }
 /**
  * Creates a new instance of this class.
  *
  * @param \Conjoon\Mail\Client\Folder\Folder $folder
  * @param mixed $id
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(\Conjoon\Mail\Client\Folder\Folder $folder, $id)
 {
     $data = array('id' => $id);
     ArgumentCheck::check(array('id' => array('type' => 'string', 'allowEmpty' => false)), $data);
     $id = $data['id'];
     $this->id = $id;
     $this->folder = $folder;
 }
 /**
  * Creates a new instance of this class.
  *
  * @param \Conjoon\Mail\Client\Message\MessageLocation $messageLocation
  * @param mixed $id
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(MessageLocation $messageLocation, $id)
 {
     $data = array('id' => $id);
     ArgumentCheck::check(array('id' => array('type' => 'string', 'allowEmpty' => false)), $data);
     $id = $data['id'];
     $this->id = $id;
     $this->messageLocation = $messageLocation;
 }
 /**
  * Returns an entity identified by the passed $id. The $id
  * in this case must be of type \Conjoon\Mail\Client\Message\MessageLocation
  * representing the location of the message or the raw id of the data
  * as managed by teh udnerlying data storage..
  *
  * @param \Conjoon\Mail\Client\Message\MessageLocation $id
  *
  * @return \Conjoon\Data\Entity\DataEntity
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function findById($id)
 {
     if (is_object($id)) {
         $data = array('messageLocation' => $id);
         ArgumentCheck::check(array('messageLocation' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Message\\MessageLocation')), $data);
         $id = $id->getUId();
     }
     return parent::findById($id);
 }
Example #10
0
 /**
  * Returns the connection object for this repository.
  * Clients must specify a mail account object with the options, holding the
  * connection information and user credentials for the remote repository.
  *
  * @param array $options an array An array containing configuration information
  *              for the connection which should be established
  *              - mailAccount: an instance of
  *              \Conjoon\Data\Entity\Mail\MailAccountEntity
  *
  * @return \Conjoon\Data\Repository\Remote\RemoteConnection
  *
  * @throws \Conjoon\Argument\InvalidArgumentException if the mail account
  * object was not specified, or if the account was invalid configured
  */
 public function getConnection(array $options = array())
 {
     ArgumentCheck::check(array('mailAccount' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Data\\Entity\\Mail\\MailAccountEntity')), $options);
     $mailAccount = $options['mailAccount'];
     if (!$mailAccount->getId()) {
         throw new InvalidArgumentException("The specified mail account does not contain a valid id");
     }
     return $this->getConnectionFromPoolForAccount($mailAccount);
 }
 /**
  * @inherit Conjoon_Text_Parser::parse
  */
 public function parse($input)
 {
     $data = array('message' => $input);
     ArgumentCheck::check(array('message' => array('allowEmpty' => false, 'type' => 'string')), $data);
     $message = $data['message'];
     if (strpos((string) $input, "\n\n") === false) {
         throw new InvalidArgumentException("Malformed message. Could not find splitter.");
     }
     $parts = explode("\n\n", $message, 2);
     if (count($parts) != 2) {
         return array('contentTextPlain' => '', 'contentTextHtml' => '');
     }
     $this->_setIconvEncoding(self::ICONV_UTF_8);
     $emailItem = array();
     $message = new \Conjoon_Mail_Message(array('headers' => $parts[0], 'noToplines' => true, 'content' => $parts[1]));
     $encodingInformation = $this->_getEncodingInformation($message);
     $contentType = $encodingInformation['contentType'];
     try {
         switch ($contentType) {
             case 'text/plain':
                 $emailItem['contentTextPlain'] = $this->_decode($message->getContent(), $encodingInformation);
                 break;
             case 'text/html':
                 $emailItem['contentTextHtml'] = $this->_decode($message->getContent(), $encodingInformation);
                 break;
             case 'multipart/mixed':
                 $this->_parseMultipartMixed($message, $emailItem);
                 break;
             case 'multipart/alternative':
                 $this->_parseMultipartAlternative($message, $emailItem);
                 break;
             case 'multipart/related':
                 $this->_parseMultipartRelated($message, $emailItem);
                 break;
             case 'multipart/signed':
                 $this->_parseMultipartSigned($message, $emailItem);
                 break;
             case 'multipart/report':
                 $this->_parseMultipartReport($message, $emailItem);
                 break;
             default:
                 $emailItem['contentTextPlain'] = $this->_decode($message->getContent(), $encodingInformation);
                 break;
         }
     } catch (\Exception $e) {
         throw new \Conjoon_Text_Parser_Exception("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     if (!isset($emailItem['contentTextPlain'])) {
         $emailItem['contentTextPlain'] = '';
     }
     if (!isset($emailItem['contentTextHtml'])) {
         $emailItem['contentTextHtml'] = '';
     }
     $this->_setIconvEncoding(self::ICONV_OLD);
     return $emailItem;
 }
 /**
  * @inheritdoc
  */
 public function getValueFor($key, array $data)
 {
     $keydata = array('key' => $key);
     ArgumentCheck::check(array('key' => array('type' => 'string', 'allowEmpty' => false)), $keydata);
     $key = $keydata['key'];
     if (!array_key_exists($key, $data)) {
         throw new MissingKeyException("key \"{$key}\" does not exist in data");
     }
     return $data[$key];
 }
Example #13
0
 /**
  * - user: Conjoon_User_User
  *
  * @param Array $options An array with options this request should be
  *                       configured with:
  *                       - user: \Conjoon\User\User
  *
  * @throws Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(array $options)
 {
     $data = array('options' => $options);
     ArgumentCheck::check(array('options' => array('type' => 'array', 'allowEmpty' => false)), $data);
     ArgumentCheck::check(array('user' => array('type' => 'instanceof', 'class' => '\\Conjoon\\User\\User')), $options);
     if (isset($options['parameters'])) {
         if (!is_array($options['parameters'])) {
             throw new InvalidArgumentException("\"parameters\" must be of type array");
         }
         $this->parameters = $options['parameters'];
     }
     $this->user = $options['user'];
 }
 /**
  * @inheritdoc
  */
 public function generateKey($data)
 {
     ArgumentCheck::check(array('userId' => array('type' => 'int', 'greaterThan' => 0, 'allowEmpty' => false), 'messageId' => array('type' => 'string', 'greaterThan' => 0, 'allowEmpty' => false), 'path' => array('type' => 'string', 'strict' => true, 'allowEmpty' => false), 'format' => array('type' => 'string', 'strict' => true, 'allowEmpty' => false), 'externalResources' => array('type' => 'bool', 'allowEmpty' => false)), $data);
     $path = json_decode($data['path']);
     if ($path === null || !is_array($path)) {
         throw new \Conjoon\Argument\InvalidArgumentException("\"path\" does not seem to be a valid json encoded path");
     }
     $strPath = implode('_', $path);
     if (preg_match('~^[a-zA-Z0-9_]+$~D', $strPath) === 0) {
         $strPath = md5($strPath);
     }
     $arrStr = array($data['userId'], $data['messageId'], $strPath, $data['format'], (string) (int) $data['externalResources']);
     return new \Conjoon\Mail\Client\Service\ServiceResult\Cache\GetMessageCacheKey(implode('_', $arrStr));
 }
 /**
  * Tries to load the class specified in $className.
  *
  * @param string $className
  *
  * @return boolean
  *
  * @throws \Conjoon\Io\FileNotFoundException
  * @throws \Conjoon\Lang\ClassNotFoundException
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function loadClass($className)
 {
     $data = array('className' => $className);
     ArgumentCheck::check(array('className' => array('type' => 'string', 'allowEmpty' => false)), $data);
     $className = $data['className'];
     if (!class_exists($className, false)) {
         $fileName = str_replace('\\', '/', ltrim($className, '\\')) . '.php';
         $res = @(include_once $fileName);
         if ($res === false) {
             throw new FileNotFoundException("Could not find file \"{$fileName}\" for class \"{$className}\"");
         }
         if (!class_exists($className, false)) {
             throw new ClassNotFoundException("Could not find class \"{$className}\" in \"{$fileName}\"");
         }
     }
     return true;
 }
 /**
  * Override so the composite key containing the messageId and the
  * userId can be passed.
  *
  * @param array $id An assoc array containing the uId and the userId
  * of the flag to query.
  *
  */
 public function findById($id)
 {
     $data = array('id' => $id);
     ArgumentCheck::check(array('id' => array('type' => 'array', 'allowEmpty' => false, 'inArray' => array('uId', 'userId'))), $data);
     $id = $data['id'];
     ArgumentCheck::check(array('uId' => array('type' => 'int', 'allowEmpty' => false, 'greaterThan' => 0), 'userId' => array('type' => 'int', 'allowEmpty' => false, 'greaterThan' => 0)), $id);
     $uId = $id['uId'];
     $userId = $id['userId'];
     $entity = $this->find(array('groupwareEmailItems' => $uId, 'users' => $userId));
     if ($entity === null) {
         return null;
     }
     $className = static::getEntityClassName();
     if (!$entity instanceof $className) {
         throw new InvalidArgumentException("entity must be of type {$className}");
     }
     return $entity;
 }
 /**
  * Returns an entity identified by the passed $id. The $id
  * in this case must be of type \Conjoon\Mail\Client\Message\AttachmentLocation
  * representing the location of the attachment OR the raw id of the data
  * as managed by the underlying data storage.
  *
  * @param {mixed} $id
  *
  * @return \Conjoon\Data\Entity\DataEntity
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function findById($id)
 {
     if (is_object($id)) {
         $data = array('attachmentLocation' => $id);
         ArgumentCheck::check(array('attachmentLocation' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Message\\AttachmentLocation')), $data);
         $attachmentLocation = $data['attachmentLocation'];
         $key = $attachmentLocation->getIdentifier();
         $messageLocation = $attachmentLocation->getMessageLocation();
         $messageUid = $messageLocation->getUid();
         $query = $this->getEntityManager()->createQuery("SELECT a from Conjoon\\Data\\Entity\\Mail\\DefaultAttachmentEntity a " . "WHERE a.key = :key and a.message = :messageUid");
         $query->setParameter('key', $key);
         $query->setParameter('messageUid', $messageUid);
         try {
             return $query->getSingleResult();
         } catch (\Doctrine\ORM\NoResultException $e) {
             return null;
         }
     }
     return parent::findById($id);
 }
Example #18
0
 /**
  * @inheritdoc
  */
 public function __construct($options)
 {
     /**
      * @see \Conjoon\Argument\Check
      */
     require_once 'Conjoon/Argument/ArgumentCheck.php';
     $data = array('user' => $options);
     ArgumentCheck::check(array('user' => array('type' => 'instanceof', 'class' => 'Conjoon_Modules_Default_User')), $data);
     $options = $data['user'];
     if ($options->getId() == "" || $options->getFirstName() == "" || $options->getLastName() == "" || $options->getUsername() == "" || $options->getEmailAddress() == "") {
         /**
          * @see Conjoon\User\UserException
          */
         require_once 'Conjoon/User/UserException.php';
         throw new UserException("Cannot use instance of Conjoon_Modules_Default_User - " . "object data is not valid");
     }
     $this->_id = (string) $options->getId();
     $this->_firstName = (string) $options->getFirstName();
     $this->_lastName = (string) $options->getLastName();
     $this->_userName = (string) $options->getUsername();
     $this->_emailAddress = (string) $options->getEmailAddress();
 }
 /**
  * @inheritdoc
  */
 public function applyMailAccountsToFolder(array $mailAccounts, \Conjoon\Mail\Client\Folder\Folder $targetFolder)
 {
     $data = array('accounts' => $mailAccounts, 'folder' => $targetFolder);
     $config = array('accounts' => array('type' => 'arrayType', 'minLength' => 1, 'allowEmpty' => false, 'class' => '\\Conjoon\\Data\\Entity\\Mail\\MailAccountEntity'), 'folder' => array(array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Folder\\Folder')));
     ArgumentCheck::check($config, $data);
     try {
         $isAccessible = $this->folderSecurityService->isFolderHierarchyAccessible($targetFolder);
     } catch (\Conjoon\Mail\Client\Security\FolderSecurityServiceException $e) {
         throw new FolderServiceException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     if (!$isAccessible) {
         throw new \Conjoon\Mail\Client\Security\FolderAccessException("Folder {$targetFolder} is not accessible by the user.");
     }
     return $this->mailFolderCommons->applyMailAccountsToFolder($mailAccounts, $targetFolder);
 }
 /**
  * @inheritdoc
  */
 public function getMessage($uId)
 {
     $this->throwExceptionIfNotConnected();
     $data = array('uId' => $uId);
     ArgumentCheck::check(array('uId' => array('type' => 'string', 'allowEmpty' => false)), $data);
     $uId = $data['uId'];
     return $this->_getMessage($uId);
 }
 /**
  * Creates a new instance of this class.
  *
  * @param \Conjoon\Data\Entity\Mail\DefaultMailAccountEntity $account
  * @param array $options An array of configuration options, optional,
  *              with the following key/value pairs:
  *              - classLoader: an instance of \Conjoon\Lang\ClassLoader. If
  *                omitted, Conjoon\Lang\DefaultClassLoader will be used.
  *              - imapConnectionClassName: the name of the class to use
  *                for the imap repository connection, must inherit from
  *                \Conjoon\Data\Repository\Remote\ImapConnection
  *              - imapAdapteeClassName: the adaptee to use for the
  *                imapConnection, must inherit from
  *                \Conjoon\Data\Repository\Remote\ImapAdaptee
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  * @throws \Conjoon\Data\Repository\Mail\MailRepositoryException
  */
 public function __construct(\Conjoon\Data\Entity\Mail\DefaultMailAccountEntity $account, array $options = array())
 {
     $this->account = $account;
     if (!empty($options)) {
         ArgumentCheck::check(array('classLoader' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Lang\\ClassLoader', 'allowEmpty' => false, 'mandatory' => false), 'imapConnectionClassName' => array('type' => 'string', 'allowEmpty' => false, 'mandatory' => false), 'imapAdapteeClassName' => array('type' => 'string', 'allowEmpty' => false, 'mandatory' => false)), $options);
     }
     if (isset($options['classLoader'])) {
         $this->classLoader = $options['classLoader'];
     } else {
         /**
          * @see \Conjoon\Lang\DefaultClassLoader
          */
         require_once 'Conjoon/Lang/DefaultClassLoader.php';
         $this->classLoader = new \Conjoon\Lang\DefaultClassLoader();
     }
     try {
         if (isset($options['imapConnectionClassName'])) {
             $this->imapConnectionClassName = $options['imapConnectionClassName'];
             $this->classLoader->loadClass($this->imapConnectionClassName);
         }
         if (isset($options['imapAdapteeClassName'])) {
             $this->imapAdapteeClassName = $options['imapAdapteeClassName'];
             $this->classLoader->loadClass($this->imapAdapteeClassName);
         }
     } catch (\Exception $e) {
         throw new MailRepositoryException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
 }
 /**
  * The message text to transform can be found in $data['message']['contentTextHtml'].
  * If the message text cannot be found, the key 'contentTextPlain' will be looked up,
  * and any content found therein used as the mail message text.
  *
  * @inheritdoc
  */
 public function execute(array $data)
 {
     try {
         ArgumentCheck::check(array('message' => array('type' => 'array', 'allowEmpty' => false)), $data);
         ArgumentCheck::check(array('contentTextHtml' => array('type' => 'string', 'allowEmpty' => true)), $data['message']);
         $text = $data['message']['contentTextHtml'];
         if ($text == "") {
             if (isset($data['message']['contentTextPlain'])) {
                 return $this->plainReadableStrategy->execute($data);
             } else {
                 return new ReadableStrategyResult("", false, false);
             }
         }
         $parseResult = $this->externalResourcesParser->parse($text);
         $parseData = $parseResult->getData();
         return new ReadableStrategyResult($this->htmlPurifier->purify($text), $parseData['externalResources'], $this->areExternalResourcesAllowed());
     } catch (\Exception $e) {
         /**
          * @see \Conjoon\Mail\Client\Message\Strategy\StrategyException;
          */
         require_once 'Conjoon/Mail/Client/Message/Strategy/StrategyException.php';
         throw new StrategyException("Exception thrown by previous exception", 0, $e);
     }
 }
 /**
  * @inheritdoc
  */
 public function moveFolderTo($sourceFolder, $targetFolder, $newSourceName = null)
 {
     $data = array('sourceFolder' => $sourceFolder, 'targetFolder' => $targetFolder, 'newSourceName' => $newSourceName);
     $config = array('newSourceName' => array('type' => 'string', 'allowEmpty' => true, 'strict' => true));
     ArrayUtil::apply($config, $this->getFolderHybridCheckConfiguration('sourceFolder'));
     ArrayUtil::apply($config, $this->getFolderHybridCheckConfiguration('targetFolder'));
     ArgumentCheck::check($config, $data);
     $sourceFolderEntity = null;
     $targetFolderEntity = null;
     $newSourceName = $data['newSourceName'];
     if (!$this->doesFolderAllowChildFolders($targetFolder)) {
         throw new NoChildFoldersAllowedException("Folder {$targetFolder} does not allow child folders.");
     }
     $targetFolderEntity = $this->makeFolderEntity($targetFolder);
     $sourceFolderEntity = $this->makeFolderEntity($sourceFolder);
     if (!$this->isMetaInfoInFolderHierarchyUnique($sourceFolderEntity, $targetFolderEntity->getMetaInfo())) {
         throw new FolderMetaInfoMismatchException("Source {$sourceFolder} and target {$targetFolder} do not share the " . "same Meta Info");
     }
     $tmpArr = $targetFolderEntity->getMailAccounts();
     $targetMailAccounts = array();
     foreach ($tmpArr as $targetAccount) {
         $targetMailAccounts[] = $targetAccount;
     }
     try {
         $this->folderRepository->register($sourceFolderEntity);
     } catch (\Exception $e) {
         throw new FolderServiceException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     if ($newSourceName !== null) {
         $sourceFolderEntity->setName($newSourceName);
     }
     $sourceFolderEntity->setParent($targetFolderEntity);
     $this->removeMailAccountsFromFolder($sourceFolderEntity);
     $this->applyMailAccountsToFolder($targetMailAccounts, $sourceFolderEntity);
     $this->applyTypeToFolder(self::FOLDERTYPE_FOLDER, $sourceFolderEntity, true);
     try {
         $this->folderRepository->flush();
     } catch (\Exception $e) {
         throw new FolderServiceException("Exception thrown by previous exception: " . $e->getMessage(), 0, $e);
     }
     return $sourceFolderEntity;
 }
 /**
  * @inherit Conjoon_Text_Transformer::transform
  */
 public function transform($input)
 {
     $data = array('input' => $input);
     ArgumentCheck::check(array('input' => array('type' => 'string', 'allowEmpty' => true, 'strict' => true)), $data);
     $value = $data['input'];
     // first off, add an extra whitespace char to every ">" that appears
     // at the beginning of a line, so they are not accidently identified as
     // as quotes. We will also check if the > appears after a closing tag, in this case we
     // will also add an extra whitespace.
     // This also applies to text that starts with a >
     $index = strpos($value, ">");
     if ($index === 0) {
         $value = " " . $value;
     }
     // normalize blockquote
     $value = preg_replace("/(<\\/?)(blockquote)[^>]*>/i", "\$1blockquote>", $value);
     // some browsers (IE) add linefeeds in between tags... remove them
     $value = str_replace(array("<blockquote>\n<blockquote>", "</blockquote>\n</blockquote>"), array("<blockquote><blockquote>", "</blockquote></blockquote>"), $value);
     $lines = explode("\n", $value);
     $quotes = array();
     $final = array();
     for ($nr = 0, $len = count($lines); $nr < $len; $nr++) {
         $line = $lines[$nr];
         if (trim($line) == "") {
             $final[] = implode("", $quotes) . $line;
             continue;
         } else {
             if (trim($line) == "<blockquote>") {
                 $quotes[] = '&gt;';
                 $final[] = implode("", $quotes) . preg_replace("/(<\\/?)(blockquote)[^>]*>/i", "", $line);
                 continue;
             } else {
                 if (trim($line) == "</blockquote>") {
                     $final[] = implode("", $quotes) . preg_replace("/(<\\/?)(blockquote)[^>]*>/i", "", $line);
                     array_pop($quotes);
                     continue;
                 }
             }
         }
         $vLine = str_replace(array('<blockquote>', '</blockquote>'), array("\n<blockquote>\n", "\n</blockquote>\n"), $line);
         $vLines = explode("\n", $vLine);
         for ($a = 0, $lena = count($vLines); $a < $lena; $a++) {
             $tline = $vLines[$a];
             if ($tline == '<blockquote>') {
                 $quotes[] = '&gt;';
             } else {
                 if ($tline == '</blockquote>') {
                     array_pop($quotes);
                 } else {
                     if ($tline == "") {
                         continue;
                     } else {
                         $newL = implode("", $quotes);
                         $final[] = ($newL ? $newL . ' ' : '') . ltrim($tline, ' ');
                     }
                 }
             }
         }
     }
     return implode("\n", $final);
 }
 /**
  * Creates a new instance of this result object.
  *
  * @param bool $externalResourcesAvailable true to indicate that the parser
  * found external resources, otherwise false.
  *
  * @throws \Conjoon\Argument\InvalidArgumentException if passed argument is not of
  * type bool
  */
 public function __construct($externalResourcesAvailable)
 {
     $data = array('externalResourcesAvailable' => $externalResourcesAvailable);
     ArgumentCheck::check(array('externalResourcesAvailable' => array('type' => 'bool', 'allowEmpty' => false)), $data);
     $this->externalResourcesAvailable = $data['externalResourcesAvailable'];
 }
 /**
  * Creates a new instance of this class.
  *
  * @param string $value
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct($value)
 {
     $args = array('value' => $value);
     ArgumentCheck::check(array('value' => array('type' => 'string', 'allowEmpty' => false, 'strict' => true)), $args);
     $this->value = $args['value'];
 }
 /**
  * Expects the following key/value-pairs in $data:
  * - name string The name to test against
  * - list array The list of values to test name against
  *
  * @inheritdoc
  */
 public function execute(array $data)
 {
     try {
         ArgumentCheck::check(array('name' => array('type' => 'string', 'allowBlank' => false, 'strict' => true), 'list' => array('type' => 'array', 'allowBlank' => false)), $data);
     } catch (\Conjoon\Argument\InvalidArgumentException $e) {
         throw new StrategyException($e);
     }
     $name = $data['name'];
     $cmpName = trim(strtolower($name));
     $list = $data['list'];
     $template = $this->template;
     $count = 0;
     $foundInts = 0;
     foreach ($list as $possibleMatch) {
         $target = trim(strtolower($possibleMatch));
         if ($target === $cmpName) {
             $count++;
         }
         // check now if there are already counted matches, such as "Folder (2)"
         // and consider them.
         if (stripos($target, $cmpName) === 0) {
             $possibleCounter = substr($target, strlen($cmpName));
             $possibleCounter = trim($possibleCounter);
             if (substr($possibleCounter, 0, 1) === '(' && substr($possibleCounter, strlen($possibleCounter) - 1, 1) === ')') {
                 $intVal = substr($possibleCounter, 1, strlen($possibleCounter) - 2);
                 if (is_numeric($intVal)) {
                     $intVal = (int) $intVal;
                     $foundInts = max($foundInts, $intVal);
                 }
             }
         }
     }
     $count = max($count, $foundInts + 1);
     $name = str_replace("{0}", $name, $template);
     if ($count > 0) {
         $name = str_replace("{1}", "({$count})", $name);
     } else {
         $name = str_replace("{1}", "", $name);
     }
     return new FolderNamingForMovingStrategyResult(trim($name));
 }
 /**
  * Creates a new instance of this class.
  *
  * Additional to the parent's user config property, an instance of this
  * class needs to be configured with parameters holding a messageLocation,
  * providing detailed information about the location of the message that
  * is requested.
  *
  * @param Array $options An array of options this request gets configured
  *                       with.
  *                       - user: \Conjoon\User\User
  *                       - messageLocation:
  *                         \Conjoon\Mail\Client\Message\MessageLocation
  *
  * @throws \Conjoon\Argument\InvalidArgumentException
  */
 public function __construct(array $options)
 {
     parent::__construct($options);
     ArgumentCheck::check(array('messageLocation' => array('type' => 'instanceof', 'class' => '\\Conjoon\\Mail\\Client\\Message\\MessageLocation')), $this->parameters);
 }
Example #29
0
 /**
  * @inheritdoc
  *
  * @param string $id
  */
 public function remove($id)
 {
     $args = array('id' => $id);
     ArgumentCheck::check(array('id' => array('type' => 'string', 'allowEmpty' => false, 'strict' => true)), $args);
     $id = $args['id'];
     try {
         return $this->zendCacheCore->remove($id);
     } catch (\Exception $e) {
         throw new CacheException("exception thrown by previous exception", 0, $e);
     }
 }
 /**
  * @inheritdoc
  */
 public function __construct(array $options)
 {
     $data = array('options' => $options);
     ArgumentCheck::check(array('options' => array('type' => 'array', 'allowEmpty' => false)), $data);
     ArgumentCheck::check(array('mailFolderRepository' => array('type' => 'instanceof', 'class' => 'Conjoon\\Data\\Repository\\Mail\\MailFolderRepository'), 'user' => array('type' => 'instanceof', 'class' => 'Conjoon\\User\\User'), 'mailFolderCommons' => array('type' => 'instanceof', 'class' => 'Conjoon\\Mail\\Client\\Folder\\FolderCommons')), $options);
     $this->folderRepository = $options['mailFolderRepository'];
     $this->user = $options['user'];
     $this->folderCommons = $options['mailFolderCommons'];
 }