Example #1
0
 /**
  * Method to get the data that should be injected in the form.
  *
  * @return  mixed  The data for the form.
  *
  * @since   1.6
  */
 protected function loadFormData()
 {
     // Check the session for previously entered form data.
     $data = User::getState('com_users.edit.user.data', array());
     if (empty($data)) {
         $data = $this->getItem();
     }
     // TODO: Maybe this can go into the parent model somehow?
     // Trigger the data preparation event.
     $results = Event::trigger('user.onContentPrepareData', array('com_users.profile', $data));
     // Check for errors encountered while preparing the data.
     if (count($results) && in_array(false, $results, true)) {
         $this->setError(Event::getError());
     }
     return $data;
 }
 /**
  * Method to get the registration form data.
  *
  * The base form data is loaded and then an event is fired
  * for users plugins to extend the data.
  *
  * @return	mixed		Data object on success, false on failure.
  * @since	1.6
  */
 public function getData()
 {
     if ($this->data === null) {
         $this->data = new stdClass();
         $params = Component::params('com_users');
         // Override the base user data with any data in the session.
         $temp = (array) User::getState('com_users.registration.data', array());
         foreach ($temp as $k => $v) {
             $this->data->{$k} = $v;
         }
         // Get the groups the user should be added to after registration.
         $this->data->groups = array();
         // Get the default new user group, Registered if not specified.
         $system = $params->get('new_usertype', 2);
         $this->data->groups[] = $system;
         // Unset the passwords.
         unset($this->data->password1);
         unset($this->data->password2);
         // Trigger the data preparation event.
         $results = Event::trigger('user.onContentPrepareData', array('com_users.registration', $this->data));
         // Check for errors encountered while preparing the data.
         if (count($results) && in_array(false, $results, true)) {
             $this->setError(Event::getError());
             $this->data = false;
         }
     }
     return $this->data;
 }