1
0
mirror of https://github.com/e107inc/e107.git synced 2025-05-03 10:49:12 +02:00

Forum work

This commit is contained in:
mcfly 2008-12-07 00:21:21 +00:00
parent 3641d9501e
commit 497f433bbf
6 changed files with 143 additions and 90 deletions

View File

@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/mysql_class.php,v $
| $Revision: 1.31 $
| $Date: 2008-11-29 18:47:39 $
| $Revision: 1.32 $
| $Date: 2008-12-07 00:21:20 $
| $Author: mcfly_e107 $
|
+----------------------------------------------------------------------------+
@ -30,7 +30,7 @@ $db_ConnectionID = NULL; // Stores ID for the first DB connection used - which s
* MySQL Abstraction class
*
* @package e107
* @version $Revision: 1.31 $
* @version $Revision: 1.32 $
* @author $Author: mcfly_e107 $
*/
class db {
@ -445,6 +445,10 @@ class db {
return "'{$fieldValue}'";
break;
case 'escape':
return "'".mysql_real_escape_string($fieldValue)."'";
break;
case 'todb':
default:
if($fieldValue == '') { return "''"; }

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.18 $
| $Date: 2008-12-05 20:28:05 $
| $Revision: 1.19 $
| $Date: 2008-12-07 00:21:21 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -31,16 +31,18 @@ class e107forum
$this->fieldTypes['forum_post']['post_forum'] = 'int';
$this->fieldTypes['forum_post']['post_datestamp'] = 'int';
$this->fieldTypes['forum_post']['post_thread'] = 'int';
$this->fieldTypes['forum_post']['post_options'] = 'escape';
$this->fieldTypes['forum_thread']['thread_user'] = 'int';
$this->fieldTypes['forum_thread']['thread_lastpost'] = 'int';
$this->fieldTypes['forum_thread']['thread_lastuser'] = 'int';
$this->fieldTypes['forum_thread']['thread_s'] = 'int';
$this->fieldTypes['forum_thread']['thread_forum_id'] = 'int';
$this->fieldTypes['forum_thread']['thread_active'] = 'int';
$this->fieldTypes['forum_thread']['thread_datestamp'] = 'int';
$this->fieldTypes['forum_thread']['thread_active'] = 'int';
$this->fieldTypes['forum_thread']['thread_datestamp'] = 'int';
$this->fieldTypes['forum_thread']['thread_views'] = 'int';
$this->fieldTypes['forum_thread']['thread_replies'] = 'int';
$this->fieldTypes['forum_thread']['thread_options'] = 'escape';
$this->fieldTypes['forum']['forum_lastpost_user'] = 'int';
@ -67,7 +69,6 @@ class e107forum
function getForumPermList()
{
global $e107;
$this->permList = array();
@ -253,6 +254,7 @@ class e107forum
function threadGet($id, $joinForum = true, $uid = USERID)
{
global $pref;
$e107 = e107::getInstance();
$id = (int)$id;
$uid = (int)$uid;
@ -281,7 +283,7 @@ class e107forum
{
if(trim($tmp['thread_options']) != '')
{
$tmp['thread_options'] = inserialize($tmp['thread_options']);
$tmp['thread_options'] = unserialize($tmp['thread_options']);
}
return $tmp;
}

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_post.php,v $
| $Revision: 1.23 $
| $Date: 2008-12-05 20:28:05 $
| $Revision: 1.24 $
| $Date: 2008-12-07 00:21:21 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -22,6 +22,9 @@ $e_wysiwyg = 'post';
$lan_file = e_PLUGIN.'forum/languages/'.e_LANGUAGE.'/lan_forum_post.php';
include(file_exists($lan_file) ? $lan_file : e_PLUGIN.'forum/languages/English/lan_forum_post.php');
//var_dump($_POST);
//exit;
if (isset($_POST['fjsubmit']))
{
header('location:'.$e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id'=>$_POST['forumjump'])));
@ -162,11 +165,11 @@ if (isset($_POST['fpreview']))
$tsubject = $tp->post_toHTML($_POST['subject'], true);
$tpost = $tp->post_toHTML($_POST['post'], true);
if ($_POST['poll_title'] != "" && $pref['forum_poll'])
if ($_POST['poll_title'] != '' && $pref['forum_poll'])
{
require_once(e_PLUGIN."poll/poll_class.php");
$poll = new poll;
$poll->render_poll($_POST, "forum", "notvoted");
$poll->render_poll($_POST, 'forum', 'notvoted');
}
if (!$FORUM_PREVIEW)
@ -216,6 +219,9 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
{
$postInfo = array();
$threadInfo = array();
$postOptions = array();
$threadOptions = array();
if ((isset($_POST['newthread']) && trim($_POST['subject']) == '') || trim($_POST['post']) == '')
{
message_handler('ALERT', 5);
@ -227,6 +233,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
echo "<script type='text/javascript'>document.location.href='".e_BASE."index.php'</script>\n";
exit;
}
$hasPoll = ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '');
process_upload();
$postInfo['post_ip'] = $e107->getip();
@ -258,7 +265,6 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$postResult = $forum->postAdd($postInfo);
break;
// New thread started. Add the thread info (with lastest post info), add the post.
// Update forum with latest post info
case 'nt':
@ -267,6 +273,11 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$threadInfo['thread_forum_id'] = $forumId;
$threadInfo['thread_active'] = 1;
$threadInfo['thread_datestamp'] = $time;
if($hasPoll)
{
$threadOptions['poll'] = '1';
}
$threadInfo['thread_options'] = serialize($threadOptions);
$postResult = $forum->threadAdd($threadInfo, $postInfo);
break;
}
@ -294,7 +305,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
if ($action == 'nt' && varset($_POST['poll_title']) && $_POST['poll_option'][0] != '' && $_POST['poll_option'][1] != '')
{
require_once(e_PLUGIN.'poll/poll_class.php');
$_POST['iid'] = $iid;
$_POST['iid'] = $threadId;
$poll = new poll;
$poll->submit_poll(2);
}

View File

@ -12,8 +12,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_viewtopic.php,v $
| $Revision: 1.7 $
| $Date: 2008-12-05 20:28:05 $
| $Revision: 1.8 $
| $Date: 2008-12-07 00:21:21 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -37,6 +37,7 @@ if (!e_QUERY)
include_lan(e_PLUGIN . 'forum/languages/English/lan_forum_viewtopic.php');
include_once (e_PLUGIN . 'forum/forum_class.php');
include_lan(e_PLUGIN . 'forum/templates/forum_icons_template.php');
$forum = new e107forum;
$thread = new e107ForumThread;
@ -120,7 +121,8 @@ if (!$FORUMSTART)
if (file_exists(THEME . 'forum_viewtopic_template.php'))
{
require_once (THEME . 'forum_viewtopic_template.php');
} elseif (file_exists(THEME . 'forum_template.php'))
}
elseif (file_exists(THEME . 'forum_template.php'))
{
require_once (THEME . 'forum_template.php');
}
@ -130,8 +132,6 @@ if (!$FORUMSTART)
}
}
//$forum_info['forum_name'] = $e107->tp->toHTML($threadInfo['forum_name'], true, 'no_hook,emotes_off');
// get info for main thread -------------------------------------------------------------------------------------------------------------------------------------------------------------------
$forum->set_crumb(true); // Set $BREADCRUMB (and BACKLINK)
@ -144,11 +144,50 @@ if ($pref['forum_track'] && USER)
{
if ($thread->threadInfo['track_userid'])
{
$TRACK = "<span class='smalltext'><a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId)) . "'>" . LAN_392 . "</a></span>";
$TRACK = "
<span class='smalltext'>
<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId)) . "'>" . LAN_392 . "</a>
</span>";
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
$TRACK = "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>".IMAGE_untrack."</a>
</span>
<script type='text/javascript'>
//put this in header_js or as inline script just after the markup above
$('forum-track-trigger').observe('click', function(e) {
e.stop();
new e107Ajax.Updater('forum-track-trigger-container', '".e_SELF."?id={$thread->threadId}&f=untrack', {
overlayPage: $(document.body)
});
});
</script>
";
}
else
{
$TRACK = "<span class='smalltext'><a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId)) . "'>" . LAN_391 . "</a></span>";
$TRACK = "
<span class='smalltext'>
<a href='" . $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId)) . "'>" . LAN_391 . "</a>
</span>
";
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
$TRACK = "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>".IMAGE_track."</a>
</span>
<script type='text/javascript'>
//put this in header_js or as inline script just after the markup above
$('forum-track-trigger').observe('click', function(e) {
e.stop();
new e107Ajax.Updater('forum-track-trigger-container', '".e_SELF."?id={$thread->threadId}&f=track', {
overlayPage: $(document.body)
});
});
</script>
";
}
}
@ -451,7 +490,7 @@ class e107ForumThread
function processFunction()
{
global $forum;
global $forum, $thread;
$e107 = e107::getInstance();
if (!isset($_GET['f']))
{
@ -481,22 +520,26 @@ class e107ForumThread
break;
case 'track':
if (!USER || !isset($_GET['id']))
{
return;
}
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('add', USERID, $_GET['id']);
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'untrack', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_untrack."</a>";
exit();
}
break;
// header("location:".e_SELF."?{$thread_id}.{$topic_from}");
// exit;
case 'untrack':
if (!USER || !isset($_GET['id']))
{
return;
}
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('del', USERID, $_GET['id']);
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>".IMAGE_track."</a>";
exit();
}
break;
case 'last':

