Store maps (layers) settings in DB + display only project-relevant layers

This commit is contained in:
2020-08-18 23:12:40 +02:00
parent 4c4f83b6a2
commit b0b283cf0f
4 changed files with 80 additions and 18 deletions

View File

@@ -168,6 +168,16 @@ class Project extends PhpObject {
return $iLastUpdate;
}
public function getMaps() {
$sQuery =
"SELECT codename, geo_name, min_zoom, max_zoom, attribution ".
"FROM ".Spot::MAPPING_TABLE." ".
"LEFT JOIN ".Spot::MAP_TABLE." USING(".Db::getId(Spot::MAP_TABLE).") ".
"WHERE ".Db::getId(self::PROJ_TABLE)." = ".$this->getProjectId()." ".
"OR ".Db::getId(self::PROJ_TABLE)." IS NULL ";
return $this->oDb->getArrayQuery($sQuery, true);
}
private function setProjectInfo() {
if($this->getProjectId() > 0) {
$asProject = $this->getProject();

View File

@@ -18,6 +18,8 @@ class Spot extends Main
{
//Database
const POST_TABLE = 'posts';
const MAP_TABLE = 'maps';
const MAPPING_TABLE = 'mappings';
const FEED_CHUNK_SIZE = 15;
const MAIL_CHUNK_SIZE = 5;
@@ -81,7 +83,9 @@ 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', 'timezone', 'active')
User::USER_TABLE => array('name', 'email', 'language', 'timezone', 'active'),
self::MAP_TABLE => array('codename', 'geo_name', 'min_zoom', 'max_zoom', 'attribution'),
self::MAPPING_TABLE => array(Db::getId(self::MAP_TABLE) , Db::getId(Project::PROJ_TABLE))
),
'types' => array
(
@@ -112,7 +116,11 @@ class Spot extends Main
'taken_on' => "TIMESTAMP DEFAULT 0",
'timezone' => "CHAR(64)", //see mysql.time_zone_name
'type' => "VARCHAR(20)",
'unix_time' => "INT"
'unix_time' => "INT",
'geo_name' => "VARCHAR(100)",
'min_zoom' => "TINYINT UNSIGNED",
'max_zoom' => "TINYINT UNSIGNED",
'attribution' => "VARCHAR(100)"
),
'constraints' => array
(
@@ -255,7 +263,10 @@ class Spot extends Main
$asLastUpdate = array();
$this->addTimeStamp($asLastUpdate, $this->oProject->getLastUpdate());
return self::getJsonResult($bSuccess, $sDesc, array('messages' => $asMessages, 'last_update'=>$asLastUpdate));
return self::getJsonResult($bSuccess, $sDesc, array(
'messages' => $asMessages,
'maps' => $this->oProject->getMaps(),
'last_update' => $asLastUpdate));
}
public function subscribe($sEmail) {