public function loadPermissions($user_id = null) { if (count($this->permarray)) { return $this->permarray; } $User = Auth::getUser(); if ($User) { $user_id = $User->id; } $deny_perm = intval(Settings::get('deny_perm')); if ($user_id) { $roles = DB::table('shahiemseymor_assigned_roles')->where('user_id', '=', $user_id)->lists('role_id'); $this->permarray = array_merge(DB::table('shahiemseymor_permission_role')->wherein('role_id', $roles)->where('permission_id', '<>', $deny_perm)->lists('permission_id'), [Settings::get('public_perm')]); $this->permarray = array_unique($this->permarray); return $this->permarray; } else { $this->permarray = [Settings::get('public_perm')]; } return $this->permarray; }
public function onShowEvent() { $slug = post('evid'); $e = MyEvents::with('categorys')->where('is_published', true)->find($slug); if (!$e) { return $this->page['ev'] = ['name' => 'kurtjensen.mycalendar::lang.event.error_not_found', 'cats' => $e->categorys->lists('name')]; } if ($this->usePermissions) { $this->loadPermissions(); $eventPerms = $e->categorys->lists('id'); $Allow = Category::whereIn('permission_id', $this->permarray)->lists('id'); $Deny = Category::where('permission_id', Settings::get('deny_perm'))->lists('id'); if (!count(array_intersect($eventPerms, $Allow))) { return $this->page['ev'] = ['name' => 'kurtjensen.mycalendar::lang.event.error_allow_no', 'cats' => $e->categorys->lists('name')]; } if (count(array_intersect($eventPerms, $Deny))) { return $this->page['ev'] = ['name' => 'kurtjensen.mycalendar::lang.event.error_prohibit', 'cats' => $e->categorys->lists('name')]; } } $link = $e->link ? $e->link : ''; $this->page['ev'] = ['name' => $e->name, 'date' => $e->date, 'time' => $e->human_time, 'link' => $link, 'text' => $e->text, 'cats' => $e->categorys->lists('name')]; }