Controls access to admin pages
347254
protected function controlAccessAdmin()
    {
        if ($this->is_backend && !$this->isSuperadmin()) {

            if (empty($this->current_user['role_status']) || !$this->access('admin')) {
                $this->redirect('/', $this->text('No access'), 'warning');
            }

            if (isset($this->current_route['access']) && !$this->access($this->current_route['access'])) {
                $this->setHttpStatus(403);
            }
        }
    }
436024
protected function controlAccess($permission)
    {
        if (isset($this->uid) && !$this->user->access($permission, $this->uid)) {
            $this->errorAndExit($this->text('No access'));
        }
    }
630010
public function accessDenied() {
    // Get the front page URL.
    $frontpage = $this->config('system.site')->get('page.front');

    // Determine the message we want to set.
    $text = $this->t("<p>You have insufficient permissions to view the page you're trying to access. There could be several reasons for this:</p><ul><li>You are trying to edit content you're not allowed to edit.</li><li>You are trying to view content (from a group) you don't have access to.</li><li>You are trying to access administration pages.</li></ul><p>Click the back button of your browser to go back where you came from or click <a href=\":url\">here</a> to go to the homepage</p>", [':url' => $frontpage]);

    // Return the message in the render array.
    return ['#markup' => $text];
  }
1002554
public function setupPermissions()
    {
        $app = Application::getFacadeApplication();
        $u = $app->make(\Concrete\Core\User\User::class);
        if ($u->isSuperUser() || ($this->ignorePermissions)) {
            return; // super user always sees everything. no need to limit
        }

        $accessEntities = $u->getUserAccessEntityObjects();
        $peIDs = ['-1'];
        foreach ($accessEntities as $pae) {
            $peIDs[] = $pae->getAccessEntityID();
        }

        $owpae = PageOwnerPermissionAccessEntity::getOrCreate();
        // now we retrieve a list of permission duration object IDs that are attached view_page or view_page_version
        // against any of these access entity objects. We just get'em all.
        $db = $app->make(Connection::class);
        $activePDIDs = [];
        $vpPKID = $db->GetOne('select pkID from PermissionKeys where pkHandle = ?', [$this->viewPagePermissionKeyHandle]);
        /*
        $vpvPKID = $db->GetOne('select pkID from PermissionKeys where pkHandle = \'view_page_versions\'');
        $pdIDs = $db->GetCol("select distinct pdID from PagePermissionAssignments ppa inner join PermissionAccessList pa on ppa.paID = pa.paID where pkID in (?, ?) and pdID > 0", array($vpPKID, $vpvPKID));
        */
        $pdIDs = $db->GetCol("select distinct pdID from PagePermissionAssignments ppa inner join PermissionAccessList pa on ppa.paID = pa.paID where pkID =? and pdID > 0", [$vpPKID]);
        if (count($pdIDs) > 0) {
            // then we iterate through all of them and find any that are active RIGHT NOW
            foreach ($pdIDs as $pdID) {
                $pd = PermissionDuration::getByID($pdID);
                if ($pd->isActive()) {
                    $activePDIDs[] = $pd->getPermissionDurationID();
                }
            }
        }
        $activePDIDs[] = 0;

        if ($this->includeAliases) {
            $cInheritPermissionsFromCID = 'if(p2.cID is null, p1.cInheritPermissionsFromCID, p2.cInheritPermissionsFromCID)';
        } else {
            $cInheritPermissionsFromCID = 'p1.cInheritPermissionsFromCID';
        }

        if ($this->displayOnlyApprovedPages) {
            $now = $app->make('date')->getOverridableNow();
            $nowSql = $db->quote($now);
            $cvIsApproved = " and cv.cvIsApproved = 1 and (cv.cvPublishDate is null or cv.cvPublishDate <= {$nowSql}) and (cv.cvPublishEndDate is null or cv.cvPublishEndDate >= {$nowSql})";
        } else {
            $cvIsApproved = '';
        }

        $uID = 0;
        if ($u->isRegistered()) {
            $uID = $u->getUserID();
        }

        /*
        $this->filter(false, "((select count(cID) from PagePermissionAssignments ppa1 inner join PermissionAccessList pa1 on ppa1.paID = pa1.paID where ppa1.cID = {$cInheritPermissionsFromCID} and pa1.accessType = " . PermissionKey::ACCESS_TYPE_INCLUDE . " and pa1.pdID in (" . implode(',', $activePDIDs) . ")
            and pa1.peID in (" . implode(',', $peIDs) . ") and (if(pa1.peID = " . $owpae->getAccessEntityID() . " and p1.uID <>" . $uID . ", false, true)) and (ppa1.pkID = " . $vpPKID . $cvIsApproved . " or ppa1.pkID = " . $vpvPKID . ")) > 0
            or (p1.cPointerExternalLink !='' AND p1.cPointerExternalLink IS NOT NULL))");
        $this->filter(false, "((select count(cID) from PagePermissionAssignments ppaExclude inner join PermissionAccessList paExclude on ppaExclude.paID = paExclude.paID where ppaExclude.cID = {$cInheritPermissionsFromCID} and accessType = " . PermissionKey::ACCESS_TYPE_EXCLUDE . " and pdID in (" . implode(',', $activePDIDs) . ")
            and paExclude.peID in (" . implode(',', $peIDs) . ") and (if(paExclude.peID = " . $owpae->getAccessEntityID() . " and p1.uID <>" . $uID . ", false, true)) and (ppaExclude.pkID = " . $vpPKID . $cvIsApproved . " or ppaExclude.pkID = " . $vpvPKID . ")) = 0)");
            */

        $this->filter(false, "((select count(cID) from PagePermissionAssignments ppa1 inner join PermissionAccessList pa1 on ppa1.paID = pa1.paID where ppa1.cID = {$cInheritPermissionsFromCID} and pa1.accessType = " . PermissionKey::ACCESS_TYPE_INCLUDE . " and pa1.pdID in (" . implode(',', $activePDIDs) . ")
			and pa1.peID in (" . implode(',', $peIDs) . ") and (if(pa1.peID = " . $owpae->getAccessEntityID() . " and p1.uID <>" . $uID . ", false, true)) and (ppa1.pkID = " . $vpPKID . $cvIsApproved . ")) > 0
			or (p1.cPointerExternalLink !='' AND p1.cPointerExternalLink IS NOT NULL))");
        $this->filter(false, "((select count(cID) from PagePermissionAssignments ppaExclude inner join PermissionAccessList paExclude on ppaExclude.paID = paExclude.paID where ppaExclude.cID = {$cInheritPermissionsFromCID} and accessType = " . PermissionKey::ACCESS_TYPE_EXCLUDE . " and pdID in (" . implode(',', $activePDIDs) . ")
			and paExclude.peID in (" . implode(',', $peIDs) . ") and (if(paExclude.peID = " . $owpae->getAccessEntityID() . " and p1.uID <>" . $uID . ", false, true)) and (ppaExclude.pkID = " . $vpPKID . $cvIsApproved . ")) = 0)");
    }
