OSDN Git Service

code cleanup for PLUGIN.php
authorsakamocchi <o-takashi@sakamocchi.jp>
Thu, 9 Feb 2012 14:36:17 +0000 (23:36 +0900)
committersakamocchi <o-takashi@sakamocchi.jp>
Thu, 9 Feb 2012 14:36:17 +0000 (23:36 +0900)
nucleus/libs/PLUGIN.php

index ec81a95..380715d 100644 (file)
@@ -875,14 +875,15 @@ abstract class NucleusPlugin
         * @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;
@@ -896,10 +897,17 @@ abstract class NucleusPlugin
                        $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);
@@ -937,12 +945,6 @@ abstract class NucleusPlugin
                                                        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