Esempio n. 1
0
 /**
  * Edits an existing privilege
  *
  * @access public
  * @return void
  */
 public function editAction()
 {
     $this->title = 'Edit privilege';
     $form = new PrivilegeForm();
     $privilegeModel = new Privilege();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $privilegeModel->save($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => 'The privilege was successfully edited.'));
             //Regenerate Flag and Flippers
             App_FlagFlippers_Manager::save();
             $this->_redirect('/privileges/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The provided privilege_id is invalid.'));
             $this->_redirect('/privileges/');
         }
         $row = $privilegeModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => 'The requested privilege could not be found.'));
             $this->_redirect('/privileges/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
Esempio n. 2
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Privilege();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Privilege'])) {
         $model->attributes = $_POST['Privilege'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->ID_PRIVILEGE));
         }
     }
     $this->render('create', array('model' => $model));
 }