1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

More functionality working with new db schema

This commit is contained in:
mcfly
2008-12-10 21:00:48 +00:00
parent 43598f0e3d
commit 1cf4f67cc4
5 changed files with 258 additions and 296 deletions

View File

@@ -11,13 +11,13 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/userposts.php,v $
| $Revision: 1.7 $
| $Date: 2008-07-03 20:06:53 $
| $Author: e107steved $
| $Revision: 1.8 $
| $Date: 2008-12-10 21:00:48 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
require_once("class2.php");
require_once(e_HANDLER."comment_class.php");
require_once('class2.php');
require_once(e_HANDLER.'comment_class.php');
$cobj = new comment;
require_once(HEADERF);
@@ -27,7 +27,7 @@ $_POST['f_query'] = trim($_POST['f_query']);
$action = 'exit';
if (e_QUERY)
{
$tmp = explode(".", e_QUERY);
$tmp = explode('.', e_QUERY);
$from = intval($tmp[0]); // Always defined
$action = varset($tmp[1],'exit');
if (!isset($tmp[2])) $action = 'exit';
@@ -92,7 +92,7 @@ if ($action == "comments")
{ // Legacy decode (IPV4 address as it used to be stored - hex string)
$hexip = explode('.', chunk_split($dip, 2, '.'));
$dip = hexdec($hexip[0]). '.' . hexdec($hexip[1]) . '.' . hexdec($hexip[2]) . '.' . hexdec($hexip[3]);
}
$ccaption = UP_LAN_1.$dip;
$data = $cobj->getCommentData($amount='10', $from, "comment_ip = '".$id."'");
@@ -121,15 +121,18 @@ if ($action == "comments")
if ($action == "forums" || isset($_POST['fsearch']))
if ($action == 'forums' || isset($_POST['fsearch']))
{
require_once (e_PLUGIN.'forum/forum_class.php');
$forum = new e107forum;
$forumList = implode(',', $forum->permList['view']);
if(is_numeric($id))
{
$user_id = intval($id);
$sql->db_Select("user", "user_name", "user_id=".$id);
$row = $sql->db_Fetch();
$fcaption = UP_LAN_0." ".$row['user_name'];
$uinfo = get_user_data($id);
$fcaption = UP_LAN_0.' '.$uinfo['user_name'];
}
else
{
@@ -138,54 +141,36 @@ if ($action == "forums" || isset($_POST['fsearch']))
if (!$USERPOSTS_FORUM_TABLE)
{
if (file_exists(THEME."userposts_template.php"))
if (file_exists(THEME.'userposts_template.php'))
{
require_once(THEME."userposts_template.php");
require_once(THEME.'userposts_template.php');
}
else
{
require_once(e_BASE.$THEMES_DIRECTORY."templates/userposts_template.php");
require_once(e_BASE.$THEMES_DIRECTORY.'templates/userposts_template.php');
}
}
$s_info = "";
if (isset($_POST['f_query']) && $_POST['f_query'] != "")
$s_info = '';
if (isset($_POST['f_query']) && $_POST['f_query'] != '')
{
$f_query = $tp -> toDB($_POST['f_query']);
$s_info = "AND (ft.thread_name REGEXP('".$f_query."') OR ft.thread_thread REGEXP('".$f_query."'))";
$fcaption = UP_LAN_12." ".$row['user_name'];
$s_info = "AND (t.thread_name REGEXP('".$f_query."') OR p.post_entry REGEXP('".$f_query."'))";
$fcaption = UP_LAN_12.' '.$row['user_name'];
}
$qry = "
SELECT ft.*, f.* FROM #forum_t AS ft
LEFT JOIN #forum AS f ON ft.thread_forum_id = f.forum_id
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
WHERE SUBSTRING_INDEX(ft.thread_user,'.',1) = {$user_id}
AND f.forum_class IN (".USERCLASS_LIST.")
AND fp.forum_class IN (".USERCLASS_LIST.")
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
LEFT JOIN `#forum` AS f ON f.forum_id = p.post_forum
WHERE p.post_user = {$id}
AND p.post_forum IN ({$forumList})
{$s_info}
ORDER BY ft.thread_datestamp DESC LIMIT {$from}, 10
ORDER BY p.post_datestamp DESC LIMIT {$from}, 10
";
$total_qry = "
SELECT COUNT(*) AS count FROM #forum_t AS ft
LEFT JOIN #forum AS f ON ft.thread_forum_id = f.forum_id
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
WHERE SUBSTRING_INDEX(ft.thread_user,'.',1) = {$user_id}
AND f.forum_class IN (".USERCLASS_LIST.")
AND fp.forum_class IN (".USERCLASS_LIST.")
{$s_info}
";
$ftotal = 0;
if($sql->db_Select_gen($total_qry))
{
$row = $sql->db_Fetch();
$ftotal = $row['count'];
}
if (!$sql->db_Select_gen($qry))
{
$ftext .= "<span class='mediumtext'>".UP_LAN_8."</span>";
$ftext .= "<span class='mediumtext'>".UP_LAN_8.'</span>';
}
else
{
@@ -193,10 +178,27 @@ if ($action == "forums" || isset($_POST['fsearch']))
{
$gen = new convert;
}
$render = $sql -> db_getList();
foreach ($render as $row)
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$userposts_forum_table_string .= parse_userposts_forum_table($row);
// var_dump($row);
$datestamp = $gen->convert_date($row['post_datestamp'], 'short');
if ($row['thread_datestamp'] = $row['post_datestamp'])
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.': ';
}
else
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_12.': ';
}
$USERPOSTS_FORUM_ICON = "<img src='".e_PLUGIN."forum/images/".IMODE."/new_small.png' alt='' />";
$USERPOSTS_FORUM_TOPIC_HREF_PRE = "<a href='".$e107->url->getUrl('forum', 'thread', "func=post&id={$row['post_id']}")."'>";
$USERPOSTS_FORUM_TOPIC = $tp->toHTML($row['thread_name'], true, 'USER_BODY', $id);
$USERPOSTS_FORUM_NAME_HREF_PRE = "<a href='".$e107->url->getUrl('forum', 'forum', "func=view&id={$row['post_forum']}")."'>";
$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;
$userposts_forum_table_string .= preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE);
}
$userposts_forum_table_start = preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE_START);
$USERPOSTS_FORUM_SEARCH = "<input class='tbox' type='text' name='f_query' size='20' value='' maxlength='50' /> <input class='button' type='submit' name='fsearch' value='".UP_LAN_12."' />";
@@ -204,7 +206,7 @@ if ($action == "forums" || isset($_POST['fsearch']))
$ftext .= $userposts_forum_table_start."".$userposts_forum_table_string."".$userposts_forum_table_end;
}
$ns->tablerender($fcaption, $ftext);
$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);
@@ -213,8 +215,6 @@ if ($action == "forums" || isset($_POST['fsearch']))
require_once(FOOTERF);
function parse_userposts_comments_table($row)
{
global $USERPOSTS_COMMENTS_TABLE, $pref, $gen, $tp, $menu_pref, $id, $sql2, $comment_files;
@@ -231,50 +231,4 @@ function parse_userposts_comments_table($row)
return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_COMMENTS_TABLE));
}
function parse_userposts_forum_table($row)
{
global $USERPOSTS_FORUM_TABLE, $gen, $tp, $id;
extract($row);
$gen = new convert;
$sql2 = new db;
$poster = substr($thread_user, (strpos($thread_user, ".")+1));
$datestamp = $gen->convert_date($thread_datestamp, "short");
$DATESTAMP = $datestamp;
if ($thread_parent)
{
if ($cachevar[$thread_parent])
{
$thread_name = $cachevar[$thread_parent];
}
else
{
$sql2->db_Select("forum_t", "thread_name", "thread_id = ".intval($thread_parent));
list($thread_name) = $sql2->db_Fetch();
$cachevar[$thread_parent] = $thread_name;
}
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_15.": ";
}
else
{
$USERPOSTS_FORUM_TOPIC_PRE = UP_LAN_2.": ";
}
$tmp = $thread_id;
$thread_thread = $tp->toHTML($thread_thread, TRUE, "USER_BODY", $id);
$USERPOSTS_FORUM_ICON = "<img src='".e_PLUGIN."forum/images/".IMODE."/new_small.png' alt='' />";
$USERPOSTS_FORUM_TOPIC_HREF_PRE = "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$tmp.".post'>";
$USERPOSTS_FORUM_TOPIC = $thread_name;
$USERPOSTS_FORUM_NAME_HREF_PRE = "<a href='".e_PLUGIN."forum/forum_viewforum.php?".$forum_id."'>";
$USERPOSTS_FORUM_NAME = $forum_name;
$USERPOSTS_FORUM_THREAD = $thread_thread;
$USERPOSTS_FORUM_DATESTAMP = UP_LAN_11." ".$datestamp;
return(preg_replace("/\{(.*?)\}/e", '$\1', $USERPOSTS_FORUM_TABLE));
}
?>
?>