public function build(Builder $query) { if ($this->person === null) { return $query->where(Page::ATTR_ENABLE_ACL, false); } return $query->leftJoin('page_acl', 'pages.id', '=', 'page_acl.page_id')->leftJoin('group_person', 'page_acl.group_id', '=', 'group_person.group_id')->where(function (Builder $where) { $where->where(Page::ATTR_CREATED_BY, $this->person->getId())->orWhereNull('page_acl.group_id')->orWhere('group_person.person_id', $this->person->getId()); })->groupBy('pages.id'); }
public function handle() { $attrs = ['visible_from' => time(), 'created_by' => $this->createdBy->getId()]; if ($this->parent) { $attrs = ['visible_from' => time(), 'parent_id' => $this->parent->getId(), 'visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav(), 'children_visible_in_nav' => $this->parent->childrenAreVisibleInNav(), 'children_visible_in_nav_cms' => $this->parent->childrenAreVisibleInCmsNav()]; } $page = PageFacade::create($attrs); $page->addVersion(['edited_by' => $this->createdBy->getId(), 'page_id' => $page->getId(), 'template_id' => $this->parent ? $this->parent->getDefaultChildTemplateId() : null, 'title' => 'Untitled', 'published' => true, 'embargoed_until' => time()]); return $page; }
public function check($role, Person $person, $where) { $hash = md5($role . '-' . $person->getId() . '-' . $where); if (!isset($this->cache[$hash])) { $query = DB::table('group_role')->select(DB::raw('bit_and(allowed) as allowed'))->join('group_person', 'group_person.group_id', '=', 'group_role.group_id')->join('groups', 'group_person.group_id', '=', 'groups.id')->join('roles', 'roles.id', '=', 'group_role.role_id')->whereNull('groups.deleted_at')->where('group_person.person_id', '=', $person->getId())->where('roles.name', '=', $role)->groupBy('person_id'); // Strange results if this isn't here. if ($where instanceof Page) { $query->where('group_role.page_id', '=', $where->getId()); } $result = $query->first(); $this->cache[$hash] = isset($result->allowed) ? (bool) $result->allowed : null; } return $this->cache[$hash]; }
protected function doLookup(Person $person, $role, $pageId) { $hash = md5($person->getId() . '-' . $role . '-' . $pageId); if (!isset($this->cache[$hash])) { $this->cache[$hash] = $person->isAllowed($role, $pageId); } return $this->cache[$hash]; }
public function wasCreatedBy(PersonInterface $person) { return $this->getCreatedBy() === $person->getId(); }
public function rememberLogin(Person $person) { $value = $person->getId() . '-' . $person->getRememberToken(); Cookie::queue(Cookie::forever($this->getAutoLoginCookie(), $value)); }
/** * @param PersonInterface $person * * @return $this */ public function setUploadedBy(PersonInterface $person) { $this->{self::ATTR_UPLOADED_BY} = $person->getId(); return $this; }
/** * @param PersonModelInterface $person * * @return Collection */ public function findByPerson(PersonModelInterface $person) { return $this->model->join('person_site', 'person_site.site_id', '=', 'sites.id')->where('person_site.person_id', '=', $person->getId())->orderBy('name', 'asc')->all(); }
public function build(Builder $query) { return $query->where(Asset::ATTR_UPLOADED_BY, $this->person->getId()); }
public function editSuperuser(Person $user, Person $editing) { return $user->isSuperUser() && $user->getId() !== $editing->getId(); }
/** * @param string $rules * @param Person $person * * @return RobotsFile */ public function saveRules($rules, Person $person) { DB::table('robots')->insert(['rules' => trim(strip_tags($rules)), 'edited_by' => $person->getId(), 'edited_at' => time()]); return $this; }