This commit is contained in:
+25
-28
@@ -76,7 +76,7 @@ class Spot extends Main
|
||||
'email' => 'admin@admin.com',
|
||||
'language' => self::DEFAULT_LANG,
|
||||
'timezone' => date_default_timezone_get(),
|
||||
'active' => User::USER_ACTIVE,
|
||||
'subscribed'=> User::USER_SUBSCRIBED,
|
||||
'clearance' => User::CLEARANCE_ADMIN
|
||||
));
|
||||
$this->oUser->setUserId($iUserId);
|
||||
@@ -94,13 +94,12 @@ class Spot extends Main
|
||||
Project::PROJ_TABLE => array('name', 'codename', 'active_from', 'active_to'),
|
||||
self::POST_TABLE => array(Db::getId(Project::PROJ_TABLE), Db::getId(User::USER_TABLE), 'name', 'content', 'site_time', 'timezone'),
|
||||
Media::MEDIA_TABLE => array(Db::getId(Project::PROJ_TABLE), 'filename', 'type', 'taken_on', 'posted_on', 'timezone', 'latitude', 'longitude', 'altitude', 'width', 'height', 'rotate', 'comment'),
|
||||
User::USER_TABLE => array('name', 'email', 'gravatar', 'language', 'timezone', 'active', 'clearance'),
|
||||
User::USER_TABLE => array('name', 'email', 'password', 'token', 'token_exp', 'gravatar', 'language', 'timezone', 'subscribed', 'clearance'),
|
||||
Map::MAP_TABLE => array('codename', 'pattern', 'token', 'tile_size', 'min_zoom', 'max_zoom', 'attribution'),
|
||||
Map::MAPPING_TABLE => array(Db::getId(Map::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
|
||||
),
|
||||
'types' => array
|
||||
(
|
||||
'active' => "BOOLEAN DEFAULT ".User::USER_INACTIVE,
|
||||
'clearance' => "TINYINT(1) DEFAULT ".User::CLEARANCE_USER,
|
||||
'active_from' => "TIMESTAMP DEFAULT 0",
|
||||
'active_to' => "TIMESTAMP DEFAULT 0",
|
||||
@@ -120,6 +119,7 @@ class Spot extends Main
|
||||
'model' => "VARCHAR(20)",
|
||||
'name' => "VARCHAR(100)",
|
||||
'pattern' => "VARCHAR(200) NOT NULL",
|
||||
'password' => "VARCHAR(255) NOT NULL DEFAULT ''",
|
||||
'posted_on' => "TIMESTAMP DEFAULT 0",
|
||||
'ref_feed_id' => "VARCHAR(40)",
|
||||
'ref_msg_id' => "VARCHAR(15)",
|
||||
@@ -127,9 +127,11 @@ class Spot extends Main
|
||||
'rotate' => "SMALLINT",
|
||||
'site_time' => "TIMESTAMP DEFAULT 0", //DEFAULT 0 removes auto-set to current time
|
||||
'status' => "VARCHAR(10)",
|
||||
'subscribed' => "BOOLEAN DEFAULT ".User::USER_UNSUBSCRIBED,
|
||||
'taken_on' => "TIMESTAMP DEFAULT 0",
|
||||
'timezone' => "CHAR(64) NOT NULL", //see mysql.time_zone_name
|
||||
'token' => "VARCHAR(4096)",
|
||||
'token_exp' => "TIMESTAMP DEFAULT 0",
|
||||
'type' => "VARCHAR(20)",
|
||||
'unix_time' => "INT",
|
||||
'min_zoom' => "TINYINT UNSIGNED",
|
||||
@@ -282,7 +284,7 @@ class Spot extends Main
|
||||
|
||||
private function sendEmail() {
|
||||
$oEmail = new Email($this->asContext['serv_name'], 'email.update');
|
||||
$oEmail->setDestInfo($this->oUser->getActiveUsersInfo());
|
||||
$oEmail->setDestInfo($this->oUser->getSubscribedUsersInfo());
|
||||
|
||||
//Add Position
|
||||
$asSpotMessages = $this->getSpotMessages(array($this->oProject->getLastMessageId($this->getFeedConstraints(Feed::MSG_TABLE))));
|
||||
@@ -377,32 +379,32 @@ class Spot extends Main
|
||||
return self::getJsonResult(true, '', $asLastUpdate);
|
||||
}
|
||||
|
||||
public function subscribe($sEmail, $sNickName) {
|
||||
$asResult = $this->oUser->addUser($sEmail, $this->oLang->getLanguage(), date_default_timezone_get(), $sNickName);
|
||||
$asUserInfo = $this->oUser->getUserInfo();
|
||||
public function login($sEmail, $sPassword, $sNickName) {
|
||||
$asResult = $this->oUser->login($sEmail, $sPassword, $this->oLang->getLanguage(), date_default_timezone_get(), $sNickName);
|
||||
|
||||
//Send Confirmation Email
|
||||
if($asResult['result'] && $asResult['desc']=='lang:newsletter.subscribed' && !Settings::DEBUG) {
|
||||
if($asResult['result'] && $asResult['desc'] == 'subscribe_user') return $this->subscribe();
|
||||
else return self::getJsonResult($asResult['result'], $asResult['desc'], $this->oUser->getUserInfo());
|
||||
}
|
||||
|
||||
public function logout() {
|
||||
$asResult = $this->oUser->logout();
|
||||
return self::getJsonResult($asResult['result'], $asResult['desc'], User::DEFAULT_USER);
|
||||
}
|
||||
|
||||
public function subscribe() {
|
||||
$asResult = $this->oUser->setSubscription(true);
|
||||
$asUserInfo = $this->oUser->getUserInfo();
|
||||
if($asResult['result'] && !Settings::DEBUG) {
|
||||
$oConfEmail = new Email($this->asContext['serv_name'], 'email.confirmation');
|
||||
$oConfEmail->setDestInfo($asUserInfo);
|
||||
$oConfEmail->send();
|
||||
}
|
||||
|
||||
return self::getJsonResult($asResult['result'], $asResult['desc'], $asUserInfo);
|
||||
}
|
||||
|
||||
public function unsubscribe() {
|
||||
$asResult = $this->oUser->removeUser();
|
||||
return self::getJsonResult($asResult['result'], $asResult['desc'], User::DEFAULT_USER);
|
||||
}
|
||||
|
||||
public function unsubscribeFromEmail($iUserId) {
|
||||
$this->oUser->setUserId($iUserId);
|
||||
$this->oLang->setLanguage($this->oUser->getLang(), self::DEFAULT_LANG);
|
||||
$asResult = $this->oUser->removeUser();
|
||||
|
||||
$sDesc = explode(':', $asResult['desc'])[1];
|
||||
return $this->oLang->getTranslation($sDesc);
|
||||
$asResult = $this->oUser->setSubscription(false);
|
||||
return self::getJsonResult($asResult['result'], $asResult['desc'], $this->oUser->getUserInfo());
|
||||
}
|
||||
|
||||
private function getSpotMessages($asMsgIds=array())
|
||||
@@ -726,7 +728,7 @@ class Spot extends Main
|
||||
'project' => $this->oProject->getProjects(),
|
||||
'feed' => $oFeed->getFeeds(),
|
||||
'spot' => $oFeed->getSpots(),
|
||||
'user' => $this->oUser->getActiveUsersInfo()
|
||||
'user' => $this->oUser->getSubscribedUsersInfo()
|
||||
);
|
||||
|
||||
foreach($asData['project'] as &$asProject) {
|
||||
@@ -794,7 +796,7 @@ class Spot extends Main
|
||||
default:
|
||||
$sDesc = $this->oLang->getTranslation('error.unknown_field', $sField);
|
||||
}
|
||||
$asResult = $this->oUser->getActiveUserInfo($iId);
|
||||
$asResult = $this->oUser->getUserById($iId);
|
||||
break;
|
||||
}
|
||||
if(!$bSuccess && $sDesc=='') $sDesc = Mask::LANG_PREFIX.'error.commit_db';
|
||||
@@ -852,11 +854,6 @@ class Spot extends Main
|
||||
$sDesc = $asResult['feed'][0]['desc'];
|
||||
$bSuccess = $asResult['feed'][0]['del'];
|
||||
break;
|
||||
case 'user':
|
||||
$asResult = array('user' => array($this->oUser->removeUser($iId)));
|
||||
$sDesc = $asResult['user'][0]['desc'];
|
||||
$bSuccess = $asResult['user'][0]['result'];
|
||||
break;
|
||||
}
|
||||
|
||||
return self::getJsonResult($bSuccess, $sDesc, $asResult);
|
||||
|
||||
Reference in New Issue
Block a user