233002
def access(self, user):
        """"""
        if self.denyusers:
            if user in self.denyusers:
                return False
        if self.allowusers:
            if not user in self.allowusers:
                return False
        return True
1173959
public function adminBar()
    {
        if (isset($_GET['id'])) {
            if (is_numeric($_GET['id']) && $_GET['id'] > 0) {
                $post = get_post($_GET['id']);

                if (!$post) {
                    return;
                }

                setup_postdata($post);

                add_action('admin_bar_menu', function () use ($post) {
                    global $wp_admin_bar;
                    $wp_admin_bar->add_node(array(
                        'id' => 'view_page',
                        'title' => __('View Page'),
                        'href' => get_permalink($post->ID),
                        'meta' => array(
                            'target' => '_blank'
                        )
                    ));
                }, 1050);

                self::$isEditing = array(
                    'id' => $post->ID,
                    'title' => $post->post_title
                );

                wp_reset_postdata();
            } else {
                global $archive;
                $archive = $_GET['id'];

                self::$isEditing = array(
                    'id' => null,
                    'title' => $archive
                );
            }

            self::$isEditing = apply_filters('Modularity/is_editing', self::$isEditing);

            add_action('Modularity/options_page_title_suffix', function () {
                echo ': ' . self::$isEditing['title'];
            });
        }
    }
