3 * SHOW Comment Form/List PLUG-IN FOR NucleusCMS
\r
6 * This program is free software; you can redistribute it and/or
\r
7 * modify it under the terms of the GNU General Public License
\r
8 * as published by the Free Software Foundation; either version 2
\r
9 * of the License, or (at your option) any later version.
\r
10 * (see nucleus/documentation/index.html#license for more info)
\r
13 * @copyright 2008 shizuki
\r
14 * @license http://www.gnu.org/licenses/gpl.txt GNU GENERAL PUBLIC LICENSE Version 2, June 1991
\r
15 * @version $Date$ $Revision: 1.13 $
\r
16 * @link http://japan.nucleuscms.org/wiki/plugins:ezcomment2
\r
17 * @since File available since Release 1.0
\r
23 * $Log: not supported by cvs2svn $
\r
24 * Revision 1.12 2008/07/09 03:54:07 shizuki
\r
25 * *** empty log message ***
\r
27 * Revision 1.11 2008/07/09 03:54:04 shizuki
\r
28 * *Fix header info URL:showblogs -> ezcomment2
\r
30 * * Revision 1.10 2008/07/08 16:14:57 shizuki
\r
31 * *Bug fix event_PreComment
\r
32 * *Correspondence preparations of NP_LatestWritebacks
\r
34 * Revision 1.9 2008/07/08 15:14:27 shizuki
\r
35 * * Corresponds to event_PreComment.
\r
39 * Revision 1.8 2008/07/07 15:42:54 shizuki
\r
40 * * The experimental society PHP Version: 5.2.6/MySQL Server Version (client): (5.1.25-rc-log 5.1.25-rc).
\r
41 * * The normal movement is confirmed.
\r
42 * * The SQL correction/behavior when installing, is changed a little.
\r
43 * * event_PostDeleteCommnent addition * It's corrected when being off login time and secret mode-lessly, so as not to take out a check box.
\r
44 * * NP_OpenId is indispensable in the present.
\r
45 * * NP_znSpecialTemplateParts is indispensable.
\r
46 * * It's expected to add the setting which will establish a password at the time of contribution without NP_OpenId and make it hidden from now on.
\r
47 * * It's RC edition, so please cooperate in the one with the environment.
\r
49 * Revision 1.7 2008/07/07 10:24:00 shizuki
\r
50 * * Still, the human sacrifice test version.
\r
51 * * A template was separated for for index pages and item page.
\r
52 * * Subdivision of the showComment() function.
\r
53 * * It's changed so as not to fly to an indication part for indication in case of and OpenID of anything but the first item of an index page.
\r
54 * * A profile change part besides the first item of an index page is being adjusted.
\r
57 class NP_EzComment2 extends NucleusPlugin
\r
62 * The calling number of times by the index page.
\r
69 * OpenID authentication module.
\r
76 * Flag of the case that one is invoker.
\r
92 return 'Ez Comment II';
\r
103 function getAuthor()
\r
112 * I get a plug-in, the address of the possible site or author's mail address.
\r
118 return 'http://japan.nucleuscms.org/wiki/plugins:ezcomment2';
\r
122 // {{{ getPluginDep()
\r
125 * Plugin Dependency.
\r
129 function getPluginDep()
\r
133 'NP_znSpecialTemplateParts',
\r
138 // {{{ getVersion()
\r
145 function getVersion()
\r
147 return '$Date$ $Revision: 1.13 $';
\r
151 // {{{ getDescription()
\r
154 * Plugin Description
\r
158 function getDescription()
\r
160 return _NP_EZCOMMENT2_DESC;
\r
164 // {{{ supportsFeature($what)
\r
167 * Supports Nucleus Feature
\r
172 function supportsFeature($what)
\r
175 case 'SqlTablePrefix':
\r
183 // {{{ getEventList()
\r
186 * List of feature event
\r
190 function getEventList()
\r
196 'PostDeleteComment',
\r
202 // {{{ getTableList()
\r
205 * Database tables for plugin used
\r
209 function getTableList()
\r
212 sql_table('plug_ezcomment2'),
\r
226 if (!TEMPLATE::exists('EzCommentTemplate')) {
\r
228 include_once($DIR_LIBS . 'skinie.php');
\r
229 $importer = new SKINIMPORT();
\r
230 $importer->reset();
\r
231 $template = $this->getDirectory() . 'skinbackup.xml';
\r
232 if (!@file_exists($template)) {
\r
233 $aErrors[] = 'Unable to import ' . $template . ' : file does not exist';
\r
236 $error = $importer->readFile($template);
\r
238 $aErrors[] = 'Unable to import ' . $template . ' : ' . $error;
\r
241 $error = $importer->writeToDatabase(1);
\r
243 $aErrors[] = 'Unable to import ' . $template . ' : ' . $error;
\r
247 $message = implode("<br />\n", $aErrors);
\r
251 $this->createBlogOption('secret', _NP_EZCOMMENT2_OP_SECRETMODE, 'yesno', 'yes');
\r
252 $this->createBlogOption('secComment', _NP_EZCOMMENT2_OP_SUBSTIUTION, 'text', _NP_EZCOMMENT2_OP_SUBSTIUTION_VAL);
\r
253 $this->createBlogOption('secLabel', _NP_EZCOMMENT2_OP_CHECKLABEL, 'text', _NP_EZCOMMENT2_OP_CHECKLABEL_VAL);
\r
254 $this->createOption('tabledel', _NP_EZCOMMENT2_OP_DROPTABLE, 'yesno', 'yes');
\r
255 $sql = 'CREATE TABLE IF NOT EXISTS %s ('
\r
256 . '`comid` int(11) NOT NULL, '
\r
257 . '`secflg` tinyint(1) NULL, '
\r
258 . '`module` varchar(15) NULL, '
\r
259 . '`userID` varchar(255) NULL, '
\r
260 . 'PRIMARY KEY(`comid`) );';
\r
261 sql_query(sprintf($sql, sql_table('plug_ezcomment2')));
\r
262 $this->updateTable();
\r
269 * Un Install function
\r
273 function uninstall()
\r
275 if ($this->getOption('tabledel') == 'yes')
\r
276 sql_query('DROP TABLE '.sql_table('plug_ezcomment2'));
\r
289 $this->languageInclude();
\r
290 $this->numcalled = 0;
\r
291 $this->callFlg = false;
\r
293 if ($manager->pluginInstalled('NP_OpenId') && !$this->authOpenID) {
\r
294 $this->authOpenID = $manager->getPlugin('NP_OpenId');
\r
299 // {{{ event_PostAddComment($data)
\r
302 * After adding a comment to the database.
\r
305 * commentid integer
\r
310 function event_PostAddComment($data)
\r
314 case $member->isLoggedin():
\r
315 $userID = '"' . $member->getID() . '"';
\r
316 $module = '"Nucleus"';
\r
318 case ($this->authOpenID && $this->authOpenID->isLoggedin()):
\r
319 $userID = '"' . $this->authOpenID->loggedinUser['identity'] . '"';
\r
320 $module = '"OpenID"';
\r
327 if (postVar('EzComment2_Secret')) {
\r
330 $secCheck = 'NULL';
\r
332 $sql = 'INSERT INTO ' . sql_table('plug_ezcomment2')
\r
333 . ' (`comid`, `secflg`, `module`, `userID`) VALUES (%d, %d, %s, %s)';
\r
334 sql_query(sprintf($sql, $data['commentid'], $secCheck, $module, $userID));
\r
338 // {{{ event_PostDeleteComment($data)
\r
341 * After a comment has been deleted from the database.
\r
344 * commentid integer
\r
347 function event_PostDeleteComment($data)
\r
349 $sql = 'DELETE FROM ' . sql_table('plug_ezcomment2')
\r
350 . ' WHERE `comid` = %d LIMIT 1';
\r
351 sql_query(sprintf($sql, $data['commentid']));
\r
355 // {{{ event_FormExtra(&$data)
\r
358 * Inside one of the comment, membermail or account activation forms.
\r
364 function event_FormExtra(&$data)
\r
366 global $member, $blogid;
\r
367 $this->numcalled++;
\r
368 if ($blogid && $this->getBlogOption($blogid, 'secret') == 'yes' &&
\r
369 ($member->isLoggedin() || ($this->authOpenID && $this->authOpenID->isLoggedin()))) {
\r
370 echo '<br /><input type="checkbox" value="1" name="EzComment2_Secret" id="EzComment2_Secret_' . $this->numcalled . '" />';
\r
371 echo '<label for="EzComment2_Secret_' . $this->numcalled . '">'.$this->getBlogOption($bid, 'secLabel').'</label><br />';
\r
373 if ($this->authOpenID) {
\r
374 $this->plugOpenIDdoSkinVar($this->commentSkinType, $this->commentItemId);
\r
379 // {{{ event_PreComment(&$data)
\r
382 * Inside one of the comment, membermail or account activation forms.
\r
388 function event_PreComment(&$data)
\r
390 if ($this->callFlg) return;
\r
391 $sql = 'SELECT secflg, userID FROM ' . sql_table('plug_ezcomment2')
\r
392 . ' WHERE comid = ' . intval($data['comment']['commentid']);
\r
393 $res = sql_query($sql);
\r
394 $flg = mysql_fetch_assoc($res);
\r
395 if (!$flg['secflg']) return;
\r
396 $data['comment']['identity'] = $flg['userID'];
\r
397 global $manager, $member;
\r
398 $bid = intval($data['comment']['blogid']);
\r
399 $b = $manager->getBlog($bid);
\r
400 $judge = $this->setSecretJudge($bid, $member, $b);
\r
401 $data['comment'] = $this->JudgementCommentSecrets($data['comment'], $judge);
\r
406 // {{{ doTemplateVar()
\r
409 * Basically the same as doSkinVar,
\r
410 * but this time for calls of the <%plugin(...)%>-var in templates (item header/body/footer and dateheader/footer).
\r
412 * @param object item object(refarence)
\r
420 function doTemplateVar(&$item,
\r
422 $showMode = '5/1/1',
\r
423 $destinationurl = '',
\r
424 $formTemplate = 'EzCommentTemplate',
\r
425 $listTemplate = 'EzCommentTemplate')
\r
427 $this->doSkinVar('template', $showType, $showMode, $destinationurl, $formTemplate, $listTemplate, $item);
\r
434 * When plugins are called using the <%plugin(...)%>-skinvar, this method will be called.
\r
442 * @param object item object(refarence)
\r
445 function doSkinVar($skinType,
\r
447 $showMode = '5/1/1',
\r
448 $destinationurl = '',
\r
449 $formTemplate = 'EzCommentTemplate',
\r
450 $listTemplate = 'EzCommentTemplate',
\r
451 &$commentItem = '')
\r
453 if ($skinType != 'item' && $skinType != 'template') return;
\r
454 global $manager, $member, $itemid;
\r
455 if (!$commentItem && $itemid) {
\r
456 $commentItem = $manager->getItem($itemid, 0, 0);
\r
457 if (is_array($commentItem)) {
\r
458 $commentItem = (object)$commentItem;
\r
461 if (!$commentItem || $commentItem->closed) {
\r
462 echo _ERROR_ITEMCLOSED;
\r
466 if (is_numeric($showType) || strpos($showType, '/') !== false) $showMode = $showType;
\r
467 if ($showType != 'list' && $showType != 'form') {
\r
471 $showMode = '5/1/1';
\r
473 list($maxToShow, $sortOrder, $commentOrder) = explode('/', $showMode);
\r
474 if (!$maxToShow) $maxToShow = 5;
\r
475 if (!$sortOrder) $sortOrder = 1;
\r
476 if ($commentOrder > 0) {
\r
477 $commentOrder = true;
\r
479 $commentOrder = false;
\r
481 if (!$formTemplate) $formTemplate = 'EzCommentTemplate';
\r
482 if (!$listTemplate) $listTemplate = 'EzCommentTemplate';
\r
484 switch ($showType) {
\r
486 $listTemplate = TEMPLATE::read($listTemplate);
\r
487 $this->showComment($commentItem, $listTemplate, $maxToShow, $commentOrder, $skinType);
\r
490 $formTemplate = TEMPLATE::read($formTemplate);
\r
491 $this->showForm($commentItem, $formTemplate, $destinationurl, $skinType);
\r
494 $listTemplate = TEMPLATE::read($listTemplate);
\r
495 $formTemplate = TEMPLATE::read($formTemplate);
\r
497 $this->showComment($commentItem, $listTemplate, $maxToShow, $commentOrder, $skinType);
\r
498 $this->showForm($commentItem, $formTemplate, $destinationurl, $skinType);
\r
500 $this->showForm($commentItem, $formTemplate, $destinationurl, $skinType);
\r
501 $this->showComment($commentItem, $listTemplate, $maxToShow, $commentOrder, $skinType);
\r
508 // {{{ languageInclude()
\r
511 * Include language file
\r
515 function languageInclude()
\r
517 $language = ereg_replace( '[\\|/]', '', getLanguageName());
\r
518 if (file_exists($this->getDirectory() . 'language/' . $language . '.php')) {
\r
519 include_once($this->getDirectory() . 'language/' . $language . '.php');
\r
521 include_once($this->getDirectory() . 'language/english.php');
\r
526 // {{{ updateTable()
\r
529 * Update database table
\r
533 function updateTable()
\r
535 $sql = 'SELECT c.cnumber as cid FROM ' . sql_table('comment') . ' as c '
\r
536 . 'LEFT JOIN ' . sql_table('plug_ezcomment2') . ' as s '
\r
537 . 'ON c.cnumber=s.comid WHERE s.comid IS NULL';
\r
538 $res = sql_query($sql);
\r
539 $sql = 'INSERT INTO ' . sql_table('plug_ezcomment2') . '(`comid`) VALUES (%d)';
\r
540 while ($cid = mysql_fetch_assoc($res)) {
\r
541 sql_query(sprintf($sql, $cid['cid']));
\r
546 // {{{ plugOpenIDdoSkinVar()
\r
549 * Overwride NP_OpenId's doSkinVar()
\r
555 function plugOpenIDdoSkinVar($skinType, $iid = 0)
\r
557 global $CONF, $manager, $member;
\r
558 if ($member->isLoggedIn()) return;
\r
559 $authOpenID = $this->authOpenID;
\r
560 if (!$authOpenID) return;
\r
561 $externalauth = array ( 'source' => $authOpenID->getName() );
\r
562 $manager->notify('ExternalAuth', array ('externalauth' => &$externalauth));
\r
563 if (isset($externalauth['result']) && $externalauth['result'] == true) return;
\r
564 $templateEngine = $authOpenID->_getTemplateEngine();
\r
566 $aVars['PluginURL'] = $CONF['PluginURL'];
\r
567 if ($authOpenID->isLoggedin()) {
\r
569 if ($skinType == 'template') {
\r
570 require_once 'cles/Template.php';
\r
571 $templateDirectory = rtrim($this->getDirectory(), '/');
\r
572 $templateEngine =& new cles_Template($templateDirectory);
\r
573 $templateEngine->defaultLang = 'english';
\r
574 $aVars['itemid'] = intval($iid);
\r
576 $nowURL = 'http://' . serverVar("HTTP_HOST")
\r
577 . serverVar("REQUEST_URI");
\r
578 $aVars['url'] = $authOpenID->getAdminURL() . 'rd.php?action=rd'
\r
579 . '&url=' . urlencode($nowURL);
\r
580 $aVars['nick'] = $authOpenID->loggedinUser['nick'];
\r
581 $aVars['email'] = $authOpenID->loggedinUser['email'];
\r
582 $aVars['ts'] = $authOpenID->loggedinUser['ts'];
\r
583 $aVars['identity'] = $authOpenID->loggedinUser['identity'];
\r
584 $aVars['visible'] = $aVars['nick'] ? 'false' : 'true' ;
\r
585 $actionUrl = parse_url($CONF['ActionURL']);
\r
586 $aVars['updateUrl'] = $actionUrl['path'];
\r
587 if ($skinType == 'item' || ($skinType == 'template' && $this->numcalled == 0)) {
\r
588 echo $templateEngine->fetchAndFill('yui', $aVars, 'np_openid');
\r
589 echo $templateEngine->fetchAndFill('form', $aVars, 'np_openid');
\r
591 echo $templateEngine->fetchAndFill('loggedin', $aVars, 'np_openid');
\r
592 } elseif (!$authOpenID->isLoggedin()) {
\r
594 $aVars['url'] = $authOpenID->getAdminURL() . 'rd.php?action=doauth'
\r
595 . '&return_url=' . urlencode(createItemLink(intval($iid)));
\r
596 echo $templateEngine->fetchAndFill('notloggedin', $aVars, 'np_openid');
\r
601 // {{{ checkDestinationurl($destinationurl)
\r
604 * Destinationurl check
\r
609 function checkDestinationurl($destinationurl, $iid, $cid = 0, $scid = 0)
\r
611 if (stristr($destinationurl, 'action.php') || empty($destinationurl)) {
\r
612 if (stristr($destinationurl, 'action.php')) {
\r
613 $logMessage = 'actionurl is not longer a parameter on commentform skinvars.'
\r
614 . ' Moved to be a global setting instead.';
\r
615 ACTIONLOG::add(WARNING, $logMessage);
\r
618 $linkparams['catid'] = intval($cid);
\r
621 if ($manager->pluginInstalled('NP_MultipleCategories') && $scid) {
\r
622 $linkparams['subcatid'] = intval($scid);
\r
624 $destinationurl = createItemLink(intval($iid), $linkparams);
\r
626 $destinationurl = preg_replace('|[^a-z0-9-~+_.?#=&;,/:@%]|i', '', $destinationurl);
\r
628 return $destinationurl;
\r
632 // {{{ getCommentatorInfo()
\r
635 * Get commentator info.
\r
639 function getCommentatorInfo()
\r
642 $user = cookieVar($CONF['CookiePrefix'] .'comment_user');
\r
644 $user = postVar('user');
\r
646 $userid = cookieVar($CONF['CookiePrefix'] .'comment_userid');
\r
648 $userid = postVar('userid');
\r
650 $email = cookieVar($CONF['CookiePrefix'] .'comment_email');
\r
652 $email = postVar('email');
\r
654 $body = postVar('body');
\r
665 * Show comment form
\r
673 function showForm($commentItem, $template, $destinationurl, $skinType)
\r
675 global $CONF, $manager, $member, $catid, $subcatid;
\r
676 $bid = getBlogIDFromItemID($commentItem->itemid);
\r
677 $b =& $manager->getBlog($bid);
\r
678 $b->readSettings();
\r
679 if (!$member->isLoggedIn() && !$b->commentsEnabled()) {
\r
682 $destinationurl = $this->checkDestinationurl($destinationurl, $commentItem->itemid, $catid, $subcatid);
\r
683 list($user, $userid, $email, $body) = $this->getCommentatorInfo();
\r
685 $checked = cookieVar($CONF['CookiePrefix'] .'comment_user') ? 'checked="checked" ' : '';
\r
688 'self' => $this->_hsc(serverVar('REQUEST_URI')),
\r
689 'destinationurl' => $this->_hsc($destinationurl),
\r
690 'actionurl' => $this->_hsc($CONF['ActionURL']),
\r
691 'itemid' => intval($commentItem->itemid),
\r
692 'user' => $this->_hsc($user),
\r
693 'userid' => $this->_hsc($userid),
\r
694 'email' => $this->_hsc($email),
\r
695 'body' => $this->_hsc($body),
\r
696 // 'membername' => $this->_hsc($membername),
\r
697 'rememberchecked' => $checked
\r
699 if ($skinType == 'item') {
\r
704 if ($member && $member->isLoggedIn()) {
\r
705 $formType = 'FORM_LOGGEDIN' . $formFlg;
\r
706 $loginMember = $member->createFromID($member->getID());
\r
707 $formdata['membername'] = $this->_hsc($loginMember->getDisplayName());
\r
709 $formType = 'FORM_NOTLOGGEDIN' . $formFlg;
\r
711 if ($this->authOpenID && ($skinType == 'item' || $this->numcalled == 0)) {
\r
712 $this->plugOpenIDdoSkinVar($skinType, intval($commentItem->itemid));
\r
714 $this->commentItemId = intval($commentItem->itemid);
\r
715 $this->commentSkinType = $skinType;
\r
716 $contents = $template[$formType];
\r
717 include_once($this->getDirectory() . 'EzCommentActions.php');
\r
718 $formAction =& new EzCommentFormActions($commentItem, $formdata, $loginMember);
\r
719 $parser =& new PARSER($formAction->getAllowedActions(), $formAction);
\r
720 $parser->parse(&$contents);
\r
724 // {{{ showComment()
\r
736 function showComment($commentItem, $template, $maxToShow, $commentOrder, $skinType)
\r
738 global $manager, $member;
\r
739 $bid = getBlogIDFromItemID($commentItem->itemid);
\r
740 $b =& $manager->getBlog($bid);
\r
741 if (!$b->commentsEnabled()) return;
\r
743 $maxToShow = $b->getMaxComments();
\r
745 $itemActions =& new ITEMACTIONS($b);
\r
746 $itemActions->setCurrentItem($commentItem);
\r
747 $commentObj =& new COMMENTS($commentItem->itemid);
\r
748 $commentObj->setItemActions($itemActions);
\r
749 $commentObj->commentcount = $commentObj->amountComments();
\r
750 // create parser object & action handler
\r
751 include_once($this->getDirectory() . 'EzCommentActions.php');
\r
752 $actions =& new EzCommentActions($commentObj);
\r
753 $parser =& new PARSER($actions->getAllowedActions(), $actions);
\r
754 $actions->setTemplate($template);
\r
755 $actions->setParser($parser);
\r
756 if ($commentObj->commentcount == 0) {
\r
757 $parser->parse($template['COMMENTS_NONE']);
\r
760 $actions->setPostnum($commentObj->commentcount);
\r
761 if ($maxToShow && $maxToShow < $commentObj->commentcount && $commentOrder) {
\r
762 $startnum = $commentObj->commentcount - $maxToShow;
\r
766 $comments = $this->getComments($commentOrder, intval($commentItem->itemid), $maxToShow, $startnum);
\r
767 $viewnum = mysql_num_rows($comments);
\r
768 $actions->setViewnum($viewnum);
\r
769 if ($this->getBlogOption($bid, 'secret') == 'yes') {
\r
770 $judge = $this->setSecretJudge($bid, $member, $b);
\r
773 $templateType = '';
\r
774 if ($skinType == 'template') $templateType = '_IDX';
\r
775 $blogURL = $b->getURL();
\r
776 $substitution = $this->getBlogOption($bid, 'secComment');
\r
777 $this->callFlg = true;
\r
778 $parser->parse($template['COMMENTS_HEADER' . $templateType]);
\r
780 while ($comment = mysql_fetch_assoc($comments)) {
\r
781 $comment['timestamp'] = strtotime($comment['ctime']);
\r
782 if ($judge && $comment['secret']) {
\r
783 $comment = $this->JudgementCommentSecrets($comment, $judge);
\r
785 $actions->setCurrentComment($comment);
\r
786 $manager->notify('PreComment', array('comment' => &$comment));
\r
787 $parser->parse($template['COMMENTS_BODY' . $templateType]);
\r
788 $manager->notify('PostComment', array('comment' => &$comment));
\r
791 $parser->parse($template['COMMENTS_FOOTER' . $templateType]);
\r
793 mysql_free_result($comments);
\r
798 // {{{ setSecretJudge($bid)
\r
801 * Setting for judgment of whether it's a comment of a secret.
\r
808 function setSecretJudge($bid, $member, $b)
\r
810 $memberLoggedin = $member->isLoggedin();
\r
811 $loginUser = $member->getID();
\r
812 $blogAdmin = $member->blogAdminRights($bid);
\r
813 $blogURL = $b->getURL();
\r
814 $substitution = $this->getBlogOption($bid, 'secComment');
\r
815 if ($this->authOpenID) {
\r
816 $openIDLoggedin = $this->authOpenID->isLoggedin();
\r
817 $openIDUser = $this->authOpenID->loggedinUser['identity'];
\r
820 'memberLoggedin' => $memberLoggedin,
\r
821 'loginUser' => $loginUser,
\r
822 'blogAdmin' => $blogAdmin,
\r
823 'blogURL' => $blogURL,
\r
824 'substitution' => $substitution,
\r
825 'openIDLoggedin' => $openIDLoggedin,
\r
826 'openIDUser' => $openIDUser,
\r
831 // {{{ JudgementCommentSecrets($comment, $judge)
\r
834 * Comment is secret ?
\r
842 function JudgementCommentSecrets($comment, $judge)
\r
844 /* if ($judge['memberLoggedin']) {
\r
846 if ($judge['loginUser'] == intval($comment['identity'])) {
\r
847 echo 'commentator';
\r
848 } elseif ($judge['blogAdmin']) {
\r
851 } elseif ($judge['openIDLoggedin']) {
\r
852 // echo 'openid / ';
\r
853 echo $judge['openIDUser'].' / ';
\r
854 echo $comment['identity'].' / ';
\r
857 if (!(($judge['memberLoggedin'] && ($judge['loginUser'] == intval($comment['identity']) || $judge['blogAdmin'])) ||
\r
858 ($judge['openIDLoggedin'] && $judge['openIDUser'] == $comment['identity']))) {
\r
859 $this->changeCommentSet($comment, $judge);
\r
865 // {{{ changeCommentSet($comment, $blogURL, $substitution)
\r
868 * Change secret comment contents
\r
875 function changeCommentSet(&$comment, $judge)
\r
878 $comment['body'] = $judge['substitution'];
\r
879 $comment['short'] = $judge['substitution'];
\r
880 $comment['excerpt'] = $judge['substitution'];
\r
881 $comment['userid'] = $judge['blogURL'];
\r
882 $comment['memberid'] = 0;
\r
883 $comment['user'] = '#';
\r
884 $comment['useremail'] = '#';
\r
885 $comment['userwebsite'] = '#';
\r
886 $comment['email'] = '#';
\r
887 $comment['userlinkraw'] = '#';
\r
888 $comment['userlink'] = '#';
\r
889 $comment['host'] = '127.0.0.1';
\r
890 $comment['ip'] = '127.0.0.1';
\r
891 if ($manager->pluginInstalled('NP_LatestWritebacks')) {
\r
892 $comment['commentbody'] = $judge['substitution'];
\r
893 $comment['commentator'] = '#';
\r
897 // {{{ getComments($comment, $judge)
\r
900 * Change in the comment contents.
\r
908 function getComments($commentOrder, $iid, $maxToShow, $startnum)
\r
910 $order = ($commentOrder) ? "DESC" : "ASC";
\r
912 . 'c.citem as itemid, '
\r
913 . 'c.cnumber as commentid, '
\r
914 . 'c.cbody as body, '
\r
915 . 'c.cuser as user, '
\r
916 . 'c.cmail as userid, '
\r
917 . 'c.cemail as email, '
\r
918 . 'c.cmember as memberid, '
\r
920 . 'c.chost as host, '
\r
922 . 'c.cblog as blogid, '
\r
923 . 's.comid as cid, '
\r
924 . 's.secflg as secret, '
\r
925 . 's.module as modname, '
\r
926 . 's.userID as identity '
\r
927 . ' FROM ' . sql_table('comment') . ' as c '
\r
928 . ' LEFT OUTER JOIN ' . sql_table('plug_ezcomment2') . ' as s '
\r
929 . ' ON c.cnumber = s.comid '
\r
930 . ' WHERE c.citem = ' . intval($iid)
\r
931 . ' ORDER BY c.ctime '
\r
934 if ($order == "DESC") {
\r
935 $query .=' LIMIT ' . intval($maxToShow);
\r
937 $query .=' LIMIT ' . intval($startnum) . ',' . intval($maxToShow);
\r
940 return sql_query($query);
\r
945 // {{{ getTemplateParts()
\r
948 * Comment form/list template via NP_znSpecialTemplateParts
\r
952 function getTemplateParts()
\r
954 $this->languageInclude();
\r
956 'FORM_LOGGEDIN_IDX' => _NP_EZCOMMENT2_FORM_LOGGEDIN_IDX,
\r
957 'FORM_NOTLOGGEDIN_IDX' => _NP_EZCOMMENT2_FORM_NOTLOGGEDIN_IDX,
\r
958 'FORM_LOGGEDIN_ITM' => _NP_EZCOMMENT2_FORM_LOGGEDIN_ITM,
\r
959 'FORM_NOTLOGGEDIN_ITM' => _NP_EZCOMMENT2_FORM_NOTLOGGEDIN_ITM,
\r
960 'COMMENTS_BODY_IDX' => _NP_EZCOMMENT2_COMMENTS_BODY_IDX,
\r
961 'COMMENTS_FOOTER_IDX' => _NP_EZCOMMENT2_COMMENTS_FOOTER_IDX,
\r
962 'COMMENTS_HEADER_IDX' => _NP_EZCOMMENT2_COMMENTS_HEADER_IDX,
\r
975 function _hsc($str)
\r
977 return htmlspecialchars($str, ENT_QUOTES, _CHARSET);
\r