1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 20:30:39 +02:00

More work on edit, and some pagination

This commit is contained in:
mcfly
2008-12-13 21:52:19 +00:00
parent 04aa586bbf
commit 0f7c3be9ed
11 changed files with 114 additions and 93 deletions

View File

View File

View File

@@ -1,5 +1,5 @@
<?php
// $Id: forum.php,v 1.2 2008-12-09 21:46:14 mcfly_e107 Exp $
// $Id: forum.php,v 1.3 2008-12-13 21:52:19 mcfly_e107 Exp $
function url_forum_forum($parms)
{
switch($parms['func'])
@@ -15,6 +15,10 @@ function url_forum_forum($parms)
case 'main':
return e_PLUGIN_ABS.'forum/forum.php';
break;
}
case 'post':
return e_PLUGIN_ABS."forum/forum_post.php?f={$parms['type']}}id={$parms['id']}";
break;
}
}

View File

@@ -1,5 +1,5 @@
<?php
// $Id: thread.php,v 1.5 2008-12-11 16:02:05 mcfly_e107 Exp $
// $Id: thread.php,v 1.6 2008-12-13 21:52:19 mcfly_e107 Exp $
function url_forum_thread($parms)
{
switch($parms['func'])
@@ -14,7 +14,8 @@ function url_forum_thread($parms)
break;
case 'view':
return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}";
$page = (varset($parms['page']) ? '&p='.$parms['page'] : '');
return e_PLUGIN_ABS."forum/forum_viewtopic.php?id={$parms['id']}{$page}";
break;
case 'last':

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.24 $
| $Date: 2008-12-11 21:50:18 $
| $Revision: 1.25 $
| $Date: 2008-12-13 21:52:18 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -30,6 +30,8 @@ class e107forum
$this->fieldTypes['forum_post']['post_user'] = 'int';
$this->fieldTypes['forum_post']['post_forum'] = 'int';
$this->fieldTypes['forum_post']['post_datestamp'] = 'int';
$this->fieldTypes['forum_post']['post_edit_datestamp'] = 'int';
$this->fieldTypes['forum_post']['post_edit_user'] = 'int';
$this->fieldTypes['forum_post']['post_thread'] = 'int';
$this->fieldTypes['forum_post']['post_options'] = 'escape';
$this->fieldTypes['forum_post']['post_attachments'] = 'escape';
@@ -248,12 +250,27 @@ class e107forum
return false;
}
function threadUpdate($threadInfo, $inc)
function threadUpdate($threadId, $threadInfo)
{
$e107 = e107::getInstance();
$threadInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_thread'];
$threadInfo['WHERE'] = 'thread_id = '.(int)$threadId;
// var_dump($threadInfo);
// exit;
$e107->sql->db_Update('forum_thread', $threadInfo);
//TODO: Add this
}
function postUpdate($postId, $postInfo)
{
$e107 = e107::getInstance();
$postInfo['_FIELD_TYPES'] = $this->fieldTypes['forum_post'];
$postInfo['WHERE'] = 'post_id = '.(int)$postId;
// var_dump($postInfo);
// exit;
$e107->sql->db_Update('forum_post', $postInfo);
}
function threadGet($id, $joinForum = true, $uid = USERID)
{
global $pref;
@@ -433,6 +450,18 @@ class e107forum
}
}
/**
* Given threadId and postId, determine which number of post in thread the postid is
*
*/
function postGetPostNum($threadId, $postId)
{
$threadId = (int)$threadId;
$postId = (int)$postId;
$e107 = e107::getInstance();
return $e107->sql->db_Count('forum_post', '(*)', "WHERE post_id <= {$postId} AND post_thread = {$threadId} ORDER BY post_id ASC");
}
function thread_postnum($thread_id)
{

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.30 $
| $Date: 2008-12-11 21:50:18 $
| $Revision: 1.31 $
| $Date: 2008-12-13 21:52:18 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -69,7 +69,7 @@ switch($action)
}
echo "forumId = $forumId <br />";
//echo "forumId = $forumId <br />";
// check if user can post to this forum ...
if (!$forum->checkPerm($forumId, 'post'))
{
@@ -322,6 +322,7 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
$poll->submit_poll(2);
}
$e107cache->clear('newforumposts');
$threadLink = $e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $threadId));
$forumLink = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $forumId));
if ($pref['forum_redirect'])
@@ -345,16 +346,18 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
}
echo (isset($_POST['newthread']) ? $FORUMTHREADPOSTED : $FORUMREPLYPOSTED);
$e107cache->clear('newforumposts');
require_once(FOOTERF);
exit;
}
}
}
require_once(HEADERF);
if (isset($_POST['update_thread']))
{
// var_dump($_POST);
// var_dump($threadInfo);
// var_dump($postInfo);
// exit;
if (!$_POST['subject'] || !$_POST['post'])
{
$error = "<div style='text-align:center'>".LAN_27."</div>";
@@ -363,23 +366,24 @@ if (isset($_POST['update_thread']))
{
if (!isAuthor())
{
require_once(HEADERF);
$ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96.'</div>');
require_once(FOOTERF);
exit;
}
$newvals['thread_edit_datestamp'] = time();
$newvals['thread_thread'] = $_POST['post'];
$newvals['thread_name'] = $_POST['subject'];
$newvals['thread_active'] = (isset($_POST['email_notify'])) ? '99' : '1'; // Always set in case it's changed
if (isset($_POST['threadtype']) && MODERATOR)
{
$newvals['thread_s'] = $_POST['threadtype'];
}
$forum->thread_update($id, $newvals);
$e107cache->clear("newforumposts");
$url = e_PLUGIN."forum/forum_viewtopic.php?{$thread_info['head']['thread_id']}.0";
echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
$postVals['post_edit_datestamp'] = time();
$postVals['post_edit_user'] = USERID;
$postVals['post_entry'] = $_POST['post'];
$threadVals['thread_name'] = $_POST['subject'];
$forum->threadUpdate($postInfo['post_thread'], $threadVals);
$forum->postUpdate($postInfo['post_id'], $postVals);
$e107cache->clear('newforumposts');
$url = $e107->url->getUrl('forum', 'thread', "func=post&id={$postInfo['post_id']}");
header('location:'.$url);
exit;
}
}
@@ -387,27 +391,31 @@ if (isset($_POST['update_reply']))
{
if (!$_POST['post'])
{
$error = "<div style='text-align:center'>".LAN_27."</div>";
$error = "<div style='text-align:center'>".LAN_27.'</div>';
}
else
{
if (!isAuthor())
{
$ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96."</div>");
require_once(HEADERF);
$ns->tablerender(LAN_95, "<div style='text-align:center'>".LAN_96.'</div>');
require_once(FOOTERF);
exit;
}
$url = e_PLUGIN."forum/forum_viewtopic.php?{$id}.post";
echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
$newvals['thread_edit_datestamp'] = time();
$newvals['thread_thread'] = $_POST['post'];
$forum->thread_update($id, $newvals);
$e107cache->clear("newforumposts");
$url = e_PLUGIN."forum/forum_viewtopic.php?{$id}.post";
echo "<script type='text/javascript'>document.location.href='".$url."'</script>\n";
$postVals['post_edit_datestamp'] = time();
$postVals['post_edit_user'] = USERID;
$postVals['post_entry'] = $_POST['post'];
$forum->postUpdate($postInfo['post_id'], $postVals);
$e107cache->clear('newforumposts');
$url = $e107->url->getUrl('forum', 'thread', "func=post&id={$postInfo['post_id']}");
header('location:'.$url);
exit;
}
}
require_once(HEADERF);
if ($error)
{
$ns->tablerender(LAN_20, $error);
@@ -524,7 +532,7 @@ else
function isAuthor()
{
global $postInfo;
print_a($postInfo);
// print_a($postInfo);
return ((USERID === $postInfo['post_user']) || MODERATOR);
}

View File

@@ -29,7 +29,7 @@ return $tp->parseTemplate($THREADTOPIC_REPLY, TRUE, $forum_shortcodes);
SC_END
SC_BEGIN FORMSTART
return "<form enctype='multipart/form-data' method='post' action='".e_SELF."?".e_QUERY."' id='dataform'>";
return "<form enctype='multipart/form-data' method='post' action='".e_SELF.'?'.e_QUERY."' id='dataform'>";
SC_END
SC_BEGIN FORMEND

View File

@@ -316,20 +316,25 @@ SC_END
SC_BEGIN LASTEDIT
global $postInfo, $gen;
//var_dump($postInfo);
if ($postInfo['post_edit_datestamp'])
{
return $gen->convert_date($postInfo['thread_edit_datestamp'],'forum');
return $gen->convert_date($postInfo['post_edit_datestamp'],'forum');
}
SC_END
SC_BEGIN LASTEDITBY
global $postInfo;
$e107 = e107::getInstance();
if ($postInfo['post_edit_datestamp'])
if(isset($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>";
}
return $postInfo['edit_name'];
}
return '';
SC_END
SC_BEGIN POLL

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.13 $
| $Date: 2008-12-11 21:50:18 $
| $Revision: 1.14 $
| $Date: 2008-12-13 21:52:18 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -42,6 +42,10 @@ include_lan(e_PLUGIN . 'forum/templates/forum_icons_template.php');
$forum = new e107forum;
$thread = new e107ForumThread;
if(isset($_GET['f']) && $_GET['f'] == 'post')
{
$thread->processFunction();
}
$thread->init();
@@ -80,7 +84,7 @@ if (MODERATOR && isset($_POST['mod']))
$thread->threadInfo = $forum->threadGet($thread->threadId);
}
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
$postList = $forum->PostGet($thread->threadId, ($thread->page-1) * $thread->perPage, $thread->perPage);
//var_dump($thread->threadInfo);
require_once (e_HANDLER . 'level_handler.php');
@@ -449,7 +453,7 @@ class e107ForumThread
$e107 = e107::getInstance();
$this->threadId = (int)varset($_GET['id']);
$this->perPage = (varset($_GET['perpage']) ? (int)$_GET['perpage'] : $pref['forum_postspage']);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 0);
$this->page = (varset($_GET['p']) ? (int)$_GET['p'] : 1);
//If threadId doesn't exist, or not given, redirect to main forum page
if (!$this->threadId || !$this->threadInfo = $forum->threadGet($this->threadId))
@@ -492,7 +496,7 @@ class e107ForumThread
function processFunction()
{
global $forum, $thread;
global $forum, $thread, $pref;
$e107 = e107::getInstance();
if (!isset($_GET['f']))
{
@@ -503,47 +507,15 @@ class e107ForumThread
switch ($function)
{
case 'post':
if ($thread_id)
{
$post_num = $forum->thread_postnum($thread_id);
$pages = ceil(($post_num['post_num'] + 1) / $pref['forum_postspage']);
$topic_from = ($pages - 1) * $pref['forum_postspage'];
if ($post_num['parent'] != $thread_id)
{
header("location: " . e_SELF . "?{$post_num['parent']}.{$topic_from}#post_{$thread_id}");
exit;
}
}
else
{
header('Location:' . $e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
$postId = varset($_GET['id']);
$postInfo = $forum->postGet($postId,'post');
$postNum = $forum->postGetPostNum($postInfo['post_thread'], $postId);
$postPage = ceil($postNum / $pref['forum_postspage']);
$url = $e107->url->getUrl('forum', 'thread', "func=view&id={$postInfo['post_thread']}&page=$postPage");
// echo "url: $url <br />";
header('location: '.$url);
exit;
break;
/*
case 'track':
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;
case 'untrack':
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':
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);

View File

@@ -4,8 +4,8 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/languages/English/lan_forum_viewtopic.php,v $
| $Revision: 1.1.1.1 $
| $Date: 2006-12-02 04:35:18 $
| $Revision: 1.2 $
| $Date: 2008-12-13 21:52:19 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -85,5 +85,6 @@ define("FORLAN_101", "Email Thread");
define("FORLAN_102", "Print View");
define('FORLAN_103', '[user deleted]');
define('FORLAN_104', 'Thread not found');
define('FORLAN_BY', 'by');
define("FORLAN_HIDDEN", "HIDDEN - LOGIN AND REPLY TO REVEAL");
?>

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_viewtopic_template.php,v $
| $Revision: 1.4 $
| $Date: 2008-12-11 21:50:18 $
| $Revision: 1.5 $
| $Date: 2008-12-13 21:52:19 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -20,9 +20,10 @@
if (!defined('e107_INIT')) { exit; }
if(!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%;margin-left:auto;margin-right:auto"); }
$sc_style['LASTEDIT']['pre'] = "<br /><br /><span class='smallblacktext'>[ ".LAN_29.' ';
$sc_style['LASTEDIT']['pre'] = "<br /><br /><span class='smallblacktext'>[ ".LAN_29." ";
$sc_style['LASTEDIT']['post'] = " ]</span>";
$sc_style['LASTEDITBY']['pre'] = ' '.FORLAN_BY.' ';
$sc_style['LASTEDITBY']['post'] = ' ]</span>';
$sc_style['LEVEL']['pre'] = "<div class='spacer'>";
$sc_style['LEVEL']['post'] = "</div>";
@@ -129,7 +130,7 @@ $FORUMTHREADSTYLE = "<tr>
<td class='forumheader3' style='vertical-align:top'>{POLL}
{POST}
{ATTACHMENTS}
{LASTEDIT}
{LASTEDIT}{LASTEDITBY=link}
{SIGNATURE}
</td>
</tr>
@@ -215,7 +216,7 @@ $FORUMREPLYSTYLE = "<tr>
</td>
<td class='forumheader3' style='vertical-align:top'>{POST}
{ATTACHMENTS}
{LASTEDIT}
{LASTEDIT}{LASTEDITBY}
{SIGNATURE}
</td>
</tr>