Exemple #1
0
function smarty_function_d3comment($params, &$smarty)
{
    $forum_dirpath = XOOPS_TRUST_PATH . '/modules/d3forum';
    require_once $forum_dirpath . '/class/D3commentObj.class.php';
    $mydirname = @$params['mydirname'];
    $classname = @$params['class'];
    $mytrustdirname = '';
    if ($mydirname != '') {
        @(include XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/mytrustdirname.php');
    }
    $params['mytrustdirname'] = $mytrustdirname;
    $class_bases = array(XOOPS_ROOT_PATH . '/modules/' . $mydirname . '/class', XOOPS_TRUST_PATH . '/modules/' . $mytrustdirname . '/class', XOOPS_TRUST_PATH . '/modules/d3forum/class');
    foreach ($class_bases as $class_base) {
        if (file_exists($class_base . '/' . $classname . '.class.php')) {
            require_once $class_base . '/' . $classname . '.class.php';
            break;
        }
    }
    $m_params['forum_dirname'] = $forum_dirname;
    $m_params['external_dirname'] = $mydirname;
    $m_params['classname'] = $classname;
    $m_params['external_trustdirname'] = $mytrustdirname;
    if (class_exists($classname)) {
        $obj =& D3commentObj::getInstance($m_params);
        $obj->d3comObj->setSmarty($smarty);
        switch ($params['mode']) {
            case 'count':
                $obj->d3comObj->displayCommentsCount($params);
                break;
            case 'display_inline':
            default:
                $obj->d3comObj->displayCommentsInline($params);
                break;
        }
    } else {
        echo "class parameter is invalid in <{d3comment}>";
    }
}
Exemple #2
0
 function &main_get_comment_object($forum_dirname, $external_link_format)
 {
     require_once dirname(dirname(__FILE__)) . '/class/D3commentObj.class.php';
     $params['forum_dirname'] = $forum_dirname;
     @(list($params['external_dirname'], $params['classname'], $params['external_trustdirname']) = explode('::', $external_link_format));
     $obj =& D3commentObj::getInstance($params);
     return $obj->d3comObj;
 }
Exemple #3
0
function d3forum_display_comment($mydirname, $forum_id, $params)
{
    global $xoopsUser, $xoopsConfig, $xoopsModule;
    // check the d3forum exists and is active
    $module_hanlder =& xoops_gethandler('module');
    $module =& $module_hanlder->getByDirname($mydirname);
    if (!is_object($module) || !$module->getVar('isactive')) {
        return;
    }
    // check permission of "module_read"
    $moduleperm_handler =& xoops_gethandler('groupperm');
    $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
    if (!$moduleperm_handler->checkRight('module_read', $module->getVar('mid'), $groups)) {
        return;
    }
    // subject_raw
    $params['subject_raw'] = empty($params['subject_escaped']) ? @$params['subject'] : d3forum_common_unhtmlspecialchars(@$params['subject']);
    // read d3comment class and make the object
    // for using d3forum_comment plugin with d3com class
    if (!empty($params['class'])) {
        $class_name = preg_replace('/[^0-9a-zA-Z_]/', '', $params['class']);
        $external_dirname = @$params['mydirname'];
        $external_trustdirname = @$params['mytrustdirname'];
        // auto external_dirname
        if ($external_dirname == '' && is_object($GLOBALS['xoopsModule'])) {
            $external_dirname = $GLOBALS['xoopsModule']->getVar('dirname');
        }
        // naao from
        require_once dirname(dirname(__FILE__)) . '/class/D3commentObj.class.php';
        // search and include the class file
        if ($external_trustdirname && file_exists(XOOPS_TRUST_PATH . "/modules/{$external_trustdirname}/class/{$class_name}.class.php")) {
            require_once XOOPS_TRUST_PATH . "/modules/{$external_trustdirname}/class/{$class_name}.class.php";
        } else {
            if ($external_dirname && file_exists(XOOPS_ROOT_PATH . "/modules/{$external_dirname}/class/{$class_name}.class.php")) {
                require_once XOOPS_ROOT_PATH . "/modules/{$external_dirname}/class/{$class_name}.class.php";
            } else {
                include_once dirname(dirname(__FILE__)) . "/class/{$class_name}.class.php";
                $external_dirname = '';
                $external_trustdirname = '';
            }
        }
        $m_params['forum_dirname'] = $mydirname;
        $m_params['external_dirname'] = $external_dirname;
        $m_params['class_name'] = $class_name;
        $m_params['external_trustdirname'] = $external_trustdirname;
        if (class_exists($class_name)) {
            $obj =& D3commentObj::getInstance($m_params);
            $external_link_id = $obj->d3comObj->external_link_id($params);
        }
        // naao to
    }
    // for conventional module
    if (!is_object($obj->d3comObj)) {
        if (!empty($params['itemname'])) {
            $external_link_id = @$_GET[$params['itemname']];
            if (empty($external_link_id)) {
                return;
            }
        } else {
            echo "set valid itemname or class in <{d3forum_comment}> of the template";
            return;
        }
    }
    $params['external_link_id'] = $external_link_id;
    $params['external_dirname'] = $external_dirname;
    $params['external_trustdirname'] = $external_trustdirname;
    $smarty = null;
    d3forum_render_comments($mydirname, $forum_id, $params, $smarty);
}
Exemple #4
0
function &d3forum_get_comment_object( $forum_dirname, $external_link_format )
{
	$params['forum_dirname'] = $forum_dirname ;

	@list( $params['external_dirname'] , $params['classname'] , $params['external_trustdirname'] ) 
		= explode( '::' , $external_link_format ) ;

	$this->d3comObj =& D3commentObj::getInstance ( $params ) ;
	
	return $this->d3comObj->d3comObj ;
}