예제 #1
0
파일: Role.php 프로젝트: josmel/movistar
 public function init()
 {
     $roleDt = new Application_Model_DbTable_Role();
     $primaryKey = $roleDt->getPrimaryKey();
     $this->setMethod('post');
     $this->setEnctype('multipart/form-data');
     $this->setAttrib('idrol', $primaryKey);
     $this->setAction('/admin/role/edit');
     $objType2 = new Admin_Model_Acl();
     $objfea = new Admin_Model_AclRole();
     $e = new Zend_Form_Element_Hidden($primaryKey);
     $this->addElement($e);
     $e = new Zend_Form_Element_MultiCheckbox('idacl');
     $e->setMultiOptions($objType2->getGreatAll());
     if ($this->_idrol !== null) {
         $ma = $objfea->getRoleAcl($this->_idrol);
         $idsgreat = array();
         foreach ($ma as $resulta) {
             $idsgreat[] = $resulta['idacl'];
         }
         $e->setValue($idsgreat);
         $role = new Admin_Model_Role();
         $b = $role->getRoleId($this->_idrol);
     }
     $this->addElement($e);
     $e = new Zend_Form_Element_Text('name');
     $e->setAttrib('class', 'inpt-medium');
     $e->setAttrib('placeholder', 'Nombre');
     $this->addElement($e);
     $e = new Zend_Form_Element_Checkbox('state');
     $e->setValue(true);
     $this->addElement($e);
     foreach ($this->getElements() as $element) {
         $element->removeDecorator('Label');
         $element->removeDecorator('DtDdWrapper');
         $element->removeDecorator('HtmlTag');
     }
 }
예제 #2
0
 public function deleteAction()
 {
     $this->_helper->layout()->disableLayout();
     $this->_helper->viewRenderer->setNoRender(true);
     $id = $this->getParam('id');
     $rpta = array();
     if (!empty($id)) {
         try {
             $aclRole = new Admin_Model_Users();
             $da = $aclRole->getUserRoles($id);
             if (count($da) == 0) {
                 $aclRole = new Admin_Model_AclRole();
                 $aclRole->deletRole($id);
                 $obj = new Application_Entity_RunSql('Role');
                 $obj->erase = $id;
                 $rpta['msj'] = 'ok';
             } else {
                 //                    $msg = "El rol esta siendo utilizado por usuarios activos";
                 //                    $this->_flashMessenger->success($msg);
                 //                    $this->_redirect('/admin/role');
                 $rpta['msj'] = 'El rol esta siendo utilizado por usuarios activos';
             }
         } catch (Exception $e) {
             $rpta['msj'] = $e->getMessage();
         }
     } else {
         $rpta['msj'] = 'faltan datos';
     }
     $this->getResponse()->setHttpResponseCode(200)->setHeader('Content-type', 'application/json; charset=UTF-8', true)->appendBody(json_encode($rpta));
 }