From 58c8b3b0315405094c448da6486354250914ea6f Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Thu, 8 Jan 2009 02:46:09 +0000 Subject: module::event now takes an unlimited number of args added module::incr_var() ftw. --- core/helpers/module.php | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'core/helpers/module.php') diff --git a/core/helpers/module.php b/core/helpers/module.php index 498bf865..9bce7a44 100644 --- a/core/helpers/module.php +++ b/core/helpers/module.php @@ -204,7 +204,9 @@ class module_Core { $class = "{$module->name}_event"; $function = str_replace(".", "_", $name); if (method_exists($class, $function)) { - call_user_func_array(array($class, $function), array(&$data)); + $args = func_get_args(); + array_shift($args); + call_user_func_array(array($class, $function), $args); } } } @@ -245,6 +247,19 @@ class module_Core { } /** + * Increment the value of a variable for this module + * @param string $module_name + * @param string $name + * @param string $increment (optional, default is 1) + */ + public function incr_var($module_name, $name, $increment=1) { + Database::instance()->query( + "UPDATE `vars` SET `value` = `value` + $increment " . + "WHERE `module_name` = '$module_name' " . + "AND `name` = '$name'"); + } + + /** * Remove a variable for this module. * @param string $module_name * @param string $name -- cgit v1.2.3