Ejemplo n.º 1
0
 /**
  * Add a host entry for a member
  *
  * @return  void
  */
 public function addTask()
 {
     // Check for request forgeries
     Request::checkToken();
     // Incoming member ID
     $id = Request::getInt('id', 0);
     if (!$id) {
         $this->setError(Lang::txt('MEMBERS_NO_ID'));
         $this->displayTask();
         return;
     }
     // Load the profile
     $profile = new \Hubzero\User\Profile();
     $profile->load($id);
     // Incoming host
     $host = Request::getVar('host', '');
     if (!$host) {
         $this->setError(Lang::txt('MEMBERS_NO_HOST'));
         $this->displayTask($id);
         return;
     }
     $hosts = $profile->get('host');
     $hosts[] = $host;
     // Update the hosts list
     $profile->set('host', $hosts);
     if (!$profile->update()) {
         $this->setError($profile->getError());
     }
     // Push through to the hosts view
     $this->displayTask($profile);
 }