11
script_fu
Re: Signed member in the comments?

Your answer is in template over riding. This is where I would start.

\themes\your_theme\modules\newbb\newbb_thread.html

Something like this would need to be used from one of the templates in cbb.

<{if $topic_post.post_signature}>

_________________

<{$topic_post.post_signature}>

<{/if}>

Then you would need to figure out where the code would go in other modules. The code might need to be redone inorder to work.

\themes\your_theme\modules\news\news_item.html
\themes\your_theme\modules\news\news_article.html


This is just an example... Meaning not tested...

You could go through all this and still might half to hack the core with new code in order for this to work.

12
Will_H
Re: Signed member in the comments?
  • 2007/12/24 14:25

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


nah, I suggest you look at the user profile template in the system module.

Your issue is a little more complex.

XOOPS modules do not hook on their own, but trying to use a variable from cbb is not the answer because cbb utilizes frameworks which has its own independent module.textsanitizer.php

user profile template. I am not home to see what the variable is, but you stand a better chance with that one.

Again, hooking... not part of xoops... so may not work... but best course of action. Unless of course its a frameworks dependent module.... you get my drift.

13
script_fu
Re: Signed member in the comments?

Like I said it was just an example. I am not a coder but was trying to get some sort of direction started towards a solution.

14
trabis
Re: Signed member in the comments?
  • 2007/12/24 16:19

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


Hello,
It's simple to do and it should be implemented in the next version of Xoops.

Just replace your root/class/commentrenderer.php with this content:

// $Id: commentrenderer.php 2 2005-11-02 18:23:29Z skalpa $
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                                                    //
//  ------------------------------------------------------------------------ //
//  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.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu)                                          //
// URL: https://xoops.org/ http://www.xoopscube.jp/  http://www.myweb.ne.jp/  //
// Project: The XOOPS Project (https://xoops.org/)                        //
// ------------------------------------------------------------------------- //
/**
 * Display comments
 *
 * @package        kernel
 * @subpackage    comment
 *
 * @author        Kazumi Ono     
 * @copyright    (c) 2000-2003 The XOOPS Project - www.xoops.org
 */
class XoopsCommentRenderer {

    
/**#@+
     * @access    private
     */
    
var $_tpl;
    var 
$_comments null;
    var 
$_useIcons true;
    var 
$_doIconCheck false;
    var 
$_memberHandler;
    var 
$_statusText;
    
/**#@-*/

