getFirst("AdminModel",array("id"=>$regCode,"email"=>$email,"active"=>false));
if (is_null($giornalista)){
GUIHandler::redirect("admin/login.php");
}
$action = PostHandler::get("action");
if (!is_null($action) && strcmp("", $action)!=0){
if (strcmp("confirm", $action)==0){
$err = false;
$exc = new GUIException(array());
$giornalista->nome = trim(PostHandler::get("nome"));
$giornalista->cognome = trim(PostHandler::get("cognome"));
$giornalista->username = trim(PostHandler::get("username"));
// Validate Username
if (strcmp($giornalista->username,"")==0){
$err = true;
$exc->addMessage("Inserire un nome utente per accedere all'applicazione");
}
if (GlobalVariables::get("dao")->count("AdminModel",array("username"=>$giornalista->username)) > 0 ){
$err = true;
$exc->addMessage("Il nome utente '".$giornalista->username."' è già in uso");
}
// Validate Password
if (strcmp($pass,"")==0){
$err = true;
$exc->addMessage("Inserire una password per accedere all'applicazione");
}
$pass = trim(PostHandler::get("password"));
if (strcmp($pass,PostHandler::get("password_confirm"))!=0){
$err = true;
$exc->addMessage("Le password inserite non coincidono");
}
$giornalista->password = sha1($pass);
if ($err){
throw $exc;
}
$giornalista->active = true;
GlobalVariables::get("dao")->save($giornalista);
GUIHandler::redirect("admin/login.php");
}
}
}catch(GUIException $ex){
$error = $ex->getMessageMerged("
");
}catch (Exception $exec){
LoggingFacilityManager::getLogger("gui")->log(LoggingFacility::$LEVEL_ERROR, $exec->getMessage());
$error = "Si è verificato un errore inaspettato durante l'esecuzione della pagina. Se l'errore persiste contattare il supporto tecnico.";
}
?>