CHANGE: maintainance NucleusPlugin abstract class.
以下の4つをコミット。
NucleusPlugin::$plugidをprotectedメンバーに。
NucleusPlugin::setID()を追加。
NucleusPlugin::_applyPluginOptions()をNucleusPlugin::apply_plugin_options()に変更
ADMINクラス、ITEMクラス、MANAGERクラスとインストールスクリプトの上記に関連する修正
Commit these four modification,
change NucleusPlugin::$plugid as protected member.
add NucleusPlugin::setID().
rename NucleusPlugin::_applyPluginOptions() as apply_plugin_options().
change some codes in ADMIN, ITEM, MANAGER class and install script.
// get and install the plugin
$manager->clearCachedInfo('installedPlugins');
$plugin =& $manager->getPlugin($plugName);
- $plugin->plugid = $numCurrent;
-
+ $plugin->setID($numCurrent);
+
if ( !$plugin )
{
sql_query('DELETE FROM ' . sql_table('plugin') . ' WHERE `pfile` = \'' . addslashes($plugName) . '\'');
// store plugin options
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
+ NucleusPlugin::apply_plugin_options($aOptions);
$manager->notify('PostPluginOptionsUpdate',array('context' => 'member', 'memberid' => $memberid, 'member' => &$mem));
// if email changed, generate new password
// store plugin options
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
+ NucleusPlugin::apply_plugin_options($aOptions);
$manager->notify('PostPluginOptionsUpdate',array('context' => 'category', 'catid' => $catid));
// store plugin options
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
+ NucleusPlugin::apply_plugin_options($aOptions);
$manager->notify('PostPluginOptionsUpdate',array('context' => 'blog', 'blogid' => $blogid, 'blog' => &$blog));
$this->action_overview(_MSG_SETTINGSCHANGED);
}
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
+ NucleusPlugin::apply_plugin_options($aOptions);
$manager->notify('PostPluginOptionsUpdate',array('context' => 'global', 'plugid' => $pid));
//Setting the itemOptions
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions, $itemid);
+ NucleusPlugin::apply_plugin_options($aOptions, $itemid);
$manager->notify('PostPluginOptionsUpdate', array(
'context' => 'item',
'itemid' => $itemid,
//update the itemOptions
$aOptions = requestArray('plugoption');
- NucleusPlugin::_applyPluginOptions($aOptions);
+ NucleusPlugin::apply_plugin_options($aOptions);
$manager->notify('PostPluginOptionsUpdate', array(
'context' => 'item',
'itemid' => $itemid,
// No plugin support in AutoSaveDraft yet
//Setting the itemOptions
//$aOptions = requestArray('plugoption');
- //NucleusPlugin::_applyPluginOptions($aOptions, $itemid);
+ //NucleusPlugin::apply_plugin_options($aOptions, $itemid);
//$manager->notify('PostPluginOptionsUpdate',array('context' => 'item', 'itemid' => $itemid, 'item' => array('title' => $i_title, 'body' => $i_body, 'more' => $i_more, 'closed' => $i_closed, 'catid' => $i_catid)));
// success
}
/**
- * A helper function to load a plugin
- *
- * private
- */
+ * MANAGER::_loadPlugin()
+ * loading a certain plugin
+ *
+ * @param string $name plugin name
+ * @return void
+ */
function _loadPlugin($name)
{
if ( !class_exists($name) )
{
global $DIR_PLUGINS;
-
+
$fileName = $DIR_PLUGINS . $name . '.php';
-
+
if ( !file_exists($fileName) )
{
if ( !defined('_MANAGER_PLUGINFILE_NOTFOUND') )
ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINFILE_NOTFOUND, $name));
return 0;
}
-
+
// load plugin
include($fileName);
-
+
// check if class exists (avoid errors in eval'd code)
if ( !class_exists($name) )
{
ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINFILE_NOCLASS, $name));
return 0;
}
-
+
// add to plugin array
eval('$this->plugins[$name] = new ' . $name . '();');
-
+
// get plugid
- $this->plugins[$name]->plugid = $this->getPidFromName($name);
-
+ $this->plugins[$name]->setID($this->getPidFromName($name));
+
// unload plugin if a prefix is used and the plugin cannot handle this^
global $MYSQL_PREFIX;
if ( ($MYSQL_PREFIX != '')
ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINSQLAPI_NOTSUPPORT, $name));
return 0;
}
-
+
// call init method
$this->plugins[$name]->init();
}
$this->plugin_options = array();
$query = "SELECT d.oname as name, o.ovalue as value FROM %s o, %s d WHERE d.opid=%d AND d.oid=o.oid;";
- $query = sprintf($query, sql_table('plugin_option'), sql_table('plugin_option_desc'), (integer) $this->getID());
+ $query = sprintf($query, sql_table('plugin_option'), sql_table('plugin_option_desc'), (integer) $this->plugid);
$result = sql_query($query);
while ( $row = sql_fetch_object($result) )
{
}
/**
- * Returns the plugin ID
- *
- * public
+ * NucleusPlugin::getID()
+ * get id for this plugin
+ *
+ * @access public
+ * @param void
+ * @return integer this plugid id
*/
final public function getID()
{
- return $this->plugid;
+ return (integer) $this->plugid;
+ }
+
+ /**
+ * NucleusPlugin::setID()
+ * set favorite id for this plugin
+ *
+ * @access public
+ * @param integer $plugid favorite id for plugin
+ * @return void
+ */
+ final public function setID($plugid)
+ {
+ $this->plugid = (integer) $plugid;
+ return;
}
/**
}
// internal functions of the class starts here
-
protected $option_values; // oid_contextid => value
- protected $option_info; // context_name => array('oid' => ..., 'default' => ...)
+ protected $option_info; // context_name => array('oid' => ..., 'default' => ...)
protected $plugin_options; // see getOption()
- /* TODO: This should be protected member */
- public $plugid; // plugin id
+ protected $plugid; // plugin id
/**
* Class constructor: Initializes some internal data
*/
public function subscribtionListIsUptodate()
{
- $res = sql_query('SELECT event FROM '.sql_table('plugin_event').' WHERE pid = '.$this->getID());
+ $res = sql_query('SELECT event FROM '.sql_table('plugin_event').' WHERE pid = '.$this->plugid);
$ev = array();
while( $a = sql_fetch_array($res) )
{
}
/**
- * NucleusPlugin::_applyPluginOptions()
+ * NucleusPlugin::apply_plugin_options()
* Update its entry in database table
*
* @static
- * @param $aOptions: array ( 'oid' => array( 'contextid' => 'value'))
+ * @param $options: array ( 'oid' => array( 'contextid' => 'value'))
* (taken from request using requestVar())
* @param $newContextid: integer (accepts a contextid when it is for a new
* contextid there was no id available at the moment of writing the
* formcontrols into the page (by ex: itemOptions for new item)
* @return void
*/
- static public function _applyPluginOptions(&$aOptions, $newContextid = 0)
+ static public function apply_plugin_options(&$options, $newContextid = 0)
{
global $manager;
- if ( !is_array($aOptions) )
+ if ( !is_array($options) )
{
return;
}
- foreach ( $aOptions as $oid => $values )
+ foreach ( $options as $oid => $values )
{
// get option type info
$query = "SELECT opid, oname, ocontext, otype, oextra, odef FROM %s WHERE oid=%d;";