$filehooks) { if (!isset($plugin_filename) || $this_plugin_name == $plugin_filename) { if (array_key_exists($hook, $filehooks)) { foreach($filehooks[$hook] as $fnct) { if (function_exists($fnct)) { _pf("calling plugin func $fnct in '$this_plugin_name' for $hook ..."); $data = call_user_func($fnct,$data); _pf("done"); } } } } } return $data; } /***** Plugin options ******/ /** * Wrapper functions for plugins * * Notes: Make sure that $value and $default are not escaped strings/arrays of strings, * otherwise they will not come out of the database correctly because of rss_real_escape_string */ function rss_plugins_add_option($key, $value, $type = "string", $default = "", $desc= "", $export = NULL) { if (!$key) { return false; } $pKey = "plugins." . rss_real_escape_string($key); if (is_array($value) || $type == 'array') { $value = serialize($value); } $value = rss_real_escape_string($value); $default = $default? $default: $value; $ret = rss_query("replace into " . getTable("config") . " (key_,value_,default_,type_,desc_,export_) VALUES (" . "'$pKey','$value','$default','$type','$desc','$export')" ); configInvalidate(); return $ret; } function rss_plugins_get_option($key) { if (!$key) { return false; } return getConfig("plugins.".rss_real_escape_string($key), false); } function rss_plugins_delete_option($key) { if (!$key) { return; } $pKey = "plugins." . rss_real_escape_string($key); $ret = rss_query("delete from " . getTable("config") . " where key_='$pKey'"); configInvalidate(); return $ret; } function rss_plugins_set_item_state($itemId, $bit_mask, $set , $sqlwhere = "", $entire_db = false) { $retvalue = false; if($itemId || $entire_db) { // Check to see if itemId is set or if we are allowed to fsck up the entire db // the bitmask has a one in the spot (field(s)) we want to change. if($set ) { // Set the value to the field to 1 $sql = "update " .getTable("item") ." set unread = unread | ". $bit_mask; } else { // set the value of the field to 0 $sql = "update " .getTable("item") ." set unread = unread & ". ~ $bit_mask; } if($itemId) { if (is_array($itemId)) { $sql .= " where id in (" . implode(',',$itemId) .")"; } else { // assume it is a number or a string $sql .= " where id=" .$itemId; } } else { $sql .= " where 1"; } if($sqlwhere) { $sql .= " and " . $sqlwhere; } $retvalue = rss_query($sql); rss_invalidate_cache(); } else { $retvalue = false; } return $retvalue; } function rss_plugins_get_plugins_http_path() { //returns http://example.com/rss/plugins/ return guessTransportProto().$_SERVER['HTTP_HOST'] . getPath() . RSS_PLUGINS_DIR . "/"; } /** * loads the specified plugin file */ function rss_load_plugin( $plugin_filename ) { set_loading_plugin($plugin_filename); if( file_exists(rss_home_dir() . RSS_PLUGINS_DIR.'/'.$plugin_filename ) ) { rss_require(RSS_PLUGINS_DIR.'/'.$plugin_filename); } set_loading_plugin(''); } /** * loads the active plugins from the config, instantiates * them */ foreach(getConfig('rss.config.plugins') as $pf) { rss_load_plugin($pf); } /* * autoload plugins specific to a theme without the * need to add them to config * all plugins def must be inside a unique file called plugins.php that * do all the works */ $mythemeplugin=getThemePath(GREGARIUS_HOME)."plugins.php"; if (file_exists($mythemeplugin)) { require_once($mythemeplugin); } ?>