    /**
     * Constructor
     * 
     * @param   object  &$tpl   
     * @param   boolean $use_icons
     * @param   boolean $do_iconcheck
     **/
    
function XoopsCommentRenderer(&$tpl$use_icons true$do_iconcheck false)
    {
        
$this->_tpl =& $tpl;
        
$this->_useIcons $use_icons;
        
$this->_doIconCheck $do_iconcheck;
        
$this->_memberHandler =& xoops_gethandler('member');
        
$this->_statusText = array(XOOPS_COMMENT_PENDING => ''._CM_PENDING.''
XOOPS_COMMENT_ACTIVE => ''._CM_ACTIVE.''XOOPS_COMMENT_HIDDEN => ''._CM_HIDDEN.'');
    }

    
/**
     * Access the only instance of this class
     * 
     * @param   object  $tpl        reference to a {@link Smarty} object
     * @param   boolean $use_icons
     * @param   boolean $do_iconcheck
     * @return 
     **/
    
function &instance(&$tpl$use_icons true$do_iconcheck false)
    {
        static 
$instance;
        if (!isset(
$instance)) {
            
$instance = new XoopsCommentRenderer($tpl$use_icons$do_iconcheck);
        }
        return 
$instance;
    }

    
/**
     * Accessor
     * 
     * @param   object  &$comments_arr  array of {@link XoopsComment} objects
     **/
    
function setComments(&$comments_arr)
    {
        if (isset(
$this->_comments)) {
            unset(
$this->_comments);
        }
        
$this->_comments =& $comments_arr;
    }

    
/**
     * Render the comments in flat view
     * 
     * @param boolean $admin_view
     **/
    
function renderFlatView($admin_view false)
    {
        
$count count($this->_comments);
        for (
$i 0$i $count$i++) {
            if (
false != $this->_useIcons) {
                
$title $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).' '.$this->_comments[$i]->getVar('com_title');
            } else {
                
$title $this->_comments[$i]->getVar('com_title');
            }
            
$poster $this->_getPosterArray($this->_comments[$i]->getVar('com_uid'));
            if (
false != $admin_view) {
                
$text $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid')).''._CM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'IP: '.$this->_comments[$i]->getVar('com_ip').'
';
            } else {
                
// hide comments that are not active
                
if (XOOPS_COMMENT_ACTIVE != $this->_comments[$i]->getVar('com_status')) {
                    continue;
                } else {
                    
$text $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid'));
                }
            }
            
$this->_tpl->append('comments', array('id' => $this->_comments[$i]->getVar('com_id'), 'title' => $title'text' => $text'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), 'poster' => $poster));
        }
    }

    
/**
     * Render the comments in thread view
     * 
     * This method calls itself recursively
     * 
     * @param integer $comment_id   Should be "0" when called by client
     * @param boolean $admin_view
     * @param boolean $show_nav
     **/
    
function renderThreadView($comment_id 0$admin_view false$show_nav true)
    {
        include_once 
XOOPS_ROOT_PATH.'/class/tree.php';
        
// construct comment tree
        
$xot = new XoopsObjectTree($this->_comments'com_id''com_pid''com_rootid');
        
$tree =& $xot->getTree();

        if (
false != $this->_useIcons) {
            
$title $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title');
        } else {
            
$title $tree[$comment_id]['obj']->getVar('com_title');
        }
        if (
false != $show_nav && $tree[$comment_id]['obj']->getVar('com_pid') != 0) {
            
$this->_tpl->assign('lang_top'_CM_TOP);
            
$this->_tpl->assign('lang_parent'_CM_PARENT);
            
$this->_tpl->assign('show_threadnav'true);
        } else {
            
$this->_tpl->assign('show_threadnav'false);
        }
        if (
false != $admin_view) {
            
// admins can see all
            
$text $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid')).''._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'IP: '.$tree[$comment_id]['obj']->getVar('com_ip').'
';
        } else {
            
// hide comments that are not active
            
if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
                
// if there are any child comments, display them as root comments
                
if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
                    foreach (
$tree[$comment_id]['child'] as $child_id) {
                        
$this->renderThreadView($child_id$admin_viewfalse);
                    }
                }
                return;
            } else {
                
$text $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid'));
            }
        }
        
$replies = array();
        
$this->_renderThreadReplies($tree$comment_id$replies'  '$admin_view);
        
$show_replies = (count($replies) > 0) ? true false;
        
$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title'text' => $text'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies'show_replies' => $show_replies));
    }

    
/**
     * Render replies to a thread
     * 
     * @param   array   &$thread
     * @param   int     $key
     * @param   array   $replies
     * @param   string  $prefix
     * @param   bool    $admin_view
     * @param   integer $depth
     * @param   string  $current_prefix
     * 
     * @access    private
     **/
    
function _renderThreadReplies(&$thread$key, &$replies$prefix$admin_view$depth 0$current_prefix '')
    {
        if (
$depth 0) {
            if (
false != $this->_useIcons) {
                
$title $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title');
            } else {
                
$title $thread[$key]['obj']->getVar('com_title');
            }
            
$title = (false != $admin_view) ? $title.' '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')] : $title;
            
$replies[] = array('id' => $key'prefix' => $current_prefix'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid')));
            
$current_prefix .= $prefix;
        }
        if (isset(
$thread[$key]['child']) && !empty($thread[$key]['child'])) {
            
$depth++;
            foreach (
$thread[$key]['child'] as $childkey) {
                if (!
$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
                    
// skip this comment if it is not active and continue on processing its child comments instead
                    
if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
                        foreach (
$thread[$childkey]['child'] as $childchildkey) {
                            
$this->_renderThreadReplies($thread$childchildkey$replies$prefix$admin_view$depth);
                        }
                    }
                } else {
                    
$this->_renderThreadReplies($thread$childkey$replies$prefix$admin_view$depth$current_prefix);
                }
            }
        }
    }

    
/**
     * Render comments in nested view
     * 
     * Danger: Recursive!
     * 
     * @param integer $comment_id   Always "0" when called by client.
     * @param boolean $admin_view
     **/
    
