OSDN Git Service

chnge:$nucleus['version'] v3.5SVN to v3.50SVN
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 25 Jul 2009 14:05:06 +0000 (14:05 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Sat, 25 Jul 2009 14:05:06 +0000 (14:05 +0000)
ADD: code to warn if using a non-mysql database handler and a plugin does not supportsFeature 'SqlApi'.
CHANGE: set php setting, display_errors, to 0 when not in debug mode to keep users with poorly configured servers from displaying errors on the page.
FIX: PHP5.3 warning caused by MANAGER::notify()

git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/nucleus-jp/trunk@1043 1ca29b6e-896d-4ea0-84a5-967f57386b96

utf8/nucleus/documentation/devdocs/plugins.html
utf8/nucleus/documentation/history.html
utf8/nucleus/language/english-utf8.php
utf8/nucleus/language/english.php
utf8/nucleus/language/japanese-euc.php
utf8/nucleus/language/japanese-utf8.php
utf8/nucleus/libs/MANAGER.php
utf8/nucleus/libs/PLUGIN.php
utf8/nucleus/libs/globalfunctions.php

index b5d90c9..9168804 100755 (executable)
@@ -206,6 +206,8 @@ class NP_HelloWorld extends NucleusPlugin
         {\r
             case 'SqlTablePrefix':\r
                 return 1;\r
+                       case 'SqlApi':\r
+                               return 1;\r
             default:\r
                 return 0;\r
         }\r
@@ -1988,10 +1990,15 @@ $this-&gt;createOption('FooBar', 'foobar', 'textarea', 'This textarea is readonl
 <h2>Nucleusテーブルへのアクセス</h2>\r
 \r
 <p>v2.0まで、Nucleusテーブルへのアクセスは単に<code>nucleus_</code>と名づけられたテーブルに対してSQL命令を実行するだけのものでした。Nucleusのバージョン2.2以降はカスタム・テーブル名を利用できるようになったため、プラグイン開発に若干注意する必要があります。</p>\r
+<p>v3.5でNucleusはPDO等MySQL以外のデータベースハンドラのサポートをするようになりました。この機能はベータ実装ではありますが、プラグイン開発者はデータベースの呼び出しに使用する関数の「sql_*」への書き換えを始めてください。\r
+基本的に、使用している全ての「mysql_*」関数を「sql_*」に置き換える必要があります。たとえば<code>mysql_fetch_assoc($result)</code>は<code>sql_fetch_assoc($result)</code> に置き換えになります。\r
+全ての関数を書き換えたら、Sql APIが無い古いバージョンのNucleusインストールできないように、次に示すコードをプラグイン内に記述して、インストールに必要な最低バージョンを350に指定する必要があります。<br />\r
+<code>function getMinNucleusVersion( return '350';)</code></p>\r
 \r
 <ol>\r
     <li><code>nucleus_item</code> などの固定されたテーブル名の代わりに、テーブル名のプレフィックスを生成するために <code>sql_table('item') </code>というグローバルファンクションを利用します。</li>\r
     <li><code>supportsFeature('SqlTablePrefix')</code> が呼ばれたときにプラグインが1(真)を返すようにします。これがないと、カスタムプレフィックスがセットされている場合でバージョンが2.0より大きいNucleusではプラグインをロードできません(用心のため)。</li>\r
+    <li>3.5以降:<code>supportsFeature('SqlApi')</code> が呼ばれたときにプラグインが1(真)を返すようにします。3.5以降のバージョンでは、データベースのバックエンドにmysqlでないものを使用している場合にプラグインをロードできなくなります(用心のため)。</li>\r
 </ol>\r
 \r
 <p class="note">v2.0までのNucleusではグローバルファンクション <code>sql_table</code> は利用できないことに注意してください。もしこのメソッドを用いつつ、プラグインをv2.0以下のNucleusで動作させたい場合は、以下のコードをプラグインクラスの前に追加してください。</p>\r
index 6d19c35..567c2ba 100755 (executable)
@@ -57,6 +57,9 @@
     <li>\r
         <strong>Nucleus v3.5 (SVN)</strong>\r
         <ul>\r
+                       <li>ADD: code to warn if using a non-mysql database handler and a plugin does not supportsFeature 'SqlApi'. (ftruscot)</li>\r
+                       <li>CHANGE: set php setting, display_errors, to 0 when not in debug mode to keep users with poorly configured servers from displaying errors on the page. (ftruscot)</li>\r
+                       <li>FIX: PHP5.3 warning caused by MANAGER::notify(). See <a href="http://forum.nucleuscms.org/viewtopic.php?t=18997" title="php 5.3 Error">this thread</a>. (ftruscot)</li>\r
                <li>FIX: super-admin disallowed from uploading files if not on any teamlists. (ftruscot)</li>\r
                        <li>ADD: $CONF['ActivationDays'] variable to control days before activation expire. Manually set in config.php if needed (no admin interface). (ftruscot)</li>\r
                        <li>CHANGE:Notify ITEM link after karma votes(ACTION.php). (shizuki)</li>\r
index 0e42ab7..0748a8b 100644 (file)
@@ -8,7 +8,7 @@
 //
 // Please note: if you want to translate this file to your own language, be aware
 // that in a next Nucleus version, new variables might be added and some other ones
-// might be deleted. Therefor, it's important to list the Nucleus version for which
+// might be deleted. Therefore, it's important to list the Nucleus version for which
 // the file was written in your document.
 //
 // Fully translated language file can be sent to us and will be made
@@ -17,8 +17,6 @@
 // Note for English
 // This file is ENGLISH Language File for NucleusCMS
 
-
-
 /**
  * English Nucleus Language File
  *
@@ -34,6 +32,7 @@ define('_PLUGS_TITLE_GETPLUGINS',             'get more plugins...');
 define('_ARCHIVETYPE_YEAR', 'year');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE',            'Newer Version Available');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT',             'Upgrade available: v');
+define('_MANAGER_PLUGINSQLAPI_NOTSUPPORT', "Plugin %s was not loaded (does not support SqlApi and you are trying to use a non-mysql db)");
 
 
 /********************************************
index b0b5939..692b9e7 100755 (executable)
@@ -8,7 +8,7 @@
 //
 // Please note: if you want to translate this file to your own language, be aware
 // that in a next Nucleus version, new variables might be added and some other ones
-// might be deleted. Therefor, it's important to list the Nucleus version for which
+// might be deleted. Therefore, it's important to list the Nucleus version for which
 // the file was written in your document.
 //
 // Fully translated language file can be sent to us and will be made
@@ -32,6 +32,7 @@ define('_PLUGS_TITLE_GETPLUGINS',             'get more plugins...');
 define('_ARCHIVETYPE_YEAR', 'year');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE',            'Newer Version Available');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT',             'Upgrade available: v');
+define('_MANAGER_PLUGINSQLAPI_NOTSUPPORT', "Plugin %s was not loaded (does not support SqlApi and you are trying to use a non-mysql db)");
 
 
 /********************************************
index 5410714..42524cd 100644 (file)
@@ -34,6 +34,7 @@ define('_PLUGS_TITLE_GETPLUGINS',             '
 define('_ARCHIVETYPE_YEAR', 'ǯ');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE',            '¿·¤·¤¤¥Ð¡¼¥¸¥ç¥ó¤¬Æþ¼ê²Äǽ¤Ç¤¹');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT',             '¥¢¥Ã¥×¥°¥ì¡¼¥É¤¬Æþ¼ê²Äǽ¤Ç¤¹¡§ v');
+define('_MANAGER_PLUGINSQLAPI_NOTSUPPORT', "¥×¥é¥°¥¤¥ó %s ¤òÆɤ߹þ¤á¤Þ¤»¤ó¤Ç¤·¤¿¡£(¤³¤Î¥×¥é¥°¥¤¥ó¤ÏSqlAPI¤ò¥µ¥Ý¡¼¥È¤·¤Æ¤¤¤Þ¤»¤ó¡£¥Ç¡¼¥¿¥Ù¡¼¥¹¤ÎÀܳÊýË¡¤ò¸«Ä¾¤·¤Æ¤¯¤À¤µ¤¤)");
 
 
 /********************************************
index 2adb476..bba9ca4 100755 (executable)
@@ -34,6 +34,7 @@ define('_PLUGS_TITLE_GETPLUGINS',             'プラグインを入手…');
 define('_ARCHIVETYPE_YEAR', '年');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TITLE',            '新しいバージョンが入手可能です');
 define('_ADMIN_SYSTEMOVERVIEW_LATESTVERSION_TEXT',             'アップグレードが入手可能です: v');
+define('_MANAGER_PLUGINSQLAPI_NOTSUPPORT', "プラグイン %s を読み込めませんでした。(このプラグインはSqlAPIをサポートしていません。データベースの接続方法を見直してください)");
 
 
 /********************************************
index 46a0f89..c8662ee 100755 (executable)
@@ -277,6 +277,15 @@ class MANAGER {
                                        return 0;
                                }
 
+                               // unload plugin if using non-mysql handler and plugin does not support it 
+                               global $MYSQL_HANDLER;
+                               if ((!in_array('mysql',$MYSQL_HANDLER)) && !$this->plugins[$name]->supportsFeature('SqlApi'))
+                               {
+                                       unset($this->plugins[$name]);
+                                       ACTIONLOG::add(WARNING, sprintf(_MANAGER_PLUGINSQLAPI_NOTSUPPORT, $name));
+                                       return 0;
+                               }
+
                                // call init method
                                $this->plugins[$name]->init();
 
@@ -411,7 +420,7 @@ class MANAGER {
                                $this->_loadPlugin($listener);
                                // do notify (if method exists)
                                if (method_exists($this->plugins[$listener], 'event_' . $eventName))
-                                       call_user_func(array(&$this->plugins[$listener],'event_' . $eventName), $data);
+                                       call_user_func(array(&$this->plugins[$listener],'event_' . $eventName), &$data);
                        }
                }
 
index 1a9cb4d..69d1ada 100755 (executable)
@@ -59,7 +59,7 @@
                }
                function doAction($type) { return _ERROR_PLUGIN_NOSUCHACTION; }
                function doIf($key,$value) { return false; }
-               function doItemVar () {}
+               function doItemVar (&$item) {}
 
                /**
                 * Checks if a plugin supports a certain feature.
@@ -69,6 +69,7 @@
                 *              Name of the feature. See plugin documentation for more info
                 *                      'SqlTablePrefix' -> if the plugin uses the sql_table() method to get table names
                 *                      'HelpPage' -> if the plugin provides a helppage
+                *                              'SqlApi' -> if the plugin uses the complete sql_* api (must also require nucleuscms 3.5)
                 */
                function supportsFeature($feature) {
                        return 0;
index c3be4b3..68f5a0d 100755 (executable)
@@ -20,7 +20,7 @@
 // needed if we include globalfunctions from install.php\r
 global $nucleus, $CONF, $DIR_LIBS, $DIR_LANG, $manager, $member;\r
 \r
-$nucleus['version'] = 'v3.5SVN';\r
+$nucleus['version'] = 'v3.50SVN';\r
 $nucleus['codename'] = '';\r
 \r
 checkVars(array('nucleus', 'CONF', 'DIR_LIBS', 'MYSQL_HOST', 'MYSQL_USER', 'MYSQL_PASSWORD', 'MYSQL_DATABASE', 'DIR_LANG', 'DIR_PLUGINS', 'HTTP_GET_VARS', 'HTTP_POST_VARS', 'HTTP_COOKIE_VARS', 'HTTP_ENV_VARS', 'HTTP_SESSION_VARS', 'HTTP_POST_FILES', 'HTTP_SERVER_VARS', 'GLOBALS', 'argv', 'argc', '_GET', '_POST', '_COOKIE', '_ENV', '_SESSION', '_SERVER', '_FILES'));\r
@@ -118,6 +118,8 @@ if (!headers_sent() ) {
 global $MYSQL_HANDLER;\r
 if (!isset($MYSQL_HANDLER))\r
        $MYSQL_HANDLER = array('mysql','');\r
+if ($MYSQL_HANDLER[0] == '')\r
+       $MYSQL_HANDLER[0] = 'mysql';\r
 include_once($DIR_LIBS . 'sql/'.$MYSQL_HANDLER[0].'.php');\r
 // end new for 3.5 sql_* wrapper\r
 include_once($DIR_LIBS . 'mysql.php');\r