1
phillipd
How do you remove the "Preferences" menu in admin.
  • 2004/10/31 19:22

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


After creating an "Admin" script for my module I note there is always a "Preferences" menu item when I "mouse over" the module icon. How do I remove this? I only have one menuitem in my menu.php. Where does the other item come from?

Thanks

Doug P

2
smdcom
Re:How do you remove the

why don't you paste your menu.php here... maybe we can have a view of it..

3
tedsmith
Re:How do you remove the
  • 2004/10/31 19:41

  • tedsmith

  • Home away from home

  • Posts: 1151

  • Since: 2004/6/2 1


If I recall correctly, you can specify in Groups which user groups have admin privilages for certain areas.

Firstly, if you create a new group like 'Restricted Admins', then, Edit Group for 'Restricted Admins' in the Groups section, then, you could adjust a user not to have the Preferences option in their menu by adding him to the 'Restricted Admins' Group and then leaving unticked the 'preferences' box in Groups\Restricted Admins\System Admin Rights.

Then, when that user logs in and cliks on their System Admin box (providing you grant them webmaster status) they'll get everything else but Preferences. Or have I totally mis-understood what you are asking?

4
dheltzel
Re: How do you remove the "Preferences" menu in admin.
  • 2004/10/31 19:53

  • dheltzel

  • Not too shy to talk

  • Posts: 164

  • Since: 2003/1/8 1


Quote:

phillipd wrote:
After creating an "Admin" script for my module I note there is always a "Preferences" menu item when I "mouse over" the module icon. How do I remove this? I only have one menuitem in my menu.php. Where does the other item come from?

Thanks

Doug P

It's there because you have at least 1 config item defined in your module's xoops_version.php. The config items are managed automatically, and the preferences page is created by XOOPS to allow the admin to edit the preferences.

Dennis

5
phillipd
Re: How do you remove the "Preferences" menu in admin.
  • 2004/10/31 22:05

  • phillipd

  • Quite a regular

  • Posts: 219

  • Since: 2004/4/20


Ahh, I see. I had a:

$modversion['hasComments'] = 1;

In xoops_version.php

I removed that and the preferences option went away.

Thanks for the lead...

Still waiting for a piece of sample admin code with smarty tags...

I went ahead and wrote the admin module in php/html. I'll post it here for others to see and learn from. Try not to laugh... It is a GIS app that forms a URL to a ESRI/Oracle map service. The result is the requested map comes up in a browser with the requested bounding box and attributes. Kind of like mapquest with more data behind the map. This is just the admin code (index.php) to set reasonable defaults. The rest of the app is at the bottom. I hope it's acceptable to post code here. Sample code is what I learn from so I hope someone can learn from mine. XOOPS is cool!

/////////////////////////////////////////////////////////
//
// admin/index.php
//
/////////////////////////////////////////////////////////
<?php
include '../../../include/cp_header.php';
if ( file_exists("../language/".$xoopsConfig['language']."/main.php") ) {
include "../language/".$xoopsConfig['language']."/main.php";
} else {
include "../language/english/main.php";
}
$op = "listdefaults";

if (isset($HTTP_GET_VARS)) {
foreach ($HTTP_GET_VARS as $k => $v) {
$$k = $v;
}
}

if (isset($HTTP_POST_VARS)) {
foreach ($HTTP_POST_VARS as $k => $v) {
$$k = $v;
}
}

if ($op == "listdefaults") {
xoops_cp_header();
///////////////////////////////////////////////////////////////////////////////
///
/// Displays and sets GIS extents for city, zip and lon/lat views
///
///////////////////////////////////////////////////////////////////////////////
$opts = 'SELECT * FROM '.$xoopsDB->prefix('gis_options').'';
$result = $xoopsDB->query($opts);
list($dum,$dum,$mapservice,$cityext,$zipext,$lonlatext) = $xoopsDB->fetchRow($result);
echo "
<h3 style='text-align:center;'>"._MM_CURRENT."</h3>
<h4 style='text-align:left;'>"._MM_EXTENT_HELP."</h4>
<form action='index.php' method='post'>
<table border='0' cellpadding='0' cellspacing='0' width='90%'>
<tr>
<td class='bg2'>
<table width='100%' border='5' cellpadding='4' cellspacing='1'>

<tr nowrap='nowrap'>
<td class='bg3' width='200'>"._MM_CITY_EXT." </td>
<td class='bg1'width='400'><input type='text' value='$cityext' name='cityext' size='15' maxlength='255' /></td>
</tr>
<tr nowrap='nowrap'>
<td class='bg3' width='200'>"._MM_ZIP_EXT." </td>
<td class='bg1'width='400'><input type='text'value='$zipext' name='zipext' size='15' maxlength='255' /></td>
</tr>
<tr nowrap='nowrap'>
<td class='bg3' width='200'>"._MM_LONLAT_EXT." </td>
<td class='bg1'width='400'><input type='text' value='$lonlatext' name='lonlatext' size='15' maxlength='255' /></td>
</tr>
<tr nowrap='nowrap'>
<td class='bg3' width='200'>"._MM_MAP_SERVICE." </td>
<td class='bg1'width='400'><input type='text' value='$mapservice' name='mapservice' size='55' maxlength='255' /></td>
</tr>
<tr>
<td class='bg3'>&nbsp;</td>
<td class='bg1'>
<input type='hidden' name='op' value='setextents' />
<input type='submit' value='"._MM_SETDEFAULTS."' /></td>
</tr>
</table>
</td>
</tr>
</table>
</form>";

xoops_cp_footer();
exit();
}

