OSDN Git Service

コード書いただけ、実験まだ
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 4 Jul 2008 11:00:34 +0000 (11:00 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Fri, 4 Jul 2008 11:00:34 +0000 (11:00 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@647 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_EzComment2/NP_EzComment2.php

index 05d6ca0..dc14e44 100644 (file)
@@ -46,12 +46,16 @@ class NP_EzComment2 extends NucleusPlugin
                return array(
                        'ExternalAuth',
                        'LoginSuccess',
+                       'FormExtra',
+                       'PostAddComment',
                );
        }
 
        function event_ExternalAuth(&$data)
        {
                if ($this->flgLoggedin) return;
+               $authPlugins = array('OpenId');
+               if (!in_array($data['externalauth']['source'], $authPlugins)) return;
                global $manager;
                $pluginName = 'NP_' . $data['externalauth']['source'];
                if ($manager->pluginInstalled($pluginName)) {
@@ -69,6 +73,23 @@ class NP_EzComment2 extends NucleusPlugin
                $this->authModule  = $data['member'];
        }
 
+       function event_PostAddComment($data) {
+               global $manager;
+               $comment = $data['comment'];
+               if (intval(getNucleusVersion()) >= 330) {
+                       $email = $comment['email'];
+               } else {
+                       $email = $comment['userid'];
+               }
+               if (postVar('EzComment2_Secret')) {
+                       $secCheck = 1;
+               } else {
+                       $secCheck = 0;
+               }
+               $sql = 'INSERT INTO ' . sql_table('plug_ezcomment2') . '(`comid`, `secflg`) VALUES (%d, %d)';
+               sql_query(sprintf($sql, $comment['commentid'], $secCheck));
+       }
+
        function install()
        {
                if (!TEMPLATE::exists('EzCommentTemplateDefault')) {
@@ -108,6 +129,12 @@ class NP_EzComment2 extends NucleusPlugin
                }
        }
 
+       function event_FormExtra(&$data) {
+               $this->numcalled++;
+               echo '<br /><input type="checkbox" value="1" name="EzComment2_Secret" id="EzComment2_Secret_' . $this->numcalled . '" />';
+               echo '<label for="EzComment2_Secret_' . $this->numcalled . '">'.$this->getOption('secLabel').'</label><br />';
+       }
+
        function uninstall()
        {
                if ($this->getOption('tabledel') == 'yes')
@@ -122,6 +149,7 @@ class NP_EzComment2 extends NucleusPlugin
                } else {
                        include_once($this->getDirectory() . 'language/english.php');
                }
+               $this->numcalled = 0;
        }
 
        function updateTable()