OSDN Git Service

MERGE: リビジョン1818。Parserクラスのコンストラクタを変更。BaseActions派生クラスのメソッド名を変更
[nucleus-jp/nucleus-next.git] / nucleus / libs / COMMENTACTIONS.php
index 252db77..b320145 100644 (file)
-<?php\r
-/*\r
- * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)\r
- * Copyright (C) 2002-2012 The Nucleus Group\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- * (see nucleus/documentation/index.html#license for more info)\r
- */\r
-/**\r
- * This class is used when parsing comment templates\r
- *\r
- * @license http://nucleuscms.org/license.txt GNU General Public License\r
- * @copyright Copyright (C) 2002-2012 The Nucleus Group\r
- * @version $Id: CommentActions.php 1626 2012-01-09 15:46:54Z sakamocchi $\r
- */\r
-\r
-class CommentActions extends BaseActions\r
-{\r
-\r
-       // ref to COMMENTS object which is using this object to handle\r
-       // its templatevars\r
-       var $commentsObj;\r
-\r
-       // template to use to parse the comments\r
-       var $template;\r
-\r
-       // comment currenlty being handled (mysql result assoc array; see Comments::showComments())\r
-       var $currentComment;\r
-\r
-       function __construct(&$comments) {\r
-               // call constructor of superclass first\r
-               $this->BaseActions();\r
-\r
-               // reference to the comments object\r
-               $this->setCommentsObj($comments);\r
-       }\r
-\r
-       function getDefinedActions() {\r
-               return array(\r
-                       'blogurl',\r
-                       'commentcount',\r
-                       'commentword',\r
-                       'email',\r
-                       'itemlink',\r
-                       'itemid',\r
-                       'itemtitle',\r
-                       'date',\r
-                       'time',\r
-                       'commentid',\r
-                       'body',\r
-                       'memberid',\r
-                       'timestamp',\r
-                       'host',\r
-                       'ip',\r
-                       'blogid',\r
-                       'authtext',\r
-                       'user',\r
-                       'userid',\r
-                       'userlinkraw',\r
-                       'userlink',\r
-                       'useremail',\r
-                       'userwebsite',\r
-                       'userwebsitelink',\r
-                       'excerpt',\r
-                       'short',\r
-                       'skinfile',\r
-                       'set',\r
-                       'plugin',\r
-                       'include',\r
-                       'phpinclude',\r
-                       'parsedinclude',\r
-                       'if',\r
-                       'else',\r
-                       'endif',\r
-                       'elseif',\r
-                       'ifnot',\r
-                       'elseifnot'\r
-               );\r
-       }\r
-\r
-       function setParser(&$parser) {\r
-               $this->parser =& $parser;\r
-       }\r
-\r
-       function setCommentsObj(&$commentsObj) {\r
-               $this->commentsObj =& $commentsObj;\r
-       }\r
-\r
-       function setTemplate($template) {\r
-               $this->template =& $template;\r
-       }\r
-       \r
-       /**\r
-        * CommentActions::setCurrentComment()\r
-        * Set $currentcommentid and $currentcommentarray\r
-        * \r
-        * @param       Array   $comment        array with comment elements\r
-        * @return      void\r
-        * \r
-        */\r
-       function setCurrentComment(&$comment)\r
-       {\r
-               global $currentcommentid, $currentcommentarray, $manager;\r
-               \r
-               if ( $comment['memberid'] != 0 )\r
-               {\r
-                       if ( !array_key_exists('COMMENTS_AUTH', $this->template) )\r
-                       {\r
-                               $comment['authtext'] = '';\r
-                       }\r
-                       else\r
-                       {\r
-                               $comment['authtext'] = $this->template['COMMENTS_AUTH'];\r
-                       }\r
-                       \r
-                       $mem =& $manager->getMember($comment['memberid']);\r
-                       $comment['user'] = $mem->getDisplayName();\r
-                       \r
-                       if ( $mem->getURL() )\r
-                       {\r
-                               $comment['userid'] = $mem->getURL();\r
-                       }\r
-                       else\r
-                       {\r
-                               $comment['userid'] = $mem->getEmail();\r
-                       }\r
-                       \r
-                       $comment['userlinkraw'] = Link::create_link(\r
-                                                                               'member',\r
-                                                                               array(\r
-                                                                                       'memberid' => $comment['memberid'],\r
-                                                                                       'name' => $mem->getDisplayName(),\r
-                                                                                       'extra' => $this->commentsObj->itemActions->linkparams\r
-                                                                               )\r
-                                                                       );\r
-               }\r
-               else\r
-               {\r
-                       // create smart links\r
-                       if ( !array_key_exists('userid', $comment) || !empty($comment['userid']) )\r
-                       {\r
-                               if ( (i18n::strpos($comment['userid'], 'http://') === 0) || (i18n::strpos($comment['userid'], 'https://') === 0) )\r
-                               {\r
-                                       $comment['userlinkraw'] = $comment['userid'];\r
-                               }\r
-                               else\r
-                               {\r
-                                       $comment['userlinkraw'] = 'http://' . $comment['userid'];\r
-                               }\r
-                       }\r
-                       else if ( NOTIFICATION::address_validation($comment['email']) )\r
-                       {\r
-                               $comment['userlinkraw'] = 'mailto:' . $comment['email'];\r
-                       }\r
-                       else if ( NOTIFICATION::address_validation($comment['userid']) )\r
-                       {\r
-                               $comment['userlinkraw'] = 'mailto:' . $comment['userid'];\r
-                       }\r
-               }\r
-               \r
-               $this->currentComment =& $comment;\r
-               $currentcommentid = $comment['commentid'];\r
-               $currentcommentarray = $comment;\r
-               return;\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar authtext\r
-        */\r
-       function parse_authtext() {\r
-               if ($this->currentComment['memberid'] != 0)\r
-                       $this->parser->parse($this->template['COMMENTS_AUTH']);\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar blogid\r
-        */\r
-       function parse_blogid() {\r
-               echo $this->currentComment['blogid'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar blogurl\r
-        */\r
-       function parse_blogurl() {\r
-               global $manager;\r
-               $blogid = getBlogIDFromItemID($this->commentsObj->itemid);\r
-               $blog =& $manager->getBlog($blogid);\r
-               echo $blog->getURL();\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar body\r
-        */\r
-       function parse_body() {\r
-               echo $this->highlight($this->currentComment['body']);\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar commentcount\r
-        */\r
-       function parse_commentcount() {\r
-                       echo $this->commentsObj->commentcount;\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar commentid\r
-        */\r
-       function parse_commentid() {\r
-               echo $this->currentComment['commentid'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar commentword\r
-        */\r
-       function parse_commentword() {\r
-               if ($this->commentsObj->commentcount == 1)\r
-                       echo $this->template['COMMENTS_ONE'];\r
-               else\r
-                       echo $this->template['COMMENTS_MANY'];\r
-       }\r
-       \r
-       /**\r
-        * CommentActions::parse_date()\r
-        * Parse templatevar date\r
-        * \r
-        * @format      String  $format Date format according to PHP\r
-        * @return      void\r
-        * \r
-        */\r
-       function parse_date($format = '')\r
-       {\r
-               if ( $format !== '' )\r
-               {\r
-                       /* do nothing */\r
-                       ;\r
-               }\r
-               else if ( !array_key_exists('FORMAT_DATE', $this->template) || $this->template['FORMAT_DATE'] === '' )\r
-               {\r
-                       $format = '%X';\r
-               }\r
-               else\r
-               {\r
-                       $format = $this->template['FORMAT_DATE'];\r
-               }\r
-               \r
-               $offset = $this->commentsObj->itemActions->blog->getTimeOffset() * 3600;\r
-               \r
-               echo i18n::formatted_datetime($format, $this->currentComment['timestamp'], $offset);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse templatevar email\r
-        */\r
-       function parse_email() {\r
-               $email = $this->currentComment['email'];\r
-               $email = str_replace('@', ' (at) ', $email);\r
-               $email = str_replace('.', ' (dot) ', $email);\r
-               echo $email;\r
-       }\r
-\r
-       /**\r
-        * CommentActions::parse_excerpt()\r
-        * Parse templatevar excerpt\r
-        * \r
-        * @param       Void\r
-        * @return      String  templatevar excerpt\r
-        */\r
-       function parse_excerpt()\r
-       {\r
-               echo Entity::hen(Entity::shorten($this->currentComment['body'], 60, '...'));\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar host\r
-        */\r
-       function parse_host() {\r
-               echo $this->currentComment['host'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar ip\r
-        */\r
-       function parse_ip() {\r
-               echo $this->currentComment['ip'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar itemid\r
-        */\r
-       function parse_itemid() {\r
-               echo $this->commentsObj->itemid;\r
-       }\r
-       \r
-       /**\r
-        * CommentActions::parse_itemlink()\r
-        * Parse templatevar itemlink\r
-        * \r
-        * @param       Void\r
-        * @return      Void\r
-        */\r
-       function parse_itemlink()\r
-       {\r
-               echo Link::create_link(\r
-                       'item',\r
-                       array(\r
-                               'itemid' => $this->commentsObj->itemid,\r
-                               'timestamp' => $this->commentsObj->itemActions->currentItem->timestamp,\r
-                               'title' => $this->commentsObj->itemActions->currentItem->title,\r
-                               'extra' => $this->commentsObj->itemActions->linkparams\r
-                       )\r
-               );\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse templatevar itemtitle\r
-        */\r
-       function parse_itemtitle($maxLength = 0) {\r
-               if ($maxLength == 0)\r
-                       $this->commentsObj->itemActions->parse_title();\r
-               else\r
-                       $this->commentsObj->itemActions->parse_syndicate_title($maxLength);\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar memberid\r
-        */\r
-       function parse_memberid() {\r
-               echo $this->currentComment['memberid'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar short\r
-        */\r
-       function parse_short() {\r
-               $tmp = strtok($this->currentComment['body'],"\n");\r
-               $tmp = str_replace('<br />','',$tmp);\r
-               echo $tmp;\r
-               if ($tmp != $this->currentComment['body'])\r
-                       $this->parser->parse($this->template['COMMENTS_CONTINUED']);\r
-       }\r
-       \r
-       /**\r
-        * CommentActions::parse_time()\r
-        * Parse templatevar time\r
-        * \r
-        * @param       string  $format datetime format referring to strftime() in PHP's built-in function\r
-        * @return      void\r
-        * \r
-        */\r
-       function parse_time($format = '')\r
-       {\r
-               if ( $format === '' )\r
-               {\r
-                       /* do nothing */\r
-                       ;\r
-               }\r
-               else if ( !array_key_exists('FORMAT_TIME', $this->template) || $this->template['FORMAT_TIME'] === '' )\r
-               {\r
-                       $format = '%x';\r
-               }\r
-               else\r
-               {\r
-                       $format = $this->template['FORMAT_TIME'];\r
-               }\r
-               \r
-               echo i18n::formatted_datetime($format, $this->currentComment['timestamp']);\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse templatevar timestamp\r
-        */\r
-       function parse_timestamp() {\r
-               echo $this->currentComment['timestamp'];\r
-       }\r
-\r
-       /**\r
-         * Executes a plugin templatevar\r
-         *\r
-         * @param pluginName name of plugin (without the NP_)\r
-         *\r
-         * extra parameters can be added\r
-         */\r
-       function parse_plugin($pluginName) {\r
-               global $manager;\r
-\r
-               // only continue when the plugin is really installed\r
-               if (!$manager->pluginInstalled('NP_' . $pluginName))\r
-                       return;\r
-\r
-               $plugin =& $manager->getPlugin('NP_' . $pluginName);\r
-               if (!$plugin) return;\r
-\r
-               // get arguments\r
-               $params = func_get_args();\r
-\r
-               // remove plugin name\r
-               array_shift($params);\r
-\r
-               // pass info on current item and current comment as well\r
-               $params = array_merge(array(&$this->currentComment),$params);\r
-               $params = array_merge(array(&$this->commentsObj->itemActions->currentItem),$params);\r
-\r
-               call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params);\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar user\r
-        * @param string $mode\r
-        */\r
-       function parse_user($mode = '')\r
-       {\r
-               global $manager;\r
-\r
-               if ( $mode == 'realname' && $this->currentComment['memberid'] > 0 )\r
-               {\r
-                       $member =& $manager->getMember($this->currentComment['memberid']);\r
-                       echo $member->getRealName();\r
-               }\r
-               else\r
-               {\r
-                       echo Entity::hsc($this->currentComment['user']);\r
-               }\r
-       }\r
-\r
-       /**\r
-        * CommentActions::parse_useremail()\r
-        * Output mail address\r
-        * \r
-        * @param       void\r
-        * @return      void\r
-        */\r
-       function parse_useremail() {\r
-               global $manager;\r
-               if ( $this->currentComment['memberid'] > 0 )\r
-               {\r
-                       $member =& $manager->getMember($this->currentComment['memberid']);\r
-                       \r
-                       if ( $member->email != '' )\r
-                       {\r
-                               echo $member->email;\r
-                       }\r
-               }\r
-               else\r
-               {\r
-                       if ( NOTIFICATION::address_validation($this->currentComment['email']) )\r
-                       {\r
-                               echo $this->currentComment['email'];\r
-                       }\r
-                       elseif ( NOTIFICATION::address_validation($this->currentComment['userid']) )\r
-                       {\r
-                               echo $this->currentComment['userid'];\r
-                       }\r
-               }\r
-               return;\r
-       }\r
-       \r
-       /**\r
-        * Parse templatevar userid\r
-        */\r
-       function parse_userid() {\r
-                       echo $this->currentComment['userid'];\r
-       }\r
-\r
-\r
-       /**\r
-        * Parse templatevar userlink\r
-        */\r
-       function parse_userlink() {\r
-               if ($this->currentComment['userlinkraw']) {\r
-                       echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';\r
-               } else {\r
-                       echo $this->currentComment['user'];\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar userlinkraw\r
-        */\r
-       function parse_userlinkraw() {\r
-               echo $this->currentComment['userlinkraw'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar userwebsite\r
-        */\r
-       function parse_userwebsite() {\r
-               if (!(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false))\r
-                       echo $this->currentComment['userlinkraw'];\r
-       }\r
-\r
-       /**\r
-        * Parse templatevar userwebsitelink\r
-        */\r
-       function parse_userwebsitelink() {\r
-               if (!(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false)) {\r
-                       echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';\r
-               } else {\r
-                       echo $this->currentComment['user'];\r
-               }\r
-       }\r
-\r
-       // function to enable if-else-elseif-elseifnot-ifnot-endif to comment template fields\r
-\r
-       /**\r
-        * Checks conditions for if statements\r
-        *\r
-        * @param string $field type of <%if%>\r
-        * @param string $name property of field\r
-        * @param string $value value of property\r
-        */\r
-       function checkCondition($field, $name='', $value = '') {\r
-               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;\r
-\r
-               $condition = 0;\r
-               switch($field) {\r
-                       case 'category':\r
-                               $condition = ($blog && $this->_ifCategory($name,$value));\r
-                               break;\r
-                       case 'itemcategory':\r
-                               $condition = ($this->_ifItemCategory($name,$value));\r
-                               break;\r
-                       case 'blogsetting':\r
-                               $condition = ($blog && ($blog->getSetting($name) == $value));\r
-                               break;\r
-                       case 'itemblogsetting':\r
-                               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));\r
-                               $condition = ($b && ($b->getSetting($name) == $value));\r
-                               break;\r
-                       case 'loggedin':\r
-                               $condition = $member->isLoggedIn();\r
-                               break;\r
-                       case 'onteam':\r
-                               $condition = $member->isLoggedIn() && $this->_ifOnTeam($name);\r
-                               break;\r
-                       case 'admin':\r
-                               $condition = $member->isLoggedIn() && $this->_ifAdmin($name);\r
-                               break;\r
-                       case 'author':\r
-                               $condition = ($this->_ifAuthor($name,$value));\r
-                               break;\r
-/*                     case 'nextitem':\r
-                               $condition = ($itemidnext != '');\r
-                               break;\r
-                       case 'previtem':\r
-                               $condition = ($itemidprev != '');\r
-                               break;\r
-                       case 'archiveprevexists':\r
-                               $condition = ($archiveprevexists == true);\r
-                               break;\r
-                       case 'archivenextexists':\r
-                               $condition = ($archivenextexists == true);\r
-                               break;\r
-                       case 'skintype':\r
-                               $condition = ($name == $this->skintype);\r
-                               break; */\r
-                       case 'hasplugin':\r
-                               $condition = $this->_ifHasPlugin($name, $value);\r
-                               break;\r
-                       default:\r
-                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->_ifPlugin($field, $name, $value);\r
-                               break;\r
-               }\r
-               return $condition;\r
-       }\r
-\r
-       /**\r
-        *  Different checks for a category\r
-        */\r
-       function _ifCategory($name = '', $value='') {\r
-               global $blog, $catid;\r
-\r
-               // when no parameter is defined, just check if a category is selected\r
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
-                       return $blog->isValidCategory($catid);\r
-\r
-               // check category name\r
-               if ($name == 'catname') {\r
-                       $value = $blog->getCategoryIdFromName($value);\r
-                       if ($value == $catid)\r
-                               return $blog->isValidCategory($catid);\r
-               }\r
-\r
-               // check category id\r
-               if (($name == 'catid') && ($value == $catid))\r
-                       return $blog->isValidCategory($catid);\r
-\r
-               return false;\r
-       }\r
-\r
-\r
-       /**\r
-        *  Different checks for an author\r
-        */\r
-       function _ifAuthor($name = '', $value='') {\r
-               global $member, $manager;\r
-\r
-               if ($this->currentComment['memberid'] == 0) return false;\r
-\r
-               $mem =& $manager->getMember($this->currentComment['memberid']);\r
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));\r
-               $citem =& $manager->getItem($this->currentComment['itemid'],1,1);\r
-\r
-               // when no parameter is defined, just check if item author is current visitor\r
-               if (($name != 'isadmin' && $name != 'name' && $name != 'isauthor' && $name != 'isonteam')) {\r
-                       return (intval($member->getID()) > 0 && intval($member->getID()) == intval($citem['authorid']));\r
-               }\r
-\r
-               // check comment author name\r
-               if ($name == 'name') {\r
-                       $value = trim(strtolower($value));\r
-                       if ($value == '')\r
-                               return false;\r
-                       if ($value == strtolower($mem->getDisplayName()))\r
-                               return true;\r
-               }\r
-\r
-               // check if comment author is admin\r
-               if ($name == 'isadmin') {\r
-                       $blogid = intval($b->getID());\r
-                       if ($mem->isAdmin())\r
-                               return true;\r
-\r
-                       return $mem->isBlogAdmin($blogid);\r
-               }\r
-\r
-               // check if comment author is item author\r
-               if ($name == 'isauthor') {\r
-                       return (intval($citem['authorid']) == intval($this->currentComment['memberid']));\r
-               }\r
-\r
-               // check if comment author is on team\r
-               if ($name == 'isonteam') {\r
-                       return $mem->teamRights(intval($b->getID()));\r
-               }\r
-\r
-               return false;\r
-       }\r
-\r
-       /**\r
-        *  Different checks for a category\r
-        */\r
-       function _ifItemCategory($name = '', $value='') {\r
-               global $catid, $manager;\r
-\r
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));\r
-               $citem =& $manager->getItem($this->currentComment['itemid'],1,1);\r
-               $icatid = $citem['catid'];\r
-\r
-               // when no parameter is defined, just check if a category is selected\r
-               if (($name != 'catname' && $name != 'catid') || ($value == ''))\r
-                       return $b->isValidCategory($icatid);\r
-\r
-               // check category name\r
-               if ($name == 'catname') {\r
-                       $value = $b->getCategoryIdFromName($value);\r
-                       if ($value == $icatid)\r
-                               return $b->isValidCategory($icatid);\r
-               }\r
-\r
-               // check category id\r
-               if (($name == 'catid') && ($value == $icatid))\r
-                       return $b->isValidCategory($icatid);\r
-\r
-               return false;\r
-       }\r
-\r
-\r
-       /**\r
-        *  Checks if a member is on the team of a blog and return his rights\r
-        */\r
-       function _ifOnTeam($blogName = '') {\r
-               global $blog, $member, $manager;\r
-\r
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));\r
-\r
-               // when no blog found\r
-               if (($blogName == '') && (!is_object($b)))\r
-                       return 0;\r
-\r
-               // explicit blog selection\r
-               if ($blogName != '')\r
-                       $blogid = getBlogIDFromName($blogName);\r
-\r
-               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
-                       // use current blog\r
-                       $blogid = $b->getID();\r
-\r
-               return $member->teamRights($blogid);\r
-       }\r
-\r
-       /**\r
-        *  Checks if a member is admin of a blog\r
-        */\r
-       function _ifAdmin($blogName = '') {\r
-               global $blog, $member, $manager;\r
-\r
-               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));\r
-\r
-               // when no blog found\r
-               if (($blogName == '') && (!is_object($b)))\r
-                       return 0;\r
-\r
-               // explicit blog selection\r
-               if ($blogName != '')\r
-                       $blogid = getBlogIDFromName($blogName);\r
-\r
-               if (($blogName == '') || !$manager->existsBlogID($blogid))\r
-                       // use current blog\r
-                       $blogid = $b->getID();\r
-\r
-               return $member->isBlogAdmin($blogid);\r
-       }\r
-\r
-\r
-       /**\r
-        *      hasplugin,PlugName\r
-        *         -> checks if plugin exists\r
-        *      hasplugin,PlugName,OptionName\r
-        *         -> checks if the option OptionName from plugin PlugName is not set to 'no'\r
-        *      hasplugin,PlugName,OptionName=value\r
-        *         -> checks if the option OptionName from plugin PlugName is set to value\r
-        */\r
-       function _ifHasPlugin($name, $value) {\r
-               global $manager;\r
-               $condition = false;\r
-               // (pluginInstalled method won't write a message in the actionlog on failure)\r
-               if ($manager->pluginInstalled('NP_'.$name)) {\r
-                       $plugin =& $manager->getPlugin('NP_' . $name);\r
-                       if ($plugin != NULL) {\r
-                               if ($value == "") {\r
-                                       $condition = true;\r
-                               } else {\r
-                                       list($name2, $value2) = preg_split('#=#', $value, 2);\r
-                                       if ($value2 == "" && $plugin->getOption($name2) != 'no') {\r
-                                               $condition = true;\r
-                                       } else if ($plugin->getOption($name2) == $value2) {\r
-                                               $condition = true;\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-               return $condition;\r
-       }\r
-\r
-       /**\r
-        * Checks if a plugin exists and call its doIf function\r
-        */\r
-       function _ifPlugin($name, $key = '', $value = '') {\r
-               global $manager;\r
-\r
-               $plugin =& $manager->getPlugin('NP_' . $name);\r
-               if (!$plugin) return;\r
-\r
-               $params = func_get_args();\r
-               array_shift($params);\r
-\r
-               return call_user_func_array(array(&$plugin, 'doIf'), $params);\r
-       }\r
-\r
-}\r
+<?php
+/*
+ * Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
+ * Copyright (C) 2002-2009 The Nucleus Group
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ * (see nucleus/documentation/index.html#license for more info)
+ */
+/**
+ * This class is used when parsing comment templates
+ *
+ * @license http://nucleuscms.org/license.txt GNU General Public License
+ * @copyright Copyright (C) 2002-2009 The Nucleus Group
+ * @version $Id: CommentActions.php 1626 2012-01-09 15:46:54Z sakamocchi $
+ */
+
+class CommentActions extends BaseActions
+{
+       /**
+        * CommentsActions::$commentsObj
+        * ref to COMMENTS object which is using this object to handle its templatevars
+        */
+       private $commentsObj;
+       
+       /**
+        * CommentsActions::$template
+        * template to use to parse the comments
+        */
+       private $template;
+       
+       /**
+        * CommentsActions::$currentComment
+        * comment currenlty being handled (mysql result assoc array; see Comments::showComments())
+        */
+       private $currentComment;
+       
+       /**
+        * CommentsActions::$defined_actions
+        * defined actions in this class
+        */
+       static private $defined_actions = array(
+               'authtext',
+               'blogid',
+               'blogurl',
+               'body',
+               'commentcount',
+               'commentid',
+               'commentword',
+               'date',
+               'email',
+               'excerpt',
+               'host',
+               'ip',
+               'itemid',
+               'itemlink',
+               'itemtitle',
+               'memberid',
+               'plugin',
+               'short',
+               'time',
+               'timestamp',
+               'user',
+               'useremail',
+               'userid',
+               'userlink',
+               'userlinkraw',
+               'userwebsite',
+               'userwebsitelink'
+       );
+       
+       /**
+        * CommentActions::__construct()
+        * 
+        * @param       object  $comments       instance of Comments class
+        * @return      void
+        */
+       public function __construct(&$comments)
+       {
+               // call constructor of superclass first
+               parent::__construct();
+               
+               // reference to the comments object
+               $this->setCommentsObj($comments);
+               return;
+       }
+       
+       /**
+        * CommentActions::getAvailableActions()
+        * 
+        * @param       void
+        * @return array        actions array
+        */
+       public function getAvailableActions()
+       {
+               return array_merge(self::$defined_actions, parent::getAvailableActions());
+       }
+       
+       /**
+        * 
+        * CommentActions::setCommentsObj()
+        * 
+        * @param       object  $commentsObj    instance of Comments class
+        * @return      void
+        */
+       public function setCommentsObj(&$commentsObj)
+       {
+               $this->commentsObj =& $commentsObj;
+               return;
+       }
+       
+       /**
+        * CommentActions::setTemplate()
+        * 
+        * @param       array   $template       array includes templates
+        * @return      void
+        */
+       public function setTemplate($template)
+       {
+               $this->template =& $template;
+               return;
+       }
+       
+       /**
+        * CommentActions::setCurrentComment()
+        * Set $currentcommentid and $currentcommentarray
+        * 
+        * @param       array   $comment        associated array includes comment information
+        * @return      void
+        */
+       public function setCurrentComment(&$comment)
+       {
+               global $currentcommentid, $currentcommentarray, $manager;
+               
+               if ( $comment['memberid'] != 0 )
+               {
+                       if ( !array_key_exists('COMMENTS_AUTH', $this->template) )
+                       {
+                               $comment['authtext'] = '';
+                       }
+                       else
+                       {
+                               $comment['authtext'] = $this->template['COMMENTS_AUTH'];
+                       }
+                       
+                       $mem =& $manager->getMember($comment['memberid']);
+                       $comment['user'] = $mem->getDisplayName();
+                       
+                       if ( $mem->getURL() )
+                       {
+                               $comment['userid'] = $mem->getURL();
+                       }
+                       else
+                       {
+                               $comment['userid'] = $mem->getEmail();
+                       }
+                       
+                       $data = array(
+                               'memberid'      => $comment['memberid'],
+                               'name'          => $mem->getDisplayName(),
+                               'extra'         => $this->commentsObj->itemActions->linkparams
+                       );
+                       
+                       $comment['userlinkraw'] = Link::create_link('member', $data);
+               }
+               else
+               {
+                       // create smart links
+                       if ( !array_key_exists('userid', $comment) || !empty($comment['userid']) )
+                       {
+                               if ( (i18n::strpos($comment['userid'], 'http://') === 0) || (i18n::strpos($comment['userid'], 'https://') === 0) )
+                               {
+                                       $comment['userlinkraw'] = $comment['userid'];
+                               }
+                               else
+                               {
+                                       $comment['userlinkraw'] = 'http://' . $comment['userid'];
+                               }
+                       }
+                       else if ( NOTIFICATION::address_validation($comment['email']) )
+                       {
+                               $comment['userlinkraw'] = 'mailto:' . $comment['email'];
+                       }
+                       else if ( NOTIFICATION::address_validation($comment['userid']) )
+                       {
+                               $comment['userlinkraw'] = 'mailto:' . $comment['userid'];
+                       }
+               }
+               
+               $this->currentComment =& $comment;
+               $currentcommentid = $comment['commentid'];
+               $currentcommentarray = $comment;
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_authtext()
+        * Parse templatevar authtext
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_authtext()
+       {
+               if ( $this->currentComment['memberid'] != 0 )
+               {
+                       $this->parser->parse($this->template['COMMENTS_AUTH']);
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_blogid()
+        * Parse templatevar blogid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_blogid() {
+               echo $this->currentComment['blogid'];
+       }
+       
+       /**
+        * CommentActions::parse_blogurl()
+        * Parse templatevar blogurl
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_blogurl()
+       {
+               global $manager;
+               $blogid = getBlogIDFromItemID($this->commentsObj->itemid);
+               $blog =& $manager->getBlog($blogid);
+               echo $blog->getURL();
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_body()
+        * Parse templatevar body
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_body() {
+               echo $this->highlight($this->currentComment['body']);
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_commentcount()
+        * Parse templatevar commentcount
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_commentcount()
+       {
+               echo $this->commentsObj->commentcount;
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_commentid()
+        * Parse templatevar commentid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_commentid()
+       {
+               echo $this->currentComment['commentid'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_commentword()
+        * Parse templatevar commentword
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_commentword()
+       {
+               if ( $this->commentsObj->commentcount == 1 )
+               {
+                       echo $this->template['COMMENTS_ONE'];
+               }
+               else
+               {
+                       echo $this->template['COMMENTS_MANY'];
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_date()
+        * Parse templatevar date
+        * 
+        * @format      String  $format Date format according to PHP
+        * @return      void
+        */
+       public function parse_date($format = '')
+       {
+               if ( $format !== '' )
+               {
+                       /* do nothing */
+                       ;
+               }
+               else if ( !array_key_exists('FORMAT_DATE', $this->template) || $this->template['FORMAT_DATE'] === '' )
+               {
+                       $format = '%X';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_DATE'];
+               }
+               
+               $offset = $this->commentsObj->itemActions->blog->getTimeOffset() * 3600;
+               
+               echo i18n::formatted_datetime($format, $this->currentComment['timestamp'], $offset);
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_excerpt()
+        * Parse templatevar email
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_email()
+       {
+               $email = $this->currentComment['email'];
+               $email = str_replace('@', ' (at) ', $email);
+               $email = str_replace('.', ' (dot) ', $email);
+               echo $email;
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_excerpt()
+        * Parse templatevar excerpt
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_excerpt()
+       {
+               echo Entity::hen(Entity::shorten($this->currentComment['body'], 60, '...'));
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_host()
+        * Parse templatevar host
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_host()
+       {
+               echo $this->currentComment['host'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_ip()
+        * Parse templatevar ip
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_ip()
+       {
+               echo $this->currentComment['ip'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_itemid()
+        * Parse templatevar itemid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_itemid()
+       {
+               echo $this->commentsObj->itemid;
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_itemlink()
+        * Parse templatevar itemlink
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_itemlink()
+       {
+               $data = array(
+                       'itemid'        => $this->commentsObj->itemid,
+                       'timestamp'     => $this->commentsObj->itemActions->currentItem['timestamp'],
+                       'title'         => $this->commentsObj->itemActions->currentItem['title'],
+                       'extra'         => $this->commentsObj->itemActions->linkparams
+               );
+               
+               echo Link::create_link('item', $data);
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_itemtitle()
+        * Parse templatevar itemtitle
+        * 
+        * @param       integer $maxLength      maximum length for item title
+        * @return      void
+        */
+       public function parse_itemtitle($maxLength = 0)
+       {
+               if ( $maxLength == 0 )
+               {
+                       $this->commentsObj->itemActions->parse_title();
+               }
+               else
+               {
+                       $this->commentsObj->itemActions->parse_syndicate_title($maxLength);
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_memberid()
+        * Parse templatevar memberid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_memberid()
+       {
+               echo $this->currentComment['memberid'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_short()
+        * Parse templatevar short
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_short()
+       {
+               $tmp = strtok($this->currentComment['body'], "\n");
+               $tmp = str_replace('<br />', '', $tmp);
+               echo $tmp;
+               if ( $tmp != $this->currentComment['body'] )
+               {
+                       $this->parser->parse($this->template['COMMENTS_CONTINUED']);
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_time()
+        * Parse templatevar time
+        * 
+        * @param       string  $format datetime format referring to strftime() in PHP's built-in function
+        * @return      void
+        */
+       public function parse_time($format = '')
+       {
+               if ( $format !== '' )
+               {
+                       /* do nothing */
+                       ;
+               }
+               else if ( !array_key_exists('FORMAT_TIME', $this->template) || $this->template['FORMAT_TIME'] === '' )
+               {
+                       $format = '%x';
+               }
+               else
+               {
+                       $format = $this->template['FORMAT_TIME'];
+               }
+               
+               echo i18n::formatted_datetime($format, $this->currentComment['timestamp']);
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_timestamp()
+        * Parse templatevar timestamp
+        * 
+        * @param       void
+        * @return      void
+        * 
+        */
+       public function parse_timestamp()
+       {
+               echo $this->currentComment['timestamp'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_plugin()
+        * Executes a plugin templatevar
+        *
+        * @param       string  $pluginName     name of plugin (without the NP_)
+        * @param       extra parameters can be added
+        * @return      void
+        */
+       public function parse_plugin($pluginName)
+       {
+               global $manager;
+               
+               // only continue when the plugin is really installed
+               if ( !$manager->pluginInstalled("NP_{$pluginName}") )
+               {
+                       return;
+               }
+               
+               $plugin =& $manager->getPlugin("NP_{$pluginName}");
+               if ( !$plugin )
+               {
+                       return;
+               }
+               
+               // get arguments
+               $params = func_get_args();
+               
+               // remove plugin name
+               array_shift($params);
+               
+               // pass info on current item and current comment as well
+               $params = array_merge(array(&$this->currentComment), $params);
+               $params = array_merge(array(&$this->commentsObj->itemActions->currentItem), $params);
+               
+               call_user_func_array(array(&$plugin,'doTemplateCommentsVar'), $params);
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_user()
+        * Parse templatevar user
+        * 
+        * @param       string  $mode   realname or else
+        * @return      void
+        */
+       public function parse_user($mode = '')
+       {
+               global $manager;
+               
+               if ( $mode == 'realname' && $this->currentComment['memberid'] > 0 )
+               {
+                       $member =& $manager->getMember($this->currentComment['memberid']);
+                       echo $member->getRealName();
+               }
+               else
+               {
+                       echo Entity::hsc($this->currentComment['user']);
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_useremail()
+        * Output mail address
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_useremail() {
+               global $manager;
+               if ( $this->currentComment['memberid'] > 0 )
+               {
+                       $member =& $manager->getMember($this->currentComment['memberid']);
+                       
+                       if ( $member->email != '' )
+                       {
+                               echo $member->email;
+                       }
+               }
+               else
+               {
+                       if ( NOTIFICATION::address_validation($this->currentComment['email']) )
+                       {
+                               echo $this->currentComment['email'];
+                       }
+                       elseif ( NOTIFICATION::address_validation($this->currentComment['userid']) )
+                       {
+                               echo $this->currentComment['userid'];
+                       }
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_userid()
+        * Parse templatevar userid
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_userid()
+       {
+               echo $this->currentComment['userid'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_userlink()
+        * Parse templatevar userlink
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_userlink()
+       {
+               if ( $this->currentComment['userlinkraw'] )
+               {
+                       echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
+               }
+               else
+               {
+                       echo $this->currentComment['user'];
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_userlinkraw()
+        * Parse templatevar userlinkraw
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_userlinkraw()
+       {
+               echo $this->currentComment['userlinkraw'];
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_userwebsite()
+        * Parse templatevar userwebsite
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_userwebsite()
+       {
+               if ( !(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false) )
+               {
+                       echo $this->currentComment['userlinkraw'];
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::parse_userwebsitelink()
+        * Parse templatevar userwebsitelink
+        * 
+        * @param       void
+        * @return      void
+        */
+       public function parse_userwebsitelink()
+       {
+               if ( !(i18n::strpos($this->currentComment['userlinkraw'], 'http://') === false) )
+               {
+                       echo '<a href="'.$this->currentComment['userlinkraw'].'" rel="nofollow">'.$this->currentComment['user'].'</a>';
+               }
+               else
+               {
+                       echo $this->currentComment['user'];
+               }
+               return;
+       }
+       
+       /**
+        * CommentActions::checkCondition()
+        * Checks conditions for if statements
+        *
+        * @param       string  $field  type of <%if%>
+        * @param       string  $name   property of field
+        * @param       string  $value  value of property
+        * @return      boolean
+        */
+       protected function checkCondition($field, $name='', $value = '') {
+               global $catid, $blog, $member, $itemidnext, $itemidprev, $manager, $archiveprevexists, $archivenextexists;
+               $condition = 0;
+               switch ( $field )
+               {
+                       case 'category':
+                               $condition = ($blog && $this->ifCategory($name,$value));
+                               break;
+                       case 'itemcategory':
+                               $condition = ($this->ifItemCategory($name,$value));
+                               break;
+                       case 'blogsetting':
+                               $condition = ($blog && ($blog->getSetting($name) == $value));
+                               break;
+                       case 'itemblogsetting':
+                               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
+                               $condition = ($b && ($b->getSetting($name) == $value));
+                               break;
+                       case 'loggedin':
+                               $condition = $member->isLoggedIn();
+                               break;
+                       case 'onteam':
+                               $condition = $member->isLoggedIn() && $this->ifOnTeam($name);
+                               break;
+                       case 'admin':
+                               $condition = $member->isLoggedIn() && $this->ifAdmin($name);
+                               break;
+                       case 'author':
+                               $condition = ($this->ifAuthor($name,$value));
+                               break;
+                       case 'hasplugin':
+                               $condition = $this->ifHasPlugin($name, $value);
+                               break;
+                       default:
+                               $condition = $manager->pluginInstalled('NP_' . $field) && $this->ifPlugin($field, $name, $value);
+                       break;
+               }
+               return $condition;
+       }
+       
+       /**
+        * CommentActions::ifCategory()
+        * Different checks for a category
+        * 
+        * @param       string  $key    key of category
+        * @param       string  $value  value for key of category
+        * @return      boolean
+        */
+       private function ifCategory($key = '', $value = '')
+       {
+               global $blog, $catid;
+               
+               // when no parameter is defined, just check if a category is selected
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )
+               {
+                       return $blog->isValidCategory($catid);
+               }
+               
+               // check category name
+               if ( $key == 'catname' )
+               {
+                       $value = $blog->getCategoryIdFromName($value);
+                       if ($value == $catid)
+                       return $blog->isValidCategory($catid);
+               }
+               
+               // check category id
+               if ( ($key == 'catid') && ($value == $catid) )
+               {
+                       return $blog->isValidCategory($catid);
+               }
+               return FALSE;
+       }
+       
+       /**
+        * CommentActions::ifAuthor()
+        * Different checks for an author
+        *
+        * @param       string  $key    key of data for author
+        * @param       string  $value  value of data for author
+        * @return      boolean correct or not
+        */
+       private function ifAuthor($key = '', $value = '')
+       {
+               global $member, $manager;
+               
+               if ( $this->currentComment['memberid'] == 0 )
+               {
+                       return FALSE;
+               }
+               
+               $mem =& $manager->getMember($this->currentComment['memberid']);
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
+               $citem =& $manager->getItem($this->currentComment['itemid'], 1, 1);
+               
+               // when no parameter is defined, just check if item author is current visitor
+               if (($key != 'isadmin' && $key != 'name' && $key != 'isauthor' && $key != 'isonteam')) {
+                       return (intval($member->getID()) > 0 && intval($member->getID()) == intval($citem['authorid']));
+               }
+               
+               // check comment author name
+               if ( $key == 'name' )
+               {
+                       $value = trim(strtolower($value));
+                       if ( $value == '' )
+                       {
+                               return FALSE;
+                       }
+                       if ( $value == strtolower($mem->getDisplayName()) )
+                       {
+                               return TRUE;
+                       }
+               }
+               
+               // check if comment author is admin
+               if ( $key == 'isadmin' )
+               {
+                       $blogid = intval($b->getID());
+                       if ( $mem->isAdmin() )
+                       {
+                               return TRUE;
+                       }
+                       return $mem->isBlogAdmin($blogid);
+               }
+               
+               // check if comment author is item author
+               if ( $key == 'isauthor' )
+               {
+                       return (intval($citem['authorid']) == intval($this->currentComment['memberid']));
+               }
+               
+               // check if comment author is on team
+               if ( $key == 'isonteam' )
+               {
+                       return $mem->teamRights(intval($b->getID()));
+               }
+               return FALSE;
+       }
+       
+       /**
+        * CommentActions::ifItemCategory()
+        * Different checks for a category
+        *
+        * @param       string  $key    key of data for category to which item belongs
+        * @param       string  $value  value of data for category to which item belongs
+        * @return boolean      correct or not
+        */
+       private function ifItemCategory($key = '', $value = '')
+       {
+               global $catid, $manager;
+       
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
+               $citem =& $manager->getItem($this->currentComment['itemid'],1,1);
+               $icatid = $citem['catid'];
+       
+               // when no parameter is defined, just check if a category is selected
+               if ( ($key != 'catname' && $key != 'catid') || ($value == '') )
+               {
+                       return $b->isValidCategory($icatid);
+               }
+       
+               // check category name
+               if ( $key == 'catname' )
+               {
+                       $value = $b->getCategoryIdFromName($value);
+                       if ( $value == $icatid )
+                       {
+                               return $b->isValidCategory($icatid);
+                       }
+               }
+       
+               // check category id
+               if ( ($key == 'catid') && ($value == $icatid) )
+               {
+                       return $b->isValidCategory($icatid);
+               }
+               return FALSE;
+       }
+       
+       /**
+        * CommentActions::ifOnTeam()
+        * Checks if a member is on the team of a blog and return his rights
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean correct or not
+        */
+       private function ifOnTeam($blogName = '')
+       {
+               global $blog, $member, $manager;
+               
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
+               
+               // when no blog found
+               if ( ($blogName == '') && (!is_object($b)) )
+               {
+                       return 0;
+               }
+               
+               // explicit blog selection
+               if ( $blogName != '' )
+               {
+                       $blogid = getBlogIDFromName($blogName);
+               }
+               
+               // use current blog
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
+               {
+                       $blogid = $b->getID();
+               }
+               
+               return $member->teamRights($blogid);
+       }
+       
+       /**
+        * CommentActions::ifAdmin()
+        * Checks if a member is admin of a blog
+        * 
+        * @param       string  $blogName       name of weblog
+        * @return      boolean correct or not
+        */
+       private function ifAdmin($blogName = '')
+       {
+               global $blog, $member, $manager;
+               
+               $b =& $manager->getBlog(getBlogIDFromItemID($this->currentComment['itemid']));
+               
+               // when no blog found
+               if ( ($blogName == '') && (!is_object($b)) )
+               {
+                       return 0;
+               }
+               
+               // explicit blog selection
+               if ( $blogName != '' )
+               {
+                       $blogid = getBlogIDFromName($blogName);
+               }
+               
+               // use current blog
+               if ( ($blogName == '') || !$manager->existsBlogID($blogid) )
+               {
+                       $blogid = $b->getID();
+               }
+               
+               return $member->isBlogAdmin($blogid);
+       }
+       
+       /**
+        * CommentActions::ifHasPlugin()
+        *      hasplugin,PlugName
+        *         -> checks if plugin exists
+        *      hasplugin,PlugName,OptionName
+        *         -> checks if the option OptionName from plugin PlugName is not set to 'no'
+        *      hasplugin,PlugName,OptionName=value
+        *         -> checks if the option OptionName from plugin PlugName is set to value
+        *
+        * @param       string  $name   name of plugin
+        * @param       string  $value  key (and value) of plugin option
+        * @return      boolean correct or not
+        */
+       private function ifHasPlugin($name, $value)
+       {
+               global $manager;
+               $condition = FALSE;
+               
+               // (pluginInstalled method won't write a message in the actionlog on failure)
+               if ( $manager->pluginInstalled('NP_'.$name) )
+               {
+                       $plugin =& $manager->getPlugin("NP_{$name}");
+                       if ( $plugin != NULL )
+                       {
+                               if ( $value == "" )
+                               {
+                                       $condition = true;
+                               }
+                               else
+                               {
+                                       list($name2, $value2) = preg_split('#=#', $value, 2);
+                                       if ( $value2 == "" && $plugin->getOption($name2) != 'no' )
+                                       {
+                                               $condition = true;
+                                       }
+                                       else if ( $plugin->getOption($name2) == $value2 )
+                                       {
+                                               $condition = true;
+                                       }
+                               }
+                       }
+               }
+               return $condition;
+       }
+       
+       /**
+        * CommentActions::ifPlugin()
+        * Checks if a plugin exists and call its doIf function
+        * 
+        * @param       string  $name   name of plugin
+        * @param       string  $key    key of plugin option
+        * @param       string  $value  value of plugin option
+        * @return      boolean callback output from plugin
+        */
+       private function ifPlugin($name, $key = '', $value = '')
+       {
+               global $manager;
+               
+               $plugin =& $manager->getPlugin("NP_{$name}");
+               if ( !$plugin )
+               {
+                       return;
+               }
+               
+               $params = func_get_args();
+               array_shift($params);
+               
+               return call_user_func_array(array(&$plugin, 'doIf'), $params);
+       }
+}