public function SelectFeatures($resId, $schemaName, $className, $format)
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($format, array("xml", "html", "geojson"));
     $mimeType = $this->GetMimeTypeForFormat($fmt);
     try {
         $sessionId = "";
         if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
             $sessionId = $resId->GetRepositoryName();
         }
         $this->EnsureAuthenticationForSite($sessionId, true, $mimeType);
         $siteConn = new MgSiteConnection();
         $siteConn->Open($this->userInfo);
         $site = $siteConn->GetSite();
         $this->VerifyWhitelist($resId->ToString(), $mimeType, "SELECTFEATURES", $fmt, $site, $this->userName);
         $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
         $query = new MgFeatureQueryOptions();
         $filter = $this->GetRequestParameter("filter", "");
         $propList = $this->GetRequestParameter("properties", "");
         $orderby = $this->GetRequestParameter("orderby", "");
         $orderOptions = $this->GetRequestParameter("orderoption", "asc");
         $maxFeatures = $this->GetRequestParameter("maxfeatures", "");
         $transformto = $this->GetRequestParameter("transformto", "");
         $bbox = $this->GetRequestParameter("bbox", "");
         $pageSize = $this->GetRequestParameter("pagesize", -1);
         $pageNo = $this->GetRequestParameter("page", -1);
         //Internal debugging flag
         $chunk = $this->GetBooleanRequestParameter("chunk", true);
         if ($pageNo >= 0 && $pageSize === -1) {
             $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "pagesize"), $mimeType);
         }
         if ($filter !== "") {
             $query->SetFilter($filter);
         }
         $limit = -1;
         if ($maxFeatures !== "") {
             $limit = intval($maxFeatures);
         }
         if ($propList !== "") {
             $propNames = explode(",", $propList);
             //If you have a comma in your property names, it's your own fault :)
             foreach ($propNames as $propName) {
                 $query->AddFeatureProperty($propName);
             }
         }
         if ($orderby !== "") {
             $orderPropNames = explode(",", $orderby);
             //If you have a comma in your property names, it's your own fault :)
             $orderProps = new MgStringCollection();
             foreach ($orderPropNames as $propName) {
                 $orderProps->Add($propName);
             }
             $orderOpt = MgOrderingOption::Ascending;
             if (strtolower($orderOptions) === "desc") {
                 $orderOpt = MgOrderingOption::Descending;
             }
             $query->SetOrderingFilter($orderProps, $orderOpt);
         }
         $transform = null;
         if ($transformto !== "") {
             $transform = MgUtils::GetTransform($featSvc, $resId, $schemaName, $className, $transformto);
         }
         if ($bbox !== "") {
             $parts = explode(",", $bbox);
             if (count($parts) == 4) {
                 $wktRw = new MgWktReaderWriter();
                 $geom = $wktRw->Read(MgUtils::MakeWktPolygon($parts[0], $parts[1], $parts[2], $parts[3]));
                 //Transform the bbox if we have the flag indicating so
                 $bboxIsTargetCs = $this->GetBooleanRequestParameter("bboxistargetcs", false);
                 if ($bboxIsTargetCs) {
                     //Because it has been declared the bbox is in target coordiantes, we have to transform that bbox back to the
                     //source, which means we need an inverse transform
                     $invTx = MgUtils::GetTransform($featSvc, $resId, $schemaName, $className, $transformto, true);
                     $geom = $geom->Transform($invTx);
                 }
                 $clsDef = $featSvc->GetClassDefinition($resId, $schemaName, $className);
                 $query->SetSpatialFilter($clsDef->GetDefaultGeometryPropertyName(), $geom, MgFeatureSpatialOperations::EnvelopeIntersects);
             }
         }
         $reader = $featSvc->SelectFeatures($resId, "{$schemaName}:{$className}", $query);
         $owriter = null;
         if ($chunk === "0") {
             $owriter = new MgSlimChunkWriter($this->app);
         } else {
             $owriter = new MgHttpChunkWriter();
         }
         if ($pageSize > 0) {
             if ($pageNo < 1) {
                 $pageNo = 1;
             }
             $pageReader = new MgPaginatedFeatureReader($reader, $pageSize, $pageNo, $limit);
             $result = new MgReaderChunkedResult($featSvc, $pageReader, $limit, $owriter, $this->app->localizer);
         } else {
             $result = new MgReaderChunkedResult($featSvc, $reader, $limit, $owriter, $this->app->localizer);
         }
         $result->CheckAndSetDownloadHeaders($this->app, $format);
         if ($transform != null) {
             $result->SetTransform($transform);
         }
         if ($fmt === "html") {
             $result->SetHtmlParams($this->app);
         }
         $result->Output($format);
     } catch (MgException $ex) {
         $this->OnException($ex, $mimeType);
     }
 }
