Log in when subscribing an existing email
This commit is contained in:
18
inc/user.php
18
inc/user.php
@@ -38,16 +38,23 @@ class User extends PhpObject {
|
|||||||
//Check Email availability
|
//Check Email availability
|
||||||
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>'1'));
|
$iUserId = $this->oDb->selectValue(self::USER_TABLE, Db::getId(self::USER_TABLE), array('email'=>$sEmail, 'active'=>'1'));
|
||||||
|
|
||||||
if($iUserId > 0) $sDesc = 'lang:nl_email_exists';
|
if($iUserId > 0) {
|
||||||
|
//Log user in
|
||||||
|
$sDesc = 'lang:nl_email_exists';
|
||||||
|
$bSuccess = true;
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
//Add/Reactivate user
|
//Add/Reactivate user
|
||||||
$iUserId = $this->oDb->insertUpdateRow(self::USER_TABLE, array('email'=>$sEmail, 'language'=>$sLang, 'active'=>'1'), array('email'));
|
$iUserId = $this->oDb->insertUpdateRow(self::USER_TABLE, array('email'=>$sEmail, 'language'=>$sLang, 'active'=>'1'), array('email'));
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
||||||
else $bSuccess = true;
|
else {
|
||||||
|
$sDesc = 'lang:nl_subscribed';
|
||||||
|
$bSuccess = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Set Cookie (valid 1 year)
|
//Set Cookie (valid 1 year)
|
||||||
if($iUserId > 0) {
|
if($bSuccess) {
|
||||||
$this->setUserId($iUserId);
|
$this->setUserId($iUserId);
|
||||||
$this->updateCookie();
|
$this->updateCookie();
|
||||||
}
|
}
|
||||||
@@ -62,7 +69,10 @@ class User extends PhpObject {
|
|||||||
if($this->iUserId > 0) {
|
if($this->iUserId > 0) {
|
||||||
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->iUserId, array('active'=>'0'));
|
$iUserId = $this->oDb->updateRow(self::USER_TABLE, $this->iUserId, array('active'=>'0'));
|
||||||
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
if($iUserId==0) $sDesc = 'lang:error_commit_db';
|
||||||
else $bSuccess = true;
|
else {
|
||||||
|
$sDesc = 'lang:nl_unsubscribed';
|
||||||
|
$bSuccess = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else $sDesc = 'lang:nl_unknown_email';
|
else $sDesc = 'lang:nl_unknown_email';
|
||||||
|
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ newsletter = Keep in touch!
|
|||||||
nl_email_placeholder= my@email.com
|
nl_email_placeholder= my@email.com
|
||||||
nl_subscribed_desc = You're all set. We'll send you updates as soon as we get them
|
nl_subscribed_desc = You're all set. We'll send you updates as soon as we get them
|
||||||
nl_unsubscribed_desc= Write down your email address and we'll send you François' position as soon as we get it :)
|
nl_unsubscribed_desc= Write down your email address and we'll send you François' position as soon as we get it :)
|
||||||
nl_email_exists = This email is already subscribed
|
nl_email_exists = This email is already subscribed. You can unsubscribe by clicking on the button above.
|
||||||
nl_subscribe = Subscribe
|
nl_subscribe = Subscribe
|
||||||
nl_subscribed = Thanks! You'll receive a confirmation email shortly
|
nl_subscribed = Thanks! You'll receive a confirmation email shortly
|
||||||
nl_unsubscribe = Unsubscribe
|
nl_unsubscribe = Unsubscribe
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ newsletter = Rester en contact
|
|||||||
nl_email_placeholder= mon@email.com
|
nl_email_placeholder= mon@email.com
|
||||||
nl_subscribed_desc = C'est tout bon. On t'enverra les nouvelles posititions dès qu'on les reçoit
|
nl_subscribed_desc = C'est tout bon. On t'enverra les nouvelles posititions dès qu'on les reçoit
|
||||||
nl_unsubscribed_desc= Ajoute ton adresse email et on t'enverra la nouvelle position de François dès qu'on la reçoit :)
|
nl_unsubscribed_desc= Ajoute ton adresse email et on t'enverra la nouvelle position de François dès qu'on la reçoit :)
|
||||||
nl_email_exists = Cette adresse email est déjà enregistrée
|
nl_email_exists = Cette adresse email est déjà enregistrée. Vous pouvez vous désinscrire en cliquant sur le bouton ci-dessus.
|
||||||
nl_subscribe = S'abonner
|
nl_subscribe = S'abonner
|
||||||
nl_subscribed = Merci ! Tu vas recevoir un email de confirmation très bientôt
|
nl_subscribed = Merci ! Tu vas recevoir un email de confirmation très bientôt
|
||||||
nl_unsubscribe = Se désinscrire
|
nl_unsubscribe = Se désinscrire
|
||||||
|
|||||||
@@ -274,8 +274,8 @@ function initSettings(){
|
|||||||
else {
|
else {
|
||||||
oSpot.get(
|
oSpot.get(
|
||||||
sAction,
|
sAction,
|
||||||
function(asData) {
|
function(asData, sDesc) {
|
||||||
settingsFeedback('success', oSpot.lang('nl_'+sAction+'d'));
|
settingsFeedback('success', sDesc);
|
||||||
oSpot.vars('user', asData);
|
oSpot.vars('user', asData);
|
||||||
setUserInterface();
|
setUserInterface();
|
||||||
},
|
},
|
||||||
@@ -306,15 +306,10 @@ function setUserInterface() {
|
|||||||
if(asUserInfo.name) $('#name').val(asUserInfo.name);
|
if(asUserInfo.name) $('#name').val(asUserInfo.name);
|
||||||
}
|
}
|
||||||
else { //Unsubscribed User
|
else { //Unsubscribed User
|
||||||
//Switch to subcribe mode
|
|
||||||
$('#email').val('').prop('disabled', false);
|
$('#email').val('').prop('disabled', false);
|
||||||
$('#nl_btn').attr({name: 'subscribe', title: oSpot.lang('nl_subscribe'), 'class':'subscribe'});
|
$('#nl_btn').attr({name: 'subscribe', title: oSpot.lang('nl_subscribe'), 'class':'subscribe'});
|
||||||
$('#nl_desc').text(oSpot.lang('nl_unsubscribed_desc'));
|
$('#nl_desc').text(oSpot.lang('nl_unsubscribed_desc'));
|
||||||
|
|
||||||
//Reset nickname
|
|
||||||
$('#name').val('');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onAutoUpdate(bFirstExec) {
|
function onAutoUpdate(bFirstExec) {
|
||||||
|
|||||||
@@ -14,3 +14,4 @@
|
|||||||
* Fix video fullscreen button on ios
|
* Fix video fullscreen button on ios
|
||||||
* Fix lightbox portrait mode: push text under
|
* Fix lightbox portrait mode: push text under
|
||||||
* Subscribe to message feed
|
* Subscribe to message feed
|
||||||
|
* Add mail frequency slider
|
||||||
@@ -86,7 +86,7 @@ function Spot(asGlobals)
|
|||||||
if(oData.desc.substr(0, self.consts.lang_prefix.length)==self.consts.lang_prefix) oData.desc = self.lang(oData.desc.substr(5));
|
if(oData.desc.substr(0, self.consts.lang_prefix.length)==self.consts.lang_prefix) oData.desc = self.lang(oData.desc.substr(5));
|
||||||
|
|
||||||
if(oData.result==self.consts.error) fOnError(oData.desc);
|
if(oData.result==self.consts.error) fOnError(oData.desc);
|
||||||
else fOnSuccess(oData.data);
|
else fOnSuccess(oData.data, oData.desc);
|
||||||
})
|
})
|
||||||
.fail(function(jqXHR, textStatus, errorThrown)
|
.fail(function(jqXHR, textStatus, errorThrown)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user