Esempio n. 1
0
 /**
  * This function returns a pager object holding the given user's favorite entries
  * each entry holds the kuser object of its host.
  *
  * @param int $kuserId = the requested user
  * @param int $type = the favorite type (currently only SUBJECT_TYPE_ENTRY will match)
  * @param int $privacy = the privacy filter
  * @param int $pageSize = number of kshows in each page
  * @param int $page = the requested page
  * @return the pager object
  */
 public static function getUserFavorites($kuserId, $type, $privacy, $pageSize, $page, $order = entry::ENTRY_SORT_MOST_VIEWED)
 {
     $c = new Criteria();
     entryPeer::setOrder($c, $order);
     $c->addJoin(entryPeer::KUSER_ID, kuserPeer::ID, Criteria::INNER_JOIN);
     $c->addJoin(entryPeer::ID, favoritePeer::SUBJECT_ID, Criteria::INNER_JOIN);
     $c->add(favoritePeer::KUSER_ID, $kuserId);
     $c->add(favoritePeer::SUBJECT_TYPE, $type);
     $c->add(favoritePeer::PRIVACY, $privacy);
     $c->setDistinct();
     // our assumption is that a request for private favorites should include public ones too
     if ($privacy == favorite::PRIVACY_TYPE_USER) {
         $c->addOr(favoritePeer::PRIVACY, favorite::PRIVACY_TYPE_WORLD);
     }
     $c->addAscendingOrderByColumn(entryPeer::NAME);
     $pager = new sfPropelPager('entry', $pageSize);
     $pager->setCriteria($c);
     $pager->setPage($page);
     $pager->setPeerMethod('doSelectJoinkuser');
     $pager->setPeerCountMethod('doCountJoinkuser');
     $pager->init();
     return $pager;
 }