コード例 #1
0
 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];
 }
コード例 #2
0
ファイル: CreatePage.php プロジェクト: robbytaylor/boom-core
 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;
 }
コード例 #3
0
 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];
 }
コード例 #4
0
ファイル: Page.php プロジェクト: boomcms/boom-core
 public function wasCreatedBy(PersonInterface $person)
 {
     return $this->getCreatedBy() === $person->getId();
 }
コード例 #5
0
ファイル: Auth.php プロジェクト: robbytaylor/boom-core
 public function rememberLogin(Person $person)
 {
     $value = $person->getId() . '-' . $person->getRememberToken();
     Cookie::queue(Cookie::forever($this->getAutoLoginCookie(), $value));
 }
コード例 #6
0
ファイル: Asset.php プロジェクト: robbytaylor/boom-core
 /**
  * @param PersonInterface $person
  *
  * @return $this
  */
 public function setUploadedBy(PersonInterface $person)
 {
     $this->{self::ATTR_UPLOADED_BY} = $person->getId();
     return $this;
 }
コード例 #7
0
 public function before(Person $person, $ability)
 {
     if ($person->isSuperuser() || Auth::check('managePages', Request::instance())) {
         return true;
     }
 }
コード例 #8
0
ファイル: Site.php プロジェクト: boomcms/boom-core
 /**
  * @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();
 }
コード例 #9
0
ファイル: UploadedBy.php プロジェクト: boomcms/boom-core
 public function build(Builder $query)
 {
     return $query->where(Asset::ATTR_UPLOADED_BY, $this->person->getId());
 }
コード例 #10
0
 public function editSuperuser(Person $user, Person $editing)
 {
     return $user->isSuperUser() && $user->getId() !== $editing->getId();
 }
コード例 #11
0
ファイル: Person.php プロジェクト: robbytaylor/boom-core
 public function save(PersonInterface $person)
 {
     $person->save();
     return $person;
 }
コード例 #12
0
ファイル: Acl.php プロジェクト: boomcms/boom-core
 public function shouldBeApplied()
 {
     return $this->person === null || $this->person->can('managePages', $this->site) !== true;
 }
コード例 #13
0
ファイル: RobotsFile.php プロジェクト: boomcms/boom-robotstxt
 /**
  * @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;
 }
コード例 #14
0
ファイル: PersonPolicy.php プロジェクト: boomcms/boom-core
 /**
  * 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);
 }
コード例 #15
0
 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);
     });
 }
コード例 #16
0
 public function before(Person $person, $ability)
 {
     if ($person->isSuperuser()) {
         return true;
     }
 }