<?php

/**
 * LayoutController - handles generation of minor website parts
 * 
 * @author Lukáš Havlíček
 * @version 1.0
 */
class LayoutController extends Zend_Controller_Action 
{
	
    public function messagesMenuAction() 
    {
    	$this->view->leftmenu = (int) $this->_getParam('leftmenu');
		$this->render();
    }
    
    public function documentsMenuAction() 
    {
    	$rights = new Rights();
		$user = Zend_Registry::get('user');
		$categoryList = $rights->getCategoryRights($user->id_user, $user->super_admin);
		
		$this->view->rights = $categoryList;
    	
    	
		$contains = array();
		foreach ($categoryList as $i) {
			if ($i['read']) {
				$contains[] = $i['id_category'];
			}
		}
		
		if ($user->super_admin) {
			$contains = null;
		}
		
		
    	$table = new Categoryies();
		$this->view->data = $table->getMenu(null, $contains);
		
    	$this->view->leftmenu = (int) $this->_getParam('leftmenu');
    }
    
    public function loggedUserAction() 
    {
        $auth = Zend_Auth::getInstance()->setStorage(new Zend_Auth_Storage_Session('iso'));
        $user = $auth->getIdentity();
		
		$users = new Users();
		$row = $users->fetchRow($users->select()->where('id_user = ?', $user->id_user));
		
		if ($row) {
            $this->view->user = $row;
        }
        
        $this->render();
    }
    
    public function confirmationsMenuAction() 
    {
        $this->render();
    }
}
