本文整理汇总了PHP中App::isGranted方法的典型用法代码示例。如果您正苦于以下问题:PHP App::isGranted方法的具体用法?PHP App::isGranted怎么用?PHP App::isGranted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App
的用法示例。
在下文中一共展示了App::isGranted方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderLabel
protected function renderLabel(ItemInterface $item, array $options)
{
$html = '<i class="' . $item->getIcon() . '"></i> ';
$html .= '<span>' . $item->getLabel() . '</span>';
if ($item->hasChildren()) {
$drop = false;
foreach ($item->getChildren() as $child) {
if (\App::isGranted($child->getPermissions())) {
$drop = true;
}
}
if ($drop) {
$html .= '<i class="fa fa-angle-left pull-right"></i>';
}
}
return $html;
}
示例2:
<?php
if (\App::isGranted('addCategory')) {
?>
<?php
$this->load->view($modulePath . 'category/new');
}
?>
<?php
$this->load->view($modulePath . 'category/list_content');
示例3: delete
public function delete($slug)
{
if (!\App::isGranted('deleteCategory')) {
redirect('admin/dashboard');
}
try {
if (!$slug) {
throw new Exception("Error Processing Request.", 1);
}
$categoryManager = $this->container->get('post.category_manager');
$category = $categoryManager->getCategoryBySlug($slug);
if (!$category) {
throw new Exception("Category not found.", 1);
}
if ($category->getSlug() == 'uncategorized') {
throw new Exception("Illegal Operation.", 1);
}
if (count($category->getPosts()) <= 0) {
$categoryManager->removeCategory($category);
$this->session->setFlashMessage('feedback', "Post type ({$slug}) has been deleted completely.", 'success');
redirect(site_url('admin/post/category'));
} else {
$unCategory = $categoryManager->getCategoryBySlug('uncategorized');
$posts = $category->getPosts();
foreach ($posts as $post) {
$post->addCategory($unCategory);
}
$categoryManager->removeCategory($category);
$this->doctrine->em->flush();
$this->session->setFlashMessage('feedback', "Post type ({$slug}) has been deleted completely.", 'success');
redirect(site_url('admin/post/category'));
}
} catch (\Exception $e) {
$this->session->setFlashMessage('feedback', "Unable to delete category: {$e->getMessage()}", 'error');
redirect(site_url('admin/post/category'));
}
}
示例4: count
echo $count;
?>
.</td>
<td><?php
echo $cat->getName();
?>
</td>
<td><?php
echo $cat->getPosts() ? count($cat->getPosts()) : 0;
?>
</td>
<td><?php
if (\App::isGranted('editCategory')) {
echo action_button('edit', site_url('admin/post/category/edit/' . $cat->getSlug()), array('title' => 'Edit ' . $cat->getName())) . " ";
}
if (\App::isGranted('deleteCategory')) {
echo action_button('delete', site_url('admin/post/category/delete/' . $cat->getSlug()), array('title' => 'Delete ' . $cat->getName()));
}
?>
</td>
</tr>
<?php
}
}
?>
<?php
if ($count == 0) {
?>
<tr>
<td colspan="6" style="text-align: center;">
<strong>No Category found!</strong>
示例5: delete
public function delete($slug = null)
{
if (!\App::isGranted('deletePost')) {
redirect('admin/dashboard');
}
try {
if (!$slug) {
throw new Exception("Error processing request.", 1);
}
$postManager = $this->container->get('post.post_manager');
$post = $postManager->getPostBySlug($slug);
if (!$post) {
throw new Exception("Post not found.", 1);
}
if (!$post->isTrashed()) {
throw new Exception("Post cannot be deleted permanently from this state.", 1);
}
$title = $post->getTitle();
$postManager->removePost($post);
$this->session->setFlashMessage('feedback', "Post ({$title}) has been deleted permanently.", 'success');
redirect(site_url('admin/post'));
} catch (Exception $e) {
$this->session->setFlashMessage('feedback', "Unable to delete post: {$e->getMessage()}", 'error');
redirect(site_url('admin/post'));
}
}
示例6:
<?php
if (\App::isGranted('addPage')) {
?>
<!-- Main content -->
<section class="content-header">
<span><a href="<?php
echo site_url('admin/page/add');
?>
" class="btn btn-primary">Add Page</a></span>
</section>
<?php
}
?>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box box-solid box-mag">
<div class="box-header with-border">
<h3 class="box-title">List of Pages</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#published" data-toggle="tab"><strong>Published</strong></a></li>
<li><a href="#draft" data-toggle="tab"><strong>Draft</strong></a></li>
<li><a href="#trash" data-toggle="tab"><strong>Trash</strong></a></li>
<li><a href="#all" data-toggle="tab"><strong>All</strong></a></li>
</ul>
<div class="tab-content">
示例7: action_button
}
break;
case post\models\Post::STATUS_DRAFT:
if (\App::isGranted('editPost')) {
echo action_button('edit', site_url('admin/post/edit/' . $post->getSlug()), array('title' => 'Edit ' . $post->getTitle())) . " ";
echo action_button('publish', site_url('admin/post/publish/' . $post->getSlug()), array('title' => 'Publish ' . $post->getTitle())) . " ";
}
if (\App::isGranted('deletePost')) {
echo action_button('delete', site_url('admin/post/delete/' . $post->getSlug()), array('title' => 'Delete ' . $post->getTitle() . ' permanently!')) . " ";
}
break;
case post\models\Post::STATUS_TRASH:
if (\App::isGranted('editPost')) {
echo action_button('restore', site_url('admin/post/restore/' . $post->getSlug()), array('title' => 'Restore ' . $post->getTitle())) . " ";
}
if (\App::isGranted('deletePost')) {
echo action_button('delete', site_url('admin/post/delete/' . $post->getSlug()), array('title' => 'Delete ' . $post->getTitle() . ' permanently!')) . " ";
}
break;
}
?>
</td>
</tr>
<?php
}
?>
<?php
if ($list == 0) {
?>
<tr>
示例8:
<?php
if (\App::isGranted('addUser')) {
?>
<!-- Main content -->
<section class="content-header">
<span><a href="<?php
echo site_url('admin/user/add');
?>
" class="btn btn-primary">Add User</a></span>
</section>
<?php
}
?>
<section class="content">
<div class="row">
<div class="col-xs-12">
<div class="box box-solid box-mag">
<div class="box-header with-border">
<h3 class="box-title">List of Users</h3>
</div><!-- /.box-header -->
<div class="box-body">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#active" data-toggle="tab"><strong>Active</strong></a></li>
<li><a href="#trash" data-toggle="tab"><strong>Trash</strong></a></li>
<li><a href="#all" data-toggle="tab"><strong>All</strong></a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="active">
示例9: count
echo $count;
?>
.</td>
<td><?php
echo $pt->getName();
?>
</td>
<td><?php
echo $pt->getPosts() ? count($pt->getPosts()) : 0;
?>
</td>
<td><?php
if (\App::isGranted('editPostType')) {
echo action_button('edit', site_url('admin/post/type/edit/' . $pt->getSlug()), array('title' => 'Edit ' . $pt->getName())) . " ";
}
if (\App::isGranted('deletePostType')) {
echo action_button('delete', site_url('admin/post/type/delete/' . $pt->getSlug()), array('title' => 'Delete ' . $pt->getName()));
}
?>
</td>
</tr>
<?php
}
}
?>
<?php
if ($count == 0) {
?>
<tr>
<td colspan="6" style="text-align: center;">
<strong>No Post Types found!</strong>
示例10: permissions
public function permissions($slug)
{
if (!\App::isGranted('moderatePermission')) {
redirect('admin/dashboard');
}
try {
if (!$slug) {
throw new Exception("Error Processing Request.", 1);
}
$groupManager = $this->container->get('user.group_manager');
$permManager = $this->container->get('user.permission_manager');
$group = $groupManager->getGroupBySlug($slug);
if (!$group) {
throw new Exception("Group not found.", 1);
}
//retrict if trying to assign permission of super admin group
if (\App::isSuperGroup($group)) {
redirect('admin/dashboard');
}
$groupPermissions = $group->getPermissions();
$dbPermissions = array();
foreach ($groupPermissions as $p) {
$dbPermissions[] = $p->getId();
}
$permissions = $permManager->getPermissions();
$allPermissions = array();
foreach ($permissions as $p) {
$module = $p->getModule();
$allPermissions[$module][] = array('id' => $p->getId(), 'name' => $p->getName(), 'description' => $p->getDescription());
}
if ($this->input->post()) {
$assignedPermissions = $this->input->post('assigned_permissions');
if (count($assignedPermissions) <= 0) {
$this->session->setFlashMessage('feedback', "At least one permission is required.", 'error');
redirect(current_url());
}
// first remove all old permissions
$group->resetPermissions();
foreach ($assignedPermissions as $p) {
$perm = $permManager->getPermissionById($p);
$group->addPermission($perm);
}
$groupManager->updateGroup($group);
$this->session->setFlashMessage('feedback', "Group ({$slug}) permission has been set successfully.", 'success');
redirect(site_url('admin/user/group'));
}
$this->breadcrumbs->push('Permissions', current_url());
$this->templateData['pageTitle'] = 'Group Permissions';
$this->templateData['group'] = $group;
$this->templateData['dbPermissions'] = $dbPermissions;
$this->templateData['allPermissions'] = $allPermissions;
$this->templateData['content'] = 'group/permissions';
$this->load->view('backend/main_layout', $this->templateData);
} catch (\Exception $e) {
$this->session->setFlashMessage('feedback', "Unable to assign group permissions: {$e->getMessage()}", 'error');
redirect(site_url('admin/user/group'));
}
}
示例11: delete
public function delete($slug)
{
if (!\App::isGranted('deletePostType')) {
redirect('admin/dashboard');
}
try {
if (!$slug) {
throw new Exception("Error Processing Request.", 1);
}
$postTypeManager = $this->container->get('post.post_type_manager');
$postType = $postTypeManager->getPostTypeBySlug($slug);
if (!$postType) {
throw new Exception("Post Type not found.", 1);
}
if ($postType->getSlug() == 'general') {
throw new Exception("Illegal Operation.", 1);
}
if (count($postType->getPosts()) <= 0) {
$postTypeManager->removePostType($postType);
$this->session->setFlashMessage('feedback', "Post type ({$slug}) has been deleted completely.", 'success');
redirect(site_url('admin/post/type'));
}
if ($this->input->post()) {
$this->form_validation->set_rules('newPostType', 'New Post Type', 'required|trim|numeric');
if ($this->form_validation->run($this)) {
$newPostType = $postTypeManager->getPostTypeById($this->input->post('newPostType'));
if (!$newPostType) {
throw new Exception("Illegal operation.", 1);
}
if ($newPostType->getSlug() == $postType->getSlug()) {
throw new Exception("Illegal operation.", 1);
}
$posts = $postType->getPosts();
foreach ($posts as $post) {
$post->setPostType($newPostType);
}
$postTypeManager->removePostType($postType);
$this->doctrine->em->flush();
$this->session->setFlashMessage('feedback', "Post type ({$slug}) has been deleted completely.", 'success');
redirect(site_url('admin/post/type'));
}
}
$this->breadcrumbs->push('Delete', current_url());
$this->templateData['pageTitle'] = 'Delete Post Type';
$this->templateData['postType'] = $postType;
$this->templateData['content'] = 'post/type/delete';
$this->load->view('backend/main_layout', $this->templateData);
} catch (\Exception $e) {
$this->session->setFlashMessage('feedback', "Unable to delete post type: {$e->getMessage()}", 'error');
redirect(site_url('admin/post/type'));
}
}
示例12: action_button
echo action_button('block', site_url('admin/user/block/' . $user->getUsername()), array('title' => 'Block ' . $user->getUsername())) . " ";
}
if (\App::isGranted('deleteUser')) {
echo action_button('trash', site_url('admin/user/trash/' . $user->getUsername()), array('title' => 'Delete ' . $user->getUsername())) . " ";
}
break;
case user\models\User::STATUS_BLOCK:
if (\App::isGranted('editUser')) {
echo action_button('unblock', site_url('admin/user/unblock/' . $user->getUsername()), array('title' => 'Unblock ' . $user->getUsername())) . " ";
}
break;
case user\models\User::STATUS_TRASH:
if (\App::isGranted('editUser')) {
echo action_button('restore', site_url('admin/user/activate/' . $user->getUsername()), array('title' => 'Restore ' . $user->getUsername())) . " ";
}
if (\App::isGranted('deleteUser')) {
echo action_button('delete', site_url('admin/user/delete/' . $user->getUsername()), array('title' => 'Delete ' . $user->getUsername() . ' permanently!')) . " ";
}
break;
}
}
?>
</td>
</tr>
<?php
}
?>
<?php
if ($list == 0) {
?>
示例13: resetPassword
public function resetPassword($username)
{
if (!\App::isGranted('resetPassword')) {
redirect('admin/dashboard');
}
try {
if (!$username) {
throw new Exception("Error Processing Request.", 1);
}
$userManager = $this->container->get('user.user_manager');
$user = $userManager->getUserByUsername($username);
if (!$user) {
throw new Exception("User not found.", 1);
}
//retrict if trying to edit super user
if (\App::isSuperUser($user, false)) {
redirect('admin/dashboard');
}
if (!$user->isActive()) {
throw new Exception("User is currently disabled.", 1);
}
if ($this->input->post()) {
$ruleManager = $this->container->get('user.rule_manager');
$this->form_validation->set_rules($ruleManager->getRules(array('password', 'confPassword')));
if ($this->form_validation->run($this)) {
$user->setPassword(password_hash($this->input->post('password'), PASSWORD_BCRYPT));
$userManager->updateUser($user);
$this->session->setFlashMessage('feedback', "User ({$user->getUsername()}) password has been reset.", 'success');
redirect(site_url('admin/user'));
}
}
$this->breadcrumbs->push('Reset Password', current_url());
$this->templateData['pageTitle'] = 'Reset Password';
$this->templateData['user'] = $user;
$this->templateData['content'] = 'user/reset_password';
$this->load->view('backend/main_layout', $this->templateData);
} catch (\Exception $e) {
$this->session->setFlashMessage('feedback', "Unable to reset password: {$e->getMessage()}", 'error');
redirect(site_url('admin/user'));
}
}
示例14: action_button
}
break;
case page\models\Page::STATUS_DRAFT:
if (\App::isGranted('editPage')) {
echo action_button('edit', site_url('admin/page/edit/' . $page->getSlug()), array('title' => 'Edit ' . $page->getTitle())) . " ";
echo action_button('publish', site_url('admin/page/publish/' . $page->getSlug()), array('title' => 'Publish ' . $page->getTitle())) . " ";
}
if (\App::isGranted('deletePage')) {
echo action_button('delete', site_url('admin/page/delete/' . $page->getSlug()), array('title' => 'Delete ' . $page->getTitle() . ' permanently!')) . " ";
}
break;
case page\models\Page::STATUS_TRASH:
if (\App::isGranted('editPage')) {
echo action_button('restore', site_url('admin/page/restore/' . $page->getSlug()), array('title' => 'Restore ' . $page->getTitle())) . " ";
}
if (\App::isGranted('deletePage')) {
echo action_button('delete', site_url('admin/page/delete/' . $page->getSlug()), array('title' => 'Delete ' . $page->getTitle() . ' permanently!')) . " ";
}
break;
}
?>
</td>
</tr>
<?php
}
?>
<?php
if ($list == 0) {
?>
<tr>