1183498
def manage_admins():
    """"""
    build = g.build

    # Do not show cached data
    db.session.add(build)
    db.session.refresh(build)

    add_form = forms.AddAdminForm()
    if add_form.validate_on_submit():

        invitation_user_id = '%s:%s' % (
            models.User.EMAIL_INVITATION, add_form.email_address.data)

        invitation_user = models.User.query.get(invitation_user_id)
        if not invitation_user:
            invitation_user = models.User(
                id=invitation_user_id,
                email_address=add_form.email_address.data)
            db.session.add(invitation_user)

        db.session.add(build)
        db.session.add(invitation_user)
        db.session.refresh(build, lockmode='update')

        build.owners.append(invitation_user)
        save_admin_log(build, invited_new_admin=True,
                       message=invitation_user.email_address)

        db.session.commit()

        logging.info('Added user=%r as owner to build_id=%r',
                     invitation_user.id, build.id)
        return redirect(url_for('manage_admins', build_id=build.id))

    add_form.build_id.data = build.id

    revoke_form_list = []
    for user in build.owners:
        form = forms.RemoveAdminForm()
        form.user_id.data = user.id
        form.build_id.data = build.id
        form.revoke.data = True
        revoke_form_list.append((user, form))

    return render_template(
        'view_admins.html',
        build=build,
        add_form=add_form,
        revoke_form_list=revoke_form_list)
369059
def can_view(self, user):
        """"""
        return user.is_admin or user in self.users \
            or self.project.class_ in user.admin_for
85859
protected function controlAccessAccount()
    {
        $account_id = $this->url->getAccountId();

        if ($account_id === false || $this->uid === $account_id) {
            return null;
        }

        if ($this->isSuperadmin($account_id) && !$this->isSuperadmin()) {
            $this->setHttpStatus(403);
            return null;
        }

        if (!$this->access('user')) {
            $this->setHttpStatus(403);
        }
    }
320567
public void setAdminPage(String url, String docPath, List<Interceptor> interceptors) {
        adminPage = HandlerUtil.staticFiles(url, docPath);
    }
1160077
public function AdminPage()
	{
		$this->RequirePermission(ExampleUser::$PERMISSION_ADMIN, 
				'SecureExample.LoginForm', 
				'Login is required to access the admin page',
				'Admin permission is required to access the admin page');
		
		$this->Assign("currentUser", $this->GetCurrentUser());
		
		$this->Assign('page','adminpage');
		$this->Render("SecureExample");
	}
300323
protected function mapAdminRoutes()
    {
        Routes\Admin\ProfileRoutes::register();

        $this->prefix($this->config()->get('arcanesoft.auth.route.prefix', 'authorization'))
             ->group(function () {
                 Routes\Admin\StatsRoutes::register();
                 Routes\Admin\UsersRoutes::register();
                 Routes\Admin\RolesRoutes::register();
                 Routes\Admin\PermissionsRoutes::register();
                 Routes\Admin\PasswordResetsRoutes::register();
             });
    }
