<?php
/**
* @file startup_finc.php - Controls what happens on startup
* @Id $Id: startup_func.php,v 1.6 2004/07/13 17:26:20 jason Exp $
*
* Cynus - a web-based content manager
* Copyright (C) 2003 Brett and Jason Profitt
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* 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.
*
*/
/***************************
Startup - string startup()
Reads the startup table and executes the
things that need to be done
***************************/
function startup() {
global $user_config, $config;
$required=array();
$query="SELECT * from `$config[sql_prefix]startup` WHERE `min_level` <= '$user_config[level]'";
$result=mysql_query($query);
while($start=mysql_fetch_assoc($result)) {
if(!in_array("$start[module]/$start[file]", $required)) {
if($start['module']!='base') {
$file="modules/$start[module]/";
}
$file .= $start['file'];
require_once($file);
array_push($required, "$start[module]/$start[file]");
}
$statement="\$content .= $start[function]();";
eval($statement);
$content .= '<br /><br />' . "\n";
}
return $content;
}
/************************
Add to Startup - add_startup(string $name, string $file, string $function, string $module,
int $min_level, int $enabled)
This adds a function to be called at startup. These are the parameter descriptions:
$name - The function needs a name that can be displayed in the control panel
$file - Which file is going to need to be included to call this. Note, don't make this a file
that your module will include, as it will result in an error. This is a feature,
not a bug.
$function - The function that is to be called. This function can return a string and other modules
or the base can decide to use it if it chooses.
$min_level - The minimum level a user can have before the function will be called.
$enabled - You'll probably just want this as 1, but if you don't want in enabled by default,
set it to 0
************************/
function add_startup($name, $file, $function, $module, $min_level, $enabled) {
global $config;
#just to make sure we don't mess things up if somebody uses a '
$name=addslashes($name);
$query="INSERT into `$config[sql_prefix]startup` (name, file, function, module, min_level, enabled) " .
"VALUES ('$name', '$file', '$function', '$module', '$min_level', '$enabled')";
mysql_query($query);
}
?>