예제 #1
1
 /**
  * Change the active status of a flag on development
  *
  * @access public
  * @return void
  */
 public function toggledevAction()
 {
     $id = $this->getRequest()->getParam('id');
     $flagModel = new Flag();
     $flagModel->toggleFlag($id, APP_STATE_DEVELOPMENT);
     App_FlagFlippers_Manager::save();
     $this->_redirect('/flags/');
 }
예제 #2
0
 /**
  * delete url rewriting 
  * @author EL GUENNUNI Sohaib s.elguennuni@gmail.com
  * @param 
  * @return 
  */
 public function deleteAction()
 {
     $this->title = 'Delete url';
     $form = new DeleteForm();
     $urlModel = new UrlAlias();
     if ($this->getRequest()->isPost()) {
         $urlModel->deleteById($this->_getParam('id'));
         $this->_helper->FlashMessenger(array('msg-success' => 'The url was successfully deleted.'));
         //Regenerate Flag and Flippers
         App_FlagFlippers_Manager::save();
         $this->_redirect('/url/');
     } else {
         $id = $this->_getParam('id');
         $row = $urlModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-warning' => sprintf('We cannot find url with id %s', $id)));
             $this->_redirect('/url/');
         }
         $form->populate($row->toArray());
         $this->view->item = $row;
     }
     $this->view->form = $form;
 }
 /**
  * Allows users to logically delete other users
  * (should be reserved for administrators)
  *
  * @access public
  * @return void
  */
 public function deleteAction()
 {
     $this->title = 'Delete this user';
     $form = new DeleteForm();
     $userModel = new BackofficeUser();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $userModel->deleteById($form->getValue('id'));
             $this->_helper->FlashMessenger(array('msg-success' => 'The item was successfully deleted.'));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/users/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The id you provided is invalid.'));
             $this->_redirect('/users/');
         }
         if ($id == 1) {
             $this->_helper->FlashMessenger(array('msg-error' => 'It is forbidden to mess with the admin account in this release.'));
             $this->_redirect('/users/');
         }
         $row = $userModel->findById($id);
         if (empty($row)) {
             $this->_helper->FlashMessenger(array('msg-error' => 'The requested item cannot be found.'));
             $this->_redirect('/users/');
         }
         $this->view->item = $row;
         $form->populate($row->toArray());
     }
     $this->view->form = $form;
 }
예제 #4
0
 /**
  * Allows the user to manage individual permissions for each
  * user group
  *
  * @access public
  * @return void
  */
 public function flippersAction()
 {
     $this->title = 'Manage permissions for this group.';
     $form = new GroupPermissionsForm();
     $fliperModel = new Flipper();
     $groupModel = new Group();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($this->getRequest()->getPost())) {
             $fliperModel->savePermissions($form->getValues());
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('Permissions for group %s were successfully updated.', $group['name'])));
             App_FlagFlippers_Manager::save();
             $this->_redirect('/groups/');
         }
     } else {
         $id = $this->_getParam('id');
         if (!is_numeric($id)) {
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('We cannot find group with id %s', $id)));
             $this->_redirect('/groups/');
         }
         $group = $groupModel->findById($id);
         $flipper = $fliperModel->findByGroupId($id);
         if (empty($group)) {
             $this->_helper->FlashMessenger(array('msg-success' => sprintf('The permissions for the group %s were updated.', $form->getValue('name'))));
             $this->_redirect('/groups/');
         }
         $form->populate($flipper->toArray(), $id);
         $this->view->item = $group;
     }
     $this->view->form = $form;
 }