From becc2ebf680d7dbf74ac364a148428889c608488 Mon Sep 17 00:00:00 2001 From: rica-carv Date: Tue, 6 Dec 2016 18:02:14 +0000 Subject: [PATCH] Add files via upload --- .../shortcodes/batch/forum_shortcodes.php | 301 ++++-------------- 1 file changed, 69 insertions(+), 232 deletions(-) diff --git a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php index 1c2499f6e..2b6d8aa4d 100644 --- a/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php +++ b/e107_plugins/forum/shortcodes/batch/forum_shortcodes.php @@ -128,6 +128,7 @@ class forum_shortcodes extends e_shortcode // To be reworked to get the $forum var $trackPref = $forum->prefs->get('track'); +//var_dump($forum->checkPerm($this->var['forum_id'], 'post')); if(!empty($trackPref) && $forum->checkPerm($this->var['forum_id'], 'post')) { $uInfo[2] = "".LAN_FORUM_0030.""; @@ -347,7 +348,7 @@ class forum_shortcodes extends e_shortcode if(USER && is_array($this->newFlagList) && in_array($this->var['forum_id'], $this->newFlagList)) { - $url = $this->lastpostdata('url'); + $url = $this->sc_lastpost('url'); return "".IMAGE_new.''; } elseif(empty($this->var['forum_replies']) && defined('IMAGE_noreplies')) @@ -402,7 +403,8 @@ class forum_shortcodes extends e_shortcode { // global $f; // return "".$f['forum_threads'].""; - return "".$this->var['forum_threads'].""; +// EQUAL TO SC_THREADS....................... + return $this->var['forum_threads']; } @@ -410,7 +412,8 @@ class forum_shortcodes extends e_shortcode { // global $f; // return "".$f['forum_replies'].""; - return "".$this->var['forum_replies'].""; +// EQUAL TO SC_REPLIES....................... + return $this->var['forum_replies']; } @@ -419,246 +422,21 @@ class forum_shortcodes extends e_shortcode return (!empty($this->var['text'])) ? "
".LAN_FORUM_0069.": {$this->var['text']}
":""; } -//----- ######################################################## -//----- Functions sc_latspostuser, sc_lastpostdate & sc_lastpost to be rewritten, since they pratically use the same code??? -//----- Also, viewforum_shortcodes uses similar shortcodes definitions...... -/*----- function sc_lastpostuser() { -// global $f; -// $e107 = e107::getInstance(); -// $tp = e107::getParser(); - -// if ($f['forum_lastpost_info']) - if ($this->var['forum_lastpost_info']) - { -// list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']); -// $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); - -// if ($f['user_name']) - $lastpost_name = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']); - - if ($this->var['user_name']) - { - -// $lastpost_name = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; - $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; - } -//---- else -//---- { -//---- $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); -//---- } - -// $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here. - - return $lastpost_name; - // {forum_sef}/{thread_id}-{thread_sef} - -// $urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); -// $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; -// $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; -// $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); -// $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - - } -//---- else -//---- { - return ""; -// $fVars->LASTPOSTDATE = "-"; -// $fVars->LASTPOST = '-'; -//---- } -} - function sc_lastpostdate() - { -// global $f, $forum; - global $forum; -// $e107 = e107::getInstance(); -// $tp = e107::getParser(); -$gen = new convert; - -// if ($f['forum_lastpost_info']) - if ($this->var['forum_lastpost_info']) - { -// list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']); - list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); -// if ($f['user_name']) -// { - -// $lastpost_name = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; -// } -// else -// { -// $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); -// } - - $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here. - -// $fVars->LASTPOSTUSER = $lastpost_name; - // {forum_sef}/{thread_id}-{thread_sef} - -// $urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); - $urlData = array('forum_sef'=>$this->var['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); - $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; - return "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; -// $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); -// $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - - } -//---- else -//---- { -// $fVars->LASTPOSTUSER = ""; - return "-"; -// $fVars->LASTPOST = '-'; -//---- } -} - function sc_lastpost() - { - - $e107 = e107::getInstance(); - $gen = new convert; - - // if ($f['forum_lastpost_info']) - if ($this->var['forum_lastpost_info']) - { - // list($lastpost_datestamp, $lastpost_thread) = explode('.', $f['forum_lastpost_info']); - list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); - // $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); - // $lastpost_name = e107::getParser()->toHTML($f['forum_lastpost_user_anon']); - // if ($f['user_name']) - $lastpost_name = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']); - - if ($this->var['user_name']) - { - // $lastpost_name = " $f['user_name'], 'id' => $f['forum_lastpost_user']))."'>{$f['user_name']}"; - $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; - } - //---- else - //---- { - //---- $lastpost_name = $tp->toHTML($f['forum_lastpost_user_anon']); - //---- } - - // $lastpost = $forum->threadGetLastpost($lastpost_thread); //XXX TODO inefficient to have SQL query here. - - // $fVars->LASTPOSTUSER = $lastpost_name; - // {forum_sef}/{thread_id}-{thread_sef} - - // $urlData = array('forum_sef'=>$f['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); - // $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; - // $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; - $lastpost_datestamp = $gen->convert_date($lastpost_datestamp, 'forum'); - return $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - - } - //---- else - //---- { - // $fVars->LASTPOSTUSER = ""; - // $fVars->LASTPOSTDATE = "-"; - return '-'; - //---- } - } ------*/ - - function lastpostdata($mode='') - { - - if (empty($this->var['forum_lastpost_info'])) - { - return false; - } - - global $forum; - - list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); - - // e107::getDebug()->log($this->var); - - - $lastpost = $forum->threadGetLastpost($lastpost_thread); //FIXME TODO inefficient to have SQL query here. - $urlData = array('forum_sef'=>$this->var['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); - $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; - - if (!empty($this->var['user_name'])) - { - $lastpost_name = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; - } - else - { - $lastpost_name = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']); - } - - $relativeDate = e107::getParser()->toDate($lastpost_datestamp,'relative'); - - switch($mode) - { - // $fVars->LASTPOSTUSER = $lastpost_name; - case "user": - return $lastpost_name; - break; - - // $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; - case "date": - return "". $relativeDate.""; - break; - - case "url": - return $url; - break; - - // $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - case 'post': - - return $relativeDate.'
'.$lastpost_name." ".IMAGE_post2.''; - - // code to be executed if n is different from all labels; - } - - - return false; - - // return $lastpost_datestamp; - /*-- - - --*/ - - - // $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - - /*---- - $fVars->LASTPOSTUSER = $lastpost_name; - $fVars->LASTPOSTDATE .= "". $gen->computeLapse($lastpost_datestamp, time(), false, false, 'short').""; - $fVars->LASTPOST = $lastpost_datestamp.'
'.$lastpost_name." $lastpost_name, 'id' => $lastpost_thread))."'>".IMAGE_post2.''; - -----*/ - - - - - - /*---- - else - { - $fVars->LASTPOSTUSER = ""; - $fVars->LASTPOSTDATE = "-"; - $fVars->LASTPOST = '-'; - } - ----*/ - - } - - - function sc_lastpostuser() - { - return $this->lastpostdata('user'); + return $this->sc_lastpost('username'); } function sc_lastpostdate() { - return $this->lastpostdata('date'); + return $this->sc_lastpost('datelink'); } function sc_lastpost($parm = null) { +/* if(!empty($parm['type'])) { switch($parm['type']) @@ -687,9 +465,68 @@ $gen = new convert; } return $this->lastpostdata('post'); - } +*/ + if (empty($this->var['forum_lastpost_info'])) + { + return false; + } + + global $forum; + + list($lastpost_datestamp, $lastpost_thread) = explode('.', $this->var['forum_lastpost_info']); + + // e107::getDebug()->log($this->var); + + + $lastpost = $forum->threadGetLastpost($lastpost_thread); //FIXME TODO inefficient to have SQL query here. + $urlData = array('forum_sef'=>$this->var['forum_sef'], 'thread_id'=>$lastpost['post_thread'],'thread_sef'=>$lastpost['thread_sef']); + $url = e107::url('forum', 'topic', $urlData)."?last=1#post-".$lastpost['post_id']; + + if (!empty($this->var['user_name'])) + { + $lastpost_username = " $this->var['user_name'], 'id' => $this->var['forum_lastpost_user']))."'>{$this->var['user_name']}"; + } + else + { + $lastpost_username = e107::getParser()->toHTML($this->var['forum_lastpost_user_anon']); + } + + $relativeDate = e107::getParser()->toDate($lastpost_datestamp,'relative'); + + if(!empty($parm['type'])) + { + switch($parm['type']) +// switch($mode) + { + case "username": + return $lastpost_username; +// break; + + case "datelink": + return "". $relativeDate.""; +// break; + case "date": + return $relativeDate; + + case "url": + return $url; +// break; + case "name": + return $lastpost['thread_name']; +// default: + +// return $relativeDate.'
'.$lastpost_name." ".IMAGE_post2.''; + + // code to be executed if n is different from all labels; + } + } + return $relativeDate.'
'.$lastpost_username." ".IMAGE_post2.''; +// return false; + + } + function sc_startertitle() {