1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-25 17:01:43 +02:00

Forum coding, always forum code

This commit is contained in:
mcfly
2008-12-05 01:30:56 +00:00
parent b3ca240eab
commit 8fc3e3542e
6 changed files with 165 additions and 74 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum.php,v $
| $Revision: 1.7 $
| $Date: 2008-12-04 21:36:09 $
| $Revision: 1.8 $
| $Date: 2008-12-05 01:30:56 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -359,15 +359,17 @@ function parse_forum($f, $restricted_string = "")
function parse_subs($subList, $lastpost_datestamp)
{
$e107 = e107::getInstance();
$ret = array();
$ret['text'] = "";
foreach($subList as $sub)
{
$ret['text'] .= ($ret['text'] ? ", " : "");
$ret['text'] .= "<a href='".e_PLUGIN."forum/forum_viewforum.php?{$sub['forum_id']}'>{$sub['forum_name']}</a>";
$ret['text'] .= ($ret['text'] ? ", " : "");
$suburl = $e107->url->getUrl('forum', 'forum', array('func' => 'view', 'id' => $sub['forum_id']));
$ret['text'] .= "<a href='{$suburl}'>".$e107->tp->toHTML($sub['forum_name']).'</a>';
$ret['threads'] += $sub['forum_threads'];
$ret['replies'] += $sub['forum_replies'];
$tmp = explode(".", $sub['forum_lastpost_info']);
$tmp = explode('.', $sub['forum_lastpost_info']);
if($tmp[0] > $lastpost_datestamp)
{
$ret['lastpost_info'] = $sub['forum_lastpost_info'];
@@ -378,11 +380,27 @@ function parse_subs($subList, $lastpost_datestamp)
return $ret;
}
if (e_QUERY == "track")
if (e_QUERY == 'track')
{
$sql2 = new db;
$tmp = explode("-", USERREALM);
foreach($tmp as $key => $value)
// if(!USER) { return ; }
if($trackedThreadList = $forum->getTrackedThreadList(USERID, 'list'))
{
// $sql2 = new db;
// $tmp = explode("-", USERREALM);
$qry = "SELECT * from `#forum_thread` WHERE thread_id IN({$trackedThreadList}) ORDER BY thread_lastpost DESC";
if($e107->sql->db_Select_gen($qry))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
var_dump($row);
}
}
}
/*
foreach($trackedThreads as $threadId)
{
if ($value)
{
@@ -424,6 +442,7 @@ if (e_QUERY == "track")
{
echo $forum_track_start.$forum_trackstring.$forum_track_end;
}
*/
}
if (e_QUERY == "new")

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_admin.php,v $
| $Revision: 1.4 $
| $Date: 2008-11-26 03:24:51 $
| $Revision: 1.5 $
| $Date: 2008-12-05 01:30:56 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -172,6 +172,7 @@ if(isset($_POST['submit_parent']))
$tmp['forum_datestamp'] = time();
$tmp['forum_class'] = (int)$_POST['forum_class'];
$tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
if($e107->sql->db_Insert('forum',$tmp))
{
$forum->show_message(FORLAN_22.' - '.LAN_CREATED);
@@ -184,10 +185,17 @@ if(isset($_POST['submit_parent']))
if(isset($_POST['update_parent']))
{
$_POST['forum_name'] = $tp->toDB($_POST['forum_name']);
$sql->db_Update("forum", "forum_name='".$_POST['forum_name']."', forum_class='".$_POST['forum_class']."', forum_postclass='{$_POST['forum_postclass']}' WHERE forum_id=$id");
$tmp = $_POST;
unset($tmp['update_parent']);
$tmp['_FIELD_TYPES']['forum_name'] = 'todb';
$tmp['_FIELD_TYPES']['forum_class'] = 'int';
$tmp['_FIELD_TYPES']['forum_postclass'] = 'int';
$tmp['_FIELD_TYPES']['forum_threadclass'] = 'int';
$tmp['WHERE'] = 'forum_id = '.(int)$id;
// print_a($tmp);
$sql->db_Update('forum', $tmp);
$forum->show_message(FORLAN_14);
$action = "main";
$action = 'main';
}
if(isset($_POST['submit_forum']))
@@ -199,6 +207,7 @@ if(isset($_POST['submit_forum']))
$tmp['forum_datestamp'] = time();
$tmp['forum_class'] = (int)$_POST['forum_class'];
$tmp['forum_postclass'] = (int)$_POST['forum_postclass'];
$tmp['forum_threadclass'] = (int)$_POST['forum_threadclass'];
$tmp['forum_parent'] = (int)$_POST['forum_parent'];
if($e107->sql->db_Insert('forum',$tmp))
{
@@ -212,14 +221,29 @@ if(isset($_POST['submit_forum']))
if(isset($_POST['update_forum']))
{
$mods = $_POST['forum_moderators'];
$_POST['forum_name'] = $tp->toDB($_POST['forum_name']);
$_POST['forum_description'] = $tp->toDB($_POST['forum_description']);
$forum_parent = $row['forum_id'];
$sql->db_Update("forum", "forum_name='".$_POST['forum_name']."', forum_description='".$_POST['forum_description']."', forum_parent='".$_POST['forum_parent']."', forum_moderators='".$mods."', forum_class='".$_POST['forum_class']."', forum_postclass='{$_POST['forum_postclass']}' WHERE forum_id=$id");
$sql->db_Update("forum", "forum_moderators='".$mods."', forum_class='".$_POST['forum_class']."', forum_postclass='{$_POST['forum_postclass']}' WHERE forum_sub=$id");
$tmp = $_POST;
unset($tmp['update_forum']);
$tmp['_FIELD_TYPES']['forum_name'] = 'todb';
$tmp['_FIELD_TYPES']['forum_description'] = 'todb';
$tmp['_FIELD_TYPES']['forum_parent'] = 'int';
$tmp['_FIELD_TYPES']['forum_class'] = 'int';
$tmp['_FIELD_TYPES']['forum_postclass'] = 'int';
$tmp['_FIELD_TYPES']['forum_threadclass'] = 'int';
$tmp['_FIELD_TYPES']['forum_moderators'] = 'int';
$tmp['WHERE'] = 'forum_id = '.(int)$id;
$tmp2['_FIELD_TYPES'] = $tmp['_FIELD_TYPES'];
$tmp2['forum_moderators'] = $tmp['forum_moderators'];
$tmp2['forum_class'] = $tmp['forum_class'];
$tmp2['forum_postclass'] = $tmp['forum_postclass'];
$tmp2['forum_threadclass'] = $tmp['forum_threadclass'];
$tmp2['WHERE'] = 'forum_sub = '.(int)$id;
$sql->db_Update('forum', $tmp);
$sql->db_Update('forum', $tmp2);
$forum->show_message(FORLAN_12);
$action = "main";
$action = 'main';
}
if (isset($_POST['update_order']))
@@ -261,7 +285,7 @@ if (isset($_POST['do_prune']))
{
$msg = $for->forum_prune($_POST['prune_type'], $_POST['prune_days'], $_POST['pruneForum']);
$forum->show_message($msg);
$action = "main";
$action = 'main';
}
if (isset($_POST['set_ranks']))
@@ -307,20 +331,20 @@ if (isset($_POST['frsubmit']))
if ($delete == 'main') {
if ($sql->db_Delete("forum", "forum_id='$del_id' ")) {
if ($sql->db_Delete('forum', "forum_id='$del_id' ")) {
$forum->show_message(FORLAN_96);
}
}
if ($action == "create")
if ($action == 'create')
{
if ($sql->db_Select("forum", "*", "forum_parent='0' "))
if ($sql->db_Select('forum', '*', "forum_parent='0' "))
{
$forum->create_forums($sub_action, $id);
}
else
{
header("location:".e_ADMIN."forum.php");
header('location:'.e_ADMIN.'forum.php');
exit;
}
}
@@ -390,12 +414,12 @@ if ($delete == 'reported')
}
if ($action == "sr")
if ($action == 'sr')
{
$forum->show_reported($sub_action);
}
if (!e_QUERY || $action == "main")
if (!e_QUERY || $action == 'main')
{
$forum->show_existing_forums($sub_action, $id);
}
@@ -421,10 +445,10 @@ function headerjs()
}
function forum_admin_adminmenu()
{
global $forum;
global $action;
$forum->show_options($action);
}
?>
function forum_admin_adminmenu()
{
global $forum;
global $action;
$forum->show_options($action);
}
?>

View File

@@ -9,8 +9,8 @@
* Forum admin functions
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/forum_admin_class.php,v $
* $Revision: 1.5 $
* $Date: 2008-12-04 21:36:09 $
* $Revision: 1.6 $
* $Date: 2008-12-05 01:30:56 $
* $Author: mcfly_e107 $
*
*/
@@ -359,7 +359,7 @@ class forumAdmin
<div style='text-align:left; padding-left: 30px'>
<a href='".e_SELF."?create.edit.{$forum['forum_id']}'>".ADMIN_EDIT_ICON."</a>
<a href='".e_SELF."?delete.{$forum['forum_id']}'>".ADMIN_DELETE_ICON."</a>
&nbsp;&nbsp;<a href='".e_SELF."?subs.{$forum['forum_id']}'>".$sub_img."</a>
&nbsp;&nbsp;<a href='".e_SELF."?subs.{$forum['forum_id']}'>".$sub_img."</a> (".count($subList[$forum['forum_parent']][$forum['forum_id']]).")
</div>
";
}
@@ -400,6 +400,7 @@ class forumAdmin
$row['forum_name'] = '';
$row['forum_class'] = e_UC_PUBLIC;
$row['forum_postclass'] = e_UC_MEMBER;
$row['forum_threadclass'] = e_UC_MEMBER;
}
$text = "<div style='text-align:center'>
@@ -415,12 +416,17 @@ class forumAdmin
<tr>
<td style='width:40%' class='forumheader3'>".FORLAN_23.":<br /><span class='smalltext'>(".FORLAN_24.")</span></td>
<td style='width:60%' class='forumheader3'>".$e107->e_userclass->uc_dropdown('forum_class', $row['forum_class'], 'nobody,public,member,admin,classes')."</td>
<td style='width:60%' class='forumheader3'>".$e107->user_class->uc_dropdown('forum_class', $row['forum_class'], 'nobody,public,member,admin,classes')."</td>
</tr>
<tr>
<td style='width:40%' class='forumheader3'>".FORLAN_142.":<br /><span class='smalltext'>(".FORLAN_143.")</span></td>
<td style='width:60%' class='forumheader3'>".$e107->e_userclass->uc_dropdown("forum_postclass", $row['forum_postclass'], 'nobody,public,member,admin,classes')."</td>
<td style='width:60%' class='forumheader3'>".$e107->user_class->uc_dropdown("forum_postclass", $row['forum_postclass'], 'nobody,public,member,admin,classes')."</td>
</tr>
<tr>
<td style='width:40%' class='forumheader3'>".FORLAN_184.":<br /><span class='smalltext'>(".FORLAN_185.")</span></td>
<td style='width:60%' class='forumheader3'>".$e107->user_class->uc_dropdown('forum_threadclass', $row['forum_threadclass'], 'nobody,public,member,admin,classes')."</td>
</tr>
<tr style='vertical-align:top'>
@@ -453,7 +459,7 @@ class forumAdmin
{
if ($e107->sql->db_Select('forum', '*', "forum_id=$id"))
{
$fInfo = $e107->sql->db_Fetch();
$fInfo = $e107->sql->db_Fetch(MYSQL_ASSOC);
}
}
else
@@ -462,7 +468,8 @@ class forumAdmin
'forum_parent' => 0,
'forum_moderators' => e_UC_ADMIN,
'forum_class' => e_UC_PUBLIC,
'forum_postclass' => e_UC_MEMBER
'forum_postclass' => e_UC_MEMBER,
'forum_threadclass' => e_UC_MEMBER
);
}
@@ -517,6 +524,11 @@ class forumAdmin
<td style='width:60%' class='forumheader3'>".$e107->user_class->uc_dropdown('forum_postclass', $fInfo['forum_postclass'], 'nobody,public,member,admin,classes')."</td>
</tr>
<tr>
<td style='width:40%' class='forumheader3'>".FORLAN_184.":<br /><span class='smalltext'>(".FORLAN_185.")</span></td>
<td style='width:60%' class='forumheader3'>".$e107->user_class->uc_dropdown('forum_threadclass', $fInfo['forum_threadclass'], 'nobody,public,member,admin,classes')."</td>
</tr>
<tr style='vertical-align:top'>
<td colspan='2' style='text-align:center' class='forumheader'>";
if ($sub_action == "edit")

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.16 $
| $Date: 2008-12-04 21:36:09 $
| $Revision: 1.17 $
| $Date: 2008-12-05 01:30:56 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -22,6 +22,7 @@ class e107forum
{
var $permList = array();
var $fieldTypes = array();
var $userViewed = array();
function e107forum()
{
@@ -112,6 +113,38 @@ class e107forum
return (in_array($forumId, $this->permList[$type]));
}
function threadViewed($threadId)
{
$e107 = e107::getInstance();
if(!$this->userViewed)
{
if(isset($e107->currentUser['user_plugin_forum_views']))
{
$this->userViewed = explode('.', $e107->currentUser['user_plugin_forum_viewed']);
}
}
if(is_array($this->userViewed) && in_array($threadId, $this->userViewed))
{
return true;
}
return false;
}
function getTrackedThreadList($id, $retType = 'array')
{
$e107 = e107::getInstance();
$id = (int)$id;
if($e107->sql->db_Select('forum_track', 'track_thread', 'track_userid = '.$id))
{
while($row = $e107->sql->db_Fetch(MYSQL_ASSOC))
{
$ret[] = $row['track_thread'];
}
return ($retType == 'array' ? $ret : implode(',', $ret));
}
return false;
}
/*
* Add a post to the db.
*

View File

@@ -4,9 +4,9 @@
| e107 website system - Language File.
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/languages/English/lan_forum_admin.php,v $
| $Revision: 1.2 $
| $Date: 2008-01-06 21:16:37 $
| $Author: e107steved $
| $Revision: 1.3 $
| $Date: 2008-12-05 01:30:56 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
define("FORLAN_1", "You must enter the number of days you wish to prune.");
@@ -205,4 +205,7 @@ define("FORLAN_181", "Confirm Delete");
define("FORLAN_182", "also recalculate replies for all threads in selected forum");
define("FORLAN_183", "(this function is not allowed when selecting 'all forums' due to the number of queries it will generate)");
define('FORLAN_184', 'Thread Creation permission');
define('FORLAN_185', 'Indicates who can create new threads');
?>

View File

@@ -9,8 +9,8 @@
* View specific forums
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/forum/viewforum.php,v $
* $Revision: 1.6 $
* $Date: 2008-12-04 21:36:09 $
* $Revision: 1.7 $
* $Date: 2008-12-05 01:30:56 $
* $Author: mcfly_e107 $
*
*/
@@ -62,7 +62,7 @@ $forumId = (int)$_REQUEST['id'];
if (!$forum->checkPerm($forumId, 'view'))
{
header("Location:".$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
header('Location:'.$e107->url->getUrl('forum', 'forum', array('func' => 'main')));
exit;
}
@@ -89,8 +89,12 @@ $forumInfo['forum_description'] = $e107->tp->toHTML($forumInfo['forum_descriptio
$_forum_name = (substr($forumInfo['forum_name'], 0, 1) == '*' ? substr($forumInfo['forum_name'], 1) : $forumInfo['forum_name']);
define('e_PAGETITLE', LAN_01.' / '.$_forum_name);
define('MODERATOR', $forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators']));
$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
//define('MODERATOR', $forum_info['forum_moderators'] != '' && check_class($forum_info['forum_moderators']));
//$modArray = $forum->forum_getmods($forum_info['forum_moderators']);
$modArray = $forum->forum_getmods($thread->forum_info['forum_moderators']);
define('MODERATOR', (USER && is_array($modArray) && in_array(USERID, array_keys($modArray))));
$message = '';
if (MODERATOR)
{
@@ -160,7 +164,6 @@ if(substr($forum_info['sub_parent'], 0, 1) == '*')
$forum->set_crumb(); // set $BREADCRUMB (and $BACKLINK)
$FORUMTITLE = $forumInfo['forum_name'];
//$MODERATORS = LAN_404.": ".$forum_info['forum_moderators'];
$MODERATORS = LAN_404.': '.implode(', ', $modArray);
$BROWSERS = '';
if(varset($pref['track_online']))
@@ -320,16 +323,14 @@ require_once(FOOTERF);
function parse_thread($thread_info)
{
global $forum, $tp, $FORUM_VIEW_FORUM, $FORUM_VIEW_FORUM_STICKY, $FORUM_VIEW_FORUM_ANNOUNCE, $gen, $pref, $forum_id, $menu_pref;
$text = "";
$e107 = e107::getInstance();
$text = '';
$VIEWS = $thread_info['thread_views'];
$REPLIES = $thread_info['thread_total_replies'];
print_a($thread_info);
if ($REPLIES)
{
$lastpost_datestamp = $gen->convert_date($thread_info['thread_lastpost'], 'forum');
// $tmp = explode(".", $thread_info['thread_lastuser'], 2);
if($thread_info['lastpost_username'])
{
$LASTPOST = "<a href='".e_BASE."user.php?id.".$tmp[0]."'>".$thread_info['lastpost_username']."</a>";
@@ -348,12 +349,12 @@ print_a($thread_info);
$LASTPOST .= '<br />'.$lastpost_datestamp;
}
$newflag = FALSE;
$newflag = false;
if (USER)
{
if ($thread_info['thread_lastpost'] > USERLV && !preg_match("#\b".$thread_info['thread_id']."\b#", USERVIEWED))
if ($thread_info['thread_lastpost'] > USERLV && !$forum->threadViewed($thread_info['thread_id']))
{
$newflag = TRUE;
$newflag = true;
}
}
@@ -393,7 +394,7 @@ print_a($thread_info);
{
$thread_thread = substr($thread_thread, 0, $tip_length)." ".$menu_pref['newforumposts_postfix'];
}
$thread_thread = str_replace("'", "&#39;", $thread_thread);
$thread_thread = str_replace("'", '&#39;', $thread_thread);
$title = "title='".$thread_thread."'";
}
else
@@ -409,10 +410,10 @@ print_a($thread_info);
{
for($a = 0; $a <= 2; $a++)
{
$PAGES .= $PAGES ? " " : "";
$PAGES .= $PAGES ? ' ' : '';
$PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>";
}
$PAGES .= " ... ";
$PAGES .= ' ... ';
for($a = $pages-3; $a <= $pages-1; $a++)
{
$PAGES .= $PAGES ? " " : "";
@@ -423,15 +424,15 @@ print_a($thread_info);
{
for($a = 0; $a <= ($pages-1); $a++)
{
$PAGES .= $PAGES ? " " : "";
$PAGES .= $PAGES ? ' ' : '';
$PAGES .= "<a href='".e_PLUGIN."forum/forum_viewtopic.php?".$thread_info['thread_id'].".".($a * $pref['forum_postspage'])."'>".($a+1)."</a>";
}
}
$PAGES = LAN_316." [&nbsp;".$PAGES."&nbsp;]";
$PAGES = LAN_316.' [&nbsp;'.$PAGES.'&nbsp;]';
}
else
{
$PAGES = "";
$PAGES = '';
}
if (MODERATOR)
@@ -454,19 +455,18 @@ print_a($thread_info);
}
$text .= "</td>
<td style='vertical-align:top; text-align:center; width:20%' class='forumheader3'>".$THREADDATE."<br />
";
$tmp = explode(".", $thread_info['thread_user'], 2);
<td style='vertical-align:top; text-align:center; width:20%' class='forumheader3'>".$THREADDATE.'<br />';
$tmp = explode('.', $thread_info['thread_user'], 2);
if($thread_info['user_name'])
{
$POSTER = "<a href='".e_BASE."user.php?id.".$tmp[0]."'>".$thread_info['user_name']."</a>";
}
else
{
if($tmp[1])
if($thread_info['thread_user_anon'])
{
$x = explode(chr(1), $tmp[1]);
$POSTER = $tp->toHTML($x[0]);
$POSTER = $e107->tp->toHTML($thread_info['thread_user_anon']);
}
else
{
@@ -487,7 +487,7 @@ print_a($thread_info);
if (!$REPLIES)
{
$REPLIES = LAN_317; // 'None'
$LASTPOST = " - ";
$LASTPOST = ' - ';
}
return(preg_replace("/\{(.*?)\}/e", '$\1', $FORUM_VIEW_FORUM));
@@ -518,7 +518,7 @@ function parse_sub($subInfo)
$lp_thread = "<a href='".$e107->url->getUrl('forum', 'thread', array('func' => 'last', 'id' => $tmp[1]))."'>".IMAGE_post2.'</a>';
$lp_date = $gen->convert_date($tmp[0], 'forum');
$tmp = explode(".", $subInfo['forum_lastpost_user'],2);
$tmp = explode('.', $subInfo['forum_lastpost_user'],2);
if($subInfo['user_name'])
{