Пример #1
0
 /**
  * Counts stars made by a given user.
  * 
  * @param  int  $user_id
  * @return int
  */
 public static function countUserStars($user_id = null)
 {
     if (!$user_id) {
         $user_id = sfPropelActAsStarredBehaviorToolkit::getUserId();
     }
     if (!$user_id) {
         throw new sfException('Cannot retrieve current user.');
     }
     $c = new Criteria();
     $c->add(StarPeer::USER_ID, $user_id);
     return StarPeer::doCount($c);
 }
 /**
  * Clear a star for a given object
  *
  * @param  BaseObject  $object
  **/
 public function clearStar(BaseObject $object)
 {
     $user_id = sfPropelActAsStarredBehaviorToolkit::getUserId();
     if (!$user_id) {
         throw new sfException('Cannot retrieve curent user.');
     }
     $c = new Criteria();
     $c->add(StarPeer::STARRED_ID, $object->getPrimaryKey());
     $c->add(StarPeer::STARRED_MODEL, get_class($object));
     $c->add(StarPeer::USER_ID, $user_id);
     StarPeer::doDelete($c);
 }