Example #1
0
$edit = array_key_exists('id', $_GET);
if ($edit) {
    $Users = Utils::getFocByGetId();
} else {
    // set defaults
    $Users = new Foc();
    $Users->setPriority(Foc::PRIORITY_MEDIUM);
    $dueOn = new DateTime("+1 day");
    $dueOn->setTime(0, 0, 0);
    $Users->setDueOn($dueOn);
}
if (array_key_exists('cancel', $_POST)) {
    // redirect
    Utils::redirect('detail', array('id' => $Users->getId()));
} elseif (array_key_exists('save', $_POST)) {
    // for security reasons, do not map the whole $_POST['foc']
    $data = array('username' => $_POST['Users']['username'], 'firsname' => $_POST['Users']['firsname'], 'lastname' => $_POST['Users']['lastname'], 'email' => $_POST['Users']['email'], 'password' => $_POST['Users']['password']);
    // map
    UsersMapper::map($Users, $data);
    // validate
    $errors = UsersValidator::validate($Users);
    // validate
    if (empty($errors)) {
        // save
        $dao = new FocDao();
        $Users = $dao->save($Users);
        Flash::addFlash('Changes saved successfully.');
        // redirect
        Utils::redirect('detail', array('id' => $Users->getId()));
    }
}
Example #2
0
 public function setStatus($status)
 {
     UsersValidator::validateStatus($status);
     $this->status = $status;
 }
Example #3
0
<?php

$status = Utils::getUrlParam('status');
UsersValidator::validateStatus($status);
$dao = new UsersDao();
$search = new FocSearchCriteria();
$search->setStatus($status);
// data for template
$title = Utils::capitalize($status) . 'Users';
$Users = $dao->find($search);