/** * User edit type method * * @return void */ public function type() { if (null === $this->request->getPath(1)) { Response::redirect($this->request->getBasePath()); } else { $this->prepareView('type.phtml', array('assets' => $this->project->getAssets(), 'acl' => $this->project->getService('acl'), 'phireNav' => $this->project->getService('phireNav'))); $user = new Model\User(); $user->getById($this->request->getPath(1)); // If user is found and valid if (null !== $user->id) { $this->view->set('title', $this->view->i18n->__('Users') . ' ' . $this->view->separator . ' ' . $this->view->i18n->__('Type') . ' ' . $this->view->separator . ' ' . $user->username)->set('typeId', $user->type_id); $form = new Form\User($this->request->getBasePath() . $this->request->getRequestUri(), 'post', 0, false, 0, $this->project->getService('acl')); // If the form is submitted if ($this->request->isPost()) { $form->setFieldValues(array('type_id' => $this->request->getPost('type_id'))); // If the form is valid, save user type if ($form->isValid()) { $user->updateType($form, $this->project->module('Phire')); Response::redirect($this->request->getBasePath() . '?saved=' . time()); // Else, re-render the form with errors } else { $this->view->set('form', $form); $this->send(); } // Else, render the form } else { $form->setFieldValues(array('type_id' => $user->type_id)); $this->view->set('form', $form); $this->send(); } // Else redirect } else { Response::redirect($this->request->getBasePath()); } } }