コード例 #1
0
ファイル: RoleController.php プロジェクト: valizr/MMA
 public function deleteAction()
 {
     //		//check if the auth user has acces to this modul
     //		if(!Needs_Tools::hasAccess(Zend_Registry::get('user')->getRoleId(),'stergere_rol')){
     //			$this->_redirect('/');
     //		}
     //
     $id = $this->getRequest()->getParam('id');
     //		//check if user can delete this role (if it's his role child role)
     //		if(!Needs_Tools::checkIfSubRole(Zend_Registry::get('user')->getRoleId(),$id)){
     //			$this->_redirect('/');
     //		}
     $model = new Default_Model_Role();
     if ($model->find($id)) {
         //all sub childs goes a level up
         $parentId = $model->getIdParent();
         $graph = new Needs_Graph($model, false, array('idParent', 'id'), 'array', true);
         if ($graph->moveChildren($parentId)) {
             //TODO:fallback if couldn't delete children
         }
         if ($model->delete()) {
             $this->_flashMessenger->addMessage("<div class='success canhide'><p>Rolul a fost sters cu succes.</p><a href='javascript:;'></a></div>");
         } else {
             $this->_flashMessenger->addMessage("<div class='failure canhide'><p>S-a produs o eroare in stergerea rolului. Nu s-a efectuat nici o modificare</p><a href='javascript:;'></a></div>");
         }
     }
     $this->_redirect(WEBROOT . 'role');
 }