Example #1
0
 /**
  * Returns the account ids for the passed feed ids.
  *
  * @param array integer $feedIds
  *
  * @return array
  */
 private function _getAccountIdsForFeedIds(array $feedIds)
 {
     /**
      * @see Conjoon_Filter_PositiveArrayValues
      */
     require_once 'Conjoon/Filter/PositiveArrayValues.php';
     $filter = new Conjoon_Filter_PositiveArrayValues();
     $feedIds = $filter->filter($feedIds);
     if (empty($feedIds)) {
         return array();
     }
     $model = $this->_getItemModel();
     return $model->getAccountIdsForFeedIds($feedIds);
 }
 /**
  * Maps the specified folder ids in $folderIds to the account id specified
  * in $accountId.
  *
  * @param array $folderIds
  * @param integer $accountId
  *
  * @return integer The total number of data added
  */
 public function mapFolderIdsToAccountId(array $folderIds, $accountId)
 {
     $accountId = (int) $accountId;
     if ($accountId <= 0) {
         return 0;
     }
     /**
      * @see Conjoon_Filter_PositiveArrayValues
      */
     require_once 'Conjoon/Filter/PositiveArrayValues.php';
     $filter = new Conjoon_Filter_PositiveArrayValues();
     $folderIds = $filter->filter($folderIds);
     if (empty($folderIds)) {
         return 0;
     }
     $a = 0;
     for ($i = 0, $len = count($folderIds); $i < $len; $i++) {
         $res = $this->insert(array('groupware_email_folders_id' => $folderIds[$i], 'groupware_email_accounts_id' => $accountId));
         $a = $res ? $a + 1 : $a;
     }
     return $a;
 }
Example #3
0
 /**
  * Ads a relationship for the specified folder ids and the $userId to this table.
  *
  * @param Array $folderIds
  * @param integer $userId
  * @param string $relationshipType
  *
  * @return integer The total number of added data
  */
 public function addRelationship(array $folderIds, $userId, $relationshipType)
 {
     $userId = (int) $userId;
     if ($userId <= 0) {
         return 0;
     }
     if (!$this->_checkRelationshipType($relationshipType)) {
         return 0;
     }
     /**
      * @see Conjoon_Filter_PositiveArrayValues
      */
     require_once 'Conjoon/Filter/PositiveArrayValues.php';
     $filter = new Conjoon_Filter_PositiveArrayValues();
     $folderIds = $filter->filter($folderIds);
     if (empty($folderIds)) {
         return 0;
     }
     $a = 0;
     for ($i = 0, $len = count($folderIds); $i < $len; $i++) {
         $res = $this->insert(array('groupware_files_folders_id' => $folderIds[$i], 'users_id' => $userId, 'relationship' => $relationshipType));
         $a = $res ? $a + 1 : $a;
     }
     return $a;
 }
Example #4
0
 /**
  * Removes all the accounts for the specified account ids, for the user
  * with the specified $userId.
  *
  * @param array $accountIds
  * @param integer $userId
  *
  * @return array An array with the ids that got successfully removed
  *
  * @throws InvalidArgumentException
  */
 public function removeAccountsForIds(array $accountIds, $userId)
 {
     $userId = (int) $userId;
     if ($userId <= 0) {
         throw new InvalidArgumentException("Invalid argument supplied, accountId was \"{$accountId}\"");
     }
     /**
      * @see Conjoon_Filter_PositiveArrayValues
      */
     require_once 'Conjoon/Filter/PositiveArrayValues.php';
     $filter = new Conjoon_Filter_PositiveArrayValues();
     $accountIds = $filter->filter($accountIds);
     $removed = array();
     for ($i = 0, $len = count($accountIds); $i < $len; $i++) {
         if ($this->removeAccountForId($accountIds[$i], $userId) === true) {
             $removed[] = $accountIds[$i];
         }
     }
     return $removed;
 }