Example #1
0
{
    return null;
}
if (count($_POST) == 0) {
    http_response::redir('/admin');
}
// setup
$user = user::getInstance();
$registry = registry::getInstance();
// valid submit buttons
$submits = array('commit', 'upload', 'removeAvatar', 'removeImage', 'cancel');
$validButtonLabels = array('Ladda upp', 'Ta bort Avatar', 'Avbryt', "Byt lösenord", 'skapa lösenord');
// needed for the page header.
admin::getModels();
// how shall we response? Ajaxbased or traditional based?
$ajaxMode = http_request::getBoolean('ajaxMode');
//preparing some variables
$returnPath = "";
$entityId = "";
// validate action from GET and store to registry if success
$registry['actionRoute'] = http_request::getString('action');
$validActions = array('new.do', 'edit.do', 'delete.do');
if ($registry['actionRoute'] != 'edit.do' && http_request::getString('id') != false) {
    throw new Exception("Something went terribly,terribly wrong ...");
}
if ($registry['actionRoute'] == false || !in_array($registry['actionRoute'], $validActions)) {
    throw new Exception("Illegal action <b>" . $registry['actionRoute'] . "</b>. Valid actions are: " . implode(", ", $validActions));
}
// validate model and construct if correct.
$registry['modelLabel'] = http_request::getString('model');
if ($registry['modelLabel'] == false || !file_exists(ROOT . '/model/' . $registry['modelLabel'] . ".php")) {