示例#1
0
文件: index.php 项目: r3-gis/EcoGIS
<?php

require_once __DIR__ . '/../../author/config/config.php';
$db = GCApp::getDB();
$user = new GCUser();
$showAsPublic = 1;
if ($user->isAuthenticated()) {
    if (empty($_REQUEST['show_as_public'])) {
        $showAsPublic = 0;
    }
}
$lang = 'it';
if (!empty($_REQUEST['lang'])) {
    $lang = $_REQUEST['lang'];
}
//$mapsetName = 'gestel_2014';
//$project = 'gestel_2014';
if (!empty($_REQUEST['mapset'])) {
    $mapsetName = $_REQUEST['mapset'];
}
$sql = 'SELECT project_name, mapset_srid FROM ' . DB_SCHEMA . '.mapset WHERE mapset_name = :name';
$stmt = $db->prepare($sql);
$stmt->execute(array('name' => $mapsetName));
$mapset = $stmt->fetch();
$project = $mapset['project_name'];
$srid = $mapset['mapset_srid'];
$spatial = $db->query("SELECT * FROM public.spatial_ref_sys WHERE srid = {$srid}")->fetch();
$mapsetURL = PUBLIC_URL;
// "http://freegis.r3-gis.com/author/"
$queryParams = array();
parse_str($_SERVER['QUERY_STRING'], $queryParams);
 public function isUserGCAdmin($user = false)
 {
     if ($user) {
         $mdl_user = $user->getObject();
     } else {
         $current_user = new GCUser();
         $mdl_user = $current_user->getObject();
     }
     global $CFG;
     $sql = "SELECT SUM(rc.permission)\n                FROM {$this->short_name}.mdl_role_capabilities rc\n                JOIN {$this->short_name}.mdl_context ctx\n                  ON ctx.id=rc.contextid\n                JOIN {$this->short_name}.mdl_role_assignments ra\n                  ON ra.roleid=rc.roleid AND ra.contextid=ctx.id\n                WHERE ctx.contextlevel=10\n                  AND ra.userid = ?\n                  AND rc.capability IN ('moodle/site:config', 'moodle/legacy:admin', 'moodle/site:doanything')\n                GROUP BY rc.capability\n                HAVING SUM(rc.permission) > 0";
     if ($this->gcQuery($sql, array($mdl_user->id), true)) {
         return true;
     }
     return false;
 }