OSDN Git Service

表示処理追加
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Thu, 3 Jul 2008 16:34:47 +0000 (16:34 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Thu, 3 Jul 2008 16:34:47 +0000 (16:34 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@646 1ca29b6e-896d-4ea0-84a5-967f57386b96

trunk/NP_EzComment2/NP_EzComment2.php
trunk/NP_EzComment2/npezcomment2/language/english.php
trunk/NP_EzComment2/npezcomment2/language/japanese-euc.php
trunk/NP_EzComment2/npezcomment2/language/japanese-utf8.php

index 5af3d1c..05d6ca0 100644 (file)
@@ -2,8 +2,8 @@
 
 class NP_EzComment2 extends NucleusPlugin
 {
-       var $isLoggedin = false;
-       var $isMemberLoggedin = false;
+       var $authModule  = null;
+       var $flgLoggedin = false;
 
        function getName()
        {
@@ -51,17 +51,22 @@ class NP_EzComment2 extends NucleusPlugin
 
        function event_ExternalAuth(&$data)
        {
-               if ($this->isLoggedin) return;
+               if ($this->flgLoggedin) return;
                global $manager;
-               $authPlug =& $manager->getPlugin('NP_' . $data['externalauth']['source']);
-               if( $authPlug->isLoggedin() ){
-                       $this->isLoggedin = true;
+               $pluginName = 'NP_' . $data['externalauth']['source'];
+               if ($manager->pluginInstalled($pluginName)) {
+                       $authPlugin =& $manager->getPlugin($pluginName);
+                       if( $authPlugin->isLoggedin() ){
+                               $this->flgLoggedin = true;
+                               $this->authModule  = $authPlugin;
+                       }
                }
        }
 
        function event_LoginSuccess($data)
        {
-               $this->isMemberLoggedin = true;
+               $this->flgLoggedin = true;
+               $this->authModule  = $data['member'];
        }
 
        function install()
@@ -90,13 +95,16 @@ class NP_EzComment2 extends NucleusPlugin
                                $message = implode("<br />\n", $aErrors);
                                doError($message);
                        }
-                       createBlogOption('secret', 'Enable seacret comment ?', 'yesno', 'no');
-                       createOption('tabledel', 'Database table drop when uninstall ?', 'yesno', 'no');
+                       createBlogOption('secret',     _NP_EZCOMMENT2_OP_SECRETMODE,  'yesno', 'no');
+                       createBlogOption('secComment', _NP_EZCOMMENT2_OP_SUBSTIUTION, 'text',  _NP_EZCOMMENT2_OP_SUBSTIUTION_VAL);
+                       createBlogOption('secLabel',   _NP_EZCOMMENT2_OP_CHECKLABEL,  'text',  _NP_EZCOMMENT2_OP_CHECKLABEL_VAL);
+                       createOption('tabledel',       _NP_EZCOMMENT2_OP_DROPTABLE,   'yesno', 'no');
                        $sql = 'CREATE TABLE IF NOT EXISTS %s ('
-                                . 'comid  int(11) NOT NULL,'
-                                . 'secflg int(11) NOT NULL,'
-                                . 'PRIMARY KEY(comid) );';
+                                . '`comid`  int(11) NOT NULL,'
+                                . '`secflg` tinyint(1) NULL,'
+                                . 'PRIMARY KEY(`comid`) );';
                        sql_query(sprintf($sql, sql_table('plug_ezcomment2')));
+                       $this->updateTable();
                }
        }
 
@@ -116,6 +124,15 @@ class NP_EzComment2 extends NucleusPlugin
                }
        }
 
