Наследование: extends Cms\Classes\ComponentBase
 /**
  * Executed when this component is bound to a page or layout.
  */
 public function onRun()
 {
     $this->appId = GraphAPI::instance()->appId;
     $this->redirectLogin = $this->property('redirectLogin') ? $this->controller->pageUrl($this->property('redirectLogin')) : URL::previous();
     $this->redirectSignup = $this->property('redirectSignup') ? $this->controller->pageUrl($this->property('redirectSignup')) : URL::previous();
     return parent::onRun();
 }
Пример #2
0
 /**
  * Executed when this component is bound to a page or layout.
  */
 public function onRun()
 {
     $this->setProperty('security', self::ALLOW_USER);
     if ($redirect = parent::onRun()) {
         return $redirect;
     }
     /** @var $user User */
     $user = $this->page['user'];
     $redirectUrl = $this->controller->pageUrl($this->property('redirect'));
     $allowedGroup = $this->property('group', null);
     $group = UserGroup::where('id', $allowedGroup);
     if (!$group || !$user->inGroup($group)) {
         return Redirect::guest($redirectUrl);
     }
     $this->page['group'] = $group;
 }
Пример #3
0
 public function boot()
 {
     Session::extend(function ($component) {
         /* @var $component Session */
     });
     User::extend(function ($model) {
         /* @var $model User */
         $model->belongsToMany['groups'] = ['BnB\\UserGroup\\Models\\UserGroup', 'table' => 'users_groups'];
     });
     Event::listen('backend.menu.extendItems', function ($manager) {
         $manager->addSideMenuItems('RainLab.User', 'user', ['groups' => ['label' => 'bnb.usergroup::lang.groups.all_groups', 'icon' => 'icon-users', 'url' => Backend::url('bnb/usergroup/usergroups'), 'permissions' => ['rainlab.groups.access_groups']]]);
     });
     Event::listen('backend.form.extendFields', function ($widget) {
         //Extend groups controller
         if (!$widget->getController() instanceof \RainLab\User\Controllers\Users) {
             return;
         }
         if (!$widget->model instanceof \RainLab\User\Models\User) {
             return;
         }
         $widget->addTabFields(['groups' => ['label' => trans('bnb.usergroup::lang.user.groups'), 'comment' => trans('bnb.usergroup::lang.user.groups_comment'), 'type' => 'relation', 'tab' => 'bnb.usergroup::lang.user.groups', 'span' => 'auto']]);
     });
 }