Example #1
0
 /**
  *
  * @param Doctrine_Query $query
  * @param sfUser $user
  * @param type $alias
  * @return Doctrine_Query
  */
 public function filterScope(Doctrine_Query $query, sfUser $user, $alias = 'l')
 {
     $where = "{$alias}.location_scope_id = 5";
     if (!$user->isAnonymous()) {
         $uniq = self::$uniq++;
         $where .= "\r\n                    or {$alias}.location_scope_id = 1\r\n                    or {$alias}.location_scope_id = 3\r\n                    or {$alias}.created_by = " . $user->getProfile()->id . "\r\n                    or {$alias}.created_by in (SELECT fa{$uniq}.accepter_id FROM friend fa{$uniq} WHERE fa{$uniq}.accepted = 1 and fa{$uniq}.requester_id = " . $user->getProfile()->id . ")\r\n                    or {$alias}.created_by in (SELECT fr{$uniq}.requester_id FROM friend fr{$uniq} WHERE fr{$uniq}.accepted = 1 and fr{$uniq}.accepter_id = " . $user->getProfile()->id . ")";
     }
     $query->addWhere($where);
     return $query;
 }