Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
<?php

if (\App::isGranted('addCategory')) {
    ?>
	<?php 
    $this->load->view($modulePath . 'category/new');
}
?>

<?php 
$this->load->view($modulePath . 'category/list_content');
Ejemplo n.º 3
0
<?php

if (\App::isGranted('addPostType')) {
    ?>
	<?php 
    $this->load->view($modulePath . 'post/type/new');
}
?>

<?php 
$this->load->view($modulePath . 'post/type/list_content');
Ejemplo n.º 4
0
 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'));
     }
 }
Ejemplo n.º 5
0
        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())) . "&emsp;";
        }
        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>
Ejemplo n.º 6
0
 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'));
     }
 }
Ejemplo n.º 7
0
<?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">
Ejemplo n.º 8
0
            }
            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())) . "&emsp;";
                echo action_button('publish', site_url('admin/post/publish/' . $post->getSlug()), array('title' => 'Publish ' . $post->getTitle())) . "&emsp;";
            }
            if (\App::isGranted('deletePost')) {
                echo action_button('delete', site_url('admin/post/delete/' . $post->getSlug()), array('title' => 'Delete ' . $post->getTitle() . ' permanently!')) . "&emsp;";
            }
            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())) . "&emsp;";
            }
            if (\App::isGranted('deletePost')) {
                echo action_button('delete', site_url('admin/post/delete/' . $post->getSlug()), array('title' => 'Delete ' . $post->getTitle() . ' permanently!')) . "&emsp;";
            }
            break;
    }
    ?>
					</td>
				</tr>
		    <?php 
}
?>

		    <?php 
if ($list == 0) {
    ?>
		    <tr>
Ejemplo n.º 9
0
<?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">
Ejemplo n.º 10
0
        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())) . "&emsp;";
        }
        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>
Ejemplo n.º 11
0
 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'));
     }
 }
Ejemplo n.º 12
0
<?php

if (\App::isGranted('manageUserGroup')) {
    ?>
	<?php 
    $this->load->view($modulePath . 'group/new');
}
?>

<?php 
$this->load->view($modulePath . 'group/list_content');
Ejemplo n.º 13
0
 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'));
     }
 }
Ejemplo n.º 14
0
                    echo action_button('block', site_url('admin/user/block/' . $user->getUsername()), array('title' => 'Block ' . $user->getUsername())) . "&emsp;";
                }
                if (\App::isGranted('deleteUser')) {
                    echo action_button('trash', site_url('admin/user/trash/' . $user->getUsername()), array('title' => 'Delete ' . $user->getUsername())) . "&emsp;";
                }
                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())) . "&emsp;";
                }
                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())) . "&emsp;";
                }
                if (\App::isGranted('deleteUser')) {
                    echo action_button('delete', site_url('admin/user/delete/' . $user->getUsername()), array('title' => 'Delete ' . $user->getUsername() . ' permanently!')) . "&emsp;";
                }
                break;
        }
    }
    ?>
					</td>
				</tr>
		    <?php 
}
?>

		    <?php 
if ($list == 0) {
    ?>
Ejemplo n.º 15
0
<?php

if (\App::isGranted('addPost')) {
    ?>
<!-- Main content -->
<section class="content-header">
		<span><a href="<?php 
    echo site_url('admin/post/add');
    ?>
" class="btn btn-primary">Add Post</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 Posts</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">
Ejemplo n.º 16
0
 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'));
     }
 }
Ejemplo n.º 17
0
            }
            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())) . "&emsp;";
                echo action_button('publish', site_url('admin/page/publish/' . $page->getSlug()), array('title' => 'Publish ' . $page->getTitle())) . "&emsp;";
            }
            if (\App::isGranted('deletePage')) {
                echo action_button('delete', site_url('admin/page/delete/' . $page->getSlug()), array('title' => 'Delete ' . $page->getTitle() . ' permanently!')) . "&emsp;";
            }
            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())) . "&emsp;";
            }
            if (\App::isGranted('deletePage')) {
                echo action_button('delete', site_url('admin/page/delete/' . $page->getSlug()), array('title' => 'Delete ' . $page->getTitle() . ' permanently!')) . "&emsp;";
            }
            break;
    }
    ?>
					</td>
				</tr>
		    <?php 
}
?>

		    <?php 
if ($list == 0) {
    ?>
		    <tr>