/** Edit staff profile * @access public * @return void * @throws Pas_Exception_Param */ public function editAction() { $form = new ContactForm(); $form->submit->setLabel('Save'); $form->removeElement('role'); $form->removeElement('alumni'); $form->removeElement('identifier'); $form->removeElement('role'); $form->removeElement('dbaseID'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $address = $form->getValue('address_1') . ',' . $form->getValue('address_2') . ',' . $form->getValue('town') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ', UK'; $coords = $this->_geocoder->getCoordinates($address); if ($coords) { $lat = $coords['lat']; $lon = $coords['lon']; $pm = new Pas_Service_Geo_GeoPlanet($this->_helper->config()->webservice->ydnkeys->appid); $place = $pm->reverseGeoCode($lat, $lon); $woeid = $place['woeid']; } else { $lat = null; $lon = null; $woeid = null; } $updateData = $form->getValues(); $updateData['latitude'] = $lat; $updateData['longitude'] = $lon; $updateData['woeid'] = $woeid; $where = array(); $where[] = $this->_contacts->getAdapter()->quoteInto('dbaseID = ?', $this->getIdentityForForms()); $this->_contacts->update($updateData, $where); $this->getFlash()->addMessage('Contact information updated!'); $this->redirect('/users/account/'); } else { $form->populate($formData); } } else { $contact = $this->_contacts->fetchRow($this->_contacts->select()->where('dbaseID = ' . $this->getIdentityForForms())); if (is_null($contact)) { throw new Pas_Exception_Param('Admin has not yet set up a profile for you', 500); } else { $form->populate($contact->toArray()); } } }
/** Edit a contact's details * @access public * @return void */ public function editAction() { $form = new ContactForm(); $form->submit->setLabel('Save'); $this->view->form = $form; if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($this->_request->getPost())) { $address = $form->getValue('address_1') . ',' . $form->getValue('address_2') . ',' . $form->getValue('town') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ', UK'; $coords = $this->getGeoCoder()->getCoordinates($address); if ($coords) { $lat = $coords['lat']; $lon = $coords['lon']; $place = $this->getGeoPlanet()->reverseGeoCode($lat, $lon); $woeid = $place['woeid']; } else { $lat = null; $lon = null; $woeid = null; } $updateData = $form->getValues(); $updateData['latitude'] = $lat; $updateData['longitude'] = $lon; $updateData['woeid'] = $woeid; $where = array(); $where[] = $this->getContacts()->getAdapter()->quoteInto('id = ?', $this->getParam('id')); $this->getContacts()->update($updateData, $where); $this->getFlash()->addMessage('Contact information updated!'); $this->redirect($this->_redirectUrl . 'contact/id/' . $this->getParam('id')); } else { $form->populate($this->_request->getPost()); } } else { $id = (int) $this->_request->getParam('id', 0); if ($id > 0) { $contact = $this->getContacts()->fetchRow('id=' . $id); $form->populate($contact->toArray()); } } }
$form->Build(); $form->enforceRules(); $showForm = !($form->submitted() && $form->validate()); $intro_id = $showForm ? AMP_CONTENT_PUBLICPAGE_ID_CONTACT_US : AMP_CONTENT_PUBLICPAGE_ID_CONTACT_US_RESPONSE; $modid = AMP_MODULE_ID_CONTACT_US; require_once "AMP/BaseTemplate.php"; $flash =& AMP_System_Flash::instance(); print $flash->execute(); require_once "AMP/BaseModuleIntro.php"; if (!isset($MM_email_contact)) { $MM_email_contact = false; } if (!defined('AMP_SITE_EMAIL_CONTACT')) { define('AMP_SITE_EMAIL_CONTACT', $MM_email_contact); } if ($showForm) { print $form->output(); } elseif (AMP_SITE_EMAIL_CONTACT) { $data = $form->getValues(); require_once 'AMP/System/Email.inc.php'; $email_maker = new AMPSystem_Email(); $email_maker->setRecipient(AMP_SITE_EMAIL_CONTACT); $email_maker->setMessage($data['message']); $email_maker->setSender($data['sender_email']); $email_maker->setSenderName(false); $email_maker->setSubject($data['subject']); $email_maker->execute(); } else { print AMP_TEXT_ERROR_TOOL_NOT_CONFIGURED; } require_once "AMP/BaseFooter.php";