/**
  * Get the Basic settings form.
  * @param array $values
  * @return Form
  */
 protected function getBasicForm($values = array())
 {
     $form = new Form();
     $form->setMethod('POST');
     $form->setAction(PHPCI_URL . 'settings/basic');
     $field = new Form\Element\Select('language');
     $field->setRequired(true);
     $field->setLabel(Lang::get('language'));
     $field->setClass('form-control');
     $field->setContainerClass('form-group');
     $field->setOptions(Lang::getLanguageOptions());
     $field->setValue(Lang::getLanguage());
     $form->addField($field);
     $field = new Form\Element\Submit();
     $field->setValue(Lang::get('save'));
     $field->setClass('btn btn-success pull-right');
     $form->addField($field);
     $form->setValues($values);
     return $form;
 }
Exemple #2
0
 protected function userForm($values, $type = 'add')
 {
     $form = new FormElement();
     $form->setMethod('POST');
     if ($type == 'add') {
         $form->setAction($this->config->get('site.full_admin_url') . '/user/add');
     } else {
         $form->setAction($this->config->get('site.full_admin_url') . '/user/edit/' . $values['id']);
     }
     $form->setClass('smart-form');
     $fieldset = new Form\FieldSet('fieldset');
     $form->addField($fieldset);
     if (isset($values['id'])) {
         $field = new Form\Element\Hidden('id');
         $field->setRequired(true);
         $field->setValue($values['id']);
         $fieldset->addField($field);
     }
     $field = new Form\Element\Text('name');
     $field->setRequired(true);
     $field->setLabel('Name');
     $fieldset->addField($field);
     $field = new Form\Element\Email('email');
     $field->setRequired(true);
     $field->setLabel('Email Address');
     $fieldset->addField($field);
     $field = new Form\Element\Password('password');
     if ($type == 'add') {
         $field->setRequired(true);
     } else {
         $field->setRequired(false);
     }
     $field->setLabel('Password' . ($type == 'edit' ? ' (leave blank to keep current password)' : ''));
     $fieldset->addField($field);
     if ($this->currentUser->getIsAdmin()) {
         $field = new Form\Element\Select('is_admin');
         $field->setRequired(false);
         $field->setLabel('Administrator');
         $field->setOptions([0 => 'No', 1 => 'Yes']);
         $fieldset->addField($field);
     }
     $data = [&$form, &$values];
     Event::trigger('userForm', $data);
     list($form, $values) = $data;
     $fieldset = new Form\FieldSet('fieldset3');
     $form->addField($fieldset);
     $field = new Form\Element\Submit();
     $field->setValue('Save User');
     $field->setClass('btn-success');
     $fieldset->addField($field);
     $form->setValues($values);
     return $form;
 }
Exemple #3
0
 /**
  * Allows the user to edit their profile.
  * @return string
  */
 public function profile()
 {
     $user = $_SESSION['phpci_user'];
     if ($this->request->getMethod() == 'POST') {
         $name = $this->getParam('name', null);
         $email = $this->getParam('email', null);
         $password = $this->getParam('password', null);
         $currentLang = Lang::getLanguage();
         $chosenLang = $this->getParam('language', $currentLang);
         if ($chosenLang !== $currentLang) {
             setcookie('phpcilang', $chosenLang, time() + 10 * 365 * 24 * 60 * 60, '/');
             Lang::setLanguage($chosenLang);
         }
         $_SESSION['phpci_user'] = $this->userService->updateUser($user, $name, $email, $password);
         $user = $_SESSION['phpci_user'];
         $this->view->updated = 1;
     }
     $this->layout->title = $user->getName();
     $this->layout->subtitle = Lang::get('edit_profile');
     $values = $user->getDataArray();
     if (array_key_exists('phpcilang', $_COOKIE)) {
         $values['language'] = $_COOKIE['phpcilang'];
     }
     $form = new Form();
     $form->setAction(PHPCI_URL . 'user/profile');
     $form->setMethod('POST');
     $name = new Form\Element\Text('name');
     $name->setClass('form-control');
     $name->setContainerClass('form-group');
     $name->setLabel(Lang::get('name'));
     $name->setRequired(true);
     $form->addField($name);
     $email = new Form\Element\Email('email');
     $email->setClass('form-control');
     $email->setContainerClass('form-group');
     $email->setLabel(Lang::get('email_address'));
     $email->setRequired(true);
     $form->addField($email);
     $password = new Form\Element\Password('password');
     $password->setClass('form-control');
     $password->setContainerClass('form-group');
     $password->setLabel(Lang::get('password_change'));
     $password->setRequired(false);
     $form->addField($password);
     $lang = new Form\Element\Select('language');
     $lang->setClass('form-control');
     $lang->setContainerClass('form-group');
     $lang->setLabel(Lang::get('language'));
     $lang->setRequired(true);
     $lang->setOptions(Lang::getLanguageOptions());
     $form->addField($lang);
     $submit = new Form\Element\Submit();
     $submit->setClass('btn btn-success');
     $submit->setValue(Lang::get('save'));
     $form->addField($submit);
     $form->setValues($values);
     $this->view->form = $form;
     return $this->view->render();
 }