262553
protected function registerPermissions()
    {
        $group = PermissionFacade::add(
            'page',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.page.title');
            }
        );
        $group->addPermission(
            'admin-page-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.page.list')
                    ->routes('admin.page.index');
            }
        );
        $group->addPermission(
            'admin-page-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.page.create')
                    ->routes('admin.page.create,admin.page.store');
            }
        );
        $group->addPermission(
            'admin-page-update', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.page.edit')
                    ->routes('admin.page.edit,admin.page.update');
            }
        );
        $group->addPermission(
            'admin-page-destroy', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.page.destroy')
                    ->routes('admin.page.destroy');
            }
        );
        $group->addPermission(
            'admin-page-show', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.page.show')
                    ->routes('admin.page.show');
            }
        );

        $group = PermissionFacade::add(
            'menu', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.menu.title');
            }
        );

        $group->addPermission(
            'admin-menu-list', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.menu.front')
                    ->routes('admin.menu.index');
            }
        );

        $group->addPermission(
            'admin-menu-store', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.menu.save')
                    ->routes('admin.menu.store');
            }
        );

        $group = PermissionFacade::add(
            'category', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.category.title');
            }
        );
        $group->addPermission(
            'admin-category-list', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.category.list')
                    ->routes('admin.category.index');
            }
        );
        $group->addPermission(
            'admin-category-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.category.create')
                    ->routes('admin.category.create,admin.category.store');
            }
        );
        $group->addPermission(
            'admin-category-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.category.edit')
                    ->routes('admin.category.edit,admin.category.update');
            }
        );
        $group->addPermission(
            'admin-category-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.category.destroy')
                    ->routes('admin.category.destroy');
            }
        );
        $group->addPermission(
            'admin-category-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.category.show')
                    ->routes('admin.category.show');
            }
        );

        $group = PermissionFacade::add(
            'product',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.product.title');
            }
        );

        $group->addPermission(
            'admin-product-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.product.list')
                    ->routes('admin.product.index');
            }
        );
        $group->addPermission(
            'admin-product-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.product.create')
                    ->routes('admin.product.create,admin.product.store');
            }
        );
        $group->addPermission(
            'admin-product-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.product.edit')
                    ->routes('admin.product.edit,admin.product.update');
            }
        );
        $group->addPermission(
            'admin-product-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.product.destroy')
                    ->routes('admin.product.destroy');
            }
        );
        $group->addPermission(
            'admin-product-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.product.show')
                    ->routes('admin.product.show');
            }
        );

        $group = PermissionFacade::add(
            'order',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.order.title');
            }
        );

        $group->addPermission(
            'admin-order-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order.list')
                    ->routes('admin.order.index');
            }
        );

        $group->addPermission(
            'admin-order-view',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order.view')
                    ->routes('admin.order.view');
            }
        );
        $group->addPermission(
            'admin-order-send-invoice-email',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order.sent_invoice_by_mail')
                    ->routes('admin.order.send-email-invoice');
            }
        );
        $group->addPermission(
            'admin-order-change-status', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order.status_change')
                    ->routes('admin.order.change-status,admin.order.update-status');
            }
        );

        $group = PermissionFacade::add(
            'order-status',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.order_status.title');
            }
        );
        $group->addPermission(
            'admin-order-status-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order_status.list')
                    ->routes('admin.order-status.index');
            }
        );
        $group->addPermission(
            'admin-order-status-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order_status.create')
                    ->routes('admin.order-status.create,admin.order-status.store');
            }
        );
        $group->addPermission(
            'admin-order-status-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order_status.edit')
                    ->routes('admin.order-status.edit,admin.order-status.update');
            }
        );
        $group->addPermission(
            'admin-order-status-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order_status.destroy')
                    ->routes('admin.order-status.destroy');
            }
        );
        $group->addPermission(
            'admin-order-status-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.order_status.show')
                    ->routes('admin.order-status.show');
            }
        );

        $group = PermissionFacade::add(
            'attribute',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.attribute.title');
            }
        );
        $group->addPermission(
            'admin-attribute-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.attribute.list')
                    ->routes('admin.attribute.index');
            }
        );
        $group->addPermission(
            'admin-attribute-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.attribute.create')
                    ->routes('admin.attribute.create,admin.attribute.store');
            }
        );
        $group->addPermission(
            'admin-attribute-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.attribute.edit')
                    ->routes('admin.attribute.edit,admin.attribute.update');
            }
        );
        $group->addPermission(
            'admin-attribute-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.attribute.destroy')
                    ->routes('admin.attribute.destroy');
            }
        );
        $group->addPermission(
            'admin-attribute-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.attribute.show')
                    ->routes('admin.attribute.show');
            }
        );

        $group = PermissionFacade::add(
            'property',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.property.title');
            }
        );

        $group->addPermission(
            'admin-property-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.property.list')
                    ->routes('admin.property.index');
            }
        );
        $group->addPermission(
            'admin-property-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.property.create')
                    ->routes('admin.property.create,admin.property.store');
            }
        );
        $group->addPermission(
            'admin-attribute-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.property.edit')
                    ->routes('admin.property.edit,admin.property.update');
            }
        );
        $group->addPermission(
            'admin-property-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.property.destroy')
                    ->routes('admin.property.destroy');
            }
        );
        $group->addPermission(
            'admin-property-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.property.show')
                    ->routes('admin.property.show');
            }
        );

        $group = PermissionFacade::add(
            'user',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.user.title');
            }
        );

        $group->addPermission(
            'admin-user-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user.list')
                    ->routes('admin.user.index');
            }
        );
        $group->addPermission(
            'admin-user-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user.create')
                    ->routes('admin.user.create,admin.user.store');
            }
        );
        $group->addPermission(
            'admin-user-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user.edit')
                    ->routes('admin.user.edit,admin.user.update');
            }
        );
        $group->addPermission(
            'admin-user-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user.destroy')
                    ->routes('admin.user.destroy');
            }
        );
        $group->addPermission(
            'admin-user-show', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user.show')
                    ->routes('admin.user.show');
            }
        );

        $group = PermissionFacade::add(
            'user-group',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.user_group.title');
            }
        );

        $group->addPermission(
            'admin-user-group-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user_group.list')
                    ->routes('admin.user-group.index');
            }
        );
        $group->addPermission(
            'admin-user-group-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user_group.create')
                    ->routes('admin.user-group.create,admin.user-group.store');
            }
        );
        $group->addPermission(
            'admin-user-group.update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user_group.edit')
                    ->routes('admin.user-group.edit,admin.user-group.update');
            }
        );
        $group->addPermission(
            'admin-user-group-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user_group.destroy')
                    ->routes('admin.user-group.destroy');
            }
        );
        $group->addPermission(
            'admin-user-group-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.user_group.show')
                    ->routes('admin.user-group.show');
            }
        );

        $group = PermissionFacade::add(
            'admin-user',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.admin_user.title');
            }
        );

        $group->addPermission(
            'admin-admin-user-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.admin_user.list')
                    ->routes('admin.admin-user.index');
            }
        );
        $group->addPermission(
            'admin-admin-user-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.admin_user.create')
                    ->routes('admin.admin-user.create,admin.admin-user.store');
            }
        );
        $group->addPermission(
            'admin-admin-user-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.admin_user.edit')
                    ->routes('admin.admin-user.edit,admin.admin-user.update');
            }
        );
        $group->addPermission(
            'admin-admin-user-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.admin_user.destroy')
                    ->routes('admin.admin-user.destroy');
            }
        );
        $group->addPermission(
            'admin-admin-user-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.admin_user.show')
                    ->routes('admin.admin-user.show');
            }      
        );

        $group = PermissionFacade::add(
            'role',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.role.title');
            }
        );

        $group->addPermission(
            'admin-role-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.role.list')
                    ->routes('admin.role.index');
            }
        );
        $group->addPermission(
            'admin-role-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.role.create')
                    ->routes('admin.role.create,admin.role.store');
            }           
        );
        $group->addPermission(
            'admin-role-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.role.edit')
                    ->routes('admin.role.edit,admin.role.update');
            }
        );
        $group->addPermission(
            'admin-role-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.role.destroy')
                    ->routes('admin.role.destroy');
            }
        );
        $group->addPermission(
            'admin-role-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.role.show')
                    ->routes('admin.role.show');
            }
        );

        $group = PermissionFacade::add(
            'configuration',
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.configuration.title');
            }
        );

        $group->addPermission(
            'admin-configuration',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.configuration.view')
                    ->routes('admin.configuration');
            }
        );
        $group->addPermission(
            'admin-configuration-store',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.configuration.edit')
                    ->routes('admin.configuration.store');
            }    
        );

        $group = PermissionFacade::add(
            'site-currency',
            function (PermissionGroup $group) {
                $group->label('Site Currency Permissions');
            }
        );

        $group->addPermission(
            'admin-site-currency-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.site_currency.title')
                    ->routes('admin.site-currency.index');
            }
        );
        $group->addPermission(
            'admin-site-currency-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.site_currency.create')
                    ->routes('admin.site-currency.create,admin.site-currency.store');
            }
        );
        $group->addPermission(
            'admin-site-currency-update', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.site_currency.edit')
                    ->routes('admin.site-currency.edit,admin.site-currency.update');
            }
        );
        $group->addPermission(
            'admin-site-currency-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.site_currency.destroy')
                    ->routes('admin.site-currency.destroy');
            }
        );
        $group->addPermission(
            'admin-site-currency-show', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.site_currency.show')
                    ->routes('admin.site-currency.show');
            }
        );

        $group = PermissionFacade::add(
            'country', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.country.title');
            }
        );

        $group->addPermission(
            'admin-country-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.country.list')
                    ->routes('admin.country.index');
            }
        );
        $group->addPermission(
            'admin-country-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.country.create')
                    ->routes('admin.country.create,admin.country.store');
            }
        );
        $group->addPermission(
            'admin-country-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.country.edit')
                    ->routes('admin.country.edit,admin.country.update');
            }
        );
        $group->addPermission(
            'admin-country-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.country.destroy')
                    ->routes('admin.country.destroy');
            }
        );
        $group->addPermission(
            'admin-country-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.country.show')
                    ->routes('admin.country.show');
            }
        );
        $group = PermissionFacade::add(
            'language', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.language.title');
            }
        );

        $group->addPermission(
            'admin-language-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.language.list')
                    ->routes('admin.language.index');
            }
        );
        $group->addPermission(
            'admin-language-create',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.language.create')
                    ->routes('admin.language.create,admin.language.store');
            }
        );
        $group->addPermission(
            'admin-language-update',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.language.edit')
                    ->routes('admin.language.edit,admin.language.update');
            }
        );
        $group->addPermission(
            'admin-language-destroy',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.language.destroy')
                    ->routes('admin.language.destroy');
            }
        );
        $group->addPermission(
            'admin-language-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.language.show')
                    ->routes('admin.language.show');
            }
        );

        $group = PermissionFacade::add(
            'state', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.state.title');
            }
        );

        $group->addPermission(
            'admin-state-list', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.state.list')
                    ->routes('admin.state.index');
            }
        );
        $group->addPermission(
            'admin-state-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.state.create')
                    ->routes('admin.state.create,admin.state.store');
            }
        );
        $group->addPermission(
            'admin-state-update', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.state.edit')
                    ->routes('admin.state.edit,admin.state.update');
            }
        );
        $group->addPermission(
            'admin-site-currency-destroy', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.state.destroy')
                    ->routes('admin.state.destroy');
            }
        );
        $group->addPermission(
            'admin-site-currency-show',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.state.show')
                    ->routes('admin.state.show');
            }
        );

        $group = PermissionFacade::add(
            'theme', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.theme.title');
            }
        );

        $group->addPermission(
            'admin-theme-list',
            function (Permission $permission) {
                $permission->label('avored-framework::permission.theme.list')
                    ->routes('admin.theme.index');
            }
        );
        $group->addPermission(
            'admin-theme-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.theme.create')
                    ->routes('admin.create.index', 'admin.theme.store');
            }
        );
        $group->addPermission(
            'admin-theme-activated', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.theme.activated')
                    ->routes('admin.activated.index');
            }
        );
        $group->addPermission(
            'admin-theme-deactivated', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.theme.deactivated')
                    ->routes('admin.deactivated.index');
            }
        );

        $group = PermissionFacade::add(
            'module', 
            function (PermissionGroup $group) {
                $group->label('avored-framework::permission.module.title');
            }
        );

        $group->addPermission(
            'admin-module-list', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.module.list')
                    ->routes('admin.module.index');
            }
        );
        $group->addPermission(
            'admin-module-create', 
            function (Permission $permission) {
                $permission->label('avored-framework::permission.module.upload')
                    ->routes('admin.create.index', 'admin.module.store');
            }
        );

        Blade::if(
            'hasPermission', 
            function ($routeName) {
                $condition = false;
                $user = Auth::guard('admin')->user();
                if (!$user) {
                    $condition = $user->hasPermission($routeName) ?: false;
                }
                $converted_res = ($condition) ? 'true' : 'false';
                return "<?php if ($converted_res): ?>";
            }
        );
    }