if ($op == "setextents") {
$myts =& MyTextSanitizer::getInstance();
//
// Grab the numbers from the text gadgets above
//
$cityext = $HTTP_POST_VARS['cityext'];
$zipext = $HTTP_POST_VARS['zipext'];
$lonlatext = $HTTP_POST_VARS['lonlatext'];
//$mapservice = $HTTP_POST_VARS['mapservice'];
$mapservice = $myts->oopsAddSlashes(trim($HTTP_POST_VARS['mapservice']));
//
// Create a update query with the new values
//
$sql = "UPDATE ".$xoopsDB->prefix("gis_options")." set
opt_service='".$mapservice."',
opt_cityextent=".$cityext.",
opt_zipextent=".$zipext.",
opt_lonlatextent=".$lonlatext." WHERE opt_id=1";
//
// Update the gis_options table
//
if (!$xoopsDB->query($sql)) {
xoops_cp_header();
echo "Could not update GIS defaults, tell your System Administrator!";
xoops_cp_footer();
} else {
redirect_header("index.php?op=listdefaults",5,_MM_OPTSUCCESS);
}
}

?>
-----------------------------------------------------

And my mysql.sql file:

CREATE TABLE gis_zip (
zip_id int(15) unsigned NOT NULL auto_increment,
zip_zip varchar(255) NOT NULL default '',
zip_x float NOT NULL default '0.0',
zip_y float NOT NULL default '0.0',
PRIMARY KEY (zip_id)
) TYPE=MyISAM;

CREATE TABLE gis_city (
city_id int(15) unsigned NOT NULL auto_increment,
city_name varchar(255) NOT NULL default '',
city_state varchar(255) NOT NULL default '',
city_x float NOT NULL default '0.0',
city_y float NOT NULL default '0.0',
PRIMARY KEY (city_id)
) TYPE=MyISAM;

CREATE TABLE gis_sites (
site_id int(15) unsigned NOT NULL auto_increment,
site_name varchar(255) NOT NULL default '',
x1 float NOT NULL default '0.0',
y1 float NOT NULL default '0.0',
xx float NOT NULL default '0.0',
y2 float NOT NULL default '0.0',
PRIMARY KEY (site_id)
) TYPE=MyISAM;