+       function updateTable()
+       {
+               $sql = 'SELECT cnumber FROM ' . sql_table('comment') . ' ORDER BY cnumber';
+               $res = sql_query($sql);
+               $sql = 'INSERT INTO ' . sql_table('plug_ezcomment2') . '(`comid`) VALUES (%d)';
+               while ($cid = mysql_fetch_assoc($res)) {
+                       sql_query(sprintf($sql, $cid['cnumber']));
+               }
+       }
 
        function doTemplateVar(&$item,
                                                        $showType       = '',
@@ -296,9 +313,12 @@ class NP_EzComment2 extends NucleusPlugin
                           . 'c.ctime, '
                           . 'c.chost   as host, '
                           . 'c.cip     as ip, '
-                          . 'c.cblog   as blogid'
-                          . ' FROM ' . sql_table('comment') . ' as c'
-                          . ' WHERE c.citem=' . intval($commentItem->itemid)
+                          . 'c.cblog   as blogid, '
+                          . 's.secflg  as secret'
+                          . ' FROM ' . sql_table('comment') . ' as c, '
+                          .            sql_table('plug_ezcomment2') . ' as s '
+                          . ' WHERE c.citem = ' . intval($commentItem->itemid) . ', '
+                          . ' AND   s.comid = c.cnumber '
                           . ' ORDER BY c.ctime '
                           . $order;
                if ($maxToShow) {
@@ -311,11 +331,29 @@ class NP_EzComment2 extends NucleusPlugin
                $comments = sql_query($query);
                $viewnum  = mysql_num_rows($comments);
                $actions->setViewnum($viewnum);
+               if ($this->getBlogOption($bid, 'secret') == 'yes') {
+                       $secretMode = true;
+                       if ($this->flgLoggedin)
+                               $secretComments = $this->getSecretComments();
+               }
 
                $parser->parse($template['COMMENTS_HEADER']);
 
                while ( $comment = mysql_fetch_assoc($comments) ) {
                        $comment['timestamp'] = strtotime($comment['ctime']);
+                       if ($comment['secret']) {
+                               global $member;
+                               if (!$this->flgLoggedin ||
+                                       ( !$menber->blogAdminRights($bid) &&
+                                         !in_array($comment['commentid'], $secretComments)) )
+                               {
+                                       $comment['body']   = $this->getBlogOption($bid, 'secComment');
+                                       $comment['userid'] = $b->getURL();
+                                       $comment['email']  = '#';
+                                       $comment['host']   = '127.0.0.1';
+                                       $comment['ip']     = '127.0.0.1';
+                               }
+                       }
                        $actions->setCurrentComment($comment);
                        $manager->notify('PreComment', array('comment' => &$comment));
                        $parser->parse($template['COMMENTS_BODY']);
index 6f204b7..59c90e2 100644 (file)
@@ -8,3 +8,10 @@ define('_NP_EZCOMMENT2_DESC', 'Insert a comment form and a list of comments.'
 define('_NP_EZCOMMENT2_FORM_TEMPLATES',   'NP_EzComment2 CommentForm Template');
 define('_NP_EZCOMMENT2_FORM_LOGGEDIN',    'Comment form for loggedin');
 define('_NP_EZCOMMENT2_FORM_NOTLOGGEDIN', 'Comment form for not loggedin');
+
+define('_NP_EZCOMMENT2_OP_SECRETMODE',      'Is the secret mode made effective ?');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION',     'Substitution seacret comment.');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL',      'Label in a check box.');
+define('_NP_EZCOMMENT2_OP_DROPTABLE',       'When uninstalling, is a table eliminated ?');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION_VAL', 'Only an administrator can read this comment.');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL_VAL',  'Indication is permitted only an administrator.');
index 06da8f7..10fd394 100644 (file)
@@ -7,3 +7,10 @@ define('_NP_EZCOMMENT2_DESC', '
 define('_NP_EZCOMMENT2_FORM_TEMPLATES',   'NP_EzComment2ÍÑ¥³¥á¥ó¥È¥Õ¥©¡¼¥à¤Î¥Æ¥ó¥×¥ì¡¼¥È');
 define('_NP_EZCOMMENT2_FORM_LOGGEDIN',    '¥á¥ó¥Ð¡¼¤¬¥í¥°¥¤¥ó¤·¤Æ¤¤¤ë¤È¤­¤Ëɽ¼¨¤µ¤ì¤ë¥Õ¥©¡¼¥à');
 define('_NP_EZCOMMENT2_FORM_NOTLOGGEDIN', '¥í¥°¥¤¥ó¤·¤Æ¤¤¤Ê¤¤¥á¥ó¥Ð¡¼¡¢¤Þ¤¿¤Ï¥²¥¹¥È¤Ëɽ¼¨¤µ¤ì¤ë¥Õ¥©¡¼¥à');
+
+define('_NP_EZCOMMENT2_OP_SECRETMODE',      '\8e¢¥Ê¥¤¥·¥ç¥³¥á¥ó¥È\8e£¤òÍ­¸ú¤Ë¤·¤Þ¤¹¤«¡©');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION',     '\8e¢¥Ê¥¤¥·¥ç¥³¥á¥ó¥È\8e£¤ÎÂåÂØ¥³¥á¥ó¥È');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL',      '¥Á¥§¥Ã¥¯¥Ü¥Ã¥¯¥¹¤Î¥é¥Ù¥ë');
+define('_NP_EZCOMMENT2_OP_DROPTABLE',       '¥¢¥ó¥¤¥ó¥¹¥È¡¼¥ë¤Î»þ¤Ë¥Ç¡¼¥¿¥Ù¡¼¥¹¤«¤é¥Æ¡¼¥Ö¥ë¤òºï½ü¤·¤Þ¤¹¤«¡©');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION_VAL', '¤³¤Î¥³¥á¥ó¥È¤Ï´ÉÍý¼Ô¤Î¤ß±ÜÍ÷¤Ç¤­¤Þ¤¹');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL_VAL',  '´ÉÍý¼Ô¤Ë¤À¤±É½¼¨¤òµö²Ä¤¹¤ë');
index c8d571b..d5d8a8c 100644 (file)
@@ -7,3 +7,10 @@ define('_NP_EZCOMMENT2_DESC', 'コメントリストとコメントフォーム
 define('_NP_EZCOMMENT2_FORM_TEMPLATES',   'NP_EzComment2用コメントフォームのテンプレート');
 define('_NP_EZCOMMENT2_FORM_LOGGEDIN',    'メンバーがログインしているときに表示されるフォーム');
 define('_NP_EZCOMMENT2_FORM_NOTLOGGEDIN', 'ログインしていないメンバー、またはゲストに表示されるフォーム');
+
+define('_NP_EZCOMMENT2_OP_SECRETMODE',      '「ナイショコメント」を有効にしますか?');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION',     '「ナイショコメント」の代替コメント');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL',      'チェックボックスのラベル');
+define('_NP_EZCOMMENT2_OP_DROPTABLE',       'アンインストールの時にデータベースからテーブルを削除しますか?');
+define('_NP_EZCOMMENT2_OP_SUBSTIUTION_VAL', 'このコメントは管理者のみ閲覧できます');
+define('_NP_EZCOMMENT2_OP_CHECKLABEL_VAL',  '管理者にだけ表示を許可する');