public function auth($key = null, $level = array("all" => true), $neverAllowSubUser = false) { if ($_SESSION['subuser'] == \app\conf\Connection::$param['postgisschema'] && $neverAllowSubUser == false) { $response['success'] = true; } elseif ($_SESSION['subuser']) { $text = "You don't have privileges to do this. Please contact the database owner, who can grant you privileges."; if (sizeof($level) == 0) { $response['success'] = false; $response['message'] = $text; $response['code'] = 403; } else { $layer = new \app\models\Layer(); $privileges = (array) json_decode($layer->getValueFromKey($key, "privileges")); //print_r($_SESSION); $subuserLevel = $privileges[$_SESSION['usergroup'] ?: $_SESSION['subuser']]; if (!isset($level[$subuserLevel])) { $response['success'] = false; $response['message'] = $text; $response['code'] = 403; } else { $response['success'] = true; } } } else { $response['success'] = true; } return $response; }
public function createCluster($distance, $data) { $layer = new \app\models\Layer(); $geometryType = $this->geometryType ?: $layer->getValueFromKey($this->layer, "type"); if ($geometryType != "POINT" && $geometryType != "MULTIPOINT") { $response['success'] = false; $response['message'] = "Only point layers can be clustered"; $response['code'] = 400; return $response; } $this->reset(); // Set layer def $def = $this->tile->get(); if (!$def['success']) { $response['success'] = false; $response['message'] = "Error"; $response['code'] = 400; return $response; } $def["data"][0]["cluster"] = $distance; $def["data"][0]["meta_tiles"] = true; $def["data"][0]["meta_size"] = 4; $defJson = json_encode($def["data"][0]); $res = $this->tile->update($defJson); if (!$res['success']) { $response['success'] = false; $response['message'] = "Error"; $response['code'] = 400; return $response; } //Set single class if (\app\conf\App::$param["mapserver_ver_7"]) { $ClusterFeatureCount = "Cluster_FeatureCount"; } else { $ClusterFeatureCount = "Cluster:FeatureCount"; } $expression = "[{$ClusterFeatureCount}]=1"; $name = "Single"; $res = $this->update(0, self::createClass($geometryType, $name, $expression, 10, "#0000FF", $data)); if (!$res['success']) { $response['success'] = false; $response['message'] = "Error"; $response['code'] = 400; return $response; } //Set cluster class $expression = "[{$ClusterFeatureCount}]>1"; $name = "Cluster"; $data->labelText = "[{$ClusterFeatureCount}]"; $data->labelSize = "9"; $data->labelPosition = "cc"; $data->symbolSize = "50"; $data->overlaySize = "35"; $data->overlayColor = "#00FF00"; $data->overlaySymbol = "circle"; $data->symbol = "circle"; $data->opacity = "25"; $data->overlayOpacity = "70"; $data->force = true; $res = $this->update(1, self::createClass($geometryType, $name, $expression, 20, "#00FF00", $data)); if (!$res['success']) { $response['success'] = false; $response['message'] = "Error"; $response['code'] = 400; return $response; } $response['success'] = true; $response['message'] = "Updated 2 classes"; $this->storeWizard(json_encode($data)); return $response; }