skala
Julio Montoya 14 years ago
commit b059ef2899
  1. 22
      main/forum/forumfunction.inc.php
  2. 18
      main/forum/newthread.php
  3. 23
      main/forum/reply.php
  4. 31
      main/forum/viewthread.php

@ -2293,7 +2293,8 @@ function store_reply($values) {
$upload_ok = process_uploaded_file($_FILES['user_upload']);
$has_attachment = true;
}
$return = array();
if ($upload_ok) {
// We first store an entry in the forum_post table.
$sql = "INSERT INTO $table_posts (post_title, post_text, thread_id, forum_id, poster_id, post_date, post_notification, post_parent_id, visible)
@ -2323,7 +2324,8 @@ function store_reply($values) {
$file_name = $_FILES['user_upload']['name'];
if (!filter_extension($new_file_name)) {
Display :: display_error_message(get_lang('UplUnableToSaveFileFilteredExtension'));
$return['msg'] = get_lang('UplUnableToSaveFileFilteredExtension');
$return['type'] = 'error';
} else {
$new_file_name = uniqid('');
$new_path = $updir.'/'.$new_file_name;
@ -2352,28 +2354,28 @@ function store_reply($values) {
if ($current_forum['approval_direct_post'] == '1' && !api_is_allowed_to_edit(null, true)) {
$message .= '<br />'.get_lang('MessageHasToBeApproved').'<br />';
}
$message .= '<br />'.get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.$values['forum_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'">'.get_lang('Forum').'</a><br />';
$message .= get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.$values['forum_id'].'&amp;thread='.$values['thread_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.get_lang('Message').'</a>';
//$message .= '<br />'.get_lang('ReturnTo').' <a href="viewforum.php?'.api_get_cidreq().'&amp;forum='.$values['forum_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'">'.get_lang('Forum').'</a><br />';
//$message .= get_lang('ReturnTo').' <a href="viewthread.php?'.api_get_cidreq().'&amp;forum='.$values['forum_id'].'&amp;thread='.$values['thread_id'].'&amp;gidReq='.$_SESSION['toolgroup'].'&amp;origin='.$origin.'&amp;gradebook='.$gradebook.'">'.get_lang('Message').'</a>';
// Setting the notification correctly.
$my_post_notification = isset($values['post_notification']) ? $values['post_notification'] : null;
if ($my_post_notification == 1) {
set_notification('thread', $values['thread_id'], true);
}
send_notification_mails($values['thread_id'], $values);
session_unregister('formelements');
session_unregister('origin');
session_unregister('breadcrumbs');
session_unregister('addedresource');
session_unregister('addedresourceid');
Display::display_confirmation_message($message,false);
$return['msg'] = $message;
$return['type'] = 'confirmation';
} else {
Display::display_error_message(get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst'));
$return['msg'] = get_lang('UplNoFileUploaded').' '. get_lang('UplSelectFileFirst');
$return['type'] = 'error';
}
return $return;
}
/**

@ -55,12 +55,10 @@ if (isset($_GET['origin'])) {
// javascript
$htmlHeadXtra[] = '<script>
function advanced_parameters() {
if(document.getElementById(\'id_qualify\').style.display == \'none\') {
if(document.getElementById(\'id_qualify\').style.display == \'none\') {
document.getElementById(\'id_qualify\').style.display = \'block\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_hide.gif',get_lang('Hide'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
} else {
document.getElementById(\'id_qualify\').style.display = \'none\';
document.getElementById(\'img_plus_and_minus\').innerHTML=\'&nbsp;'.Display::return_icon('div_show.gif',get_lang('Show'),array('style'=>'vertical-align:middle')).'&nbsp;'.get_lang('AdvancedParameters').'\';
@ -105,7 +103,7 @@ if ($origin == 'group') {
$interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook, 'name' => $nameTools);
$interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']);
$interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[] = array('url' => 'newthread.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => get_lang('NewTopic'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('NewTopic'));
}
/* Resource Linker */
@ -170,17 +168,17 @@ handle_forum_and_forumcategories();
// Action links
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
/*
if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('Groups'),'','32').'</a>';
} else {
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png',get_lang('BackToForumOverview'),'','32').'</a>';
}
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin=group">'.Display::return_icon('forum.png',get_lang('BackToForum'),'','32').'</a>';
}*/
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'">'.Display::return_icon('back.png',get_lang('BackToForum'),'','32').'</a>';
echo '</div>';
/* Display Forum Category and the Forum information */
/*
echo "<table class=\"data_table\" width=\"100%\">\n";
if ($origin != 'learnpath') {
@ -199,7 +197,7 @@ if ($origin != 'learnpath') {
echo "</tr>\n";
}
echo '</table>';
*/
$values = show_add_post_form('newthread', '', isset($_SESSION['formelements']) ? $_SESSION['formelements'] : null);
if (!empty($values) && isset($values['SubmitPost'])) {
@ -211,4 +209,4 @@ if (!empty($values) && isset($values['SubmitPost'])) {
if ($origin != 'learnpath') {
Display :: display_footer();
}
}

@ -95,7 +95,7 @@ if ($origin == 'group') {
$interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'], 'name' => $current_forum_category['cat_title']);
$interbreadcrumb[] = array('url' => 'viewforum.php?origin='.$origin.'&amp;forum='.Security::remove_XSS($_GET['forum']), 'name' => $current_forum['forum_title']);
$interbreadcrumb[] = array('url' => 'viewthread.php?origin='.$origin.'&amp;gradebook='.$gradebook.'&amp;forum='.Security::remove_XSS($_GET['forum']).'&amp;thread='.Security::remove_XSS($_GET['thread']), 'name' => $current_thread['thread_title']);
$interbreadcrumb[] = array('url' => 'javascript: void(0);', 'name' => get_lang('Reply'));
$interbreadcrumb[] = array('url' => '#', 'name' => get_lang('Reply'));
}
/* Resource Linker */
@ -149,23 +149,24 @@ if (!$_user['user_id'] AND $current_forum['allow_anonymous'] == 0) {
if ($origin != 'learnpath') {
echo '<div class="actions">';
echo '<span style="float:right;">'.search_link().'</span>';
if ($origin == 'group') {
/*if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', '32').'</a>';
} else {
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
}
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('thread.png', get_lang('BackToThread'), '', '32').'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';*/
echo '<a href="viewthread.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gradebook='.$gradebook.'&amp;thread='.Security::remove_XSS($_GET['thread']).'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;origin='.$origin.'">'.Display::return_icon('back.png', get_lang('BackToThread'), '', '32').'</a>';
echo '</div>';
} else {
echo '<div style="height:15px">&nbsp;</div>';
}
/* Display Forum Category and the Forum information */
/*
echo "<table class=\"data_table\" width=\"100%\">";
// The forum category
echo "<tr><th style=\"padding-left:5px;\" align=\"left\" colspan=\"2\">";
echo '<span class="forum_title">'.prepare4display($current_thread['thread_title']).'</span><br />';
@ -175,7 +176,7 @@ if (!empty ($current_forum_category['cat_title'])) {
echo "</th>";
echo "</tr>";
echo '</table>';
*/
// The form for the reply
$my_action = isset($_GET['action']) ? Security::remove_XSS($_GET['action']) : '';
$my_post = isset($_GET['post']) ? Security::remove_XSS($_GET['post']) : '';
@ -184,7 +185,15 @@ $my_elements = isset($_SESSION['formelements']) ? $_SESSION['formelements'] : ''
$values = show_add_post_form($my_action, $my_post, $my_elements); // Note: This has to be cleaned first.
if (!empty($values) AND isset($_POST['SubmitPost'])) {
store_reply($values);
$result = store_reply($values);
//@todo split the show_add_post_form function
$url = 'viewthread.php?forum='.$current_thread['forum_id'].'&gradebook='.$gradebook.'&thread='.intval($_GET['thread']).'&gidReq='.api_get_group_id().'&origin='.$origin.'&msg='.$result['msg'].'&type='.$result['type'];
echo '
<script type="text/javascript">
window.location = "'.$url.'";
</script>';
//header('Location: );
}
if ($origin != 'learnpath') {

@ -72,15 +72,15 @@ if ($origin == 'group') {
//api_display_tool_title($nameTools);
} else {
$my_search = isset($_GET['search']) ? $_GET['search'] : '';
if ($origin == 'learnpath') {
require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
} else {
} else {
$interbreadcrumb[] = array('url' => 'index.php?gradebook='.$gradebook.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => $nameTools);
$interbreadcrumb[] = array('url' => 'viewforumcategory.php?forumcategory='.$current_forum_category['cat_id'].'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum_category['cat_title']));
$interbreadcrumb[] = array('url' => 'viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;origin='.$origin.'&amp;search='.Security::remove_XSS(urlencode($my_search)), 'name' => Security::remove_XSS($current_forum['forum_title']));
$interbreadcrumb[] = array('url' => '#', 'name' => Security::remove_XSS($current_thread['thread_title']));
$message = isset($message) ? $message : '';
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header('');
@ -133,13 +133,14 @@ if ($my_message != 'PostDeletedSpecial') {
echo '<span style="float:right;">'.search_link().'</span>';
if ($origin != 'learnpath') {
if ($origin == 'group') {
/*if ($origin == 'group') {
echo '<a href="../group/group_space.php?'.api_get_cidreq().'&amp;gidReq='.Security::remove_XSS($_GET['gidReq']).'&amp;gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('Groups'), '', '32').'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'&amp;origin='.$origin.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
} else {
echo '<a href="index.php?gradebook='.$gradebook.'">'.Display::return_icon('back.png', get_lang('BackToForumOverview'), '', '32').'</a>';
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'">'.Display::return_icon('forum.png', get_lang('BackToForum'), '', '32').'</a>';
}
}*/
echo '<a href="viewforum.php?forum='.Security::remove_XSS($_GET['forum']).'&amp;gidReq='.$session_toolgroup.'">'.Display::return_icon('back.png', get_lang('BackToForum'), '', '32').'</a>';
}
// The reply to thread link should only appear when the forum_category is not locked AND the forum is not locked AND the thread is not locked.
@ -202,7 +203,7 @@ if ($my_message != 'PostDeletedSpecial') {
// Note pcool: I tried to use only one sql statement (and function) for this,
// but the problem is that the visibility of the forum AND forum cateogory are stored in the item_property table.
echo '<table class="forum_table_title" width="100%">';
/*echo '<table class="forum_table_title" width="100%">';
// The thread
echo '<tr><th style="padding:5px;" align="left" colspan="6">';
@ -213,13 +214,19 @@ if ($my_message != 'PostDeletedSpecial') {
echo '</span>';
echo '</div>';
if ($origin != 'learnpath') {
//echo '<span class="forum_low_description">'.prepare4display($current_forum_category['cat_title']).' ';
}
echo '</th></tr>';
echo '</table>';
echo '</table>';*/
if (isset($_GET['msg']) && isset($_GET['type'])) {
switch($_GET['type']) {
case 'error':
Display::display_error_message($_GET['msg']);
break;
case 'confirmation':
Display::display_confirmation_message($_GET['msg']);
break;
}
}
switch ($viewmode) {
case 'flat':

Loading…
Cancel
Save