Ejemplo n.º 2
0
 /**
  * Handles GET requests for this adapter. Overridable. Does nothing if not overridden.
  */
 public function HandleGet($single)
 {
     try {
         //Apply any overrides from query string
         $ovWidth = $this->app->request->get("width");
         $ovHeight = $this->app->request->get("height");
         $ovDpi = $this->app->request->get("dpi");
         $ovScale = $this->app->request->get("scale");
         if ($ovWidth != null) {
             $this->imgWidth = $ovWidth;
         }
         if ($ovHeight != null) {
             $this->imgHeight = $ovHeight;
         }
         if ($ovDpi != null) {
             $this->dpi = $ovDpi;
         }
         if ($ovScale != null) {
             $this->viewScale = intval($ovScale);
         }
         $site = $this->siteConn->GetSite();
         $this->sessionId = $site->GetCurrentSession();
         $bCreatedSession = false;
         if ($this->sessionId === "") {
             $this->sessionId = $site->CreateSession();
             $bCreatedSession = true;
         }
         $userInfo = new MgUserInformation($this->sessionId);
         $siteConn = new MgSiteConnection();
         $siteConn->Open($userInfo);
         $this->resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
         $this->featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
         $mapName = "MapImageAdapter";
         $this->map = new MgMap($siteConn);
         $this->map->Create($this->mapDefId, $mapName);
         $this->sel = new MgSelection($this->map);
         $mapId = new MgResourceIdentifier("Session:" . $this->sessionId . "//{$mapName}.Map");
         $this->map->Save($this->resSvc, $mapId);
         $layers = $this->map->GetLayers();
         $idx = $layers->IndexOf($this->selLayerName);
         if ($idx < 0) {
             throw new Exception($this->app->localizer->getText("E_LAYER_NOT_FOUND_IN_MAP", $this->selLayerName));
         }
         $layer = $layers->GetItem($idx);
         if ($layer->GetFeatureSourceId() !== $this->featureSourceId->ToString()) {
             throw new Exception($this->app->localizer->getText("E_LAYER_NOT_POINTING_TO_EXPECTED_FEATURE_SOURCE", $this->selLayerName, $this->featureSourceId->ToString(), $layer->GetFeatureSourceId()));
         }
         $this->selLayer = $layer;
         $query = $this->CreateQueryOptions($single);
         $reader = $this->featSvc->SelectFeatures($this->featureSourceId, $this->className, $query);
         $start = -1;
         $end = -1;
         $read = 0;
         $limit = $this->limit;
         $pageNo = $this->app->request->get("page");
         if ($pageNo == null) {
             $pageNo = 1;
         } else {
             $pageNo = intval($pageNo);
         }
         $bEndOfReader = false;
         if ($this->pageSize > 0) {
             if ($pageNo > 1) {
                 $skipThisMany = ($pageNo - 1) * $this->pageSize - 1;
                 //echo "skip this many: $skipThisMany<br/>";
                 $bEndOfReader = true;
                 while ($reader->ReadNext()) {
                     if ($read == $skipThisMany) {
                         $bEndOfReader = false;
                         $limit = min($skipThisMany + $this->pageSize, $this->limit - 1) - $read;
                         break;
                     }
                     $read++;
                 }
             } else {
                 //first page, set limit to page size
                 $limit = $this->pageSize;
             }
         }
         //echo "read: $read, limit: $limit, pageSize: ".$this->pageSize." result limit: ".$this->limit;
         //die;
         $this->sel->AddFeatures($this->selLayer, $reader, $limit);
         $reader->Close();
         $this->sel->Save($this->resSvc, $mapName);
         $extents = $this->sel->GetExtents($this->featSvc);
         $extLL = $extents->GetLowerLeftCoordinate();
         $extUR = $extents->GetUpperRightCoordinate();
         $x = ($extLL->GetX() + $extUR->GetX()) / 2.0;
         $y = ($extLL->GetY() + $extUR->GetY()) / 2.0;
         if ($this->viewScale === 0) {
             $csFactory = new MgCoordinateSystemFactory();
             $cs = $csFactory->Create($this->map->GetMapSRS());
             $metersPerUnit = $cs->ConvertCoordinateSystemUnitsToMeters(1.0);
             $mcsH = $extUR->GetY() - $extLL->GetY();
             $mcsW = $extUR->GetX() - $extLL->GetX();
             $mcsH = $mcsH * $this->zoomFactor;
             $mcsW = $mcsW * $this->zoomFactor;
             $metersPerPixel = 0.0254 / $this->dpi;
             if ($this->imgHeight * $mcsW > $this->imgWidth * $mcsH) {
                 $this->viewScale = $mcsW * $metersPerUnit / ($this->imgWidth * $metersPerPixel);
             } else {
                 $this->viewScale = $mcsH * $metersPerUnit / ($this->imgHeight * $metersPerPixel);
             }
             // height-limited
         }
         $req = new MgHttpRequest("");
         $param = $req->GetRequestParam();
         $param->AddParameter("OPERATION", "GETMAPIMAGE");
         $param->AddParameter("VERSION", "1.0.0");
         $param->AddParameter("SESSION", $this->sessionId);
         $param->AddParameter("LOCALE", $this->app->config("Locale"));
         $param->AddParameter("CLIENTAGENT", "MapGuide REST Extension");
         $param->AddParameter("CLIENTIP", $this->GetClientIp());
         $param->AddParameter("FORMAT", $this->imgFormat);
         $param->AddParameter("MAPNAME", $mapName);
         $param->AddParameter("KEEPSELECTION", "1");
         $param->AddParameter("SETDISPLAYWIDTH", $this->imgWidth);
         $param->AddParameter("SETDISPLAYHEIGHT", $this->imgHeight);
         $param->AddParameter("SETDISPLAYDPI", $this->dpi);
         $param->AddParameter("SETVIEWCENTERX", $x);
         $param->AddParameter("SETVIEWCENTERY", $y);
         $param->AddParameter("SETVIEWSCALE", $this->viewScale);
         $param->AddParameter("BEHAVIOR", 3);
         //Layers + Selection
         //Apply file download parameters if specified
         if ($this->app->request->params("download") === "1" || $this->app->request->params("download") === "true") {
             $param->AddParameter("X-DOWNLOAD-ATTACHMENT", "true");
             if ($this->app->request->params("downloadname")) {
                 $param->AddParameter("X-DOWNLOAD-ATTACHMENT-NAME", $this->app->request->params("downloadname"));
             }
         }
         $this->ExecuteHttpRequest($req);
         if ($bCreatedSession === true) {
             $conn2 = new MgSiteConnection();
             $user2 = new MgUserInformation($this->sessionId);
             $conn2->Open($user2);
             $site2 = $conn2->GetSite();
             $site2->DestroySession($this->sessionId);
         }
     } catch (MgException $ex) {
         $this->OnException($ex);
     }
 }
 public function MoveResource()
 {
     $resIdStr = $this->GetRequestParameter("source");
     $sessionId = $this->GetRequestParameter("session", "");
     $fmt = "json";
     $mimeType = MgMimeType::Json;
     $this->EnsureAuthenticationForSite($sessionId, false, $mimeType);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     $site = $siteConn->GetSite();
     $this->VerifyWhitelist($resIdStr, $mimeType, "MOVE  RESOURCE", $fmt, $site, $this->userName);
     $that = $this;
     $this->EnsureAuthenticationForHttp(function ($req, $param) use($that) {
         $param->AddParameter("OPERATION", "MOVERESOURCE");
         $param->AddParameter("VERSION", "2.2.0");
         $param->AddParameter("SOURCE", $that->GetRequestParameter("source"));
         $param->AddParameter("DESTINATION", $that->GetRequestParameter("destination"));
         //Default the depth to 1 if not specified (think of the MapGuide Server!)
         $param->AddParameter("OVERWRITE", $that->GetBooleanRequestParameter("overwrite", "0"));
         $param->AddParameter("OVERWRITE", $that->GetBooleanRequestParameter("cascade", "1"));
         $that->ExecuteHttpRequest($req);
     });
 }
