1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

forum work

This commit is contained in:
mcfly
2008-12-08 02:33:34 +00:00
parent 3362a349c5
commit 4d830beec3
6 changed files with 152 additions and 84 deletions

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.7 $
* $Date: 2008-12-05 20:28:05 $
* $Revision: 1.8 $
* $Date: 2008-12-08 02:33:34 $
* $Author: mcfly_e107 $
*
*/
@@ -676,6 +676,10 @@ class forumAdmin
{
$text .= "<br /><b>".FORLAN_139."</b>";
}
if(!is_writable(e_PLUGIN.'forum/attachments'))
{
$text .= "<br /><b>Attachment file is not writable!</b>";
}
$text .= "</td>
<td style='width:25%;text-align:center' class='forumheader3' >".($pref['forum_attach'] ? "<input type='checkbox' name='forum_attach' value='1' checked='checked' />" : "<input type='checkbox' name='forum_attach' value='1' />")."</td>

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.25 $
| $Date: 2008-12-07 04:16:38 $
| $Revision: 1.26 $
| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -251,12 +251,14 @@ if (isset($_POST['newthread']) || isset($_POST['reply']))
{
foreach($uploadResult as $ur)
{
$postInfo['post_entry'] .= $ur['txt'];
$attachments[] = $ur['att'];
//$postInfo['post_entry'] .= $ur['txt'];
$_tmp = $ur['type'].'*'.$ur['file'];
if($ur['thumb']) { $_tmp .= '*'.$ur['thumb']; }
$attachments[] = $_tmp;
}
$postInfo['post_attachments'] = implode(',', $attachments);
var_dump($uploadResult);
}
var_dump($uploadResult);
switch($action)
{
@@ -542,11 +544,15 @@ function process_upload()
$postId = (int)$postId;
$ret = array();
// var_dump($_FILES);
if (isset($_FILES['file_userfile']['error']))
{
require_once(e_HANDLER.'upload_handler.php');
if ($uploaded = file_upload('/'.e_FILE.'public/', 'attachment', 'FT_'))
$attachmentDir = e_PLUGIN.'forum/attachments/';
$thumbDir = e_PLUGIN.'forum/attachments/thumb/';
if ($uploaded = process_uploaded_files($attachmentDir, 'attachment', ''))
{
foreach($uploaded as $upload)
{
@@ -554,58 +560,63 @@ function process_upload()
{
$_txt = '';
$_att = '';
$fpath = "{e_FILE}public/";
$_file = '';
$_thumb = '';
$fpath = '{e_PLUGIN}forum/attachments/';
if(strstr($upload['type'], 'image'))
{
$_type = 'img';
if(isset($pref['forum_maxwidth']) && $pref['forum_maxwidth'] > 0)
{
require_once(e_HANDLER.'resize_handler.php');
$orig_file = $upload['name'];
$p = strrpos($orig_file,'.');
$new_file = substr($orig_file, 0 , $p).'_'.substr($orig_file, $p);
if(resize_image(e_FILE.'public/'.$orig_file, e_FILE.'public/'.$new_file, $pref['forum_maxwidth']))
$new_file = 'th_'.$orig_file;
if(resize_image($attachmentDir.$orig_file, $attachmentDir.'thumb/'.$new_file, $pref['forum_maxwidth']))
{
if($pref['forum_linkimg'])
{
$parms = image_getsize(e_FILE.'public/'.$new_file);
$parms = image_getsize($attachmentDir.$new_file);
$_txt = '[br][link='.$fpath.$orig_file."][img{$parms}]".$fpath.$new_file.'[/img][/link][br]';
$_att = $new_file;
$_file = $orig_file;
$_thumb = $new_file;
//show resized, link to fullsize
}
else
{
@unlink(e_FILE.'public/'.$orig_file);
@unlink($attachmentDir.$orig_file);
//show resized
$parms = image_getsize(e_FILE.'public/'.$new_file);
$parms = image_getsize($attachmentDir.$new_file);
$_txt = "[br][img{$parms}]".$fpath.$new_file.'[/img][br]';
$_att = $new_file;
$_file = $new_file;
}
}
else
{ //resize failed, show original
$parms = image_getsize(e_FILE.'public/'.$upload['name']);
$parms = image_getsize($attachmentDir.$upload['name']);
$_txt = "[br][img{$parms}]".$fpath.$upload['name'].'[/img]';
$_att = $upload['name'];
$_file = $upload['name'];
}
}
else
{ //resizing disabled, show original
$parms = image_getsize(e_FILE.'public/'.$upload['name']);
$parms = image_getsize($attachmentDir.$upload['name']);
//resizing disabled, show original
$_txt = "[br]<div class='spacer'>[img{$parms}]".$fpath.$upload['name']."[/img]</div>\n";
$_att = $upload['name'];
$_file = $upload['name'];
}
}
else
{
//upload was not an image, link to file
$_type = 'file';
$_fname = (isset($upload['rawname']) ? $upload['rawname'] : $upload['name']);
$_txt = '[br][file='.$fpath.$upload['name'].']'.$_fname.'[/file]';
$_att = $upload['name'];
$_file = $upload['name'];
$_thumb = $_fname;
}
if($_txt && $_att)
if($_txt && $_file)
{
$ret[] = array('txt' => $_txt, 'att' => $_att);
$ret[] = array('type' => $_type, 'txt' => $_txt, 'file' => $_file, 'thumb' => $_thumb);
}
}
else

View File

@@ -27,11 +27,39 @@ $e107 = e107::getInstance();
return $e107->tp->toHTML($postInfo['post_entry'], true, 'USER_BODY', 'class:'.$post_info['user_class']);
SC_END
SC_BEGIN PRIVMESSAGE
global $pref, $post_info, $tp;
if(isset($pref['plug_installed']['pm']) && ($post_info['user_id'] > 0))
SC_BEGIN ATTACHMENTS
global $postInfo;
$e107 = e107::getInstance();
if($postInfo['post_attachments'])
{
return $tp->parseTemplate("{SENDPM={$post_info['user_id']}}");
$attachments = explode(',', $postInfo['post_attachments']);
$txt = '';
foreach($attachments as $a)
{
$info = explode('*', $a);
switch($info[0])
{
case 'file':
$txt .= IMAGE_attachment." <a href='".e_PLUGIN_ABS."forum/attachments/{$info[1]}'>{$info[2]}</a><br />";
break;
case 'img':
//if image has a thumb, show it and link to main
if(isset($info[2]))
{
$txt .= "<a href='".e_PLUGIN_ABS."forum/attachments/{$info[1]}'><img src='".e_PLUGIN_ABS."forum/attachments/thumb/{$info[2]}' alt='' /></a>";
}
}
}
return $txt;
}
SC_END
SC_BEGIN PRIVMESSAGE
global $postInfo, $tp;
if(plugInstalled('pm') && ($postInfo['post_user'] > 0))
{
return $tp->parseTemplate("{SENDPM={$postInfo['post_user']}}");
}
SC_END
@@ -99,18 +127,18 @@ return '';
SC_END
SC_BEGIN EMAILITEM
global $post_info, $tp;
if($post_info['thread_parent'] == 0)
global $postInfo, $tp;
if($postInfo['thread_start'])
{
return $tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$post_info['thread_id']}}");
return $tp->parseTemplate("{EMAIL_ITEM=".FORLAN_101."^plugin:forum.{$postInfo['post_thread']}}");
}
SC_END
SC_BEGIN PRINTITEM
global $post_info, $tp;
if($post_info['thread_parent'] == 0)
global $postInfo, $tp;
if($postInfo['thread_start'])
{
return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$post_info['thread_id']}}");
return $tp->parseTemplate("{PRINT_ITEM=".FORLAN_102."^plugin:forum.{$postInfo['post_thread']}}");
}
SC_END
@@ -130,11 +158,10 @@ return ($postInfo['user_signature'] ? "<br /><hr style='width:15%; text-align:le
SC_END
SC_BEGIN PROFILEIMG
global $post_info, $tp;
if (USER && $post_info['user_id']) {
return $tp->parseTemplate("{PROFILE={$post_info['user_id']}}");
} else {
return "";
global $postInfo, $tp;
if (USER && $postInfo['user_name'])
{
return $tp->parseTemplate("{PROFILE={$postInfo['post_user']}}");
}
SC_END
@@ -147,9 +174,10 @@ if ($postInfo['post_user'])
SC_END
SC_BEGIN VISITS
global $post_info;
if ($post_info['user_id']) {
return LAN_09.": ".$post_info['user_visits']."<br />";
global $postInfo;
if ($postInfo['user_name'])
{
return LAN_09.': '.$postInfo['user_visits'].'<br />';
}
SC_END
@@ -163,16 +191,17 @@ if ($postInfo['user_customtitle'])
SC_END
SC_BEGIN WEBSITE
global $post_info, $tp;
if ($post_info['user_homepage']) {
return LAN_08.": ".$post_info['user_homepage']."<br />";
global $postInfo, $tp;
if ($postInfo['user_homepage']) {
return LAN_08.': '.$postInfo['user_homepage'].'<br />';
}
SC_END
SC_BEGIN WEBSITEIMG
global $post_info;
if ($post_info['user_homepage'] && $post_info['user_homepage'] != "http://") {
return "<a href='{$post_info['user_homepage']}'>".IMAGE_website."</a>";
global $postInfo;
if ($postInfo['user_homepage'] && $postInfo['user_homepage'] != 'http://')
{
return "<a href='{$postInfo['user_homepage']}'>".IMAGE_website.'</a>';
}
SC_END
@@ -209,8 +238,8 @@ if (USER) {
SC_END
SC_BEGIN RPG
global $post_info;
return rpg($post_info['user_join'],$post_info['user_forums']);
global $postInfo;
return rpg($postInfo['user_join'],$postInfo['user_plugin_forum_posts']);
SC_END
SC_BEGIN MEMBERID
@@ -263,8 +292,9 @@ return $ldata[$post_info['user_id']][1];
SC_END
SC_BEGIN MODOPTIONS
if (MODERATOR) {
return showmodoptions();
if (MODERATOR)
{
return showmodoptions();
}
SC_END
@@ -274,7 +304,6 @@ if ($postInfo['post_edit_datestamp'])
{
return $gen->convert_date($postInfo['thread_edit_datestamp'],'forum');
}
return '';
SC_END
SC_BEGIN LASTEDITBY

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.9 $
| $Date: 2008-12-07 04:16:38 $
| $Revision: 1.10 $
| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -45,6 +45,13 @@ $thread = new e107ForumThread;
$thread->init();
if(isset($_POST['track_toggle']))
{
$thread->toggle_track();
exit;
}
//print_a($_POST);
if(isset($_GET['f']))
{
$thread->processFunction();
@@ -92,7 +99,6 @@ if (MODERATOR && isset($_POST['mod']))
$postList = $forum->PostGet($thread->threadId, $thread->page * $thread->perPage, $thread->perPage);
//var_dump($thread->threadInfo);
require_once (HEADERF);
require_once (e_HANDLER . 'level_handler.php');
$gen = new convert;
if ($thread->message)
@@ -143,19 +149,25 @@ $NEXTPREV .= "<a href='" . $e107->url->getUrl('forum', 'thread', array('func' =>
if ($pref['forum_track'] && USER)
{
$img = ($thread->threadInfo['track_userid'] ? IMAGE_track : IMAGE_untrack);
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track_toggle', 'id' => $thread->threadId));
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
$TRACK .= "
<span id='forum-track-trigger-container'>
<a href='{$url}' id='forum-track-trigger'>{$img}</a>
</span>
<script type='text/javascript'>
e107.runOnLoad(function(){
//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', '{$url}', {
method: 'post',
parameters: { //send query parameters here
'track_toggle': 1
},
overlayPage: $(document.body)
});
});
}, document, true);
</script>
";
}
@@ -206,6 +218,7 @@ foreach ($postList as $postInfo)
if ($i > 1)
{
$postInfo['thread_start'] = false;
$alt = !$alt;
if (isset($FORUMREPLYSTYLE_ALT) && $alt)
{
@@ -218,6 +231,7 @@ foreach ($postList as $postInfo)
}
else
{
$postInfo['thread_start'] = true;
$forthr = $e107->tp->parseTemplate($FORUMTHREADSTYLE, true, $forum_shortcodes) . "\n";
}
}
@@ -247,6 +261,7 @@ if ($forum->checkPerm($thread->threadInfo['thread_forum_id'], 'post') && $thread
$forend = preg_replace("/\{(.*?)\}/e", '$\1', $FORUMEND);
$forumstring = $forstr . $forthr . $forrep . $forend;
require_once (HEADERF);
//If last post came after USERLV and not yet marked as read, mark the thread id as read
if ($thread->threadInfo['thread_lastpost'] > USERLV && (strpos($currentUser['user_plugin_forum_viewed'], '.' . $thread->threadId . '.') === false))
{
@@ -457,6 +472,29 @@ class e107ForumThread
$this->noInc = false;
}
function toggle_track()
{
global $forum, $thread;
$e107 = e107::getInstance();
if (!USER || !isset($_GET['id'])) { return; }
if($thread->threadInfo['track_userid'])
{
$forum->track('del', USERID, $_GET['id']);
$img = IMAGE_untrack;
}
else
{
$forum->track('add', USERID, $_GET['id']);
$img = IMAGE_track;
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'view', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
}
function processFunction()
{
global $forum, $thread;
@@ -487,7 +525,7 @@ class e107ForumThread
exit;
}
break;
/*
case 'track':
if (!USER || !isset($_GET['id'])) { return; }
$forum->track('add', USERID, $_GET['id']);
@@ -510,27 +548,7 @@ class e107ForumThread
exit();
}
break;
case 'track_toggle':
if (!USER || !isset($_GET['id'])) { return; }
if($thread->threadInfo['track_userid'])
{
$forum->track('del', USERID, $_GET['id']);
$img = IMAGE_untrack;
}
else
{
$forum->track('add', USERID, $_GET['id']);
$img = IMAGE_track;
}
if(e_AJAX_REQUEST)
{
$url = $e107->url->getUrl('forum', 'thread', array('func' => 'track_toggle', 'id' => $thread->threadId));
echo "<a href='{$url}' id='forum-track-trigger'>{$img}</a>";
exit();
}
break;
*/
case 'last':
// $pref['forum_postspage'] = ($pref['forum_postspage'] ? $pref['forum_postspage'] : 10);

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_plugins/forum/templates/forum_icons_template.php,v $
| $Revision: 1.4 $
| $Date: 2008-12-07 04:16:39 $
| $Revision: 1.5 $
| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -51,6 +51,7 @@ 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_attachment", "<img src='".img_path('attach.png')."' alt='' title='' style='border:0' />");
define("IMAGE_track", "<img src='".img_path('track.png')."' alt='".LAN_392."' title='".LAN_392."' style='border:0' />");
define("IMAGE_untrack", "<img src='".img_path('untrack.png')."' alt='".LAN_391."' title='".LAN_391."' style='border:0' />");

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.2 $
| $Date: 2006-12-16 14:13:28 $
| $Revision: 1.3 $
| $Date: 2008-12-08 02:33:34 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -27,6 +27,9 @@ $sc_style['LASTEDIT']['post'] = " ]</span>";
$sc_style['LEVEL']['pre'] = "<div class='spacer'>";
$sc_style['LEVEL']['post'] = "</div>";
$sc_style['ATTACHMENTS']['pre'] = "<div id='forum_attachments'><br />";
$sc_style['ATTACHMENTS']['post'] = "</div>";
$sc_style['ANON_IP']['pre'] = "<br /><div class='smalltext'>";
$sc_style['ANON_IP']['post'] = "</div>";
@@ -104,7 +107,7 @@ $FORUMTHREADSTYLE = "<tr>
{THREADDATESTAMP}
</td>
<td style='text-align:right'>
{REPORTIMG}{EDITIMG}{QUOTEIMG}
{EMAILITEM} {PRINTITEM} {REPORTIMG}{EDITIMG}{QUOTEIMG}
</td>
</tr>
</table>
@@ -125,6 +128,7 @@ $FORUMTHREADSTYLE = "<tr>
</td>
<td class='forumheader3' style='vertical-align:top'>{POLL}
{POST}
{ATTACHMENTS}
{LASTEDIT}
{SIGNATURE}
</td>
@@ -210,6 +214,7 @@ $FORUMREPLYSTYLE = "<tr>
</div>
</td>
<td class='forumheader3' style='vertical-align:top'>{POST}
{ATTACHMENTS}
{LASTEDIT}
{SIGNATURE}
</td>