public function executeProcess(sfWebRequest $request) { global $CFG; $this->formErrors = array(); $this->institutionForm = new GcrTrialApplicationForm(); $form = $request->getPostParameters(); // make an address object to insert in to the address table for the address submitted $addressObject = new GcrAddress(); $addressObject->setStreet1($form['street1']); $addressObject->setStreet2($form['street2']); $addressObject->setCity($form['city']); $addressObject->setState($form['state']); $addressObject->setCountry($form['country']); $addressObject->setZipcode($form['zipcode']); // Try to add the eschool's address to the address table $addressObject->save(); // make a person object to insert in to the person table for contact 1 $personObject = new GcrPerson(); $personObject->setFirstName($form['first_name']); $personObject->setLastName($form['last_name']); $personObject->setAddress($addressObject->getId()); $personObject->setPhone1($form['phone1']); $personObject->setPhone2($form['phone2']); $personObject->setEmail($form['email']); // Try to add the contact 1 to the person table $personObject->save(); $verify = GcrEschoolTable::generateRandomString(); // make an array of values to validate as the institution form $institutionFields = array('id' => '', 'contact' => $personObject->getId(), 'address' => $addressObject->getId(), 'verify_hash' => $verify, 'street1' => $form['street1'], 'street2' => $form['street2'], 'city' => $form['city'], 'state' => $form['state'], 'country' => $form['country'], 'zipcode' => $form['zipcode'], 'first_name' => $form['first_name'], 'last_name' => $form['last_name'], 'phone1' => $form['phone1'], 'phone2' => $form['phone2'], 'email' => $form['email'], '_csrf_token' => $form['_csrf_token']); // try to add the eschool data to the eschool table if (!($trial_application_record = $this->processForm($institutionFields, $this->institutionForm, $request->getFiles()))) { $this->formErrors['institutionRecord'] = 'Some Field(s) Have Missing or Incorrect Data'; } // If the institution record was saved, we send an email to verify the user before creating the new institution if (count($this->formErrors) == 0) { //create Constant Contact entry for user of newly created eschool $this->ccCreateContact($form); if ($CFG->current_app->hasPrivilege('GCUser')) { // skip email verification is this is a gc admin $this->redirect($CFG->current_app->getUrl() . '/institution/verify?aid=' . $trial_application_record->getId()); } $this->redirect($CFG->current_app->getUrl() . '/institution/sendVerificationEmail?id=' . $trial_application_record->getId()); } else { $addressObject->delete(); $personObject->delete(); $this->getResponse()->setTitle('Create a Trial Platform'); $this->setTemplate('new'); } }