Ejemplo n.º 4
0
 public function LaunchResourcePreview($resId)
 {
     $sessionId = "";
     if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
         $sessionId = $resId->GetRepositoryName();
     } else {
         $sessionId = $this->app->request->params("session");
     }
     $this->EnsureAuthenticationForSite($sessionId, true);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     if ($sessionId == null) {
         $site = $siteConn->GetSite();
         $sessionId = $site->CreateSession();
         $userInfo = new MgUserInformation($sessionId);
         $siteConn->Open($userInfo);
     }
     $selfUrl = MgUtils::GetSelfUrlRoot($this->app->config("SelfUrl"));
     switch ($resId->GetResourceType()) {
         case MgResourceType::FeatureSource:
             $this->app->redirect("{$selfUrl}/../schemareport/describeschema.php?viewer=basic&schemaName=&className=&resId=" . $resId->ToString() . "&sessionId=" . $sessionId);
             break;
         case MgResourceType::LayerDefinition:
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
             $bbox = $this->GetLayerBBOX($featSvc, $resSvc, $resId);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_mapdefinition.xml");
             $content = sprintf($content, $bbox->coordsys, $bbox->minx, $bbox->maxx, $bbox->miny, $bbox->maxy, $this->CreateLayerXmlFragment($resId), "");
             //echo $content; die;
             $mdfSource = new MgByteSource($content, strlen($content));
             $mdfbr = $mdfSource->GetReader();
             $mdfPreviewId = new MgResourceIdentifier("Session:{$sessionId}//Preview.MapDefinition");
             $resSvc->SetResource($mdfPreviewId, $mdfbr, NULL);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_weblayout.xml");
             $content = sprintf($content, $mdfPreviewId->ToString());
             $source = new MgByteSource($content, strlen($content));
             $br = $source->GetReader();
             $previewId = new MgResourceIdentifier("Session:{$sessionId}//Preview.WebLayout");
             $resSvc->SetResource($previewId, $br, NULL);
             $this->app->redirect("{$selfUrl}/../mapviewerajax/?SESSION={$sessionId}&USERNAME=Anonymous&WEBLAYOUT=" . $previewId->ToString());
             break;
         case MgResourceType::MapDefinition:
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             //$map = new MgMap();
             //$map->Create($resSvc, $mdfId, $resId->GetName());
             //$sel = new MgSelection($map);
             //$sel->Save($resSvc, $resId->GetName());
             //$map->Save($resSvc, $resId);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_weblayout.xml");
             $content = sprintf($content, $resId->ToString());
             $source = new MgByteSource($content, strlen($content));
             $br = $source->GetReader();
             $previewId = new MgResourceIdentifier("Session:{$sessionId}//Preview.WebLayout");
             $resSvc->SetResource($previewId, $br, NULL);
             $this->app->redirect("{$selfUrl}/../mapviewerajax/?SESSION={$sessionId}&USERNAME=Anonymous&WEBLAYOUT=" . $previewId->ToString());
             break;
         case MgResourceType::SymbolDefinition:
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             $mapSvc = $siteConn->CreateService(MgServiceType::MappingService);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_symbollayer.xml");
             $content = sprintf($content, $resId->ToString());
             $ldfSource = new MgByteSource($content, strlen($content));
             $ldfBr = $ldfSource->GetReader();
             $ldfId = new MgResourceIdentifier("Session:{$sessionId}//SymbolPreview.LayerDefinition");
             $resSvc->SetResource($ldfId, $ldfBr, NULL);
             $br = $mapSvc->GenerateLegendImage($ldfId, 42, 100, 50, "PNG", 4, 0);
             //NOXLATE
             $this->OutputByteReader($br);
             break;
         case "WatermarkDefinition":
             $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_mapdefinition.xml");
             $content = sprintf($content, self::XY_COORDSYS, 0, 0, 0, 0, "", $this->CreateWatermarkFragment($resId));
             //echo $content; die;
             $mdfSource = new MgByteSource($content, strlen($content));
             $mdfbr = $mdfSource->GetReader();
             $mdfPreviewId = new MgResourceIdentifier("Session:{$sessionId}//Preview.MapDefinition");
             $resSvc->SetResource($mdfPreviewId, $mdfbr, NULL);
             $content = file_get_contents(dirname(__FILE__) . "/../res/preview_weblayout.xml");
             $content = sprintf($content, $mdfPreviewId->ToString());
             $source = new MgByteSource($content, strlen($content));
             $br = $source->GetReader();
             $previewId = new MgResourceIdentifier("Session:{$sessionId}//Preview.WebLayout");
             $resSvc->SetResource($previewId, $br, NULL);
             $this->app->redirect("{$selfUrl}/../mapviewerajax/?SESSION={$sessionId}&USERNAME=Anonymous&WEBLAYOUT=" . $previewId->ToString());
             break;
         default:
             $this->BadRequest($this->app->localizer->getText("E_UNPREVIEWABLE_RESOURCE_TYPE"), MgMimeType::Html);
             break;
     }
 }
 public function CreateRuntimeMap($format)
 {
     $session = $this->app->request->params("session");
     $mapDefIdStr = $this->app->request->params("mapdefinition");
     $mapName = $this->app->request->params("targetmapname");
     $reqFeatures = $this->app->request->params("requestedfeatures");
     $iconFormat = $this->app->request->params("iconformat");
     $iconWidth = $this->app->request->params("iconwidth");
     $iconHeight = $this->app->request->params("iconheight");
     $iconsPerScaleRange = $this->app->request->params("iconsperscalerange");
     $this->EnsureAuthenticationForSite($session);
     $siteConn = new MgSiteConnection();
     $siteConn->Open($this->userInfo);
     if ($session == null) {
         $site = $siteConn->GetSite();
         $session = $site->CreateSession();
         $this->userInfo = new MgUserInformation($session);
         $siteConn->Open($this->userInfo);
     }
     $mdfId = new MgResourceIdentifier($mapDefIdStr);
     if ($mapName == null) {
         $mapName = $mdfId->GetName();
     }
     //Assign default values or coerce existing ones to their expected types
     if ($reqFeatures != null) {
         $reqFeatures = intval($reqFeatures);
     }
     if ($iconFormat == null) {
         $iconFormat = "PNG";
     }
     if ($iconWidth == null) {
         $iconWidth = 16;
     } else {
         $iconWidth = intval($iconWidth);
     }
     if ($iconHeight == null) {
         $iconHeight = 16;
     } else {
         $iconHeight = intval($iconHeight);
     }
     if ($iconsPerScaleRange == null) {
         $iconsPerScaleRange = 25;
     } else {
         $iconsPerScaleRange = intval($iconsPerScaleRange);
     }
     if ($format == null) {
         $format = "xml";
     } else {
         $format = strtolower($format);
     }
     /*
     $admin = new MgServerAdmin();
     $admin->Open($this->userInfo);
     $version = explode(".", $admin->GetSiteVersion());
     */
     $version = $this->app->MG_VERSION;
     $bCanUseNative = false;
     if (intval($version[0]) > 2) {
         //3.0 or greater
         $bCanUseNative = true;
     } else {
         if (intval($version[0]) == 2 && intval($version[1]) >= 6) {
             //2.6 or greater
             $bCanUseNative = true;
         }
     }
     if ($bCanUseNative) {
         $req = new MgHttpRequest("");
         $param = $req->GetRequestParam();
         $param->AddParameter("OPERATION", "CREATERUNTIMEMAP");
         //Hmmm, this may violate REST API design, but if we're on MGOS 3.0 or newer, we must return linked tile set
         //information to the client if applicable. Meaning this API could return 2 different results depending on the
         //underlying MGOS version.
         if (intval($version[0]) >= 3) {
             $param->AddParameter("VERSION", "3.0.0");
         } else {
             $param->AddParameter("VERSION", "2.6.0");
         }
         $param->AddParameter("SESSION", $session);
         $param->AddParameter("MAPDEFINITION", $mapDefIdStr);
         $param->AddParameter("TARGETMAPNAME", $mapName);
         $param->AddParameter("REQUESTEDFEATURES", $reqFeatures);
         $param->AddParameter("ICONSPERSCALERANGE", $iconsPerScaleRange);
         $param->AddParameter("ICONFORMAT", $iconFormat);
         $param->AddParameter("ICONWIDTH", $iconWidth);
         $param->AddParameter("ICONHEIGHT", $iconHeight);
         if ($format === "json") {
             $param->AddParameter("FORMAT", MgMimeType::Json);
         } else {
             $param->AddParameter("FORMAT", MgMimeType::Xml);
         }
         $this->ExecuteHttpRequest($req);
     } else {
         //Shim the response
         $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
         $mappingSvc = $siteConn->CreateService(MgServiceType::MappingService);
         $map = new MgMap($siteConn);
         $map->Create($mdfId, $mapName);
         $mapStateId = new MgResourceIdentifier("Session:{$session}//{$mapName}.Map");
         $sel = new MgSelection($map);
         $sel->Save($resSvc, $mapName);
         $map->Save($resSvc, $mapStateId);
         $br = $this->DescribeRuntimeMapXml($mapDefIdStr, $map, $session, $mapName, $iconFormat, $iconWidth, $iconHeight, $reqFeatures, $iconsPerScaleRange, $resSvc, $mappingSvc);
         if ($format == "json") {
             $this->OutputXmlByteReaderAsJson($br);
         } else {
             $this->OutputByteReader($br);
         }
     }
 }
