diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/constants.php | 3 | ||||
-rw-r--r-- | include/functions_plugins.inc.php | 53 |
2 files changed, 41 insertions, 15 deletions
diff --git a/include/constants.php b/include/constants.php index 849f11378..ab4afe630 100644 --- a/include/constants.php +++ b/include/constants.php @@ -35,7 +35,7 @@ define('PHPWG_DEFAULT_LANGUAGE', 'en_UK.iso-8859-1'); define('GENERAL_MESSAGE', 200); define('GENERAL_ERROR', 202); define('CRITICAL_MESSAGE', 203); -define('CRITICAL_ERROR', 204); +define('CRITICAL_ERROR', 204); // Access codes define('ACCESS_NONE', 0); @@ -71,4 +71,5 @@ define('SEARCH_TABLE', $prefixeTable.'search'); define('USER_MAIL_NOTIFICATION_TABLE', $prefixeTable.'user_mail_notification'); define('TAGS_TABLE', $prefixeTable.'tags'); define('IMAGE_TAG_TABLE', $prefixeTable.'image_tag'); +define('PLUGINS_TABLE', $prefixeTable.'plugins'); ?> diff --git a/include/functions_plugins.inc.php b/include/functions_plugins.inc.php index 23b6df5cd..f381b0a89 100644 --- a/include/functions_plugins.inc.php +++ b/include/functions_plugins.inc.php @@ -67,6 +67,10 @@ function add_event_handler($event, $func, $priority=50, $accepted_args=1) } +/* Triggers an event and calls all registered event handlers + * @param string $event name of the event + * @param mixed $data data to pass to handlers +*/ function trigger_event($event, $data=null) { global $pwg_event_handlers; @@ -123,32 +127,53 @@ function trigger_event($event, $data=null) - -function get_active_plugins($runtime = true) +/* Returns an array of plugins defined in the database + * @param string $state optional filter on this state + * @param string $id optional returns only data about given plugin +*/ +function get_db_plugins($state='', $id='') { - global $conf; - if ($conf['disable_plugins'] and $runtime) + $query = ' +SELECT * FROM '.PLUGINS_TABLE; + if (!empty($state) or !empty($id) ) { - return array(); + $query .= ' +WHERE 1=1'; + if (!empty($state)) + { + $query .= ' + AND state="'.$state.'"'; + } + if (!empty($id)) + { + $query .= ' + AND id="'.$id.'"'; + } } - if (empty($conf['active_plugins'])) + + $result = pwg_query($query); + $plugins = array(); + while ($row = mysql_fetch_array($result)) { - return array(); + array_push($plugins, $row); } - return explode(',', $conf['active_plugins']); - + return $plugins; } +/*loads all the plugins on startup*/ function load_plugins() { - $plugins = get_active_plugins(); + global $conf; + if ($conf['disable_plugins']) + { + return; + } + + $plugins = get_db_plugins('active'); foreach( $plugins as $plugin) { - if (!empty($plugin)) - { - include_once( PHPWG_PLUGINS_PATH.$plugin.'/index.php' ); - } + @include_once( PHPWG_PLUGINS_PATH.$plugin['id'].'/index.php' ); } trigger_event('plugins_loaded'); } |