diff --git a/e107_themes/templates/userposts_template.php b/e107_themes/templates/userposts_template.php
index 64654e3c9..a3d853fb5 100644
--- a/e107_themes/templates/userposts_template.php
+++ b/e107_themes/templates/userposts_template.php
@@ -2,95 +2,100 @@
/*
* e107 website system
*
- * Copyright (C) 2008-2009 e107 Inc (e107.org)
+ * Copyright (C) 2008-2011 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
+ * User posts page template
*
- *
- * $Source: /cvs_backup/e107_0.8/e107_themes/templates/userposts_template.php,v $
- * $Revision$
- * $Date$
- * $Author$
+ * $URL$
+ * $Id$
*/
if (!defined('e107_INIT')) { exit; }
+
if (!defined("USER_WIDTH")){ define("USER_WIDTH", "width:95%"); }
-if(!isset($USERPOSTS_NP_TABLE))
-{
- $USERPOSTS_NP_TABLE = "
{USERPOSTS_NEXTPREV}
";
-}
+$USERPOSTS_TEMPLATE['np_table'] = "{USERPOSTS_NEXTPREV}
";
+$USERPOSTS_NP_TABLE = $USERPOSTS_TEMPLATE['np_table']; // BC, will be removed
+
+// $USERPOSTS_NP_TABLE = "{USERPOSTS_NEXTPREV}
";
// ##### USERPOSTS_COMMENTS TABLE -----------------------------------------------------------------
-if(!isset($USERPOSTS_COMMENTS_TABLE_START))
-{
- $USERPOSTS_COMMENTS_TABLE_START = "
-
-
\n";
-}
-if(!isset($USERPOSTS_COMMENTS_TABLE))
-{
- $USERPOSTS_COMMENTS_TABLE = "
-
-
- {USERPOSTS_COMMENTS_HREF_PRE}{USERPOSTS_COMMENTS_HEADING}
- {USERPOSTS_COMMENTS_DATESTAMP} ({USERPOSTS_COMMENTS_TYPE})
- |
-
-
-
-
+ $USERPOSTS_TEMPLATE['comments_table_start'] = "
+
+ {NEXTPREV}
";
-}
+ $USERPOSTS_COMMENTS_TABLE_END = $USERPOSTS_TEMPLATE['comments_table'];
+
+ $USERPOSTS_TEMPLATE['comments_table_empty'] = "
+
+
+
+ ";
+
// ##### ------------------------------------------------------------------------------------------
// ##### USERPOSTS FORUM TABLE --------------------------------------------------------------------
-if(!isset($USERPOSTS_FORUM_TABLE_START))
-{
- $USERPOSTS_FORUM_TABLE_START = "
+ // additional shortcodes available:
+ // {USERPOSTS_FORUM_SEARCH_FIELD}, {USERPOSTS_FORUM_SEARCH_BUTTON}
+ $USERPOSTS_TEMPLATE['forum_table_start'] = "
+ ";
+ $USERPOSTS_FORUM_TABLE_END = $USERPOSTS_TEMPLATE['forum_table_end']; // BC, will be removed
diff --git a/userposts.php b/userposts.php
index f85bb951a..04b520cba 100644
--- a/userposts.php
+++ b/userposts.php
@@ -1,31 +1,32 @@
db_Select("user", "user_name", "user_id=".$id);
- $row = $sql->db_Fetch();
- $user_name = $row['user_name'];
- $user_id = $id.".".$user_name."";
- }
- else
- {
- $user_name = UP_LAN_16.$id;
- }
+ //$sql->db_Select("user", "user_name", "user_id=".$id);
+ //$row = $sql->db_Fetch();
+ if($id == e107::getUser()->getId())
+ {
+ $user_name = USERNAME;
+ }
+ else
+ {
+ $user_name = e107::getSystemUser($id, false)->getName(LAN_ANONYMOUS);
+ }
- if (!$USERPOSTS_COMMENTS_TABLE)
+ /*if (!isset($USERPOSTS_TEMPLATE))
{
if (file_exists(THEME."userposts_template.php"))
{
@@ -68,23 +71,28 @@ if ($action == "comments")
}
else
{
- require_once(e_BASE.$THEMES_DIRECTORY."templates/userposts_template.php");
+ require_once(e_THEME."templates/userposts_template.php");
}
- }
+ }*/
+ // new template engine - override in THEME/templates/userposts_template.php
+ $USERPOSTS_TEMPLATE = e107::getCoreTemplate('userposts');
- $sql2 = new db;
- if(is_numeric($id))
+ $sql2 = e107::getDb('sql2');
+ if($user_name)
{
$ccaption = UP_LAN_1.$user_name;
- $sql->db_Select("user", "user_comments", "user_id=".$id);
+ /*$sql->db_Select("user", "user_comments", "user_id=".$id);
$row = $sql->db_Fetch();
- $ctotal = $row['user_comments'];
- $data = $cobj->getCommentData($amount='10', $from, "comment_author = '".$user_id."'");
+ $ctotal = $row['user_comments'];*/
+ $ctotal = e107::getSystemUser($id, false)->getValue('comments', 0); // user_* getter shorthand
+ $data = $cobj->getCommentData(10, $from, 'comment_author_id ='.$id);
}
- else
+ else // posts by IP currently disabled (see Query filtering - top of the page)
{
- $dip = $id;
+ header("Location:".SITEURL."index.php");
+ exit;
+ /*$dip = $id;
if (strlen($dip) == 8)
{ // Legacy decode (IPV4 address as it used to be stored - hex string)
$hexip = explode('.', chunk_split($dip, 2, '.'));
@@ -93,40 +101,52 @@ if ($action == "comments")
}
$ccaption = UP_LAN_1.$dip;
$data = $cobj->getCommentData($amount='10', $from, "comment_ip = '".$id."'");
+ $data = $cobj->getCommentData(10, $from, 'comment_ip ='.$tp->toDB($user_ip));*/
}
- if(empty($data) || !is_array($data)){
+ $ctext = '';
+ if(empty($data) || !is_array($data))
+ {
$ctext = "".UP_LAN_7."";
}
- global $row;
- foreach($data as $row){
- $userposts_comments_table_string .= parse_userposts_comments_table($row, $USERPOSTS_COMMENTS_TABLE);
+ else
+ {
+ $userposts_comments_table_string = '';
+ foreach($data as $row)
+ {
+ $userposts_comments_table_string .= parse_userposts_comments_table($row, $USERPOSTS_TEMPLATE['comments_table']);
+ }
+
+ $parms = $ctotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].comments.".$id;
+ $nextprev = $ctotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';
+ if($nextprev) $nextprev = str_replace('{USERPOSTS_NEXTPREV}', $nextprev, $USERPOSTS_TEMPLATE['np_table']);
+ $vars = new e_vars(array(
+ 'NEXTPREV' => $nextprev
+ ));
+
+ // preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_TEMPLATE['comments_table_start']);
+ $userposts_comments_table_start = $tp->simpleParse($USERPOSTS_TEMPLATE['comments_table_start'], $vars);
+ // preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_TEMPLATE['comments_table_end'])
+ $userposts_comments_table_end = $tp->simpleParse($USERPOSTS_TEMPLATE['comments_table_end'], $vars);
+
+ $ctext .= $userposts_comments_table_start.$userposts_comments_table_string.$userposts_comments_table_end;
+
}
-
- $userposts_comments_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE_START);
- $userposts_comments_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE_END);
-
- $ctext .= $userposts_comments_table_start."".$userposts_comments_table_string."".$userposts_comments_table_end;
-
$ns->tablerender($ccaption, $ctext);
-
- $parms = $ctotal.",10,".$from.",".e_SELF."?[FROM].comments.".$id;
- $USERPOSTS_NEXTPREV = $tp->parseTemplate("{NEXTPREV={$parms}}");
- echo preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_NP_TABLE);
}
-if ($action == 'forums' || isset($_POST['fsearch']))
+elseif ($action == 'forums')
{
require_once (e_PLUGIN.'forum/forum_class.php');
- $forum = new e107forum;
+ $forum = new e107forum();
- $forumList = implode(',', $forum->permList['view']);
+ $forumList = implode(',', $forum->getForumPermList('view'));
- if(is_numeric($id))
+ /*if(is_numeric($id))
{
$uinfo = get_user_data($id);
$fcaption = UP_LAN_0.' '.$uinfo['user_name'];
@@ -134,8 +154,24 @@ if ($action == 'forums' || isset($_POST['fsearch']))
else
{
$user_name = 0;
+ }*/
+ if($id == e107::getUser()->getId())
+ {
+ $user_name = USERNAME;
+ }
+ else
+ {
+ $user_name = e107::getSystemUser($id, false)->getName(LAN_ANONYMOUS);
}
+ if(!$user_name)
+ {
+ header("Location:".SITEURL);
+ exit;
+ }
+
+ $fcaption = UP_LAN_0.' '.$user_name;
+/*
if (!$USERPOSTS_FORUM_TABLE)
{
if (file_exists(THEME.'userposts_template.php'))
@@ -146,15 +182,19 @@ if ($action == 'forums' || isset($_POST['fsearch']))
{
require_once(e_BASE.$THEMES_DIRECTORY.'templates/userposts_template.php');
}
- }
+ }*/
+ // new template engine - override in THEME/templates/userposts_template.php
+ $USERPOSTS_TEMPLATE = e107::getCoreTemplate('userposts');
$s_info = '';
- if (isset($_POST['f_query']) && $_POST['f_query'] != '')
+ $_POST['f_query'] = trim(varset($_POST['f_query']));
+ if ($_POST['f_query'] !== '')
{
- $f_query = $tp -> toDB($_POST['f_query']);
+ $f_query = $tp->toDB($_POST['f_query']);
$s_info = "AND (t.thread_name REGEXP('".$f_query."') OR p.post_entry REGEXP('".$f_query."'))";
- $fcaption = UP_LAN_12.' '.$row['user_name'];
+ $fcaption = UP_LAN_12.' '.$user_name;
}
+
$qry = "
SELECT SQL_CALC_FOUND_ROWS p.*, t.*, f.* FROM `#forum_post` AS p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
@@ -171,70 +211,96 @@ if ($action == 'forums' || isset($_POST['fsearch']))
}
else
{
- if (!is_object($gen))
+ $gen = e107::getDateConvert();
+ $vars = new e_vars();
+
+ $userposts_forum_table_string = '';
+ while(true)
{
- $gen = new convert;
- }
- while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
- {
-// var_dump($row);
+ $row = $sql->db_Fetch(MYSQL_ASSOC);
+ if(empty($row)) break;
+
$datestamp = $gen->convert_date($row['post_datestamp'], 'short');
- if ($row['thread_datestamp'] = $row['post_datestamp'])
+ if ($row['thread_datestamp'] == $row['post_datestamp'])
{
- $USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.': ';
+ $vars->USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.': ';
}
else
{
- $USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_12.': ';
+ $vars->USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_15.': ';
}
- $USERPOSTS_FORUM_ICON = "
";
- $USERPOSTS_FORUM_TOPIC_HREF_PRE = "";
- $USERPOSTS_FORUM_TOPIC = $tp->toHTML($row['thread_name'], true, 'USER_BODY', $id);
- $USERPOSTS_FORUM_NAME_HREF_PRE = "";
- $USERPOSTS_FORUM_NAME = $tp->toHTML($row['forum_name'], true, 'USER_BODY', $id);
- $USERPOSTS_FORUM_THREAD = $tp->toHTML($row['post_entry'], true, 'USER_BODY', $id);
- $USERPOSTS_FORUM_DATESTAMP = UP_LAN_11." ".$datestamp;
+ $vars->USERPOSTS_FORUM_ICON = "
";
+ $vars->USERPOSTS_FORUM_TOPIC_HREF_PRE = "";
+ $vars->USERPOSTS_FORUM_TOPIC = $tp->toHTML($row['thread_name'], true, 'USER_BODY', $id);
+ $vars->USERPOSTS_FORUM_NAME_HREF_PRE = "";
+ $vars->USERPOSTS_FORUM_NAME = $tp->toHTML($row['forum_name'], true, 'USER_BODY', $id);
+ $vars->USERPOSTS_FORUM_THREAD = $tp->toHTML($row['post_entry'], true, 'USER_BODY', $id);
+ $vars->USERPOSTS_FORUM_DATESTAMP = UP_LAN_11." ".$datestamp;
- $userposts_forum_table_string .= preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE);
+ //$userposts_forum_table_string .= preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE);
+ $userposts_forum_table_string .= $tp->simpleParse($USERPOSTS_TEMPLATE['forum_table'], $vars);
}
- $userposts_forum_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_START);
- $USERPOSTS_FORUM_SEARCH = " ";
- $userposts_forum_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_END);
- $ftext .= $userposts_forum_table_start."".$userposts_forum_table_string."".$userposts_forum_table_end;
+
+ $vars->emptyVars();
+
+ $ftotal = $sql->total_results;
+ $parms = $ftotal.",10,".$from.",".e_REQUEST_SELF."?[FROM].forums.".$id;
+ $vars->NEXTPREV = $ftotal ? $tp->parseTemplate("{NEXTPREV={$parms}}") : '';
+ if($vars->NEXTPREV) $vars->NEXTPREV = str_replace('{USERPOSTS_NEXTPREV}', $vars->NEXTPREV, $USERPOSTS_TEMPLATE['np_table']);
+ $vars->USERPOSTS_FORUM_SEARCH_VALUE = htmlspecialchars($_POST['f_query'], ENT_QUOTES, CHARSET);
+ $vars->USERPOSTS_FORUM_SEARCH_FIELD = "";
+ $vars->USERPOSTS_FORUM_SEARCH_BUTTON = "";
+ $vars->USERPOSTS_FORUM_SEARCH = " ";
+
+ // $userposts_forum_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_START);
+ $userposts_forum_table_start = $tp->simpleParse($USERPOSTS_TEMPLATE['forum_table_start'], $vars);
+ //$userposts_forum_table_end = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_END);
+ $userposts_forum_table_end = $tp->simpleParse($USERPOSTS_TEMPLATE['forum_table_end'], $vars);
+
+ $ftext = $userposts_forum_table_start.$userposts_forum_table_string.$userposts_forum_table_end;
}
+
$ns->tablerender($fcaption, $ftext);
- $ftotal = $e107->sql->total_results;
+ /*$ftotal = $e107->sql->total_results;
$parms = $ftotal.",10,".$from.",".e_SELF."?[FROM].forums.".$id;
$USERPOSTS_NEXTPREV = $tp->parseTemplate("{NEXTPREV={$parms}}");
- echo preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_NP_TABLE);
+ echo preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_NP_TABLE);*/
+}
+else
+{
+ header("Location: ".SITEURL);
+ exit;
}
require_once(FOOTERF);
-function parse_userposts_comments_table($row, $USERPOSTS_COMMENTS_TABLE)
+function parse_userposts_comments_table($row, $template)
{
// global $USERPOSTS_COMMENTS_TABLE, $pref, $gen, $tp, $id, $sql2, $comment_files;
- $gen = new convert;
+ $gen = e107::getDateConvert();
$datestamp = $gen->convert_date($row['comment_datestamp'], "short");
$bullet = '';
if(defined('BULLET'))
{
- $bullet = '
';
+ $bullet = '
';
}
elseif(file_exists(THEME.'images/bullet2.gif'))
{
- $bullet = '
';
+ $bullet = '
';
}
- $USERPOSTS_COMMENTS_ICON = $bullet;
- $USERPOSTS_COMMENTS_DATESTAMP = UP_LAN_11." ".$datestamp;
- $USERPOSTS_COMMENTS_HEADING = $row['comment_title'];
- $USERPOSTS_COMMENTS_COMMENT = $row['comment_comment'];
- $USERPOSTS_COMMENTS_HREF_PRE = "";
- $USERPOSTS_COMMENTS_TYPE = $row['comment_type'];
+ $vars = new e_vars();
- return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE));
+ $vars->USERPOSTS_COMMENTS_ICON = $bullet;
+ $vars->USERPOSTS_COMMENTS_DATESTAMP = UP_LAN_11." ".$datestamp;
+ $vars->USERPOSTS_COMMENTS_HEADING = $row['comment_title'];
+ $vars->USERPOSTS_COMMENTS_COMMENT = $row['comment_comment'];
+ $vars->USERPOSTS_COMMENTS_HREF_PRE = "";
+ $vars->USERPOSTS_COMMENTS_TYPE = $row['comment_type'];
+
+ //return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE));
+ return e107::getParser()->simpleParse($template, $vars);
}
?>
\ No newline at end of file