Ejemplo n.º 6
0
function BuildViewer($forDwf = true)
{
    global $debug, $webLayoutDefinition, $cmds, $locale;
    global $sessionId, $username, $password, $orgSessionId;
    global $mapName;
    global $product;
    SetLocalizedFilesPath(GetLocalizationPath());
    try {
        // Initialize web tier with the site configuration file.
        InitializeWebTier();
        //fetch the parameters for this request
        //
        GetRequestParameters();
        //Open a connection with the server
        //
        $createSession = true;
        $cred = new MgUserInformation();
        if ($sessionId != '') {
            $cred->SetMgSessionId($sessionId);
            $createSession = false;
        } else {
            if ($username != '') {
                $cred->SetMgUsernamePassword($username, $password);
            } else {
                requestAuthentication();
                return;
            }
        }
        $site = new MgSiteConnection();
        $cred->SetLocale($locale);
        $cred->SetClientIp(GetClientIp());
        $cred->SetClientAgent(GetClientAgent());
        $site->Open($cred);
        if ($createSession) {
            $site1 = $site->GetSite();
            $sessionId = $site1->CreateSession();
            if ($forDwf == false) {
                $orgSessionId = $sessionId;
            }
        }
        //Get a MgWebLayout object initialized with the specified web layout definition
        //
        $webLayout = null;
        try {
            $resourceSrvc = $site->CreateService(MgServiceType::ResourceService);
            $webLayoutId = new MgResourceIdentifier($webLayoutDefinition);
            $webLayout = new MgWebLayout($resourceSrvc, $webLayoutId);
        } catch (MgUnauthorizedAccessException $e) {
            requestAuthentication();
            return;
        } catch (MgException $e) {
            $shortError = $e->GetExceptionMessage();
            $longErrorMsg = EscapeForHtml($e->GetDetails());
            header("HTTP/1.1 559 ");
            header('Content-Type: text/html; charset=utf-8');
            header("Status: 559 {$shortError}");
            echo "<html>\n<body>\n";
            echo $longErrorMsg;
            echo "</body>\n</html>\n";
            return;
        }
        //calculate the size of the variable elements of the viewer
        //
        $toolBar = $webLayout->GetToolBar();
        $statusBar = $webLayout->GetStatusBar();
        $taskPane = $webLayout->GetTaskPane();
        $infoPane = $webLayout->GetInformationPane();
        $taskBar = $taskPane->GetTaskBar();
        $mapDef = $webLayout->GetMapDefinition();
        $startupScriptCode = $webLayout->GetStartupScript();
        $selectionColor = $webLayout->GetSelectionColor();
        $mapImgFormat = $webLayout->GetMapImageFormat();
        $selImgFormat = $webLayout->GetSelectionImageFormat();
        $pointBuffer = $webLayout->GetPointSelectionBuffer();
        $showTaskPane = $taskPane->IsVisible();
        $showTaskBar = $taskBar->IsVisible();
        $showStatusbar = $statusBar->IsVisible();
        $showToolbar = $toolBar->IsVisible();
        $taskPaneWidth = $taskPane->GetWidth();
        $toolbarHeight = 30;
        $taskbarHeight = 30;
        $statusbarHeight = 26;
        $taskWidth = $showTaskPane ? $taskPaneWidth : 0;
        $toolbarHeight = $showToolbar ? $toolbarHeight : 0;
        $taskbarHeight = $showTaskBar ? $taskbarHeight : 0;
        $statusbarHeight = $showStatusbar ? $statusbarHeight : 0;
        //Encode the initial url so that it does not trip any sub-frames (especially if this url has parameters)
        $taskPaneUrl = urlencode($taskPane->GetInitialTaskUrl());
        $vpath = GetSurroundVirtualPath();
        $defHome = false;
        if ($taskPaneUrl == "") {
            $taskPaneUrl = "gettingstarted.php";
            $defHome = true;
        }
        $mapDefinitionUrl = urlencode($mapDef);
        // NOTE:
        //
        // We don't open a MgMap because it is being created by mapframe.php that is also probably running
        // as this script is running. However the naming convention is fixed enough that we can figure out
        // what to pass to the Task Pane
        $resId = new MgResourceIdentifier($mapDef);
        $mapName = $resId->GetName();
        $title = $webLayout->GetTitle();
        $enablePingServer = $webLayout->GetEnablePingServer();
        $showLegend = $infoPane->IsLegendBandVisible();
        $showProperties = $infoPane->IsPropertiesBandVisible();
        if ($showLegend || $showProperties) {
            if ($infoPane->IsVisible()) {
                $infoWidth = $infoPane->GetWidth();
                if ($infoWidth < 5) {
                    $infoWidth = 5;
                }
                //ensure visible
            } else {
                $showProperties = $showLegend = false;
                $infoWidth = 0;
            }
        } else {
            $infoWidth = 0;
        }
        //calculate the url of the inner pages
        //
        $srcToolbar = $showToolbar ? 'src="' . $vpath . 'toolbar.php?LOCALE=' . $locale . '"' : '';
        $srcStatusbar = $showStatusbar ? 'src="' . $vpath . 'statusbar.php?LOCALE=' . $locale . '"' : "";
        $srcTaskFrame = $showTaskPane ? 'src="' . $vpath . 'taskframe.php?MAPNAME=' . $mapName . '&WEBLAYOUT=' . urlencode($webLayoutDefinition) . '&DWF=' . ($forDwf ? "1" : "0") . '&SESSION=' . ($sessionId != "" ? $sessionId : "") . '&LOCALE=' . $locale . '"' : '';
        $srcTaskBar = 'src="' . $vpath . 'taskbar.php?LOCALE=' . $locale . '"';
        //view center
        //
        $ptCenter = $webLayout->GetCenter();
        if ($ptCenter == null) {
            $center = "null";
        } else {
            $coord = $ptCenter->GetCoordinate();
            $center = sprintf("new Point(%f, %f)", $coord->GetX(), $coord->GetY());
        }
        //Process commands and declare command objects
        //
        $commands = $webLayout->GetCommands();
        $cmdObjects = "";
        $cmdObject = "";
        $navCmdIndex = 0;
        $searchCmdIndex = 0;
        $measureCmdIndex = 0;
        $printCmdIndex = 0;
        $scriptCmdIndex = 0;
        $userCode = "";
        $userCodeCalls = "\nswitch(funcIndex)\n{\n";
        $selAwareCmdCount = 0;
        $selAwareCmds = "";
        for ($i = 0; $i < $commands->GetCount(); $i++) {
            $cmd = $commands->GetItem($i);
            if (!$cmd->IsUsed()) {
                continue;
            }
            $tgtViewer = $cmd->GetTargetViewerType();
            if (($tgtViewer == MgWebTargetViewerType::Dwf) != ($forDwf == true) && $tgtViewer != MgWebTargetViewerType::All) {
                continue;
            }
            $name = $cmd->GetName();
            $action = $cmd->GetAction();
            if ($action == MgWebActions::Search) {
                $cols = "var resCols" . $searchCmdIndex . " = new Array();\n";
                if ($cmd->GetResultColumnCount() > 0) {
                    for ($j = 0; $j < $cmd->GetResultColumnCount(); $j++) {
                        $col = sprintf("resCols%d[%d] = new ResultColumn(\"%s\", \"%s\");\n", $searchCmdIndex, $j, StrEscape($cmd->GetColumnDisplayNameAt($j)), StrEscape($cmd->GetColumnPropertyNameAt($j)));
                        $cols = $cols . $col;
                    }
                }
                $cmdObjects = $cmdObjects . $cols;
                // declare a new search command object
                $cmdObject = sprintf("commands[%d] = new SearchCommand(\"%s\", \"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", resCols%d, \"%s\", %d, %d, \"%s\");\n", $i, StrEscape($name), StrEscape($cmd->GetLabel()), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetLayer(), StrEscape($cmd->GetPrompt()), $searchCmdIndex, StrEscape($cmd->GetFilter()), $cmd->GetMatchLimit(), $cmd->GetTarget(), $cmd->GetTargetName());
                $searchCmdIndex++;
            } else {
                if ($action == MgWebActions::InvokeUrl) {
                    // create the parameter objects
                    $params = "var navParams" . $navCmdIndex . " = new Array();\n";
                    $layers = "var layers" . $navCmdIndex . " = new Array();\n";
                    if ($cmd->GetParameterCount() > 0) {
                        for ($j = 0; $j < $cmd->GetParameterCount(); $j++) {
                            $param = sprintf("navParams%d[%d] = new NavParam(\"%s\", \"%s\");\n", $navCmdIndex, $j, $cmd->GetParameterNameAt($j), $cmd->GetParameterValueAt($j));
                            $params = $params . $param;
                        }
                    }
                    for ($j = 0; $j < $cmd->GetLayerCount(); $j++) {
                        $layer = sprintf("layers%d[%d] = \"%s\";\n", $navCmdIndex, $j, $cmd->GetLayerNameAt($j));
                        $layers = $layers . $layer;
                    }
                    $cmdObjects = $cmdObjects . $params . $layers;
                    if ($cmd->DisabledIfSelectionEmpty() || $cmd->GetLayerCount() > 0) {
                        $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i);
                        $selAwareCmdCount++;
                    }
                    // declare a new invokeurl command object
                    $cmdObject = sprintf("commands[%d] = new InvokeUrlCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", navParams%d, %s, layers%d, %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $navCmdIndex, $cmd->DisabledIfSelectionEmpty() ? "true" : "false", $navCmdIndex, $cmd->GetTarget(), $cmd->GetTargetName());
                    $navCmdIndex++;
                } else {
                    if ($action == MgWebActions::Buffer || $action == MgWebActions::SelectWithin || $action == MgWebActions::Measure || $action == MgWebActions::ViewOptions || $action == MgWebActions::GetPrintablePage) {
                        if ($action == MgWebActions::Measure) {
                            if ($measureCmdIndex != 0) {
                                throw new Exception(GetLocalizedString("ALREADYINMEASURE", $locale));
                            }
                            $measureCmdIndex = $i;
                        } else {
                            if ($action == MgWebActions::SelectWithin) {
                                $selAwareCmds = $selAwareCmds . sprintf("selectionAwareCmds[%d] = %d;\n", $selAwareCmdCount, $i);
                                $selAwareCmdCount++;
                            }
                        }
                        // declare a new ui target command object
                        $cmdObject = sprintf("commands[%d] = new UiTargetCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetTarget(), $cmd->GetTargetName());
                    } else {
                        if ($action == MgWebActions::Help) {
                            // declare a new help  command object
                            $cmdObject = sprintf("commands[%d] = new HelpCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", \"%s\", %d, \"%s\");\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $cmd->GetUrl(), $cmd->GetTarget(), $cmd->GetTargetName());
                        } else {
                            if ($action == MgWebActions::PrintMap) {
                                // declare the print layouts
                                $layouts = "var layouts" . $printCmdIndex . " = new Array();\n";
                                for ($j = 0; $j < $cmd->GetPrintLayoutCount(); $j++) {
                                    $layout = "";
                                    $layout = sprintf("layouts%d[%d] = \"%s\";\n", $printCmdIndex, $j, $cmd->GetPrintLayoutAt($j));
                                    $layouts = $layouts . $layout;
                                }
                                $cmdObjects = $cmdObjects . $layouts;
                                // declare a new print command object
                                $cmdObject = sprintf("commands[%d] = new PrintCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", layouts%d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $printCmdIndex);
                                $printCmdIndex++;
                            } else {
                                if ($action == MgWebActions::InvokeScript) {
                                    // declare a new basic command object
                                    $cmdObject = sprintf("commands[%d] = new InvokeScriptCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\", %d);\n", $i, StrEscape($name), $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()), $scriptCmdIndex);
                                    $userCode = $userCode . "\nfunction UserFunc" . $scriptCmdIndex . "()\n{\n" . $cmd->GetScriptCode() . "\n}\n";
                                    $userCodeCalls = $userCodeCalls . sprintf("case %d: UserFunc%d(); break;\n", $scriptCmdIndex, $scriptCmdIndex);
                                    $scriptCmdIndex++;
                                } else {
                                    // declare a new basic command object
                                    $cmdObject = sprintf("commands[%d] = new BasicCommand(\"%s\", %d, \"%s\", \"%s\", \"%s\", \"%s\");\n", $i, $name, $cmd->GetAction(), $cmd->GetIconUrl(), $cmd->GetDisabledIconUrl(), StrEscape($cmd->GetTooltip()), StrEscape($cmd->GetDescription()));
                                }
                            }
                        }
                    }
                }
            }
            $cmdObjects = $cmdObjects . $cmdObject;
            $cmds[$name] = $i;
        }
        $userCodeCalls = $userCodeCalls . "\n}\n";
        //Declare toolbar items
        //
        $toolbarDef = DeclareUiItems($toolBar->GetWidgets(), "toolbarItems");
        //Declare task items
        $taskListDef = DeclareUiItems($taskBar->GetTaskList(), "taskItems");
        //Declare context menu items
        $ctxMenu = $webLayout->GetContextMenu();
        if ($ctxMenu->IsVisible()) {
            $ctxMenuDef = DeclareUiItems($ctxMenu, "ctxMenuItems");
        } else {
            $ctxMenuDef = "";
        }
        //task items texts
        //
        $taskItemTexts = "";
        $taskButtons = $taskBar->GetTaskButtons();
        for ($i = 0; $i < 4; $i++) {
            $btn = $taskButtons->GetWidget($i);
            if ($i > 0) {
                $taskItemTexts = $taskItemTexts . ",";
            }
            $taskItemTexts = $taskItemTexts . '"' . StrEscape($btn->GetName()) . '",' . '"' . StrEscape($btn->GetTooltip()) . '",' . '"' . StrEscape($btn->GetDescription()) . '",' . '"' . StrEscape($btn->GetIconUrl()) . '",' . '"' . StrEscape($btn->GetDisabledIconUrl()) . '"';
        }
        //transmit the session to the map pane if one was specified to this request
        if ($orgSessionId != "") {
            $sessionParam = "&SESSION=" . $orgSessionId;
        } else {
            $sessionParam = "";
        }
        //load the frameset template and format it
        $frameset = "";
        $viewerType = $forDwf ? "DWF" : "HTML";
        if ($showTaskBar) {
            $frameSetTempl = file_get_contents("../viewerfiles/framesettaskbar.templ");
            $frameset = sprintf($frameSetTempl, $statusbarHeight, $taskWidth, $toolbarHeight, $srcToolbar, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $vpath . "formframe.php", $taskbarHeight + 1, $srcTaskBar, $srcTaskFrame, $srcStatusbar);
        } else {
            $frameSetTempl = file_get_contents("../viewerfiles/framesetnotaskbar.templ");
            $frameset = sprintf($frameSetTempl, $toolbarHeight, $statusbarHeight, $srcToolbar, $taskWidth, $vpath . "mapframe.php", $mapDefinitionUrl, $viewerType, $showLegend ? 1 : 0, $showProperties ? 1 : 0, $infoWidth, $locale, $webLayout->GetHyperlinkTarget(), $webLayout->GetHyperlinkTargetFrame(), $webLayout->IsZoomControlVisible() ? 1 : 0, $selectionColor, $mapImgFormat, $selImgFormat, $pointBuffer, $sessionParam, $srcTaskFrame, $vpath . "formframe.php", $srcStatusbar);
        }
        $homePageUrl = urldecode($taskPaneUrl);
        if (strlen($homePageUrl) < 8 || strncasecmp($homePageUrl, "http://", 7) != 0) {
            $homePageUrl = $vpath . $homePageUrl;
        }
        //load the HTML template and format it
        //
        $templ = Localize(file_get_contents("../viewerfiles/mainframe.templ"), $locale, GetClientOS());
        print sprintf($templ, $title, GetRootVirtualFolder() . "/mapagent/mapagent.fcgi", $enablePingServer ? 1 : 0, $site->GetSite()->GetSessionTimeout(), $locale, $showToolbar ? 1 : 0, $showStatusbar ? 1 : 0, $showTaskPane ? 1 : 0, $showTaskPane ? 0 : ($showTaskBar ? 1 : 0), $homePageUrl, $defHome ? "1" : "0", $webLayoutDefinition, $mapDef, $taskWidth, $center, $webLayout->GetScale(), StrEscape($title), $forDwf ? "1" : "0", $cmdObjects, $toolbarDef, $taskListDef, $ctxMenuDef, $userCode, $taskItemTexts, $selAwareCmds, $startupScriptCode, $vpath . "quickplotpanel.php", $vpath . "measureui.php", $vpath . "searchprompt.php", $vpath . "bufferui.php", $vpath . "selectwithinui.php", $userCodeCalls, $vpath . "viewoptions.php", $frameset);
    } catch (MgUserNotFoundException $e) {
        requestAuthentication();
    } catch (MgAuthenticationFailedException $e) {
        requestAuthentication();
    } catch (MgException $e) {
        // This should be a 500 error of some sort, but
        // in order to give a nice custom error message, it looks as
        // if we shortcut things by using a 200 status.
        $shortError = $e->GetExceptionMessage();
        $longErrorMsg = EscapeForHtml($e->GetDetails());
        header("HTTP/1.1 200 ");
        header('Content-Type: text/html; charset=utf-8');
        header("Status: 200 {$shortError}");
        echo "<html>\n<body>\n";
        echo $longErrorMsg;
        echo "</body>\n</html>\n";
    } catch (Exception $ne) {
        $errorMsg = EscapeForHtml($ne->GetMessage());
        echo $errorMsg;
    }
}
Ejemplo n.º 7
0
 public function GetLayerKml($resId, $format = "kml")
 {
     //Check for unsupported representations
     $fmt = $this->ValidateRepresentation($format, array("kml", "kmz"));
     $width = $this->GetRequestParameter("width", null);
     $height = $this->GetRequestParameter("height", null);
     $drawOrder = $this->GetRequestParameter("draworder", null);
     $dpi = $this->GetRequestParameter("dpi", 96);
     $bbox = $this->GetRequestParameter("bbox", null);
     $extents = null;
     if ($width == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "width"), $this->GetMimeTypeForFormat($format));
     }
     if ($height == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "height"), $this->GetMimeTypeForFormat($format));
     }
     if ($drawOrder == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "draworder"), $this->GetMimeTypeForFormat($format));
     }
     if ($bbox == null) {
         $this->BadRequest($this->app->localizer->getText("E_MISSING_REQUIRED_PARAMETER", "bbox"), $this->GetMimeTypeForFormat($format));
     } else {
         $parts = explode(",", $bbox);
         if (count($parts) == 4) {
             $extents = new MgEnvelope($parts[0], $parts[1], $parts[2], $parts[3]);
         }
     }
     $sessionId = "";
     if ($resId->GetRepositoryType() == MgRepositoryType::Session) {
         $sessionId = $resId->GetRepositoryName();
     } else {
         $sessionId = $this->GetRequestParameter("session", "");
     }
     $this->EnsureAuthenticationForSite($sessionId, true);
     $siteConn = new MgSiteConnection();
     if ($sessionId !== "") {
         $userInfo = new MgUserInformation($sessionId);
         $siteConn->Open($userInfo);
     } else {
         $siteConn->Open($this->userInfo);
         $site = $siteConn->GetSite();
         $sessionId = $site->CreateSession();
         $userInfo = new MgUserInformation($sessionId);
         $siteConn->Open($userInfo);
     }
     $csFactory = new MgCoordinateSystemFactory();
     $csObj = $csFactory->CreateFromCode("LL84");
     $scale = MgUtils::GetScale($extents, $csObj, $width, $height, $dpi);
     $writer = new MgSlimChunkWriter($this->app);
     $doc = new MgKmlDocument($writer);
     $resSvc = $siteConn->CreateService(MgServiceType::ResourceService);
     $featSvc = $siteConn->CreateService(MgServiceType::FeatureService);
     $ldfContent = $resSvc->GetResourceContent($resId);
     $xml = new DOMDocument();
     $xml->loadXML($ldfContent->ToString());
     $destExtent = self::GetLayerExtent($csFactory, $xml, $csObj, $featSvc, $resSvc);
     $doc->StartDocument();
     $doc->WriteString("<visibility>1</visibility>");
     if ($destExtent != null) {
         $widthMeters = $csObj->ConvertCoordinateSystemUnitsToMeters($destExtent->GetWidth());
         $heightMeters = $csObj->ConvertCoordinateSystemUnitsToMeters($destExtent->GetHeight());
         $dimension = sqrt($widthMeters * $heightMeters);
         $vlNodes = $xml->getElementsByTagName("VectorLayerDefinition");
         $glNodes = $xml->getElementsByTagName("GridLayerDefinition");
         $dlNodes = $xml->getElementsByTagName("DrawingLayerDefinition");
         if ($vlNodes->length == 1) {
             $scaleRangeNodes = $vlNodes->item(0)->getElementsByTagName("VectorScaleRange");
             for ($i = 0; $i < $scaleRangeNodes->length; $i++) {
                 $scaleRange = $scaleRangeNodes->item($i);
                 $minElt = $scaleRange->getElementsByTagName('MinScale');
                 $maxElt = $scaleRange->getElementsByTagName('MaxScale');
                 $minScale = "0";
                 $maxScale = 'infinity';
                 // as MDF's VectorScaleRange::MAX_MAP_SCALE
                 if ($minElt->length > 0) {
                     $minScale = $minElt->item(0)->nodeValue;
                 }
                 if ($maxElt->length > 0) {
                     $maxScale = $maxElt->item(0)->nodeValue;
                 }
                 if ($minScale != 'infinity') {
                     $minScale = intval($minScale);
                 }
                 if ($maxScale != 'infinity') {
                     $maxScale = intval($maxScale);
                 } else {
                     $maxScale = 1000000000000.0;
                 }
                 // as MDF's VectorScaleRange::MAX_MAP_SCALE
                 if ($scale > $minScale && $scale <= $maxScale) {
                     $this->AppendScaleRange($resId, $destExtent, $dimension, $minScale, $maxScale, $dpi, $drawOrder, $format, $sessionId, $doc);
                 }
             }
         } else {
             if ($glNodes->length == 1) {
             }
         }
     }
     $doc->EndDocument();
 }
