* @static
* @param $options: array ( 'oid' => array( 'contextid' => 'value'))
* (taken from request using requestVar())
- * @param $newContextid: integer (accepts a contextid when it is for a new
+ * @param $new_contextid: 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 apply_plugin_options(&$options, $newContextid = 0)
+ static public function apply_plugin_options(&$options, $new_contextid = 0)
{
global $manager;
+
if ( !is_array($options) )
{
return;
$result = sql_query($query);
if ( $info = sql_fetch_object($result) )
{
- foreach ( $values as $key => $value )
+ foreach ( $values as $id => $value )
{
- // avoid overriding the key used by foreach statement
- $contextid=$key;
+ // decide wether we are using the contextid of newContextid
+ if ( $new_contextid != 0 )
+ {
+ $contextid = $new_contextid;
+ }
+ else
+ {
+ $contextid = $id;
+ }
// retreive any metadata
$meta = NucleusPlugin::getOptionMeta($info->oextra);
break;
}
- // decide wether we are using the contextid of newContextid
- if ( $newContextid != 0 )
- {
- $contextid = $newContextid;
- }
-
/*
* trigger event PrePluginOptionsUpdate to give the plugin the
* possibility to change/validate the new value for the option