View File

@ -11,90 +11,80 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/newforumposts_menu.php,v $
| $Revision: 1.6 $
| $Date: 2008-07-20 17:08:31 $
| $Author: e107steved $
| $Revision: 1.7 $
| $Date: 2008-12-07 00:21:21 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
if (!defined('e107_INIT')) { exit; }
global $tp;
$e107 = e107::getInstance();
$gen = new convert;
if (file_exists(e_PLUGIN."forum/languages/".e_LANGUAGE."/lan_newforumposts_menu.php"))
{
include_once(e_PLUGIN."forum/languages/".e_LANGUAGE."/lan_newforumposts_menu.php");
}
else
{
include_once(e_PLUGIN."forum/languages/English/lan_newforumposts_menu.php");
}
include_lan(e_PLUGIN.'forum/languages/English/lan_newforumposts_menu.php');
include_once(e_PLUGIN.'forum/forum_class.php');
$max_age = varset($menu_pref['newforumposts_maxage'],0);
$max_age = $max_age == 0 ? '' : "(t.thread_datestamp > ".intval(time()-$max_age*86400).") AND ";
$query2 = "
SELECT tp.thread_name AS parent_name,
t.thread_datestamp , t.thread_thread, t.thread_name, t.thread_id, t.thread_user,
f.forum_id, f.forum_name, f.forum_class, u.user_name, fp.forum_class FROM #forum_t AS t
LEFT JOIN #user AS u ON t.thread_user = u.user_id
LEFT JOIN #forum_t AS tp ON t.thread_parent = tp.thread_id
LEFT JOIN #forum AS f ON (f.forum_id = t.thread_forum_id AND f.forum_class IN (".USERCLASS_LIST."))
LEFT JOIN #forum AS fp ON f.forum_parent = fp.forum_id
WHERE {$max_age} fp.forum_class IN (".USERCLASS_LIST.")
ORDER BY t.thread_datestamp DESC LIMIT 0, ".$menu_pref['newforumposts_display'];
$max_age = varset($menu_pref['newforumposts_maxage'], 0);
$max_age = $max_age == 0 ? '' : '(t.post_datestamp > '.(time()-(int)$max_age*86400).') AND ';
$forum = new e107forum;
$forumList = implode(',', $forum->permList['view']);
$results = $sql->db_Select_gen($query2);
$qry = "
SELECT
p.post_user, p.post_id, p.post_datestamp, p.post_user_anon, p.post_entry,
t.thread_id, t.thread_datestamp, t.thread_name, u.user_name
FROM `#forum_post` as p
LEFT JOIN `#forum_thread` AS t ON t.thread_id = p.post_thread
LEFT JOIN `#user` AS u ON u.user_id = p.post_user
WHERE {$maxage} p.post_forum IN ({$forumList})
ORDER BY p.post_datestamp DESC LIMIT 0, ".$menu_pref['newforumposts_display'];
if(!$results)
if($results = $e107->sql->db_Select_gen($qry))
{
// no posts yet ..
$text = NFP_2;
}
else
{
$text = "";
$forumArray = $sql->db_getList();
foreach($forumArray as $fi)
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$datestamp = $gen->convert_date($fi['thread_datestamp'], "short");
$topic = ($fi['parent_name'] ? "Re: <i>{$fi['parent_name']}</i>" : "<i>{$fi['thread_name']}</i>");
$topic = strip_tags($tp->toHTML($topic, TRUE, "emotes_off, no_make_clickable, parse_bb", "", $pref['menu_wordwrap']));
$id = $fi['thread_id'];
if($fi['user_name'])
$datestamp = $gen->convert_date($row['post_datestamp'], 'short');
$id = $row['thread_id'];
$topic = ($row['thread_datestamp'] == $row['post_datestamp'] ? '' : 'Re:');
$topic .= strip_tags($e107->tp->toHTML($row['thread_name'], true, 'emotes_off, no_make_clickable, parse_bb', '', $pref['menu_wordwrap']));
if($row['post_user_anon'])
{
$poster = $fi['user_name'];
$poster = $row['post_user_anon'];
}
else
{
$x = explode(chr(1), $fi['thread_user']);
$tmp = explode(".", $x[0], 2);
if($tmp[1])
if($row['user_name'])
{
$poster = $tmp[1];
$poster = "<a href='".$e107->url->getUrl('core:user', 'main', array('func' => 'profile', 'id' => $row['post_user']))."'>{$row['user_name']}</a>";
}
else
{
$poster = "[deleted]";
$poster = '[deleted]';
}
}
$fi['thread_thread'] = strip_tags($tp->toHTML($fi['thread_thread'], TRUE, "emotes_off, no_make_clickable", "", $pref['menu_wordwrap']));
$fi['thread_thread'] = $tp->text_truncate($fi['thread_thread'], $menu_pref['newforumposts_characters'], $menu_pref['newforumposts_postfix']);
$post = strip_tags($e107->tp->toHTML($row['post_entry'], true, 'emotes_off, no_make_clickable', '', $pref['menu_wordwrap']));
$post = $e107->tp->text_truncate($post, $menu_pref['newforumposts_characters'], $menu_pref['newforumposts_postfix']);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $id));
$bullet = "<img src='".THEME_ABS.'images/'.(defined('BULLET') ? BULLET : 'bullet2.gif')."' alt='' />";
if ($menu_pref['newforumposts_title'])
{
$text .= "<img src='".THEME_ABS."images/".(defined("BULLET") ? BULLET : "bullet2.gif")."' alt='' /> <a href='".e_PLUGIN."forum/forum_viewtopic.php?{$id}.post'>".$topic."</a><br />".$fi['thread_thread']."<br />".NFP_11." ".$poster."<br />".$datestamp."<br /><br />";
$text .= "<a href='{$url}'>{$topic}</a><br />{$post}<br />".NFP_11." {$poster}<br />{$datestamp}<br /><br />";
}
else
{
$text .= "<img src='".THEME_ABS."images/".(defined("BULLET") ? BULLET : "bullet2.gif")."' alt='' /> <a href='".e_PLUGIN."forum/forum_viewtopic.php?{$id}.post'>".NFP_11." ".$poster."</a><br />".$fi['thread_thread']."<br />".$datestamp."<br/><br />";
$text .= "<a href='{$url}'>".NFP_11." {$poster}</a><br />{$post}<br />{$datestamp}<br/><br />";
}
}
}
else
{
$text = NFP_2;
$ns->tablerender($menu_pref['newforumposts_caption'], $text, 'nfp_menu');
}
$e107->ns->tablerender($menu_pref['newforumposts_caption'], $text, 'nfp_menu');
?>

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_icons_template.php,v $
| $Revision: 1.2 $
| $Date: 2007-03-04 16:59:32 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2008-12-07 00:21:21 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@ -51,6 +51,9 @@ define("IMAGE_admin_move2", "<img src='".img_path('admin_move.png')."' alt='".LA
define("IMAGE_post", "<img src='".img_path('post.png')."' alt='' title='' style='border:0' />");
define("IMAGE_post2", "<img src='".img_path('post2.png')."' alt='' title='' style='border:0; vertical-align:bottom' />");
define("IMAGE_report", "<img src='".img_path('report.png')."' alt='".LAN_413."' title='".LAN_413."' style='border:0' />");
define("IMAGE_track", "<img src='".img_path('edit.png')."' alt='".LAN_391."' title='".LAN_391."' style='border:0' />");
define("IMAGE_untrack", "<img src='".img_path('quote.png')."' alt='".LAN_392."' title='".LAN_392."' style='border:0' />");
// Admin <input> Icons