Add Timezone to user data

This commit is contained in:
2020-04-17 11:00:11 +02:00
parent 047b652ab7
commit 43f8b0fbf9
8 changed files with 42 additions and 32 deletions

View File

@@ -0,0 +1,6 @@
ALTER TABLE users ADD COLUMN timezone char(64) AFTER language;
ALTER TABLE users MODIFY COLUMN email VARCHAR(320) NOT NULL;
ALTER TABLE users ADD COLUMN frequency VARCHAR(1) NOT NULL AFTER active;
UPDATE users SET timezone = 'Europe/Paris', frequency = 'P';
ALTER TABLE projects MODIFY COLUMN timezone char(64);

View File

@@ -114,7 +114,7 @@ class Media extends PhpObject {
$asDbInfo = array(
Db::getId(Project::PROJ_TABLE) => $this->oProject->getProjectId(),
'filename' => $sMediaName,
'taken_on' => ($asMediaInfo['taken_ts'] > 0)?date(Db::TIMESTAMP_FORMAT, $asMediaInfo['taken_ts']):0, //Site Time (Settings::TIMEZONE)
'taken_on' => ($asMediaInfo['taken_ts'] > 0)?date(Db::TIMESTAMP_FORMAT, $asMediaInfo['taken_ts']):0, //Site Time
'posted_on' => date(Db::TIMESTAMP_FORMAT, $asMediaInfo['file_ts']), //Site Time
'rotate' => $asMediaInfo['rotate'],
'type' => $asMediaInfo['type']

View File

@@ -80,38 +80,39 @@ class Spot extends Main
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to', 'timezone'),
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time'),
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'rotate', 'comment'),
User::USER_TABLE => array('name', 'email', 'language', 'active')
User::USER_TABLE => array('name', 'email', 'language', 'timezone', 'active', 'frequency')
),
'types' => array
(
'ref_msg_id' => "INT",
'type' => "VARCHAR(20)",
'latitude' => "DECIMAL(7,5)",
'longitude' => "DECIMAL(8,5)",
'iso_time' => "VARCHAR(24)",
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
'unix_time' => "INT",
'content' => "LONGTEXT",
'battery_state' => "VARCHAR(10)",
'ref_spot_id' => "VARCHAR(10)",
'name' => "VARCHAR(100)",
'codename' => "VARCHAR(100)",
'model' => "VARCHAR(20)",
'ref_feed_id' => "VARCHAR(40)",
'description' => "VARCHAR(100)",
'status' => "VARCHAR(10)",
'active' => "BOOLEAN",
'active_from' => "TIMESTAMP DEFAULT 0",
'active_to' => "TIMESTAMP DEFAULT 0",
'timezone' => "VARCHAR(100)",
'last_update' => "TIMESTAMP DEFAULT 0",
'filename' => "VARCHAR(100) NOT NULL",
'taken_on' => "TIMESTAMP DEFAULT 0",
'posted_on' => "TIMESTAMP DEFAULT 0",
'rotate' => "SMALLINT",
'battery_state' => "VARCHAR(10)",
'codename' => "VARCHAR(100)",
'content' => "LONGTEXT",
'comment' => "LONGTEXT",
'email' => "VARCHAR(320)",
'description' => "VARCHAR(100)",
'email' => "VARCHAR(320) NOT NULL",
'filename' => "VARCHAR(100) NOT NULL",
'frequency' => "VARCHAR(1) NOT NULL",
'iso_time' => "VARCHAR(24)",
'language' => "VARCHAR(2)",
'active' => "BOOLEAN"
'last_update' => "TIMESTAMP DEFAULT 0",
'latitude' => "DECIMAL(7,5)",
'longitude' => "DECIMAL(8,5)",
'model' => "VARCHAR(20)",
'name' => "VARCHAR(100)",
'posted_on' => "TIMESTAMP DEFAULT 0",
'ref_feed_id' => "VARCHAR(40)",
'ref_msg_id' => "INT",
'ref_spot_id' => "VARCHAR(10)",
'rotate' => "SMALLINT",
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
'status' => "VARCHAR(10)",
'taken_on' => "TIMESTAMP DEFAULT 0",
'timezone' => "CHAR(64)", //see mysql.time_zone_name
'type' => "VARCHAR(20)",
'unix_time' => "INT"
),
'constraints' => array
(
@@ -248,7 +249,7 @@ class Spot extends Main
}
public function subscribe($sEmail) {
$asResult = $this->oUser->addUser($sEmail, $this->oLang->getLanguage());
$asResult = $this->oUser->addUser($sEmail, $this->oLang->getLanguage(), date_default_timezone_get());
$asUserInfo = $this->oUser->getUserInfo();
//Send Confirmation Email

View File

@@ -22,7 +22,7 @@ class User extends PhpObject {
parent::__construct(__CLASS__, Settings::DEBUG);
$this->oDb = &$oDb;
$this->iUserId = 0;
$this->asUserInfo = array(Db::getId(self::USER_TABLE)=>0, 'name'=>'', 'email'=>'', 'language'=>'', 'active'=>'0');
$this->asUserInfo = array(Db::getId(self::USER_TABLE)=>0, 'name'=>'', 'email'=>'', 'language'=>'', 'timezone'=>'', 'active'=>'0');
$this->checkUserCookie();
}
@@ -30,7 +30,7 @@ class User extends PhpObject {
return $this->asUserInfo['language'];
}
public function addUser($sEmail, $sLang) {
public function addUser($sEmail, $sLang, $sTimezone) {
$bSuccess = false;
$sDesc = '';
$sEmail = trim($sEmail);
@@ -45,7 +45,7 @@ class User extends PhpObject {
}
else {
//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, 'timezone'=>$sTimezone, 'active'=>'1'), array('email'));
if($iUserId==0) $sDesc = 'lang:error_commit_db';
else {
$sDesc = 'lang:nl_subscribed';

View File

@@ -70,6 +70,7 @@ unit_hour = h
newsletter = Keep in touch!
nl_email_placeholder= my@email.com
nl_invalid_email = It doesn't look like an email
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_email_exists = This email is already subscribed. You can unsubscribe by clicking on the button above.

View File

@@ -70,6 +70,7 @@ unit_hour = h
newsletter = Rester en contact
nl_email_placeholder= mon@email.com
nl_invalid_email = Ceci ne ressemble pas à une adresse email
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_email_exists = Cette adresse email est déjà enregistrée. Vous pouvez vous désinscrire en cliquant sur le bouton ci-dessus.

View File

@@ -270,7 +270,7 @@ function initSettings(){
var sAction = $(this).prop('name');
var sEmail = $('#email').val();
var regexEmail = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
if(!regexEmail.test(sEmail)) settingsFeedback('error', 'this is not an email');
if(!regexEmail.test(sEmail)) settingsFeedback('error', oSpot.lang('nl_invalid_email'));
else {
oSpot.get(
sAction,

View File

@@ -15,4 +15,5 @@
* Fix lightbox portrait mode: push text under
* Subscribe to message feed
* Add mail frequency slider
* Add Timezone to user table
* Add Timezone to user table
* Replace Project Time Zone with browser Time Zone when uploading media?