Exemple #1
0
 /**
  * Returns either a cached list of twitter accounts for a user, or
  * the accounts out of the database which will immediately be validated
  * against the twitter service (network access)
  *
  * @param array $options An associative array with the following
  * key value/pairs:
  *   - userId: the id of the user to fetch al twitter accounts for
  * @param Conjoon_BeanContext_Decoratable $model
  *
  * @return Array anr array with instances of
  * Conjoon_Modules_Service_Twitter_Account_Model_Account
  */
 protected function _build(array $options, Conjoon_BeanContext_Decoratable $model)
 {
     $userId = $options['userId'];
     /**
      * @see Conjoon_BeanContext_Decorator
      */
     require_once 'Conjoon/BeanContext/Decorator.php';
     $decoratedModel = new Conjoon_BeanContext_Decorator($model);
     $accounts = $decoratedModel->getAccountsForUserAsDto($userId);
     /**
      * @see Conjoon_Service_Twitter
      */
     require_once 'Conjoon/Service/Twitter.php';
     /**
      * @see Conjoon_Modules_Default_Registry_Facade
      */
     require_once 'Conjoon/Modules/Default/Registry/Facade.php';
     $protocolContext = Conjoon_Modules_Default_Registry_Facade::getInstance()->getValueForKeyAndUserId('/server/environment/protocol', $userId);
     for ($i = 0, $len = count($accounts); $i < $len; $i++) {
         $dto =& $accounts[$i];
         try {
             /**
              * @todo move to separate model
              */
             /**
              * @see Zend_Oauth_Token_Access
              */
             require_once 'Zend/Oauth/Token/Access.php';
             $accessToken = new Zend_Oauth_Token_Access();
             $accessToken->setParams(array('oauth_token' => $dto->oauthToken, 'oauth_token_secret' => $dto->oauthTokenSecret, 'user_id' => $dto->twitterId, 'screen_name' => $dto->name));
             $twitter = new Conjoon_Service_Twitter(array('username' => $dto->name, 'accessToken' => $accessToken));
             $response = $twitter->userShow($dto->name);
             $dto->twitterId = $response->id_str;
             $dto->twitterName = $response->name;
             $dto->twitterScreenName = $response->screen_name;
             $dto->twitterLocation = $response->location;
             $dto->twitterProfileImageUrl = $protocolContext === 'https' ? $response->profile_image_url_https : $response->profile_image_url;
             $dto->twitterUrl = $response->url;
             $dto->twitterProtected = $response->protected;
             $dto->twitterDescription = $response->description;
             $dto->twitterFollowersCount = $response->followers_count;
         } catch (Exception $e) {
             Conjoon_Log::log("Could not retrieve account information for twitter " . "account: \"" . $e->getMessage() . "\"", Zend_Log::INFO);
             // ignore
         }
         $dto->oauthTokenSecret = str_pad("", strlen($dto->oauthTokenSecret), '*');
     }
     return $accounts;
 }
 /**
  * Returns either a cached list of feed accounts for a user, or
  * the accounts out of the database.
  *
  * @param array $options An associative array with the following
  * key value/pairs:
  *   - userId: the id of the user to fetch all feed accounts for
  * @param Conjoon_BeanContext_Decoratable $model
  *
  * @return Array an array with instances of
  * Conjoon_Modules_Groupware_Feeds_Account_Model_Account_Dto
  */
 protected function _build(array $options, Conjoon_BeanContext_Decoratable $model)
 {
     $userId = $options['userId'];
     /**
      * @see Conjoon_BeanContext_Decorator
      */
     require_once 'Conjoon/BeanContext/Decorator.php';
     $decoratedModel = new Conjoon_BeanContext_Decorator($model);
     $accounts = $decoratedModel->getAccountsForUserAsDto($userId);
     return $accounts;
 }
Exemple #3
0
 /**
  * Returns either a cached list of email accounts for a user, or
  * the accounts out of the database.
  *
  * @param array $options An associative array with the following
  * key value/pairs:
  *   - userId: the id of the user to fetch all email accounts for
  * @param Conjoon_BeanContext_Decoratable $model
  *
  * @return Array an array with instances of
  * Conjoon_Modules_Groupware_Feeds_Account_Model_Account
  */
 protected function _build(array $options, Conjoon_BeanContext_Decoratable $model)
 {
     $userId = $options['userId'];
     /**
      * @see Conjoon_BeanContext_Decorator
      */
     require_once 'Conjoon/BeanContext/Decorator.php';
     $decoratedModel = new Conjoon_BeanContext_Decorator($model);
     $accounts = $decoratedModel->getAccountsForUserAsDto($userId);
     /**
      * @see Conjoon_Modules_Groupware_Email_ImapHelper
      */
     require_once 'Conjoon/Modules/Groupware/Email/ImapHelper.php';
     /**
      * @see Conjoon_Modules_Groupware_Email_Folder_Facade
      */
     require_once 'Conjoon/Modules/Groupware/Email/Folder/Facade.php';
     $facade = Conjoon_Modules_Groupware_Email_Folder_Facade::getInstance();
     for ($i = 0, $len = count($accounts); $i < $len; $i++) {
         $dto =& $accounts[$i];
         if ($dto->protocol == 'IMAP') {
             $folderMappings =& $dto->folderMappings;
             $folder = null;
             try {
                 $folder = $facade->getRootFolderForAccountId($dto, $userId);
                 $folder = $folder[0];
             } catch (Exception $e) {
                 // connection exception ignore
             }
             for ($a = 0, $lena = count($folderMappings); $a < $lena; $a++) {
                 if (!$folder) {
                     // connection exception, ignore
                     $folderMappings[$a]['globalName'] = "";
                     $folderMappings[$a]['delimiter'] = "";
                     $folderMappings[$a]['path'] = array();
                     continue;
                 }
                 try {
                     $folderMappings[$a]['delimiter'] = Conjoon_Modules_Groupware_Email_ImapHelper::getFolderDelimiterForImapAccount($dto);
                     $folderMappings[$a]['path'] = array_merge(array('root', $folder['id']), Conjoon_Modules_Groupware_Email_ImapHelper::splitFolderForImapAccount($folderMappings[$a]['globalName'], $dto));
                 } catch (Exception $e) {
                     // connection exception, ignore
                     $folderMappings[$a]['globalName'] = "";
                     $folderMappings[$a]['delimiter'] = "";
                     $folderMappings[$a]['path'] = array();
                 }
             }
         }
         if (!$dto->isOutboxAuth) {
             $dto->usernameOutbox = "";
             $dto->passwordOutbox = "";
         }
         $dto->passwordOutbox = str_pad("", strlen($dto->passwordOutbox), '*');
         $dto->passwordInbox = str_pad("", strlen($dto->passwordInbox), '*');
     }
     return $accounts;
 }