1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +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 <?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) function url_forum_forum($parms)
{ {
switch($parms['func']) switch($parms['func'])
@@ -15,6 +15,10 @@ function url_forum_forum($parms)
case 'main': case 'main':
return e_PLUGIN_ABS.'forum/forum.php'; return e_PLUGIN_ABS.'forum/forum.php';
break; 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 <?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) function url_forum_thread($parms)
{ {
switch($parms['func']) switch($parms['func'])
@@ -14,7 +14,8 @@ function url_forum_thread($parms)
break; break;
case 'view': 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; break;
case 'last': case 'last':

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_class.php,v $
| $Revision: 1.24 $ | $Revision: 1.25 $
| $Date: 2008-12-11 21:50:18 $ | $Date: 2008-12-13 21:52:18 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -30,6 +30,8 @@ class e107forum
$this->fieldTypes['forum_post']['post_user'] = 'int'; $this->fieldTypes['forum_post']['post_user'] = 'int';
$this->fieldTypes['forum_post']['post_forum'] = 'int'; $this->fieldTypes['forum_post']['post_forum'] = 'int';
$this->fieldTypes['forum_post']['post_datestamp'] = '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_thread'] = 'int';
$this->fieldTypes['forum_post']['post_options'] = 'escape'; $this->fieldTypes['forum_post']['post_options'] = 'escape';
$this->fieldTypes['forum_post']['post_attachments'] = 'escape'; $this->fieldTypes['forum_post']['post_attachments'] = 'escape';
@@ -248,12 +250,27 @@ class e107forum
return false; return false;
} }
function threadUpdate($threadInfo, $inc) function threadUpdate($threadId, $threadInfo)
{ {
$e107 = e107::getInstance(); $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 //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) function threadGet($id, $joinForum = true, $uid = USERID)
{ {
global $pref; 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) function thread_postnum($thread_id)
{ {

View File

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

View File

@@ -29,7 +29,7 @@ return $tp->parseTemplate($THREADTOPIC_REPLY, TRUE, $forum_shortcodes);
SC_END SC_END
SC_BEGIN FORMSTART 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_END
SC_BEGIN FORMEND SC_BEGIN FORMEND

View File

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

View File

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

View File

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

View File

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