PDA

View Full Version : Module coding format


Michael Morris
11-09-2004, 10:45 AM
One weakness of VbaCMPS is the difficultly of module install / administration. I'm going to try the following on the next version of my pet module. Note, this is an open frame that could be used for all modules.


// Module Credits area
// Author

if (!is_object($DB_site))
// If this is true then the page is being accessed directly
// We'll therefore conduct the page as an admin interface if the user has the
// right permissions. First we'll need to initialize a new page.
{
chdir("./forums"); // Perhaps chdir to admincp and use it's global.php??
error_reporting(E_ALL & ~E_NOTICE);
define('NO_REGISTER_GLOBALS', 1);
define('THIS_SCRIPT', 'modulename');
$globaltemplates = array(
'adv_portal_modadmin_modulename'
);

require_once("./global.php");

if (!can_admin) // Check for admin permissions
{
print_no_permission();
}

//sanity check
if (empty($_REQUEST['do']))
{
$_REQUEST['do'] = 'admin';
}

if ($_REQUEST['do']=='admin')
{
//Do whatever the administration interface requires.
}
if ($_REQUEST['do']=='changes')
{
//Do the changes.
}
}
// If we get this far we are a module and should perform the actions of one.
else
{
//Module Actions
}


Anybody see any potential problems with this setup??

Brian
11-09-2004, 10:50 AM
What exactly is so difficult about adding/administrating modules?
What exactly is this code that you posted supposed to do?

Our Sponsors
 

Michael Morris
11-09-2004, 11:03 AM
When you install a *new* module (not the ones that come with vba) and it has settings that need to be attended you either need to hack the admincp as part of the installation or modify the code directly.

The code above does nothing by itself - it's a non-functional outline. However in a functional version you can go to the URL of the module and, if you're logged in as an admin, you can adjust the settings of the module beyond the very basic ones in the vbaoptions panel.

For instance, suppose I wrote a random quotes module. It simply generates a random quote from a database. If you want to add quotes to the database how would you do it under the current vba system? I've not seen a module with an admin interface yet.

Brian
11-09-2004, 11:17 AM
Why would you need to hack the admin cp to add settings? You could just add them to the adv_setting table and they would appear with the rest of the vBa settings. If you have your forum in debug mode then there are options to add/remove settings and settinggroups as well. The next version will be even easier though and the settings for each module will be modified on that module's page and stored in the same table with the modules.

Our Sponsors
 

Michael Morris
11-09-2004, 11:24 AM
I'm just going to write a quote module that implements this idea - maybe a demonstrable model will make what I'm talking about clearer.

Brian
11-09-2004, 11:26 AM
I understand what you're talking about, just don't see much of a point in it when the settings can be added with the rest of the CMPS settings. Doing it that way also adds more unnecessary code for the script to process for that module.