#
# Fake data for testing
#
INSERT INTO gis_sites VALUES (1,"Knoxville",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (2,"Wilcox",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (3,"Roxbury",-77.43,41.95,-77.33,42.05);
INSERT INTO gis_sites VALUES (4,"West Boxford",-77.43,41.95,-77.33,42.05);

CREATE TABLE gis_options (
opt_id int(15) unsigned NOT NULL auto_increment,
opt_layers varchar(255) NOT NULL default '00000001100000110110010001',
opt_service varchar(255) NOT NULL default 'http://hqapp.oem.doe.gov/website/
us_detail_html',
opt_cityextent float NOT NULL default '0.15',
opt_zipextent float NOT NULL default '0.02',
opt_lonlatextent float NOT NULL default '0.05',
PRIMARY KEY (opt_id)
) TYPE=MyISAM;

INSERT INTO gis_options VALUES (1,"00000001100000110110010001","http://hqapp.oem
.doe.gov/website/us_detail_html",0.15,0.02,0.05);

CREATE TABLE gis_layers (
layer_id int(15) unsigned NOT NULL auto_increment,
layer_name varchar(255) NOT NULL default '',
PRIMARY KEY (layer_id)
) TYPE=MyISAM;
INSERT INTO gis_layers VALUES (1,"Locale");
INSERT INTO gis_layers VALUES (2,"Buildings");
INSERT INTO gis_layers VALUES (3,"");
INSERT INTO gis_layers VALUES (4,"");
INSERT INTO gis_layers VALUES (5,"Physicians");
INSERT INTO gis_layers VALUES (6,"Hospitals");
INSERT INTO gis_layers VALUES (7,"Recreation Areas");
INSERT INTO gis_layers VALUES (8,"Highways");
INSERT INTO gis_layers VALUES (9,"Streets");
INSERT INTO gis_layers VALUES (10,"");
INSERT INTO gis_layers VALUES (11,"Railroads");
INSERT INTO gis_layers VALUES (12,"");
INSERT INTO gis_layers VALUES (13,"DOE Site Buildings");
INSERT INTO gis_layers VALUES (14,"DOE Areas");
INSERT INTO gis_layers VALUES (15,"Zip Code Areas");
INSERT INTO gis_layers VALUES (16,"Counties");
INSERT INTO gis_layers VALUES (17,"Major Water");
INSERT INTO gis_layers VALUES (18,"Water Areas");
INSERT INTO gis_layers VALUES (19,"DOE Sites");
INSERT INTO gis_layers VALUES (20,"");
INSERT INTO gis_layers VALUES (21,"");
INSERT INTO gis_layers VALUES (22,"Airports");
INSERT INTO gis_layers VALUES (23,"Federal Land Areas");
INSERT INTO gis_layers VALUES (24,"Places");
INSERT INTO gis_layers VALUES (25,"Locale");
INSERT INTO gis_layers VALUES (26,"States");

OK here is the rest of the app: (index.php)

/////////////////////////////////////////////////////////
//
// index.php
//
/////////////////////////////////////////////////////////

include "../../mainfile.php";

$op = "form";
if ( isset($HTTP_POST_VARS['op']) && $HTTP_POST_VARS['op'] == "submit" ) {
$op = "submit";
}

if ( $op == "form" ) {
$xoopsOption['template_main'] = 'ecngis_searchform.html';
include XOOPS_ROOT_PATH."/header.php";
include_once XOOPS_ROOT_PATH."/class/xoopsformloader.php";

$sites_select = new XoopsFormSelect("","sites");
$sites_tray = new XoopsFormElementTray(_MM_SITE, "&nbsp;");
$sites_tray->addElement($sites_select);
$sites_select->addOption("","");
//
// Grab bounding box from DB
//
$sql = 'SELECT site_name FROM '.$xoopsDB->prefix('gis_sites').'';
$result = $xoopsDB->query($sql);

while(list($site) = $xoopsDB->fetchRow($result)) {
$sites_select->addOption($site,$site);
}

$city_text = new XoopsFormText("", "city", 20, 60);
$city_tray = new XoopsFormElementTray(_MM_CITY, "&nbsp;");
$city_tray->addElement($city_text);
$state_text = new XoopsFormText("", "state", 20, 60);
$state_tray = new XoopsFormElementTray(_MM_STATE, "&nbsp;");
$state_tray->addElement($state_text);
//$county_text = new XoopsFormText("", "county", 20, 60);
//$county_tray = new XoopsFormElementTray(_MM_COUNTY, "&nbsp;");
//$county_tray->addElement($county_text);
$zip_text = new XoopsFormText("", "zip", 20, 10);
$zip_tray = new XoopsFormElementTray(_MM_ZIP, "&nbsp;");
$zip_tray->addElement($zip_text);
$lon_text = new XoopsFormText("", "lon", 20, 60);
$lon_tray = new XoopsFormElementTray(_MM_LON, "&nbsp;");
$lon_tray->addElement($lon_text);
$lat_text = new XoopsFormText("", "lat", 20, 60);
$lat_tray = new XoopsFormElementTray(_MM_LAT, "&nbsp;");
$lat_tray->addElement($lat_text);
$op_hidden = new XoopsFormHidden("op", "submit");
$submit_button = new XoopsFormButton("", "", "Search", "submit");

//
// "searchform" is referenced in template
//
$form = new XoopsThemeForm("", "searchform", "index.php");
$form->addElement($sites_tray);
$form->addElement($city_tray);
$form->addElement($state_tray);
$form->addElement($zip_tray);
$form->addElement($lon_tray);
$form->addElement($lat_tray);
$form->addElement($op_hidden);
$form->addElement($submit_button);
$form->assign($xoopsTpl);
$xoopsTpl->assign('lang_search', _MM_SEARCH);
$xoopsTpl->assign('lang_instructions', _MM_INSTRUCTIONS);
//$site_select->setExtra("");
//$site_select->setExtra("onchange='doSite()'");
}

if ( $op == "submit" ) {
$xoopsOption['template_main'] = 'ecngis_searchresults.html';
include XOOPS_ROOT_PATH."/header.php";
$myts =& MyTextSanitizer::getInstance();
$city = $HTTP_POST_VARS['city'];
$state = $HTTP_POST_VARS['state'];
$zip = $HTTP_POST_VARS['zip'];
$lon = $HTTP_POST_VARS['lon'];
$lat = $HTTP_POST_VARS['lat'];
$site = $HTTP_POST_VARS['sites'];

$xoopsTpl->assign('lang_search', _MM_SEARCH);
$xoopsTpl->assign('lang_results', _MM_RESULTS);
$xoopsTpl->assign('lang_city', _MM_CITY);
$xoopsTpl->assign('lang_state', _MM_STATE);
$xoopsTpl->assign('lang_site', _MM_SITE);
$xoopsTpl->assign('lang_zip', _MM_ZIP);
$xoopsTpl->assign('lang_lon', _MM_LON);
$xoopsTpl->assign('lang_lat', _MM_LAT);
$xoopsTpl->assign('lang_link', _MM_LINK);

if ( !empty($HTTP_POST_VARS['sites']) ) {

$opts = 'SELECT opt_service FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($service) = $xoopsDB->fetchRow($optsresult);

$site1 = rawurlencode($site);
$row = array();
$row['site'] = $site;
$row['url'] = "$service?ActiveLayer=19&Query=NAME%3D$site1$QueryZoom=Yes";
$xoopsTpl->append('row',$row);
$xoopsTpl->assign('type', "site");
$city = $state = $zip = "";
}

if(strlen($city) > 0 || strlen($state) > 0) {
$xoopsTpl->assign('type', "city");
//
// Generate a query based on what gadgets are filled in
//
if(strlen($city) > 0 && strlen($state) > 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_name LIKE "%'.$city.'%"
AND city_state LIKE "%'.$state.'%" ORDER BY city_name';
}
if(strlen($city) > 0 && strlen($state) == 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_name LIKE "%'.$city.'%" ORDER BY city_name';
}
if(strlen($city) == 0 && strlen($state) > 0) {
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_city').'
WHERE city_state LIKE "%'.$state.'%" ORDER BY city_name';
}
$result = $xoopsDB->query($sql);
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_cityextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);

//
// Now build url for GIS viewer
//
$row = array();
$count = 0;
while (list($dbid,$dbcity, $dbstate, $dblon, $dblat) = $xoopsDB->fetchRow($result)) {
//echo"$dbcity, $dbstate, $dblon, $dblat <br></br>";
$x1 = $dblon - $extent;
$y1 = $dblat - $extent;
$x2 = $dblon + $extent;
$y2 = $dblat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = $dbcity;
$row['state'] = $dbstate;
$row['lon'] = $dblon;
$row['lat'] = $dblat;
$xoopsTpl->append('row',$row);
$count++;
}
$xoopsTpl->assign('count',$count);
}
if(strlen($zip) > 0) {
$xoopsTpl->assign('type', "zip");
$sql = 'SELECT * FROM '.$xoopsDB->prefix('gis_zip').'
WHERE zip_zip LIKE "%'.$zip.'%" ORDER BY zip_zip';
//echo "$sql <br>";
$result = $xoopsDB->query($sql);
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_zipextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);
$row = array();

$count = 0;
while (list($dbid,$dbzip, $dblon, $dblat) = $xoopsDB->fetchRow($result)) {
//echo"$dbcity, $dbstate, $dblon, $dblat <br></br>";
$x1 = $dblon - $extent;
$y1 = $dblat - $extent;
$x2 = $dblon + $extent;
$y2 = $dblat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = "";
$row['state'] = "";
$row['zip'] = $dbzip;
$row['lon'] = $dblon;
$row['lat'] = $dblat;
$xoopsTpl->append('row',$row);
$count++;
}
$xoopsTpl->assign('count',$count);
}

if(strlen($lon) > 0) {
$xoopsTpl->assign('type', "lon");
//
// Grab bounding box from DB
//
$opts = 'SELECT opt_layers,opt_service,opt_lonlatextent FROM '.$xoopsDB->prefix('gis_options').'';
$optsresult = $xoopsDB->query($opts);
list($layers,$service,$extent) = $xoopsDB->fetchRow($optsresult);
$row = array();

$count = 0;
//echo"$dbcity, $dbstate, $dblon, $dblat <br></br>";
$x1 = $lon - $extent;
$y1 = $lat - $extent;
$x2 = $lon + $extent;
$y2 = $lat + $extent;
$row['url'] = "$service/viewer.htm?box=$x1:$y1:$x2:$y2?layers=$layers";
$row['city'] = "";
$row['state'] = "";
$row['zip'] = "";
$row['lon'] = $lon;
$row['lat'] = $lat;
$xoopsTpl->append('row',$row);
$xoopsTpl->assign('count',$count);
}
}

include_once XOOPS_ROOT_PATH."/footer.php";
?>

Login

Who's Online

209 user(s) are online (113 user(s) are browsing Support Forums)


Members: 0


Guests: 209


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: May 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits