public static function retrieveCommunityIdsForSocialPublishing()
 {
     $lQuery = Doctrine_Query::create()->select('c.id')->from('Community c')->where('c.social_publishing_possible = ?', true);
     $lCommunityIds = $lQuery->execute(array(), Doctrine_Core::HYDRATE_NONE);
     $lQuery->free();
     return HydrationUtils::flattenArray($lCommunityIds);
 }
Example #2
0
 public function testFlattenArray()
 {
     $testArray = array(array(0 => 1), array(0 => 44));
     $this->assertTrue(is_array(HydrationUtils::flattenArray($testArray)));
     $this->assertEquals(2, count(HydrationUtils::flattenArray($testArray)));
     $this->assertEquals(array(1, 44), HydrationUtils::flattenArray($testArray));
 }
 public static function createWildcard($wildcard, $catalogue)
 {
     // get all available languages
     $langs = LanguageTable::getAllLanguages(false);
     foreach ($langs as $l) {
         $lQuery = Doctrine_Query::create()->from('Catalogue c')->select('c.cat_id')->where('c.name= ?', $catalogue . '.' . $l->getLang());
         $catId = $lQuery->execute(array(), Doctrine_Core::HYDRATE_NONE);
         $catId = HydrationUtils::flattenArray($catId);
         if (!$catId) {
             continue;
         }
         $t = new TransUnit();
         $t->setCatId($catId[0]);
         $t->setSource($wildcard);
         $t->save();
     }
 }
 /**
  * returns a list of ids from online-identities connected to
  * the user
  *
  * @author Matthias Pfefferle
  * @param int $pUserId
  * @return array
  */
 public static function getIdsOfFriendsByUserId($pUserId)
 {
     $lOis = array();
     $lQueryString = array();
     // @todo refactor this to query only the ids
     $lOwnedOis = OnlineIdentityTable::retrieveByUserId($pUserId);
     foreach ($lOwnedOis as $lIdentity) {
         if ($lIdentity->getFriendIds() != '') {
             $lQueryString[] = '(oi.community_id = ' . $lIdentity->getCommunityId() . ' AND oi.original_id IN (' . $lIdentity->getFriendIds() . '))';
         }
     }
     $q = new Doctrine_RawSql();
     $q->select('{oi.id}')->from('online_identity oi')->distinct()->addComponent('oi', 'OnlineIdentity');
     // !empty means, ther's at least 1 contact
     if (!empty($lQueryString)) {
         $q->where(implode(' OR ', $lQueryString));
         $lOis = $q->execute(array(), Doctrine_Core::HYDRATE_NONE);
     }
     return HydrationUtils::flattenArray($lOis);
 }