if(permission == true){
        document.form1.del.value = 1;
        document.form1.submit();
     }
   }
}
// -->
</script>
</head>
<body>

<?php 
require_once dirname(__FILE__) . "/../classes/class_administration.php";
require_once dirname(__FILE__) . "/../classes/class_gui.php";
$admin = new administration();
$permguis = $admin->getGuisByPermission(Mapbender::session()->get("mb_user_id"), true);
###export
if ($guiList) {
    $gui = gui::byName($guiList);
    try {
        $insert = $gui->toSql();
    } catch (Exception $e) {
        $insert = $e->message;
    }
    echo "<textarea rows=40 cols=80>";
    echo htmlentities($insert, ENT_QUOTES, CHARSET);
    echo "</textarea>";
}
###
if (!$guiList) {
    $v = array();
 /** identifies the IDs of WFS confs where the user is owner
  * 
  * @param Array appIdArray [optional] restrict to certain applications
  * @return integer[] the IDs of the wfs_conf-table
  */
 public function getWfsConfByPermission()
 {
     $userid = $this->id;
     $guisByPer = array();
     //	 	1.
     $adm = new administration();
     $guisByPer = $adm->getGuisByPermission($userid, true);
     if (func_num_args() === 1) {
         $arg1 = func_get_arg(0);
         if (!is_array($arg1)) {
             $arg1 = array($arg1);
         }
         $appIdArray = $arg1;
         $guisByPer = array_intersect($guisByPer, $appIdArray);
         $guisByPer = array_keys(array_flip($guisByPer));
     }
     //		$e = new mb_exception(serialize($guisByPer));
     //	 	2.
     $ownWFSconfs = array();
     if (count($guisByPer) > 0) {
         $v = array();
         $t = array();
         $sql = "SELECT wfs_conf.wfs_conf_id  FROM gui_wfs_conf, wfs_conf " . "where wfs_conf.wfs_conf_id = gui_wfs_conf.fkey_wfs_conf_id " . "and gui_wfs_conf.fkey_gui_id IN(";
         for ($i = 0; $i < count($guisByPer); $i++) {
             if ($i > 0) {
                 $sql .= ",";
             }
             $sql .= "\$" . strval($i + 1);
             array_push($v, $guisByPer[$i]);
             array_push($t, "s");
         }
         $sql .= ") GROUP BY wfs_conf.wfs_conf_id ORDER BY wfs_conf.wfs_conf_id";
         $res = db_prep_query($sql, $v, $t);
         $i = 0;
         while ($row = db_fetch_array($res)) {
             $ownWFSconfs[$i] = intval($row['wfs_conf_id']);
             $i++;
         }
     }
     return $ownWFSconfs;
 }
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
require_once dirname(__FILE__) . "/../classes/class_wms.php";
require_once dirname(__FILE__) . "/../classes/class_administration.php";
require_once dirname(__FILE__) . "/../classes/class_json.php";
$userId = Mapbender::session()->get("mb_user_id");
$command = $_GET["command"];
$guiId = $_GET["guiId"];
$groupId = $_GET["groupId"];
$admin = new administration();
$guiIdArray = $admin->getGuisByPermission($userId, false);
$resultObj = array();
if ($command == "getGroups") {
    $resultObj["group"] = array();
    $sql = "SELECT mb_group_id, mb_group_name, gettext(\$1, mb_group_description) as mb_group_description ";
    $sql .= "FROM mb_group, mb_user_mb_group ";
    $sql .= "WHERE fkey_mb_group_id = mb_group_id AND fkey_mb_user_id = \$2 ";
    $sql .= "ORDER BY mb_group_name";
    $v = array(Mapbender::session()->get("mb_lang"), $userId);
    $t = array("s", "i");
    $res = db_prep_query($sql, $v, $t);
    while ($row = db_fetch_array($res)) {
        $resultArray = array("description" => $row["mb_group_description"], "name" => $row["mb_group_name"], "id" => $row["mb_group_id"]);
        array_push($resultObj["group"], $resultArray);
    }
} else {
    die;
}
if ($searchColumnsLayer && !preg_match("/^[a-zA-Z_\\-, ]+\$/", $searchColumnsLayer)) {
    echo "[]";
    die;
}
if (!preg_match("/^[a-zA-Z_\\- ]+\$/", $query)) {
    echo "[]";
    die;
}
if (!preg_match("/^[a-zA-Z_\\-:0-9 ]+\$/", $srs)) {
    echo "[]";
    die;
}
$n = new administration();
$myguis = $n->getGuisByPermission($user_id, true);
$mywms = $n->getWmsByOwnGuis($myguis);
if ($mywms == false) {
    $mywms = array();
}
$mylayer = array();
for ($i = 0; $i < count($mywms); $i++) {
    $mylayer = array_merge($mylayer, $n->getLayerByWms($mywms[$i]));
}
$res_container_wms = array();
$res_container_layer = array();
$obj = array();
if (preg_match("/\\*/", $_REQUEST["search"])) {
    $search = trim(preg_replace("/\\*/i", "", $_REQUEST["search"]));
}
if (count($mywms) > 0) {