1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 20:57:26 +02:00

Added setScVar() function to shortcode handler, modified forum and news to use new function. More work on new level handler, implemented it in forum shortcodes.

This commit is contained in:
mcfly
2009-01-25 17:44:13 +00:00
parent c3aa41f55f
commit 6633e23f94
7 changed files with 192 additions and 194 deletions

View File

@@ -9,8 +9,8 @@
* Administration Area - Users * Administration Area - Users
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/users.php,v $
* $Revision: 1.30 $ * $Revision: 1.31 $
* $Date: 2009-01-18 16:47:41 $ * $Date: 2009-01-25 17:44:12 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
* *
*/ */
@@ -1594,7 +1594,7 @@ function show_ranks()
$fieldList['core'] = array( $fieldList['core'] = array(
'comments' => USRLAN_201, 'comments' => USRLAN_201,
'visits' => USRLAN_202, 'visits' => USRLAN_202,
'days' => USRLAN_203 'daysregged' => USRLAN_203
); );
foreach($e107->extended_struct as $field) foreach($e107->extended_struct as $field)

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/level_handler.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/level_handler.php,v $
| $Revision: 1.8 $ | $Revision: 1.9 $
| $Date: 2009-01-18 16:47:41 $ | $Date: 2009-01-25 17:44:13 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -118,6 +118,7 @@ class e107UserRank
{ {
var $ranks = array(); var $ranks = array();
var $userRanks = array();
function e107UserRank() function e107UserRank()
{ {
@@ -166,21 +167,25 @@ class e107UserRank
} }
} }
function _getImage($info) function _getImage(&$info)
{ {
if($info['lan_pfx']) $img = $info['image'];
if($info['lan_pfx'] && strpos('_', $info['image']))
{ {
$_tmp = explode('_', $info['image'], 2); $_tmp = explode('_', $info['image'], 2);
return e_LANGUAGE.'_'.$tmp[1]; $img = e_LANGUAGE.'_'.$_tmp[1];
} }
return $info['image']; return e_IMAGE_ABS.'ranks/'.$img;
} }
function getRanks($userId) function getRanks($userId)
{ {
$e107 = e107::getInstance(); $e107 = e107::getInstance();
if(!$userId && USER) { $userId = USERID; } if(!$userId && USER) { $userId = USERID; }
if($ret = getcachedvars('userRankInfo_'.$userId)) { return $ret; } if(isset($this->userRanks[$userId]))
{
return $this->userRanks[$userId];
}
$ret = array(); $ret = array();
$userData = get_user_data($userId); $userData = get_user_data($userId);
@@ -189,16 +194,16 @@ class e107UserRank
if($userData['user_perms'] == '0') if($userData['user_perms'] == '0')
{ {
//Main Site Admin //Main Site Admin
$ret['special'] = "<img src='".$this->_getImage($this->ranks['special'][1]['image'])."' /><br />"; $data['special'] = "<img src='".$this->_getImage($this->ranks['special'][1])."' /><br />";
} }
else else
{ {
//Site Admin //Site Admin
$ret['special'] = "<img src='".$this->_getImage($this->ranks['special'][2]['image'])."' /><br />"; $data['special'] = "<img src='".$this->_getImage($this->ranks['special'][2])."' /><br />";
} }
} }
$userData['daysregged'] = max(1, round((time() - $userData['user_join']) / 86400)); $userData['user_daysregged'] = max(1, round((time() - $userData['user_join']) / 86400));
$level = $this->_calcLevel($userData); $level = $this->_calcLevel($userData);
$lastRank = count($this->ranks['data']) - 1; $lastRank = count($this->ranks['data']) - 1;
@@ -209,7 +214,7 @@ class e107UserRank
} }
elseif($level >= $this->ranks['data'][$lastRank]['thresh']) elseif($level >= $this->ranks['data'][$lastRank]['thresh'])
{ {
$rank = 9; $rank = $lastRank;
} }
else else
{ {
@@ -226,28 +231,27 @@ class e107UserRank
{ {
$data['name'] = '[ '.$e107->tp->toHTML($this->ranks['data'][$rank]['name'], FALSE, 'defs').' ]'; $data['name'] = '[ '.$e107->tp->toHTML($this->ranks['data'][$rank]['name'], FALSE, 'defs').' ]';
$img_title = ($this->ranks['data'][$rank]['name'] ? "title='".$this->ranks['data'][$rank]['name']."'" : ''); $img_title = ($this->ranks['data'][$rank]['name'] ? "title='".$this->ranks['data'][$rank]['name']."'" : '');
$data['pic'] = "<img {$img_title} src='".$this->_getImage($this->ranks['data'][$rank]['image'])."' /><br />"; $data['pic'] = "<img {$img_title} src='".$this->_getImage($this->ranks['data'][$rank])."' /><br />";
cachevars('userRankInfo_'.$userId, $data);
return $data;
} }
$this->userRanks[$userId] = $data;
return $data;
} }
function _calcLevel(&$userData) function _calcLevel(&$userData)
{ {
var_dump($this->ranks['config']); global $pref;
$value = 0; $value = 0;
$calc = $this->ranks['config']['calc']; $calc = $pref['ranks_calc'];
$search = array(); $search = array();
$replace = array(); $replace = array();
foreach($this->ranks['config']['fields'] as $f) foreach(explode(',', $pref['ranks_flist']) as $f)
{ {
$search[] = $f['name']; $search[] = '{'.$f.'}';
$replace[] = $userData[$f['name']]; $replace[] = $userData['user_'.$f];
} }
$calc = str_replace($search, $replace, $calc); $calc = '$userLevelValue = '.str_replace($search, $replace, $calc).';';
$value = eval($calc); $value = eval($calc);
return $value; return $userLevelValue;
} }
} }

