Exemple #1
0
 /**
  * Handle submission of the edit form.  This primarily exists (rather
  * than using the stock Edit->process()) for the password hashing.
  *
  * @todo Find a better way to handle the password hashing.
  *
  * @param ResponseHelper $responseHelper
  * @return void
  */
 public function process(ResponseHelper $responseHelper)
 {
     if ($this->request->isPost()) {
         $this->invalidSubmission = !$this->rowEditor->isValid($this->request->getPost());
         if (!$this->invalidSubmission) {
             $title = strtolower($this->model->getSingularTitle());
             /* @var $row \Dewdrop\Auth\Db\UserRowGateway */
             $row = $this->rowEditor->getRow($this->model->getTableName());
             if ($this->isNew) {
                 $row->hashPassword($this->request->getPost('password'));
                 $responseHelper->setSuccessMessage("Successfully saved new {$title}");
             } else {
                 $responseHelper->setSuccessMessage("Successfully saved changes to {$title}");
             }
             $row->save();
             if (!$this->request->isAjax()) {
                 $responseHelper->redirectToAdminPage('index');
             } else {
                 header('Content-Type: application/json');
                 echo json_encode(['result' => 'success', 'id' => $this->component->getListing()->getPrimaryKey()->getValue()]);
                 exit;
             }
         }
     }
 }
 /**
  * Grab the selected visible columns from POST and save them back to
  * the visibility filter.
  *
  * @param ResponseHelper $responseHelper
  */
 public function process(ResponseHelper $responseHelper)
 {
     $this->component->getPermissions()->haltIfNotAllowed('adjust-columns');
     $selections = $this->request->getPost('visible_columns');
     $applyToAllUsers = (bool) $this->request->getPost('apply_to_all_users', false);
     if (is_array($selections)) {
         /* @var $filter VisibilityFilter */
         $filter = $this->component->getVisibilityFilter();
         $filter->save($this->component->getFields(), $selections, $applyToAllUsers);
     }
     $responseHelper->redirectToAdminPage('index');
 }
 /**
  * Perform any processing or data manipulation needed before render.
  *
  * A response helper object will be passed to this method to allow you to
  * easily add success messages or redirects.  This helper should be used
  * to handle these kinds of actions so that you can easily test your
  * page's code.
  *
  * @param ResponseHelper $responseHelper
  * @return ResponseHelper|null
  */
 public function process(ResponseHelper $responseHelper)
 {
     $isCurrentUser = $this->row->get('user_id') === Pimple::getResource('user')->get('user_id');
     if (!$this->component->getPermissions()->can('edit') && !$isCurrentUser) {
         return $responseHelper->redirectToUrl('/admin');
     }
     if ($this->request->isPost()) {
         $this->inputFilter->setData($this->request->getPost());
         if ($this->inputFilter->isValid()) {
             $this->row->hashPassword($this->request->getPost('password'))->save();
             if ($isCurrentUser) {
                 return $responseHelper->redirectToUrl('/admin');
             } else {
                 return $responseHelper->redirectToAdminPage('index');
             }
         }
     }
 }
Exemple #4
0
 protected function redirect(ResponseHelper $responseHelper)
 {
     $session = new Session();
     $index = $this->component->getListingQueryParamsSessionName();
     $params = isset($session[$index]) ? $session[$index] : [];
     $responseHelper->redirectToAdminPage('index', $params);
 }
Exemple #5
0
 protected function redirect(ResponseHelper $responseHelper)
 {
     $session = new Session(Pimple::getInstance());
     $index = $this->component->getListingQueryParamsSessionName();
     $params = isset($session[$index]) ? $session[$index] : [];
     if (!is_array($params)) {
         $params = (array) $params;
     }
     $responseHelper->redirectToAdminPage('index', $params);
 }