function renderNestView($comment_id 0$admin_view false)
    {
        include_once 
XOOPS_ROOT_PATH.'/class/tree.php';
        
$xot = new XoopsObjectTree($this->_comments'com_id''com_pid''com_rootid');
        
$tree =& $xot->getTree();
        if (
false != $this->_useIcons) {
            
$title $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title');
        } else {
            
$title $tree[$comment_id]['obj']->getVar('com_title');
        }
        if (
false != $admin_view) {
            
$text $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid')).''._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'IP: '.$tree[$comment_id]['obj']->getVar('com_ip').'
';
        } else {
            
// skip this comment if it is not active and continue on processing its child comments instead
            
if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
                
// if there are any child comments, display them as root comments
                
if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
                    foreach (
$tree[$comment_id]['child'] as $child_id) {
                        
$this->renderNestView($child_id$admin_view);
                    }
                }
                return;
            } else {
                
$text $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid'));
            }
        }
        
$replies = array();
        
$this->_renderNestReplies($tree$comment_id$replies25$admin_view);
        
$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title'text' => $text'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies));
    }

    
/**
     * Render replies in nested view
     * 
     * @param   array   $thread
     * @param   int     $key
     * @param   array   $replies
     * @param   string  $prefix
     * @param   bool    $admin_view
     * @param   integer $depth
     * 
     * @access    private 
     **/
    
function _renderNestReplies(&$thread$key, &$replies$prefix$admin_view$depth 0)
    {
        if (
$depth 0) {
            if (
false != $this->_useIcons) {
                
$title $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title');
            } else {
                
$title $thread[$key]['obj']->getVar('com_title');
            }
            
$text = (false != $admin_view) ? $this->_getText($thread[$key]['obj']->getVar('com_text'),$thread[$key]['obj']->getVar('com_pid')).''._CM_STATUS.': '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')].'IP: '.$thread[$key]['obj']->getVar('com_ip').'
$this->_getText($thread[$key]['obj']->getVar('com_text'),$thread[$key]['obj']->getVar('com_pid'));
            
$replies[] = array('id' => $key'prefix' => $prefix'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title'text' => $text'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid')));

            
$prefix $prefix 25;
        }
        if (isset(
$thread[$key]['child']) && !empty($thread[$key]['child'])) {
            
$depth++;
            foreach (
$thread[$key]['child'] as $childkey) {
                if (!
$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
                    
// skip this comment if it is not active and continue on processing its child comments instead
                    
if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
                        foreach (
$thread[$childkey]['child'] as $childchildkey) {
                            
$this->_renderNestReplies($thread$childchildkey$replies$prefix$admin_view$depth);
                        }
                    }
                } else {
                    
$this->_renderNestReplies($thread$childkey$replies$prefix$admin_view$depth);
                }
            }
        }
    }


    
/**
     * Get the name of the poster
     * 
     * @param   int $poster_id
     * @return  string
     * 
     * @access    private
     **/
    
function _getPosterName($poster_id)
    {
        
$poster['id'] = intval($poster_id);
        if (
$poster['id'] > 0) {
            
$com_poster =& $this->_memberHandler->getUser($poster_id);
            if (
is_object($com_poster)) {
                
$poster['uname'] = '.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'';
                return 
$poster;
            }
        }
        
$poster['id'] = 0// to cope with deleted user accounts
        
$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
        return 
$poster;
    }

    
/**
     * Get an array with info about the poster
     * 
     * @param   int $poster_id
     * @return  array
     * 
     * @access    private
     **/
    
function _getPosterArray($poster_id)
    {
        
$poster['id'] = intval($poster_id);
        if (
$poster['id'] > 0) {
            
$com_poster =& $this->_memberHandler->getUser($poster['id']);
            if (
is_object($com_poster)) {
                
$poster['uname'] = '.XOOPS_URL.'/userinfo.php?uid='.$poster['id'].'">'.$com_poster->getVar('uname').'';
                
$poster_rank $com_poster->rank();
                
$poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif'
                
$poster['rank_title'] = $poster_rank['title'];
                
$poster['avatar'] = $com_poster->getVar('user_avatar');
                
$poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's');
                
$poster['from'] = $com_poster->getVar('user_from');
                
$poster['postnum'] = $com_poster->getVar('posts');
                
$poster['status'] = $com_poster->isOnline() ? _CM_ONLINE '';
                return 
$poster;
            }
        }
        
$poster['id'] = 0// to cope with deleted user accounts
        
$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
        
$poster['rank_title'] = '';
        
