Esempio n. 1
0
 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     // Hide discussions which have tags that the user is not allowed to see.
     $query->whereNotExists(function ($query) use($actor) {
         return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
     });
 }
Esempio n. 2
0
 /**
  * @param User $actor
  * @param Tag $tag
  * @return bool|null
  */
 public function addToDiscussion(User $actor, Tag $tag)
 {
     $disallowedTags = Tag::getIdsWhereCannot($actor, 'discussion.startWithoutApproval');
     if (in_array($tag->id, $disallowedTags)) {
         return false;
     }
 }
 public function scopeDiscussionVisibility(ScopeModelVisibility $event)
 {
     // Hide discussions which have tags that the user is not allowed to see.
     if ($event->model instanceof Discussion) {
         $event->query->whereNotExists(function ($query) use($event) {
             return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($event->actor, 'view'))->where('discussions.id', new Expression('discussion_id'));
         });
     }
     if ($event->model instanceof Flag) {
         $event->query->select('flags.*')->leftJoin('posts', 'posts.id', '=', 'flags.post_id')->leftJoin('discussions', 'discussions.id', '=', 'posts.discussion_id')->whereNotExists(function ($query) use($event) {
             return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($event->actor, 'discussion.viewFlags'))->where('discussions.id', new Expression('discussion_id'));
         });
     }
 }
 public function scopeTagVisibility(ScopeModelVisibility $event)
 {
     if ($event->model instanceof Tag) {
         $event->query->whereNotIn('id', Tag::getIdsWhereCannot($event->actor, 'view'));
     }
 }
Esempio n. 5
0
 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     $query->select('flags.*')->leftJoin('posts', 'posts.id', '=', 'flags.post_id')->leftJoin('discussions', 'discussions.id', '=', 'posts.discussion_id')->whereNotExists(function ($query) use($actor) {
         return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'discussion.viewFlags'))->where('discussions.id', new Expression('discussion_id'));
     });
 }
Esempio n. 6
0
 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     $query->whereNotIn('id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'));
 }
 /**
  * @param User $actor
  * @param Builder $query
  */
 public function find(User $actor, Builder $query)
 {
     // Hide discussions which have tags that the user is not allowed to see.
     $query->whereNotExists(function ($query) use($actor) {
         return $query->select(new Expression(1))->from('discussions_tags')->whereIn('tag_id', Tag::getIdsWhereCannot($actor, 'viewDiscussions'))->where('discussions.id', new Expression('discussion_id'));
     });
     // Hide discussions with no tags if the user doesn't have that global
     // permission.
     if (!$actor->hasPermission('viewDiscussions')) {
         $query->has('tags');
     }
 }