Beispiel #1
0
 /**
  * Save hub and redirect to the hubs page
  *
  * @return void
  */
 public function saveTask()
 {
     $hub = Hub::oneOrNew(Request::getInt('id'))->set(array('name' => Request::getVar('name'), 'liaison' => Request::getVar('liaison'), 'anniversary_date' => Request::getVar('anniversary_date'), 'notes' => Request::getVar('notes', null, 'post', 'none', JREQUEST_ALLOWRAW), 'support_level' => Request::getVar('support_level')));
     $contacts = array();
     // Set the contact info on the hub
     foreach (Request::getVar('contacts', array(), 'post') as $contact) {
         // First check and make sure we don't save a completely empty contact
         if (empty($contact['name']) && empty($contact['phone']) && empty($contact['email']) && empty($contact['role'])) {
             break;
         }
         $contacts[] = Contact::oneOrNew(isset($contact['id']) ? $contact['id'] : 0)->set($contact);
     }
     $hub->attach('contacts', $contacts);
     // Save the hub info
     if (!$hub->saveAndPropagate()) {
         // Something went wrong...return errors
         foreach ($hub->getErrors() as $error) {
             $this->view->setError($error);
         }
         $this->view->setLayout('edit');
         $this->view->task = 'edit';
         $this->editTask($hub);
         return;
     }
     // Set the redirect
     App::redirect(Route::url($this->base . $this->start($hub)), Lang::txt('COM_TIME_HUBS_SAVE_SUCCESSFUL'), 'passed');
 }