Пример #1
0
 /**
  * EditAction for Users
  *
  * @return void
  */
 public function editAction()
 {
     $this->view->title = "Edit Users";
     $form = new User_Form_User();
     $form->submit->setLabel('Save');
     $form->removeElement('password');
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $model = new User_Model_Users();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             return $this->_helper->redirector('index');
         } else {
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         $id = $this->_getParam('id', 0);
         if ($id > 0) {
             $model = new User_Model_Users();
             $form->populate($model->fetchEntry($id));
         }
     }
     $this->view->form = $form;
 }
Пример #2
0
 /**
  * Delete entries
  * 
  * @param  array|string $where SQL WHERE clause(s)
  * @return int|string
  */
 public function delete($id)
 {
     $table = $this->getTable();
     // Get the parent_role from the role will delete
     $role = $this->fetchEntry($id);
     //Zend_Debug::dump($role["role_parent"], "rol que eliminamos");
     //find the roles have the parent role of the role will delete
     $rolsongs = $this->fetchParentRoles($id);
     // Zend_Debug::dump($rolsongs["0"]["id"], "el hijo del rol que eliminaremos");
     //chance the parent_role of the songs
     foreach ($rolsongs as $value) {
         $data["role_parent"] = (int) $role["role_parent"];
         $data["id"] = $value["id"];
         $this->update($data, 'id =' . (int) $value["id"]);
     }
     //find the users with the role will delete
     $users = new User_Model_Users();
     $users->getTable();
     $arrayusers = $users->fetchUsers($id);
     //Zend_Debug::dump($arrayusers,"users with role will delete");
     // chance the role to the users
     foreach ($arrayusers as $value) {
         $data["role_id"] = (int) $rolsongs["0"]["id"];
         $data["id"] = $value["id"];
         Zend_Debug::dump($data, "data1");
         $users->update($data, 'id =' . (int) $value["id"]);
     }
     $table->delete('id =' . (int) $id);
 }
Пример #3
0
 /**
  * EditAction for Users
  *
  * @return void
  */
 public function editownuserAction()
 {
     $this->view->title = "Edit Users";
     $form = new User_Form_User();
     $form->submit->setLabel('Save');
     $form->removeElement('password');
     $form->removeElement('company_id');
     $id = $_SESSION["gpms"]["storage"]->id;
     $this->gpms = new Zend_Session_Namespace('gpms');
     //TODO pasar el role implementador y administrador sin hardcode
     //si es un usuario sin permiso solo puede editar su usuario y no su role_id
     $form->removeElement('role_id');
     $id = $this->gpms->storage->id;
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $model = new User_Model_Users();
             $id = $this->getRequest()->getPost('id');
             $model->update($form->getValues(), 'id = ' . (int) $id);
             $this->_helper->redirector('index', 'company', 'company');
         } else {
             $form->populate($this->getRequest()->getPost());
         }
     } else {
         if ($id > 0) {
             $model = new User_Model_Users();
             $data = $model->fetchEntry($id);
             if ($model->haveContact($id)) {
                 $form->removeElement('add_contact');
             }
             $form->populate($data);
         }
     }
     $this->view->form = $form;
 }