$poster['avatar'] = 'blank.gif';
        
$poster['regdate'] = '';
        
$poster['from'] = '';
        
$poster['postnum'] = 0;
        
$poster['status'] = '';
        return 
$poster;
    }

    
/**
     * Get the IMG tag for the title icon
     * 
     * @param   string  $icon_image
     * @return  string  HTML IMG tag
     * 
     * @access    private
     **/
    
function _getTitleIcon($icon_image)
    {
        
$icon_image htmlspecialcharstrim$icon_image ) );
        if (
$icon_image != '') {
            if (
false != $this->_doIconCheck) {
                if (!
file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) {
                    return 
'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
                } else {
                    return 
'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
                }
            } else {
                return 
'.XOOPS_URL.'/images/subject/'.$icon_image.'" alt="" />';
            }
        }
        return 
'.XOOPS_URL.'/images/icons/no_posticon.gif" alt="" />';
    }
    
    
/**
     * Get Text with Signature
     *
     * @param   string  $text
     * @param   int  $uid
     * @return  string
     *
     * @access    private
     **/
    
function _getText($text=''$uid=0)
    {
        global 
$xoopsConfig$xoopsUser;
        if ( 
$uid != ) {
            
$poster = new XoopsUser($uid);
            if ( !
$poster->isActive() ) {
                
$poster 0;
            }
        } else {
            
$poster 0;
        }

        if ( 
$poster ) {
            if ( 
$poster->getVar("attachsig") ) {
                
$text .= "

_________________"$poster->user_sig()."

"
;
            }
        }
        return 
$text;
    }

}
?>


I´ve just added an extra function to add user signature to comments in case user is using it.
It will work in all comments of all modules that use the system comments.

There is no need to touch anything else.

Of corse, please backup first and give some feedback here.

15
script_fu
Re: Signed member in the comments?

Nice contrib...

Now how would an admin turn this feature off?

16
trabis
Re: Signed member in the comments?
  • 2007/12/24 18:29

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


System config options are set during install in install/makedata.php

Adding new options to system is up to the core team.

For now, if you don´t want to attached signatures in your comments, then you´d better not apply the patch.

17
script_fu
Re: Signed member in the comments?

Again very Nice...

18
Will_H
Re: Signed member in the comments?
  • 2007/12/25 20:32

  • Will_H

  • Friend of XOOPS

  • Posts: 1786

  • Since: 2004/10/10


yep, neat.

19
thooq
Re: Signed member in the comments?
  • 2007/12/29 19:28

  • thooq

  • Just popping in

  • Posts: 9

  • Since: 2007/11/24


Quote:
by trabis on 2007/12/24 16:19:31

Hello,
It's simple to do and it should be implemented in the next version of Xoops.

Just replace your root/class/commentrenderer.php with this content:

