Exemple #1
0
 public function __construct(Admin_Model_DbRow_Group $group)
 {
     parent::__construct();
     $this->addElement(new Zend_Form_Element_Hidden('id', array('value' => $group->get('id'), 'validators' => array('Int'))));
     $this->getElement('name')->setValue($group->get('name'));
     $this->getElement('description')->setValue($group->get('description'));
 }
 /**
  * Delete a Group
  * 
  * @access public
  * @todo FIXME: somehow the App_Form_Delete Form is gone, not working ATM!
  */
 public function deleteAction()
 {
     $groupRow = new Admin_Model_DbRow_Group($this->dbGroups->find($this->checkGroupIdParam()));
     $linkedUsers = $this->dbGroups->fetchUsersAssignedToGroup($groupRow->get('id'));
     $form = new App_Form_Delete($groupRow);
     //FIXME: File is gone, rewrite
     if ($linkedUsers->count() > 0) {
         $this->view->message = 'There are users linked to this group. Cannot delete!';
         $this->renderScript('error/deletenotpossible.phtml');
     } else {
         if ($this->getRequest()->isPost()) {
             if ($form->isValid($this->getRequest()->getParams()) && $form->getElement('del_checkbox')->isChecked() === TRUE) {
                 $this->dbGroups->deleteById($groupRow->get('id'));
                 $this->_redirect('admin/group/index');
             } else {
                 $form->setDescription('Failed to delete group. Unknown error occured.');
             }
         }
     }
     $this->view->form = $form;
     $this->view->group = $groupRow;
 }
 /**
  * Update the group informations in the database
  * a
  * @return array
  */
 public function saveEditGroupAction()
 {
     $params = Zend_Json_Decoder::decode($this->request->getParam('groups'));
     $groupModel = new Admin_Model_DbTable_Groups();
     $groupRow = new Admin_Model_DbRow_Group($groupModel->find($params['id']));
     $errors = array();
     if (strtolower($params['name']) !== strtolower($groupRow->get('name'))) {
         $dubGroupRow = $groupModel->fetchRowByGroupName($params['name']);
         if ($dubGroupRow) {
             $errors[] = 'The group already exists';
         }
     }
     if ($groupRow->get('id') && count($errors) === 0) {
         $groupRow->fromArray($params);
         $groupModel->update($groupRow->toDbArray(), $groupRow->get('id'));
         return $this->responseSuccess(array($groupRow->toDbArray()));
     }
     return $this->responseFailure('Error editing the group', $errors);
 }