View File

@@ -9,9 +9,9 @@
* News handler * News handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/news_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/news_class.php,v $
* $Revision: 1.12 $ * $Revision: 1.13 $
* $Date: 2009-01-18 00:27:10 $ * $Date: 2009-01-25 17:44:13 $
* $Author: secretr $ * $Author: mcfly_e107 $
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
@@ -236,8 +236,8 @@ class news {
$loop_uid = $news['news_author']; $loop_uid = $news['news_author'];
require_once(e_FILE.'shortcode/batch/news_shortcodes.php'); require_once(e_FILE.'shortcode/batch/news_shortcodes.php');
$e107->tp->e_sc->scClasses['news_shortcodes']->news_item = $news; setScVar('news_shortcodes', 'news_item', $news);
$e107->tp->e_sc->scClasses['news_shortcodes']->param = $param; setScVar('news_shortcodes', 'param', $param);
$text = $e107->tp->parseTemplate($NEWS_PARSE, true); $text = $e107->tp->parseTemplate($NEWS_PARSE, true);
if ($mode == 'return') if ($mode == 'return')

View File

@@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/shortcode_handler.php,v $
| $Revision: 1.23 $ | $Revision: 1.24 $
| $Date: 2009-01-16 01:02:41 $ | $Date: 2009-01-25 17:44:13 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -25,6 +25,21 @@ function register_shortcode($classFunc, $codes, $path='', $force=false)
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$sc = &$e107->tp->e_sc; $sc = &$e107->tp->e_sc;
//If codes is set to true, let's go get a list of shortcode methods
if(is_bool($codes) && $codes === true)
{
$codes = array();
$tmp = get_class_methods($classFunc);
foreach($tmp as $c)
{
if(strpos($c, 'get_') === 0)
{
$codes[] = substr($c, 4);
}
}
unset($tmp);
}
//We only register these shortcodes if they have not already been registered in some manner //We only register these shortcodes if they have not already been registered in some manner
//ie theme or other plugin .sc files //ie theme or other plugin .sc files
if(is_array($codes)) if(is_array($codes))
@@ -48,6 +63,12 @@ function register_shortcode($classFunc, $codes, $path='', $force=false)
} }
} }
function setScVar($scName, $scVar, &$value)
{
$e107 = e107::getInstance();
$e107->tp->e_sc->scClasses[$scName]->$scVar = $value;
}
function initShortcodeClass($class) function initShortcodeClass($class)
{ {
$e107 = e107::getInstance(); $e107 = e107::getInstance();
@@ -235,10 +256,16 @@ class e_shortcode
} }
$this->scClasses[$_class] = new $_class; $this->scClasses[$_class] = new $_class;
} }
if(is_callable(array($_class, $_method))) if(method_exists($this->scClasses[$_class], $_method))
{ {
$ret = $this->scClasses[$_class]->$_method($parm, $sc_mode); $ret = $this->scClasses[$_class]->$_method($parm, $sc_mode);
} }
else
{
echo $_class.'::'.$_method.' NOT FOUND!<br />';
}
break; break;
case 'func': case 'func':

View File

@@ -9,8 +9,8 @@
* Message Handler * Message Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
* $Revision: 1.37 $ * $Revision: 1.38 $
* $Date: 2009-01-10 04:39:54 $ * $Date: 2009-01-25 17:44:13 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
* *
*/ */
@@ -22,6 +22,8 @@ class e107forum
var $permList = array(); var $permList = array();
var $fieldTypes = array(); var $fieldTypes = array();
var $userViewed = array(); var $userViewed = array();
var $modArray = array();
var $e107;
function e107forum() function e107forum()
{ {
@@ -47,7 +49,7 @@ class e107forum
$this->fieldTypes['forum_thread']['thread_options'] = 'escape'; $this->fieldTypes['forum_thread']['thread_options'] = 'escape';
$this->fieldTypes['forum']['forum_lastpost_user'] = 'int'; $this->fieldTypes['forum']['forum_lastpost_user'] = 'int';
$this->e107 = e107::getInstance();
} }
function loadPermList() function loadPermList()
@@ -613,22 +615,30 @@ class e107forum
return FALSE; return FALSE;
} }
function forumGetMods($uclass = e_UC_ADMIN) function forumGetMods($uclass = e_UC_ADMIN, $force=false)
{ {
$e107 = e107::getInstance(); if(count($this->modArray) && !$force)
{
return $this->modArray;
}
if($uclass == e_UC_ADMIN || trim($uclass) == '') if($uclass == e_UC_ADMIN || trim($uclass) == '')
{ {
$e107->sql->db_Select('user', 'user_id, user_name','user_admin = 1 ORDER BY user_name ASC'); $this->e107->sql->db_Select('user', 'user_id, user_name','user_admin = 1 ORDER BY user_name ASC');
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC)) while($row = $this->e107->sql->db_Fetch(MYSQL_ASSOC))
{ {
$ret[$row['user_id']] = $row['user_name']; $this->modArray[$row['user_id']] = $row['user_name'];
} }
} }
else else
{ {
$ret = $e107->user_class->get_users_in_class($uclass, 'user_name', true); $this->modArray = $this->e107->user_class->get_users_in_class($uclass, 'user_name', true);
} }
return $ret; return $this->modArray;
}
function isModerator($uid)
{
return ($uid && in_array($uid, array_keys($this->modArray)));
} }
function forumGetForumList() function forumGetForumList()

View File

@@ -1,34 +1,21 @@
<?php <?php
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
/* register_shortcode('forum_shortcodes', true);
$codes = array( initShortcodeClass('forum_shortcodes');
'top','joined','threaddatestamp','post','postdeleted','attachments','privmessage',
'avatar','anon_ip','ip','poster','emailimg','emailitem','signature','profileimg',
'posts','visits','customtitle','website','websiteimg','editimg','quoteimg','reportimg',
'rpg','memberid','level','modoptions','lastedit','lasteditby','poll','newflag'
);
*/
$codes = array();
$tmp = get_class_methods('forum_shortcodes');
foreach($tmp as $c)
{
if(strpos($c, 'get_') === 0)
{
$codes[] = substr($c, 4);
}
}
register_shortcode('forum_shortcodes', $codes);
class forum_shortcodes class forum_shortcodes
{ {
var $e107; var $e107;
var $postInfo;
var $thread;
var $forum;
function forum_shortcodes() function forum_shortcodes()
{ {
$this->e107 = e107::getInstance(); $this->e107 = e107::getInstance();
$this->postInfo = array();
} }
function get_top() function get_top()
@@ -38,32 +25,30 @@ class forum_shortcodes
function get_joined() function get_joined()
{ {
global $postInfo, $gen; global $gen;
if ($postInfo['post_user']) if ($this->postInfo['post_user'])
{ {
return LAN_06.': '.$gen->convert_date($postInfo['user_join'], 'forum').'<br />'; return LAN_06.': '.$gen->convert_date($this->postInfo['user_join'], 'forum').'<br />';
} }
} }
function get_threaddatestamp() function get_threaddatestamp()
{ {
global $postInfo, $gen; global $gen;
return "<a id='post_{$post_info['post_id']}' href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($postInfo['post_datestamp'], 'forum'); return "<a id='post_{$this->post_info['post_id']}' href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'post', 'id' => $this->postInfo['post_id']))."'>".IMAGE_post."</a> ".$gen->convert_date($this->postInfo['post_datestamp'], 'forum');
} }
function get_post() function get_post()
{ {
global $postInfo; $emote = (isset($this->postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
$emote = (isset($postInfo['post_options']['no_emote']) ? ',emotes_off' : ''); return $this->e107->tp->toHTML($this->postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$this->postInfo['user_class']);
return $this->e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$post_info['user_class']);
} }
function get_postdeleted() function get_postdeleted()
{ {
global $postInfo; if($this->postInfo['post_status'])
if($postInfo['post_status'])
{ {
$info = unserialize($postInfo['post_options']); $info = unserialize($this->postInfo['post_options']);
return " return "
Post delete on: {$info['deldate']}<br /> Post delete on: {$info['deldate']}<br />
reason: {$info['delreason']} reason: {$info['delreason']}
@@ -74,10 +59,9 @@ class forum_shortcodes
function get_attachments() function get_attachments()
{ {
global $postInfo; if($this->postInfo['post_attachments'])
if($postInfo['post_attachments'])
{ {
$attachments = explode(',', $postInfo['post_attachments']); $attachments = explode(',', $this->postInfo['post_attachments']);
$txt = ''; $txt = '';
foreach($attachments as $a) foreach($attachments as $a)
{ {
@@ -107,30 +91,28 @@ class forum_shortcodes
function get_privmessage() function get_privmessage()
{ {
global $postInfo; if(plugInstalled('pm') && ($this->postInfo['post_user'] > 0))
if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
{ {
return $this->e107->tp->parseTemplate("{SENDPM={$postInfo['post_user']}}"); return $this->e107->tp->parseTemplate("{SENDPM={$this->postInfo['post_user']}}");
} }
} }
function get_avatar() function get_avatar()
{ {
global $postInfo; if ($this->postInfo['post_user'])
if ($postInfo['post_user'])
{ {
if(!$avatar = getcachedvars('forum_avatar_'.$postInfo['post_user'])) if(!$avatar = getcachedvars('forum_avatar_'.$this->postInfo['post_user']))
{ {
if ($postInfo['user_image']) if ($this->postInfo['user_image'])
{ {
require_once(e_HANDLER.'avatar_handler.php'); require_once(e_HANDLER.'avatar_handler.php');
$avatar = "<div class='spacer'><img src='".avatar($postInfo['user_image'])."' alt='' /></div><br />"; $avatar = "<div class='spacer'><img src='".avatar($this->postInfo['user_image'])."' alt='' /></div><br />";
} }
else else
{ {
$avatar = ''; $avatar = '';
} }
cachevars('forum_avatar_'.$postInfo['post_user'], $avatar); cachevars('forum_avatar_'.$this->postInfo['post_user'], $avatar);
} }
return $avatar; return $avatar;
} }
@@ -140,43 +122,39 @@ class forum_shortcodes
function get_anon_ip() function get_anon_ip()
{ {
global $postInfo; if($this->postInfo['post_user_anon'] && (ADMIN || MODERATOR))
if($postInfo['post_user_anon'] && (ADMIN || MODERATOR))
{ {
return $this->e107->ipDecode($postInfo['post_ip']); return $this->e107->ipDecode($this->postInfo['post_ip']);
} }
} }
function get_ip() function get_ip()
{ {
global $postInfo; if((ADMIN || MODERATOR) && !$this->postInfo['user_admin'])
if((ADMIN || MODERATOR) && !$postInfo['user_admin'])
{ {
return $this->e107->ipDecode($postInfo['post_ip']); return $this->e107->ipDecode($this->postInfo['post_ip']);
} }
} }
function get_poster() function get_poster()
{ {
global $postInfo; if($this->postInfo['user_name'])
if($postInfo['user_name'])
{ {
return "<a href='".$this->e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $postInfo['post_user']))."'>{$postInfo['user_name']}</a>"; return "<a href='".$this->e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $this->postInfo['post_user']))."'>{$this->postInfo['user_name']}</a>";
} }
else else
{ {
return '<b>'.$this->e107->tp->toHTML($postInfo['post_user_anon']).'</b>'; return '<b>'.$this->e107->tp->toHTML($this->postInfo['post_user_anon']).'</b>';
} }
} }
function get_emailimg() function get_emailimg()
{ {
global $postInfo; if($this->postInfo['user_name'])
if($postInfo['user_name'])
{ {
return (!$post_info['user_hideemail'] ? $this->e107->tp->parseTemplate("{EMAILTO={$postInfo['user_email']}}") : ''); return (!$this->postInfo['user_hideemail'] ? $this->e107->tp->parseTemplate("{EMAILTO={$this->postInfo['user_email']}}") : '');
} }
return ''; return '';
@@ -184,168 +162,145 @@ class forum_shortcodes
function get_emailitem() function get_emailitem()
{ {
if($postInfo['thread_start']) if($this->postInfo['thread_start'])
{ {
return $this->e107->tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$postInfo['post_thread']}}"); return $this->e107->tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$this->postInfo['post_thread']}}");
} }
} }
function get_printitem() function get_printitem()
{ {
global $postInfo; if($this->postInfo['thread_start'])
if($postInfo['thread_start'])
{ {
return $this->e107->tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$postInfo['post_thread']}}"); return $this->e107->tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$this->postInfo['post_thread']}}");
} }
} }
function get_signature() function get_signature()
{ {
if(!USER) { return ''; } if(!USER) { return ''; }
global $postInfo, $pref; global $pref;
static $forum_sig_shown; static $forum_sig_shown;
if(varsettrue($pref['forum_sig_once'])) if(varsettrue($pref['forum_sig_once']))
{ {
$_tmp = 'forum_sig_shown_'.$postInfo['post_user']; $_tmp = 'forum_sig_shown_'.$this->postInfo['post_user'];
if(getcachedvars($_tmp)) { return ''; } if(getcachedvars($_tmp)) { return ''; }
cachevars($_tmp, 1); cachevars($_tmp, 1);
} }
return ($postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$this->e107->tp->toHTML($postInfo['user_signature'], true).'</span>' : ''); return ($this->postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:left' /><span class='smalltext'>".$this->e107->tp->toHTML($this->postInfo['user_signature'], true).'</span>' : '');
} }
function get_profileimg() function get_profileimg()
{ {
global $postInfo; if (USER && $this->postInfo['user_name'])
if (USER && $postInfo['user_name'])
{ {
return $this->e107->tp->parseTemplate("{PROFILE={$postInfo['post_user']}}"); return $this->e107->tp->parseTemplate("{PROFILE={$this->postInfo['post_user']}}");
} }
} }
function get_posts() function get_posts()
{ {
global $postInfo; if ($this->postInfo['post_user'])
if ($postInfo['post_user'])
{ {
return LAN_67.': '.(int)$postInfo['user_plugin_forum_posts'].'<br />'; return LAN_67.': '.(int)$this->postInfo['user_plugin_forum_posts'].'<br />';
} }
} }
function get_visits() function get_visits()
{ {
global $postInfo; if ($this->postInfo['user_name'])
if ($postInfo['user_name'])
{ {
return LAN_09.': '.$postInfo['user_visits'].'<br />'; return LAN_09.': '.$this->postInfo['user_visits'].'<br />';
} }
} }
function get_customtitle() function get_customtitle()
{ {
global $postInfo; if ($this->postInfo['user_customtitle'])
if ($postInfo['user_customtitle'])
{ {
return $this->e107->tp->toHTML($postInfo['user_customtitle']).'<br />'; return $this->e107->tp->toHTML($this->postInfo['user_customtitle']).'<br />';
} }
} }
function get_website() function get_website()
{ {
global $postInfo; if ($this->postInfo['user_homepage']) {
if ($postInfo['user_homepage']) { return LAN_08.': '.$this->postInfo['user_homepage'].'<br />';
return LAN_08.': '.$postInfo['user_homepage'].'<br />';
} }
} }
function get_websiteimg() function get_websiteimg()
{ {
global $postInfo; if ($this->postInfo['user_homepage'] && $this->postInfo['user_homepage'] != 'http://')
if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://')
{ {
return "<a href='{$postInfo['user_homepage']}'>".IMAGE_website.'</a>'; return "<a href='{$this->postInfo['user_homepage']}'>".IMAGE_website.'</a>';
} }
} }
function get_editimg() function get_editimg()
{ {
global $postInfo, $threadInfo; if (USER && $this->postInfo['post_user'] == USERID && $this->thread->threadInfo['thread_active'])
if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
{ {
return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $postInfo['post_id']))."'>".IMAGE_edit.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'edit', 'id' => $this->postInfo['post_id']))."'>".IMAGE_edit.'</a> ';
} }
} }
function get_quoteimg() function get_quoteimg()
{ {
global $postInfo, $forum; if($this->forum->checkperm($this->postInfo['post_forum'], 'post'))
if($forum->checkperm($postInfo['post_forum'], 'post'))
{ {
return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $postInfo['post_id']))."'>".IMAGE_quote.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', array('func' => 'quote', 'id' => $this->postInfo['post_id']))."'>".IMAGE_quote.'</a> ';
} }
} }
function get_reportimg() function get_reportimg()
{ {
global $postInfo, $page; global $page;
if (USER) { if (USER) {
return "<a href='".$this->e107->url->getUrl('forum', 'thread', 'func=report&id='.$postInfo['post_thread'])."'>".IMAGE_report.'</a> '; return "<a href='".$this->e107->url->getUrl('forum', 'thread', 'func=report&id='.$this->postInfo['post_thread'])."'>".IMAGE_report.'</a> ';
} }
} }
function get_rpg() function get_rpg()
{ {
global $postInfo; return rpg($this->postInfo['user_join'], $this->postInfo['user_plugin_forum_posts']);
return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']);
} }
function get_memberid() function get_memberid()
{ {
global $post_info, $ldata, $pref, $forum_info; if (!$this->postInfo['post_user']) { return FALSE; }
if ($post_info['anon']) { return ''; } return "<span class='smalltext'>".LAN_195.' #'.$this->postInfo['post_user'].'</span>';
$fmod = ($post_info['user_class'] != '' && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE));
if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN)
{
$fmod = $post_info['user_admin'];
}
if (!array_key_exists($post_info['user_id'],$ldata)) {
$ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod);
}
return $ldata[$post_info['user_id']][0];
} }
function get_level() function get_level($parm)
{ {
global $post_info, $ldata, $pref, $forum_info; global $pref;
if ($post_info['anon']) { return ''; } if (!$this->postInfo['post_user']) { return ''; }
$fmod = ($post_info['user_class'] != "" && check_class($forum_info['forum_moderators'], $post_info['user_class'], TRUE));
if(!$fmod && $forum_info['forum_moderators'] == e_UC_ADMIN)
{
$fmod = $post_info['user_admin'];
}
if (!array_key_exists($post_info['user_id'],$ldata)) {
$ldata[$post_info['user_id']] = get_level($post_info['user_id'], $post_info['user_forums'], $post_info['user_comments'], $post_info['user_chats'], $post_info['user_visits'], $post_info['user_join'], $post_info['user_admin'], $post_info['user_perms'], $pref, $fmod);
}
if($parm == 'pic')
{
return $ldata[$post_info['user_id']]['pic'];
}
if($parm == 'name')
{
return $ldata[$post_info['user_id']]['name'];
}
if($parm == 'special')
{
return $ldata[$post_info['user_id']]['special'];
}
if($parm == 'userid')
{
return $ldata[$post_info['user_id']]['userid'];
}
return $ldata[$post_info['user_id']][1];
$rankInfo = $this->e107->userRank->getRanks($this->postInfo['post_user']);
if(!$parm) { $parm = 'name'; }
switch($parm)
{
case 'userid' :
return $this->get_memberid();
break;
case 'special':
if(isset($rankInfo['special'])) { return $rankInfo['special']; }
if($this->forum->isModerator($this->postInfo['post_user']))
{
return "<div class='spacer'>".IMAGE_rank_moderator_image.'</div>';
}
return '';
break;
default:
return varset($rankInfo[$parm], '');
break;
}
} }
function get_modoptions() function get_modoptions()
@@ -358,25 +313,24 @@ class forum_shortcodes
function get_lastedit() function get_lastedit()
{ {
global $postInfo, $gen; global $gen;
if ($postInfo['post_edit_datestamp']) if ($this->postInfo['post_edit_datestamp'])
{ {
return $gen->convert_date($postInfo['post_edit_datestamp'],'forum'); return $gen->convert_date($this->postInfo['post_edit_datestamp'],'forum');
} }
} }
function get_lasteditby() function get_lasteditby()
{ {
global $postInfo; if(isset($this->postInfo['edit_name']))
if(isset($postInfo['edit_name']))
{ {
if($parm == 'link') if($parm == 'link')
{ {
$e107 = e107::getInstance(); $e107 = e107::getInstance();
$url = $e107->url->getUrl('core:user', 'main', 'func=profile&id='.$postInfo['post_edit_user']); $url = $e107->url->getUrl('core:user', 'main', 'func=profile&id='.$this->postInfo['post_edit_user']);
return "<a href='{$url}'>{$postInfo['edit_name']}</a>"; return "<a href='{$url}'>{$this->postInfo['edit_name']}</a>";
} }
return $postInfo['edit_name']; return $this->postInfo['edit_name'];
} }
} }

View File

@@ -9,8 +9,8 @@
* Message Handler * Message Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $ * $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
* $Revision: 1.19 $ * $Revision: 1.20 $
* $Date: 2008-12-20 23:59:00 $ * $Date: 2009-01-25 17:44:13 $
* $Author: mcfly_e107 $ * $Author: mcfly_e107 $
* *
*/ */
@@ -59,20 +59,23 @@ if(isset($_GET['f']))
if($_GET['f'] != 'last') { $thread->init(); } if($_GET['f'] != 'last') { $thread->init(); }
} }
require_once (e_HANDLER . 'level_handler.php');
if (!is_object($e107->userRank)) { $e107->userRank = new e107UserRank; }
require_once (e_PLUGIN . 'forum/forum_shortcodes.php'); require_once (e_PLUGIN . 'forum/forum_shortcodes.php');
setScVar('forum_shortcodes', 'thread', $thread);
$pm_installed = plugInstalled('pm'); $pm_installed = plugInstalled('pm');
//Only increment thread views if not being viewed by thread starter //Only increment thread views if not being viewed by thread starter
if (USER && (USERID != $threadInfo['thread_user'] || $threadInfo['thread_total_replies'] > 0) || !$thread->noInc) if (USER && (USERID != $thread->threadInfo['thread_user'] || $thread->threadInfo['thread_total_replies'] > 0) || !$thread->noInc)
{ {
$forum->threadIncview($threadId); $forum->threadIncview($threadId);
} }
define('e_PAGETITLE', LAN_01 . ' / ' . $e107->tp->toHTML($thread->threadInfo['forum_name'], true, 'no_hook, emotes_off') . " / " . $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off')); define('e_PAGETITLE', LAN_01 . ' / ' . $e107->tp->toHTML($thread->threadInfo['forum_name'], true, 'no_hook, emotes_off') . " / " . $tp->toHTML($thread->threadInfo['thread_name'], true, 'no_hook, emotes_off'));
$modArray = $forum->forumGetMods($thread->threadInfo['forum_moderators']); $forum->modArray = $forum->forumGetMods($thread->threadInfo['forum_moderators']);
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray)))); define('MODERATOR', (USER && $forum->isModerator(USERID)));
setScVar('forum_shortcodes', 'forum', $forum);
if (MODERATOR && isset($_POST['mod'])) if (MODERATOR && isset($_POST['mod']))
{ {
@@ -83,7 +86,6 @@ if (MODERATOR && isset($_POST['mod']))
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage); $postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
require_once (e_HANDLER . 'level_handler.php');
$gen = new convert; $gen = new convert;
if ($thread->message) if ($thread->message)
{ {
@@ -155,7 +157,7 @@ if ($pref['forum_track'] && USER)
"; ";
} }
$MODERATORS = LAN_321 . implode(', ', $modArray); $MODERATORS = LAN_321 . implode(', ', $forum->modArray);
$THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : ''); $THREADSTATUS = (!$thread->threadInfo['thread_active'] ? LAN_66 : '');
@@ -186,7 +188,6 @@ if (!$FORUMREPLYSTYLE) $FORUMREPLYSTYLE = $FORUMTHREADSTYLE;
$alt = false; $alt = false;
$i = $thread->page; $i = $thread->page;
global $postInfo;
foreach ($postList as $postInfo) foreach ($postList as $postInfo)
{ {
if($postInfo['post_options']) if($postInfo['post_options'])
@@ -214,11 +215,13 @@ foreach ($postList as $postInfo)
{ {
$_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE); $_style = (isset($FORUMREPLYSTYLE_ALT) && $alt ? $FORUMREPLYSTYLE_ALT : $FORUMREPLYSTYLE);
} }
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$forrep .= $e107->tp->parseTemplate($_style, true, $forum_shortcodes) . "\n"; $forrep .= $e107->tp->parseTemplate($_style, true, $forum_shortcodes) . "\n";
} }
else else
{ {
$postInfo['thread_start'] = true; $postInfo['thread_start'] = true;
setScVar('forum_shortcodes', 'postInfo', $postInfo);
$forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n"; $forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
} }
} }
@@ -440,7 +443,7 @@ function rpg($user_join, $user_forums)
class e107ForumThread class e107ForumThread
{ {
var $message, $threadId, $threadInfo, $forumId, $perPage, $noInc, $pages; var $message, $threadId, $forumId, $perPage, $noInc, $pages;
function init() function init()
{ {