OSDN Git Service

ナイショコメント対応
authorshizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 8 Jul 2008 16:28:43 +0000 (16:28 +0000)
committershizuki <shizuki@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Tue, 8 Jul 2008 16:28:43 +0000 (16:28 +0000)
ひっそりとphp4では動かなかったりします
あと、EzComment2無しの環境では試してません

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

trunk/NP_LatestWritebacks/NP_LatestWritebacks.php

index 35c02c9..29f6b4a 100644 (file)
@@ -34,7 +34,7 @@ class NP_LatestWritebacks extends NucleusPlugin
 
        function getVersion()
        {
-               return '1.5a';
+               return '1.6';
        }
 
        function getDescription()
@@ -92,6 +92,16 @@ TrackBack list template sample
 */
        }
 
+       function pluginCheck($pluginName)
+       {
+               global $manager;
+               if (!$manager->pluginInstalled('NP_' . $pluginName)) {
+                       return false;
+               }
+               $plugin =& $manager->getPlugin('NP_' . $pluginName);
+               return $plugin;
+       }
+
        function doSkinVar($skinType,
                                           $numberOfWritebacks      = 5,
                                           $filter                  = '',
@@ -130,21 +140,32 @@ TrackBack list template sample
                $arr_res = array();
 
                if ($TBorCm != 't') {
-                       // select
+                       $join  = '';
                        $query = 'SELECT'
-                                  . ' cnumber as commentid,'
-                                  . ' cuser   as commentator,'
-                                  . ' cbody   as commentbody,'
-                                  . ' citem   as itemid,'
-                                  . ' cmember as memberid,'
-//                                . ' ctime   as commentdate,'
-                                  . ' SUBSTRING(ctime, 6, 5) as commentday,'
-                                  . ' UNIX_TIMESTAMP(ctime)  as ctimest'
-                                  . ' FROM ' . sql_table('comment');
+                                  . ' c.cnumber as commentid,'
+                                  . ' c.cuser   as commentator,'
+                                  . ' c.cbody   as commentbody,'
+                                  . ' c.citem   as itemid,'
+                                  . ' c.cmember as memberid,'
+//                                . ' c.ctime   as commentdate,'
+                                  . ' SUBSTRING(c.ctime, 6, 5) as commentday,'
+                                  . ' UNIX_TIMESTAMP(c.ctime)  as ctimest';
+                       if ($EzComment2 = $this->pluginCheck('EzComment2')) {
+                               if (method_exists($EzComment2, 'getTemplateParts')) {
+                                       $query .= ', s.comid   as cid, '
+                                                       . 's.secflg  as secret, '
+                                                       . 's.module  as modname, '
+                                                       . 's.userID  as identity ';
+                                       $join   = ' LEFT OUTER JOIN ' . sql_table('plug_ezcomment2') . ' as s '
+                                                       . ' ON c.cnumber = s.comid ';
+                               }
+                       }
+                       // select
+                       $query .= ' FROM ' . sql_table('comment') .' as c ' . $join;
                        if ($filter) {
                                $query .= ' WHERE ' . $filter;
                        }
-                       $query .= ' ORDER by ctime DESC LIMIT 0, ' . $numberOfWritebacks;
+                       $query .= ' ORDER by c.ctime DESC LIMIT 0, ' . $numberOfWritebacks;
 
                        $comments = sql_query($query);
 
@@ -154,15 +175,26 @@ TrackBack list template sample
                                        $tempBody               = strip_tags($content['commentbody']);
                                        $tempBody               = htmlspecialchars($tempBody, ENT_QUOTES);
                                        $tempBody               = shorten($tempBody, $numberOfCharacters, $toadd);
-                                       $tempBody               = htmlspecialchars($tempBody, ENT_QUOTES);
+                                       $tempBody               = htmlspecialchars(htmlspecialchars_decode($tempBody), ENT_QUOTES);
                                        $tempBody               = str_replace("\r\n", ' ', $tempBody);
                                        $content['commentdate'] = strftime($this->getOption('cmdateformat'), $content['ctimest']);
-                                       $content['commentbody'] = $tempBody;
+                                       $content['commentbody'] = str_replace("&amp;amp;", '&amp;', $tempBody);
                                        if (!empty($row->memberid)) {
                                                $mem                    = new MEMBER;
                                                $mem->readFromID(intval($row->memberid));
                                                $content['commentator'] = $mem->getRealName();
                                        }
+                                       if ($EzComment2) {
+                                               $bid = intval(getBlogIDFromItemID(intval($comment['itemid'])));
+                                               if ($EzComment2->getBlogOption($bid, 'secret') == 'yes') {
+                                                       $b     = $manager->getBlog($bid);
+                                                       global $member;
+                                                       $judge = $EzComment2->setSecretJudge($bid, $member, $b);
+                                               }
+                                       }
+                                       if ($judge && $content['secret']) {
+                                               $content = $EzComment2->JudgementCommentSecrets($content, $judge);
+                                       }
 
 /*                                     $cid  = $row->cnumber;
                                        $ct  = $row->ctimest;