531157
protected function controlOptions()
    {
        $allowed = array();

        if (!empty($this->current_route['options'])) {
            foreach (array_keys($this->current_route['options']) as $options) {
                foreach (explode(',', $options) as $option) {
                    $allowed[trim(trim($option, '-'))] = true;
                }
            }
        }

        $submitted = $this->getOptions();

        if (!empty($submitted) && !array_intersect_key($submitted, $allowed)) {
            $this->errorAndExit($this->text('Unsupported command options'));
        }
    }
1261471
def bind(cls, app, *paths, methods=None, name=None, view=None):
        """"""
        # Register self in admin
        if view is None:
            app.ps.admin.register(cls)
            if not paths:
                paths = ('%s/%s' % (app.ps.admin.cfg.prefix, name or cls.name),)
            cls.url = paths[0]
        return super(AdminHandler, cls).bind(app, *paths, methods=methods, name=name, view=view)
449436
public function pagePermissionsAction()
    {

        $view = new ViewModel();
        //fixes rendering site's header and footer in the dialog
        $view->setTerminal(true);

        /** @var \Rcm\Entity\Site $currentSite */
        $currentSite = $this->getServiceLocator()->get(
            \Rcm\Service\CurrentSite::class
        );

        $currentSiteId = $currentSite->getSiteId();

        $sourcePageName = $this->getEvent()
            ->getRouteMatch()
            ->getParam(
                'rcmPageName',
                'index'
            );

        $pageType = $this->getEvent()
            ->getRouteMatch()
            ->getParam(
                'rcmPageType',
                'n'
            );

        /** @var ResourceName $resourceName */
        $resourceName = $this->getServiceLocator()->get(
            ResourceName::class
        );

        $resourceId = $resourceName->get(
            ResourceName::RESOURCE_SITES,
            $currentSiteId,
            ResourceName::RESOURCE_PAGES,
            $pageType,
            $sourcePageName
        );

        /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */
        $aclDataService = $this->getServiceLocator()->get(
            \RcmUser\Acl\Service\AclDataService::class
        );

        //getting all set rules by resource Id
        $rules = $aclDataService->getRulesByResource($resourceId)->getData();

        //getting list of all dynamically created roles
        $allRoles = $aclDataService->getNamespacedRoles()->getData();

        $rolesHasRules = [];

        foreach ($rules as $setRuleFor) {
            //getting only the ones that are allow
            if ($setRuleFor->getRule() == 'allow') {
                $rolesHasRules[] = $setRuleFor->getRoleId();
            }
        }

        $selectedRoles = [];

        foreach ($allRoles as $key => $role) {
            $roleId = $role->getRoleId();
            if (in_array($roleId, $rolesHasRules)) {
                $selectedRoles[$roleId] = $role;
            }
        }

        $data = [
            'siteId' => $currentSiteId,
            'pageType' => $pageType,
            'pageName' => $sourcePageName,
            'roles' => $allRoles,
            'selectedRoles' => $selectedRoles,
        ];

        $view->setVariable('data', $data);

        $view->setVariable(
            'rcmPageName',
            $sourcePageName
        );
        $view->setVariable(
            'rcmPageType',
            $pageType
        );

        return $view;
    }
651394
public function revertToPagePermissions()
    {
        // this function removes all permissions records for a particular area on this page
        // and sets it to inherit from the page above
        // this function will also need to ensure that pages below it do the same

        $db = Database::connection();
        $v = array($this->getAreaHandle(), $this->getCollectionID());
        $db->executeQuery('delete from AreaPermissionAssignments where arHandle = ? and cID = ?', $v);
        $db->executeQuery('update Areas set arOverrideCollectionPermissions = 0 where arID = ?', array($this->getAreaID()));

        // now we set rescan this area to determine where it -should- be inheriting from
        $this->arOverrideCollectionPermissions = false;
        $this->rescanAreaPermissionsChain();

        $areac = $this->getAreaCollectionObject();
        if ($areac->isMasterCollection()) {
            $this->rescanSubAreaPermissionsMasterCollection($areac);
        } else {
            if ($areac->overrideTemplatePermissions()) {
                // now we scan sub areas
                $this->rescanSubAreaPermissions();
            }
        }
    }