// $Id: commentrenderer.php 2 2005-11-02 18:23:29Z skalpa $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <https://xoops.org/> //
// ------------------------------------------------------------------------ //
// 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. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: https://xoops.org/ http://www.xoopscube.jp/ http://www.myweb.ne.jp/ //
// Project: The XOOPS Project (https://xoops.org/) //
// ------------------------------------------------------------------------- //
/**
* Display comments
*
* @package kernel
* @subpackage comment
*
* @author Kazumi Ono
* @copyright (c) 2000-2003 The XOOPS Project - http://www.xoops.org
*/
class XoopsCommentRenderer {

/**#@+
* @access private
*/
var $_tpl;
var $_comments = null;
var $_useIcons = true;
var $_doIconCheck = false;
var $_memberHandler;
var $_statusText;
/**#@-*/

/**
* Constructor
*
* @param object &$tpl
* @param boolean $use_icons
* @param boolean $do_iconcheck
**/
function XoopsCommentRenderer(&$tpl, $use_icons = true, $do_iconcheck = false)
{
$this->_tpl =& $tpl;
$this->_useIcons = $use_icons;
$this->_doIconCheck = $do_iconcheck;
$this->_memberHandler =& xoops_gethandler('member');
$this->_statusText = array(XOOPS_COMMENT_PENDING => ''._CM_PENDING.'', XOOPS_COMMENT_ACTIVE => ''._CM_ACTIVE.'', XOOPS_COMMENT_HIDDEN => ''._CM_HIDDEN.'');
}

/**
* Access the only instance of this class
*
* @param object $tpl reference to a {@link Smarty} object
* @param boolean $use_icons
* @param boolean $do_iconcheck
* @return
**/
function &instance(&$tpl, $use_icons = true, $do_iconcheck = false)
{
static $instance;
if (!isset($instance)) {
$instance = new XoopsCommentRenderer($tpl, $use_icons, $do_iconcheck);
}
return $instance;
}

/**
* Accessor
*
* @param object &$comments_arr array of {@link XoopsComment} objects
**/
function setComments(&$comments_arr)
{
if (isset($this->_comments)) {
unset($this->_comments);
}
$this->_comments =& $comments_arr;
}

/**
* Render the comments in flat view
*
* @param boolean $admin_view
**/
function renderFlatView($admin_view = false)
{
$count = count($this->_comments);
for ($i = 0; $i < $count; $i++) {
if (false != $this->_useIcons) {
$title = $this->_getTitleIcon($this->_comments[$i]->getVar('com_icon')).' '.$this->_comments[$i]->getVar('com_title');
} else {
$title = $this->_comments[$i]->getVar('com_title');
}
$poster = $this->_getPosterArray($this->_comments[$i]->getVar('com_uid'));
if (false != $admin_view) {
$text = $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid')).'
'._CM_STATUS.': '.$this->_statusText[$this->_comments[$i]->getVar('com_status')].'
IP: '.$this->_comments[$i]->getVar('com_ip').'
';
} else {
// hide comments that are not active
if (XOOPS_COMMENT_ACTIVE != $this->_comments[$i]->getVar('com_status')) {
continue;
} else {
$text = $this->_getText($this->_comments[$i]->getVar('com_text'),$this->_comments[$i]->getVar('com_pid'));
}
}
$this->_tpl->append('comments', array('id' => $this->_comments[$i]->getVar('com_id'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($this->_comments[$i]->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($this->_comments[$i]->getVar('com_modified'), 'm'), 'poster' => $poster));
}
}

/**
* Render the comments in thread view
*
* This method calls itself recursively
*
* @param integer $comment_id Should be "0" when called by client
* @param boolean $admin_view
* @param boolean $show_nav
**/
function renderThreadView($comment_id = 0, $admin_view = false, $show_nav = true)
{
include_once XOOPS_ROOT_PATH.'/class/tree.php';
// construct comment tree
$xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
$tree =& $xot->getTree();

if (false != $this->_useIcons) {
$title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title');
} else {
$title = $tree[$comment_id]['obj']->getVar('com_title');
}
if (false != $show_nav && $tree[$comment_id]['obj']->getVar('com_pid') != 0) {
$this->_tpl->assign('lang_top', _CM_TOP);
$this->_tpl->assign('lang_parent', _CM_PARENT);
$this->_tpl->assign('show_threadnav', true);
} else {
$this->_tpl->assign('show_threadnav', false);
}
if (false != $admin_view) {
// admins can see all
$text = $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid')).'
'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'
IP: '.$tree[$comment_id]['obj']->getVar('com_ip').'
';
} else {
// hide comments that are not active
if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
// if there are any child comments, display them as root comments
if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
foreach ($tree[$comment_id]['child'] as $child_id) {
$this->renderThreadView($child_id, $admin_view, false);
}
}
return;
} else {
$text = $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid'));
}
}
$replies = array();
$this->_renderThreadReplies($tree, $comment_id, $replies, '  ', $admin_view);
$show_replies = (count($replies) > 0) ? true : false;
$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies, 'show_replies' => $show_replies));
}

/**
* Render replies to a thread
*
* @param array &$thread
* @param int $key
* @param array $replies
* @param string $prefix
* @param bool $admin_view
* @param integer $depth
* @param string $current_prefix
*
* @access private
**/
function _renderThreadReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0, $current_prefix = '')
{
if ($depth > 0) {
if (false != $this->_useIcons) {
$title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title');
} else {
$title = $thread[$key]['obj']->getVar('com_title');
}
$title = (false != $admin_view) ? $title.' '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')] : $title;
$replies[] = array('id' => $key, 'prefix' => $current_prefix, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'title' => $title, 'root_id' => $thread[$key]['obj']->getVar('com_rootid'), 'status' => $this->_statusText[$thread[$key]['obj']->getVar('com_status')], 'poster' => $this->_getPosterName($thread[$key]['obj']->getVar('com_uid')));
$current_prefix .= $prefix;
}
if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
$depth++;
foreach ($thread[$key]['child'] as $childkey) {
if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
// skip this comment if it is not active and continue on processing its child comments instead
if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
foreach ($thread[$childkey]['child'] as $childchildkey) {
$this->_renderThreadReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
}
}
} else {
$this->_renderThreadReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth, $current_prefix);
}
}
}
}

