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 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]; }
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; }
public function before(Person $person, $ability) { if ($person->isSuperuser() || Auth::check('managePages', Request::instance())) { return true; } }
/** * @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(); }
public function save(PersonInterface $person) { $person->save(); return $person; }
public function shouldBeApplied() { return $this->person === null || $this->person->can('managePages', $this->site) !== true; }
/** * @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; }
/** * Whether a user can edit the superuser status of another. * * @param Person $user * @param Person $editing * * @return bool */ public function editSuperuser(Person $user, Person $editing) { return $user->isSuperUser() && !$user->is($editing); }
public function send(Person $to, $subject, $viewName, $viewParams) { Mail::send("boomcms::email.{$viewName}", $viewParams, function ($message) use($to, $subject) { $message->to($to->getEmail(), $to->getName())->from(Settings::get('site.admin.email'), Settings::get('site.name'))->subject($subject); }); }
public function before(Person $person, $ability) { if ($person->isSuperuser()) { return true; } }