<?php

class Admin_IndexController extends Fiktiv_Controller_Action
{
    public function  preDispatch() {

        $acl = Zend_Registry::get('Zend_Acl');
        $auth = Zend_Auth::getInstance();

        if (!$auth->hasIdentity() || !$acl->isAllowed($auth->getIdentity()->userRole, 'admin', 'read')) {

            $this->_redirect('/');
            exit;
        }
    }

    public function indexAction()
    {
        $posts = new ModelBlogPost();
        $this->view->posts = $posts->fetchAll();
    }
}