Ejemplo n.º 8
0
        <?php 
$username = "******";
$password = "******";
try {
    $thisFile = __FILE__;
    $pos = strrpos($thisFile, '\\');
    if ($pos == false) {
        $pos = strrpos($thisFile, '/');
    }
    $configFilePath = substr($thisFile, 0, $pos + 1) . "../webconfig.ini";
    MgInitializeWebTier($configFilePath);
    $userInfo = new MgUserInformation($username, $password);
    $site = new MgSiteConnection();
    $site->Open($userInfo);
    $sessionId = $site->GetSite()->CreateSession();
} catch (MgException $e) {
    echo $e->GetExceptionMessage();
}
?>

        <h1><?php 
echo DisplayHeadings::MainHeading;
?>
</h1>

        <form action="describeschema.php" method="get">
            <?php 
echo FormText::InputResourceId;
?>
            <input name="resId" value="Library://Samples/Sheboygan/Data/RoadCenterLines.FeatureSource" type="text" size="70"><br><br>
Ejemplo n.º 9
0
 public function EnumerateRolesForUser($userName, $format)
 {
     $sessionId = $this->app->request->params("session");
     try {
         //Check for unsupported representations
         $fmt = $this->ValidateRepresentation($format, array("xml", "json"));
         $this->EnsureAuthenticationForSite($sessionId, false, $this->GetMimeTypeForFormat($format));
         $siteConn = new MgSiteConnection();
         $siteConn->Open($this->userInfo);
         $site = $siteConn->GetSite();
         try {
             $user = $site->GetUserForSession();
             //Hmmm. Should we allow Anonymous to discover its own roles?
             if ($user === "Anonymous" && $userName !== "Anonymous") {
                 $this->Unauthorized($this->GetMimeTypeForFormat($format));
             }
         } catch (MgException $ex) {
             //Could happen if we have non-anonymous credentials in the http authentication header
         }
         $content = $site->EnumerateRoles($userName);
         $mimeType = MgMimeType::Xml;
         if ($fmt === "json") {
             $mimeType = MgMimeType::Json;
         }
         $this->app->response->header("Content-Type", $mimeType);
         $this->OutputMgStringCollection($content, $mimeType);
     } catch (MgException $ex) {
         $this->OnException($ex, $this->GetMimeTypeForFormat($format));
     }
 }
Ejemplo n.º 10
0
 function SetPassword($id, $password)
 {
     $encryptedPassword = crypt($password, SALT);
     $success = $this->db->queryExec('UPDATE users SET password = "******", resetkey = "" where userid = ' . $id);
     $user = $this->GetUser($id);
     if ($success) {
         $adminUser = new MgUserInformation(MG_ADMIN_USER, MG_ADMIN_PASSWD);
         $siteConnection = new MgSiteConnection();
         $siteConnection->Open($adminUser);
         $site = $siteConnection->GetSite();
         $site->UpdateUser($user->userName(), "", $user->userName(), $password, "");
     } else {
         echo "/* failed to update user password */";
     }
     return $success;
 }
Ejemplo n.º 11
0
 public function DestroySession($sessionId)
 {
     try {
         $siteConn = new MgSiteConnection();
         $userInfo = new MgUserInformation($sessionId);
         $userInfo->SetClientAgent("MapGuide REST Extension");
         $userInfo->SetClientIp($this->GetClientIp());
         $siteConn->Open($userInfo);
         $site = $siteConn->GetSite();
         $site->DestroySession($sessionId);
     } catch (MgException $ex) {
         $this->OnException($ex);
     }
 }