/** * Deletes a Person's user account information */ public function delete() { $person = new Person($_GET['person_id']); $person->deleteUserAccount(); try { $person->save(); } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } header('Location: ' . BASE_URL . '/users'); }
public function testSave() { $person = new Person(); $person->setFirstname('First'); $person->setLastname('Last'); $person->setEmail('test@localhost'); $person->save(); $person = new Person('test@localhost'); $this->assertEquals('First', $person->getFirstname()); $this->assertEquals('Last', $person->getLastname()); $this->assertEquals('test@localhost', $person->getEmail()); }
public function delete(array $params) { try { $person = new Person($_REQUEST['id']); $person->deleteUserAccount(); $person->save(); } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } header('Location: ' . self::generateUrl('users.index')); exit; }
<?php /** * @copyright 2012-2013 City of Bloomington, Indiana * @license http://www.gnu.org/licenses/agpl.txt GNU/AGPL, see LICENSE.txt * @author Cliff Ingham <*****@*****.**> */ use Application\Models\Person; include '../configuration.inc'; $person = new Person(); $person->setFirstname('Administrator'); $person->setLastname('Person'); $person->setEmail('*****@*****.**'); $person->setUsername('admin'); //$person->setPassword(); $person->setAuthenticationMethod('Employee'); $person->setRole('Administrator'); $person->save();
public function update() { $errorURL = isset($_REQUEST['return_url']) ? $_REQUEST['return_url'] : BASE_URL . '/people'; if (isset($_REQUEST['person_id']) && $_REQUEST['person_id']) { try { $person = new Person($_REQUEST['person_id']); } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; header("Location: {$errorURL}"); exit; } } else { $person = new Person(); } if (isset($_POST['firstname'])) { try { $newRecord = $person->getId() ? false : true; $person->handleUpdate($_POST); $person->save(); if ($newRecord) { if (!empty($_POST['email'])) { $email = new Email(); $email->setPerson($person); $email->setEmail($_POST['email']); $email->save(); } if (!empty($_POST['phone'])) { $phone = new Phone(); $phone->setPerson($person); $phone->setNumber($_POST['phone']); $phone->save(); } } if (isset($_REQUEST['return_url'])) { $return_url = new Url($_REQUEST['return_url']); $return_url->person_id = $person->getId(); } elseif (isset($_REQUEST['callback'])) { $return_url = new Url(BASE_URL . '/callback'); $return_url->callback = $_REQUEST['callback']; $return_url->data = "{$person->getId()}"; } else { $return_url = $person->getURL(); } header("Location: {$return_url}"); exit; } catch (\Exception $e) { $_SESSION['errorMessages'][] = $e; } } $this->template->title = 'Update a person'; $this->template->blocks[] = new Block('people/updatePersonForm.inc', array('person' => $person)); }