Esempio n. 1
0
File: Role.php Progetto: valizr/MMA
 public function save(Default_Model_Role $value)
 {
     $auth = Zend_Auth::getInstance();
     $authAccount = $auth->getStorage()->read();
     if (null != $authAccount) {
         if (null != $authAccount->getId()) {
             $user = new Default_Model_Users();
             $user->find($authAccount->getId());
             $data = array('id' => $value->getId(), 'idParent' => $value->getIdParent(), 'name' => $value->getName(), 'isAdmin' => $value->getIsAdmin(), 'deleted' => $value->getDeleted() != NULL ? $value->getDeleted() : 0);
             if (null === ($id = $value->getId())) {
                 $data['created'] = new Zend_Db_Expr('NOW()');
                 $id = $this->getDbTable()->insert($data);
             } else {
                 $data['modified'] = new Zend_Db_Expr('NOW()');
                 $this->getDbTable()->update($data, array('id = ?' => $id));
             }
             return $id;
         }
     }
 }
Esempio n. 2
0
File: Role.php Progetto: valizr/MMA
 function edit(Default_Model_Role $model)
 {
     $this->name->setValue($model->getName());
     $this->submit->setValue('Modificare');
 }
Esempio n. 3
0
File: Tools.php Progetto: valizr/MMA
 public static function getLevelById($levelId)
 {
     $model = new Default_Model_Role();
     $model->find($levelId);
     return $model->getName();
 }
Esempio n. 4
0
 public function editAction()
 {
     //		//check if the auth user has acces to this modul
     //		if(!Needs_Tools::hasAccess(Zend_Registry::get('user')->getRoleId(),'editare_rol')){
     //			$this->_redirect('/');
     //		}
     $id = $this->getRequest()->getParam('id');
     //
     //		//check if user can edit 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)) {
         //parent
         $modelParinte = new Default_Model_Role();
         if (!$modelParinte->find($model->getIdParent())) {
             $this->_redirect('/role');
         }
         $form = new Default_Form_Role();
         $form->parentName->setValue($modelParinte->getName());
         $form->edit($model);
         $form->setDecorators(array('ViewScript', array('ViewScript', array('viewScript' => 'forms/role/adaugare.phtml'))));
         $this->view->form = $form;
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getPost())) {
                 //save
                 $model->setOptions($form->getValues());
                 if ($model->save()) {
                     $this->_flashMessenger->addMessage("<div class='success canhide'><p>Rolul a fost editat cu succes.</p><a href='javascript:;'></a></div>");
                 } else {
                     $this->_flashMessenger->addMessage("<div class='failure canhide'><p>S-a produs o eroare in editarea rolului. Nu s-a efectuat nici o modificare</p><a href='javascript:;'></a></div>");
                 }
                 $this->_redirect('/role');
             }
         }
     }
 }