backend sendRegistration

This commit is contained in:
Lorenzo Giacomelli
2016-03-08 12:20:43 +01:00
parent 17f21e8b0d
commit d1296a1fc7
7 changed files with 106 additions and 11 deletions
+8
View File
@@ -16,6 +16,14 @@ class UserModel extends Model{
if (!$this->hasProperty("email")){
throw new CoreException("Impossible to create a user without a mail address");
}
if (!$this->hasProperty("username")){
throw new CoreException("Impossible to create a user without a username");
}
if(!$this->hasProperty("password")){
new CoreException("Impossible to create a user without a password");
}
}
public static function getCollectionName(){
+1 -1
View File
@@ -275,7 +275,7 @@ catch (Exception $ex){
</div>
<?php if(sizeof($lastsNews)>0){
foreach($lastsNews as $last){
$data = $mesi[date("n",$last->data->sec)]." ".date("Y",$last->about->data->sec);
$data = $mesi[date("n",$last->about->data->sec)]." ".date("Y",$last->about->data->sec);
$string = (strlen($last->titolo) > 103) ? substr($last->titolo,0,100).'...' : $last->titolo;?>
<div class="lastContainer">
<div class="lastData"><?php echo $data;?></div>
+12 -1
View File
@@ -28,5 +28,16 @@ function openRegistrationModal(){
}
function sendRegistration(){
$.ajax({
method:'POST',
url:'sendRegistrationBackend.php',
dataType:'html',
data:$("#regForm").serialize(),
success: function(data){
},
error:function(data){
$(".modalError").html(data);
}
});
}
+34 -7
View File
@@ -4,16 +4,43 @@ require_once(dirname(__FILE__)."/load.php");
try {
?>
<form id="regForm">
<div>Email: <input type="text" name="email" value="" /></div>
<div>Password: <input type="password" name="pass" value="" /></div>
<div>Conferma password: <input type="text" name="passwordConfirm" value="" /></div>
<a href="javascript:sendRegistration();">Registrami</a>
</form>
<div class="topReg"><span></span><div><a class="close" href='javascript:$("#floating").hide();'>x</a></div></div>
<div class="modalBody">
<div class="modalError"></div>
<form id="regForm">
<div>Email: <input type="text" name="email" value="" /></div>
<div>Username: <input type="text" name="username" value=""/></div>
<div>Password: <input type="password" name="pass" value="" /></div>
<div>Conferma password: <input type="password" name="passwordConfirm" value="" /></div>
<div>Vuoi iscriverti alla newsletter? <input type="checkbox" name="newsletter" value="true" checked /></div>
</form>
</div>
<div class="regMe"><a href="javascript:sendRegistration();">Registrami</a></div>
<?php
}catch (Exception $exec){
$msg = LogModel::fromException($exec);
GlobalVariables::get("dao")->save($msg);
}
echo "zzzzzzzzzzzzzzzzzzzzzz";
?>
?>
<script type="text/javascript">
$(document).ready(function (){
function sendRegistration(){
$.ajax({
method:'POST',
url:'sendRegistrationBackend.php',
dataType:'html',
data:$('#regForm').serialize(),
success: function(data){
// $("#regForm").remove();
// $(".modalError").html(data);
alert("pene");
},
error:function(data){
// $(".modalError").html(data);
alert("capocchia");
}
});
}
});
</script>
+2 -2
View File
@@ -19,8 +19,8 @@ try {
$news->user = UserLoginManager::getLogged();
$commento = new CommentoModel($news);
$commento->titolo = $titolo;
$commento->testo = $testo;
$commento->titolo = strip_tags($titolo);
$commento->testo = strip_tags($testo);
$commento->status = CommentoModel::STATUS_PENDING;
GlobalVariables::get("dao")->save($commento);
+41
View File
@@ -0,0 +1,41 @@
<?php
require_once(dirname(__FILE__)."/load.php");
try {
$email = PostHandler::get("email");
$userName = PostHandler::get("username");
$pass = PostHandler::get("pass");
$confPass = PostHandler::get("passwordConfirm");
$newsletter = false;
if(array_key_exists("newsletter", $_POST)){
$newsletter = true;
}
echo "invitao ";
if(strcmp($pass, $confPass)==0){
// GlobalVariables::get("dao")->getFirst("UserModel",array("username"=>$userName));
// GlobalVariables::get("dao")->getFirst("UserModel",array("email"=>$email));
// GlobalVariables::get("dao")->getFirst("UserModel",array("username"=>$userName));
$user = new stdClass();
$user->email = $email;
$user->password = sha1($pass);
$user->username = $userName;
$user->newsletter = $newsletter;
$userModel = new UserModel($user);
// GlobalVariables::get("dao")->save($userModel);
echo "salvataggio riuscito";
}
else{
echo "Le due password non coincidono";
}
}catch(Exception $exec){
$msg = LogModel::fromException($exec);
GlobalVariables::get("dao")->save($msg);
}
?>
+8
View File
@@ -89,8 +89,16 @@ body{font-family:lato, arial;}
#floating{
background-color:green;
z-index:4;
padding:5px 10px;
}
.topReg{text-align:right;}
.topReg > div{display:inline-block;}
.topReg > span,a{vertical-align:top;}
.close{vertical-align:top;color:white;}
.modalBody{text-align:right;}
.modalError{text-algin:center;color:red;font-weight:bold;}
#modalBlock{}/*
margin-left:auto;
margin-right:auto;