/**
* Render comments in nested view
*
* Danger: Recursive!
*
* @param integer $comment_id Always "0" when called by client.
* @param boolean $admin_view
**/
function renderNestView($comment_id = 0, $admin_view = false)
{
include_once XOOPS_ROOT_PATH.'/class/tree.php';
$xot = new XoopsObjectTree($this->_comments, 'com_id', 'com_pid', 'com_rootid');
$tree =& $xot->getTree();
if (false != $this->_useIcons) {
$title = $this->_getTitleIcon($tree[$comment_id]['obj']->getVar('com_icon')).' '.$tree[$comment_id]['obj']->getVar('com_title');
} else {
$title = $tree[$comment_id]['obj']->getVar('com_title');
}
if (false != $admin_view) {
$text = $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid')).'
'._CM_STATUS.': '.$this->_statusText[$tree[$comment_id]['obj']->getVar('com_status')].'
IP: '.$tree[$comment_id]['obj']->getVar('com_ip').'
';
} else {
// skip this comment if it is not active and continue on processing its child comments instead
if (XOOPS_COMMENT_ACTIVE != $tree[$comment_id]['obj']->getVar('com_status')) {
// if there are any child comments, display them as root comments
if (isset($tree[$comment_id]['child']) && !empty($tree[$comment_id]['child'])) {
foreach ($tree[$comment_id]['child'] as $child_id) {
$this->renderNestView($child_id, $admin_view);
}
}
return;
} else {
$text = $this->_getText($tree[$comment_id]['obj']->getVar('com_text'),$tree[$comment_id]['obj']->getVar('com_pid'));
}
}
$replies = array();
$this->_renderNestReplies($tree, $comment_id, $replies, 25, $admin_view);
$this->_tpl->append('comments', array('pid' => $tree[$comment_id]['obj']->getVar('com_pid'), 'id' => $tree[$comment_id]['obj']->getVar('com_id'), 'itemid' => $tree[$comment_id]['obj']->getVar('com_itemid'), 'rootid' => $tree[$comment_id]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($tree[$comment_id]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($tree[$comment_id]['obj']->getVar('com_uid')), 'replies' => $replies));
}

/**
* Render replies in nested view
*
* @param array $thread
* @param int $key
* @param array $replies
* @param string $prefix
* @param bool $admin_view
* @param integer $depth
*
* @access private
**/
function _renderNestReplies(&$thread, $key, &$replies, $prefix, $admin_view, $depth = 0)
{
if ($depth > 0) {
if (false != $this->_useIcons) {
$title = $this->_getTitleIcon($thread[$key]['obj']->getVar('com_icon')).' '.$thread[$key]['obj']->getVar('com_title');
} else {
$title = $thread[$key]['obj']->getVar('com_title');
}
$text = (false != $admin_view) ? $this->_getText($thread[$key]['obj']->getVar('com_text'),$thread[$key]['obj']->getVar('com_pid')).'
'._CM_STATUS.': '.$this->_statusText[$thread[$key]['obj']->getVar('com_status')].'
IP: '.$thread[$key]['obj']->getVar('com_ip').'
' : $this->_getText($thread[$key]['obj']->getVar('com_text'),$thread[$key]['obj']->getVar('com_pid'));
$replies[] = array('id' => $key, 'prefix' => $prefix, 'pid' => $thread[$key]['obj']->getVar('com_pid'), 'itemid' => $thread[$key]['obj']->getVar('com_itemid'), 'rootid' => $thread[$key]['obj']->getVar('com_rootid'), 'title' => $title, 'text' => $text, 'date_posted' => formatTimestamp($thread[$key]['obj']->getVar('com_created'), 'm'), 'date_modified' => formatTimestamp($thread[$key]['obj']->getVar('com_modified'), 'm'), 'poster' => $this->_getPosterArray($thread[$key]['obj']->getVar('com_uid')));

$prefix = $prefix + 25;
}
if (isset($thread[$key]['child']) && !empty($thread[$key]['child'])) {
$depth++;
foreach ($thread[$key]['child'] as $childkey) {
if (!$admin_view && $thread[$childkey]['obj']->getVar('com_status') != XOOPS_COMMENT_ACTIVE) {
// skip this comment if it is not active and continue on processing its child comments instead
if (isset($thread[$childkey]['child']) && !empty($thread[$childkey]['child'])) {
foreach ($thread[$childkey]['child'] as $childchildkey) {
$this->_renderNestReplies($thread, $childchildkey, $replies, $prefix, $admin_view, $depth);
}
}
} else {
$this->_renderNestReplies($thread, $childkey, $replies, $prefix, $admin_view, $depth);
}
}
}
}


/**
* Get the name of the poster
*
* @param int $poster_id
* @return string
*
* @access private
**/
function _getPosterName($poster_id)
{
$poster['id'] = intval($poster_id);
if ($poster['id'] > 0) {
$com_poster =& $this->_memberHandler->getUser($poster_id);
if (is_object($com_poster)) {
$poster['uname'] = ''.$com_poster->getVar('uname').'';
return $poster;
}
}
$poster['id'] = 0; // to cope with deleted user accounts
$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
return $poster;
}

/**
* Get an array with info about the poster
*
* @param int $poster_id
* @return array
*
* @access private
**/
function _getPosterArray($poster_id)
{
$poster['id'] = intval($poster_id);
if ($poster['id'] > 0) {
$com_poster =& $this->_memberHandler->getUser($poster['id']);
if (is_object($com_poster)) {
$poster['uname'] = ''.$com_poster->getVar('uname').'';
$poster_rank = $com_poster->rank();
$poster['rank_image'] = ($poster_rank['image'] != '') ? $poster_rank['image'] : 'blank.gif';
$poster['rank_title'] = $poster_rank['title'];
$poster['avatar'] = $com_poster->getVar('user_avatar');
$poster['regdate'] = formatTimestamp($com_poster->getVar('user_regdate'), 's');
$poster['from'] = $com_poster->getVar('user_from');
$poster['postnum'] = $com_poster->getVar('posts');
$poster['status'] = $com_poster->isOnline() ? _CM_ONLINE : '';
return $poster;
}
}
$poster['id'] = 0; // to cope with deleted user accounts
$poster['uname'] = $GLOBALS['xoopsConfig']['anonymous'];
$poster['rank_title'] = '';
$poster['avatar'] = 'blank.gif';
$poster['regdate'] = '';
$poster['from'] = '';
$poster['postnum'] = 0;
$poster['status'] = '';
return $poster;
}

/**
* Get the IMG tag for the title icon
*
* @param string $icon_image
* @return string HTML IMG tag
*
* @access private
**/
function _getTitleIcon($icon_image)
{
$icon_image = htmlspecialchars( trim( $icon_image ) );
if ($icon_image != '') {
if (false != $this->_doIconCheck) {
if (!file_exists(XOOPS_URL.'/images/subject/'.$icon_image)) {
return '';
} else {
return '';
}
} else {
return '';
}
}
return '';
}

/**
* Get Text with Signature
*
* @param string $text
* @param int $uid
* @return string
*
* @access private
**/
function _getText($text='', $uid=0)
{
global $xoopsConfig, $xoopsUser;
if ( $uid != 0 ) {
$poster = new XoopsUser($uid);
if ( !$poster->isActive() ) {
$poster = 0;
}
} else {
$poster = 0;
}

if ( $poster ) {
if ( $poster->getVar("attachsig") ) {
$text .= "


_________________
". $poster->user_sig()."

";
}
}
return $text;
}

}
?>

I´ve just added an extra function to add user signature to comments in case user is using it.
It will work in all comments of all modules that use the system comments.

There is no need to touch anything else.

Of corse, please backup first and give some feedback here.



thank you for your contribution i tried your way
and it did not appears in any modules
can you explain it more me please

20
trabis
Re: Signed member in the comments?
  • 2007/12/29 19:48

  • trabis

  • Core Developer

  • Posts: 2269

  • Since: 2006/9/1 1


What can I say? The signature will be attached in system comments as it happens in forum posts. Just replace that file content. Is not that what you want?

Login

Who's Online

247 user(s) are online (172 user(s) are browsing Support Forums)


Members: 0


Guests: 247


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits