mirror of
https://github.com/e107inc/e107.git
synced 2025-07-30 19:30:25 +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:
@@ -1,34 +1,21 @@
|
||||
<?php
|
||||
if (!defined('e107_INIT')) { exit; }
|
||||
|
||||
/*
|
||||
$codes = array(
|
||||
'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);
|
||||
register_shortcode('forum_shortcodes', true);
|
||||
initShortcodeClass('forum_shortcodes');
|
||||
|
||||
class forum_shortcodes
|
||||
{
|
||||
|
||||
var $e107;
|
||||
var $postInfo;
|
||||
var $thread;
|
||||
var $forum;
|
||||
|
||||
function forum_shortcodes()
|
||||
{
|
||||
$this->e107 = e107::getInstance();
|
||||
$this->postInfo = array();
|
||||
}
|
||||
|
||||
function get_top()
|
||||
@@ -38,32 +25,30 @@ class forum_shortcodes
|
||||
|
||||
function get_joined()
|
||||
{
|
||||
global $postInfo, $gen;
|
||||
if ($postInfo['post_user'])
|
||||
global $gen;
|
||||
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()
|
||||
{
|
||||
global $postInfo, $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');
|
||||
global $gen;
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
$emote = (isset($postInfo['post_options']['no_emote']) ? ',emotes_off' : '');
|
||||
return $this->e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY'.$emote, 'class:'.$post_info['user_class']);
|
||||
$emote = (isset($this->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']);
|
||||
}
|
||||
|
||||
function get_postdeleted()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['post_status'])
|
||||
if($this->postInfo['post_status'])
|
||||
{
|
||||
$info = unserialize($postInfo['post_options']);
|
||||
$info = unserialize($this->postInfo['post_options']);
|
||||
return "
|
||||
Post delete on: {$info['deldate']}<br />
|
||||
reason: {$info['delreason']}
|
||||
@@ -74,10 +59,9 @@ class forum_shortcodes
|
||||
|
||||
function get_attachments()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['post_attachments'])
|
||||
if($this->postInfo['post_attachments'])
|
||||
{
|
||||
$attachments = explode(',', $postInfo['post_attachments']);
|
||||
$attachments = explode(',', $this->postInfo['post_attachments']);
|
||||
$txt = '';
|
||||
foreach($attachments as $a)
|
||||
{
|
||||
@@ -107,30 +91,28 @@ class forum_shortcodes
|
||||
|
||||
function get_privmessage()
|
||||
{
|
||||
global $postInfo;
|
||||
if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
|
||||
if(plugInstalled('pm') && ($this->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()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['post_user'])
|
||||
if ($this->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');
|
||||
$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
|
||||
{
|
||||
$avatar = '';
|
||||
}
|
||||
cachevars('forum_avatar_'.$postInfo['post_user'], $avatar);
|
||||
cachevars('forum_avatar_'.$this->postInfo['post_user'], $avatar);
|
||||
}
|
||||
return $avatar;
|
||||
}
|
||||
@@ -140,43 +122,39 @@ class forum_shortcodes
|
||||
|
||||
function get_anon_ip()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['post_user_anon'] && (ADMIN || MODERATOR))
|
||||
if($this->postInfo['post_user_anon'] && (ADMIN || MODERATOR))
|
||||
{
|
||||
return $this->e107->ipDecode($postInfo['post_ip']);
|
||||
return $this->e107->ipDecode($this->postInfo['post_ip']);
|
||||
}
|
||||
}
|
||||
|
||||
function get_ip()
|
||||
{
|
||||
global $postInfo;
|
||||
if((ADMIN || MODERATOR) && !$postInfo['user_admin'])
|
||||
if((ADMIN || MODERATOR) && !$this->postInfo['user_admin'])
|
||||
{
|
||||
return $this->e107->ipDecode($postInfo['post_ip']);
|
||||
return $this->e107->ipDecode($this->postInfo['post_ip']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function get_poster()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['user_name'])
|
||||
if($this->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
|
||||
{
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['user_name'])
|
||||
if($this->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 '';
|
||||
|
||||
@@ -184,168 +162,145 @@ class forum_shortcodes
|
||||
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
if($postInfo['thread_start'])
|
||||
if($this->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()
|
||||
{
|
||||
if(!USER) { return ''; }
|
||||
global $postInfo, $pref;
|
||||
global $pref;
|
||||
static $forum_sig_shown;
|
||||
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 ''; }
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
if (USER && $postInfo['user_name'])
|
||||
if (USER && $this->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()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['post_user'])
|
||||
if ($this->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()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['user_name'])
|
||||
if ($this->postInfo['user_name'])
|
||||
{
|
||||
return LAN_09.': '.$postInfo['user_visits'].'<br />';
|
||||
return LAN_09.': '.$this->postInfo['user_visits'].'<br />';
|
||||
}
|
||||
}
|
||||
|
||||
function get_customtitle()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['user_customtitle'])
|
||||
if ($this->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()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['user_homepage']) {
|
||||
return LAN_08.': '.$postInfo['user_homepage'].'<br />';
|
||||
if ($this->postInfo['user_homepage']) {
|
||||
return LAN_08.': '.$this->postInfo['user_homepage'].'<br />';
|
||||
}
|
||||
}
|
||||
|
||||
function get_websiteimg()
|
||||
{
|
||||
global $postInfo;
|
||||
if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://')
|
||||
if ($this->postInfo['user_homepage'] && $this->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()
|
||||
{
|
||||
global $postInfo, $threadInfo;
|
||||
if (USER && $postInfo['post_user'] == USERID && $threadInfo['thread_active'])
|
||||
if (USER && $this->postInfo['post_user'] == USERID && $this->thread->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()
|
||||
{
|
||||
global $postInfo, $forum;
|
||||
if($forum->checkperm($postInfo['post_forum'], 'post'))
|
||||
if($this->forum->checkperm($this->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()
|
||||
{
|
||||
global $postInfo, $page;
|
||||
global $page;
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']);
|
||||
return rpg($this->postInfo['user_join'], $this->postInfo['user_plugin_forum_posts']);
|
||||
}
|
||||
|
||||
function get_memberid()
|
||||
{
|
||||
global $post_info, $ldata, $pref, $forum_info;
|
||||
if ($post_info['anon']) { 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);
|
||||
}
|
||||
return $ldata[$post_info['user_id']][0];
|
||||
|
||||
if (!$this->postInfo['post_user']) { return FALSE; }
|
||||
return "<span class='smalltext'>".LAN_195.' #'.$this->postInfo['post_user'].'</span>';
|
||||
}
|
||||
|
||||
function get_level()
|
||||
function get_level($parm)
|
||||
{
|
||||
global $post_info, $ldata, $pref, $forum_info;
|
||||
if ($post_info['anon']) { 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];
|
||||
global $pref;
|
||||
if (!$this->postInfo['post_user']) { return ''; }
|
||||
|
||||
$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()
|
||||
@@ -358,25 +313,24 @@ class forum_shortcodes
|
||||
|
||||
function get_lastedit()
|
||||
{
|
||||
global $postInfo, $gen;
|
||||
if ($postInfo['post_edit_datestamp'])
|
||||
global $gen;
|
||||
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()
|
||||
{
|
||||
global $postInfo;
|
||||
if(isset($postInfo['edit_name']))
|
||||
if(isset($this->postInfo['edit_name']))
|
||||
{
|
||||
if($parm == 'link')
|
||||
{
|
||||
$e107 = e107::getInstance();
|
||||
$url = $e107->url->getUrl('core:user', 'main', 'func=profile&id='.$postInfo['post_edit_user']);
|
||||
return "<a href='{$url}'>{$postInfo['edit_name']}</a>";
|
||||
$url = $e107->url->getUrl('core:user', 'main', 'func=profile&id='.$this->postInfo['post_edit_user']);
|
||||
return "<a href='{$url}'>{$this->postInfo['edit_name']}</a>";
|
||||
}
|
||||
return $postInfo['edit_name'];
|
||||
return $this->postInfo['edit_name'];
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user