1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
| abstract class My_Controller_Action extends Zend_Controller_Action
{
protected $_connectedUser;
protected $_nameSpace;
protected $_dbTableTag;
protected $_dbTableTypeTag;
protected $_dbTableImg;
protected $_dbTableUser;
protected $_dbTableComment;
public function init()
{
$this->_dbTableImg = new Application_Model_DbTable_Img();
$this->_dbTableUser = new Application_Model_DbTable_User();
$this->_dbTableTag = new Application_Model_DbTable_Tag();
$this->_dbTableTypeTag = new Application_Model_DbTable_TypeTag();
$this->_dbTableComment = new Application_Model_DbTable_Comment();
/**
* Creation d'un objet connectedUser si l'utilisateur est connecté
* Envoi à la vue d'un tableau representant l'utilisateur regardant (viewer)
*/
$this->_nameSpace = new Zend_Session_Namespace('xBoard');
if(isset($this->_nameSpace->user)){
try{
$this->_connectedUser = $this->_dbTableUser->findUserById($this->_nameSpace->user);
if(is_null($this->_connectedUser)){
throw new Exception("Utilisateur introuvable");
}
// Récupération d'un viewer
$this->view->viewer = array(); // Pou rle modifier plus tard
$this->view->viewer = array(
'id' => $this->_connectedUser->getId(),
'preferences' => array(
'showPersonalData' => (bool)$this->_connectedUser->getPreferences('showPersonalData')
),
'access' => array(
'name' => $this->_connectedUser->getAccess()->getName(),
'tag_remove' => $this->_connectedUser->getAccess()->tagRemove(),
'typeTag_remove' => $this->_connectedUser->getAccess()->typeTagRemove(),
'typeTag_edit' => $this->_connectedUser->getAccess()->typeTagEdit(),
'tag_edit' => $this->_connectedUser->getAccess()->tagEdit(),
'user_edit' => $this->_connectedUser->getAccess()->userEdit(),
'user_remove' => $this->_connectedUser->getAccess()->userRemove()
),
);
}
catch(Exception $e){
unset($this->_nameSpace->user);
$this->_nameSpace->error = $e->getMessage();
$this->_helper->redirector('index', 'img');
}
}
etc... |
Partager