Minor - Format code - refs BT#12514

pull/2487/head
Angel Fernando Quiroz Campos 9 years ago
parent d923568cf4
commit a2370cceb7
  1. 327
      main/forum/forumqualify.php

@ -2,8 +2,8 @@
/* For licensing terms, see /license.txt */ /* For licensing terms, see /license.txt */
/** /**
* @package chamilo.forum * @package chamilo.forum
* @todo fix all this qualify files avoid including files, use classes POO jmontoya * @todo fix all this qualify files avoid including files, use classes POO jmontoya
*/ */
require_once __DIR__.'/../inc/global.inc.php'; require_once __DIR__.'/../inc/global.inc.php';
@ -60,12 +60,12 @@ $groupId = api_get_group_id();
/* /*
Header and Breadcrumbs Header and Breadcrumbs
*/ */
if (isset($_SESSION['gradebook'])){ if (isset($_SESSION['gradebook'])) {
$gradebook= $_SESSION['gradebook']; $gradebook = $_SESSION['gradebook'];
} }
if (!empty($gradebook) && $gradebook=='view') { if (!empty($gradebook) && $gradebook == 'view') {
$interbreadcrumb[]= array ( $interbreadcrumb[] = array(
'url' => '../gradebook/'.$_SESSION['gradebook_dest'], 'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
'name' => get_lang('ToolGradebook') 'name' => get_lang('ToolGradebook')
); );
@ -75,21 +75,21 @@ if ($origin == 'learnpath') {
Display::display_reduced_header(); Display::display_reduced_header();
} else { } else {
if (!empty($groupId)) { if (!empty($groupId)) {
$group_properties = GroupManager::get_group_properties($groupId); $group_properties = GroupManager::get_group_properties($groupId);
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
"url" => "../group/group.php?".api_get_cidreq(), "url" => "../group/group.php?".api_get_cidreq(),
"name" => get_lang('Groups') "name" => get_lang('Groups')
); );
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
"url" => "../group/group_space.php?".api_get_cidreq(), "url" => "../group/group_space.php?".api_get_cidreq(),
"name"=> get_lang('GroupSpace').' ('.$group_properties['name'].')' "name" => get_lang('GroupSpace').' ('.$group_properties['name'].')'
); );
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
"url" => "viewforum.php?".api_get_cidreq()."&forum=".intval($_GET['forum'])."&search=".Security::remove_XSS(urlencode($_GET['search'])), "url" => "viewforum.php?".api_get_cidreq()."&forum=".intval($_GET['forum'])."&search=".Security::remove_XSS(urlencode($_GET['search'])),
"name" => prepare4display($currentForum['forum_title']) "name" => prepare4display($currentForum['forum_title'])
); );
if ($message <> 'PostDeletedSpecial') { if ($message <> 'PostDeletedSpecial') {
$interbreadcrumb[]= array( $interbreadcrumb[] = array(
"url" => "viewthread.php?".api_get_cidreq()."&forum=".intval($_GET['forum'])."&gradebook=".$gradebook."&thread=".intval($_GET['thread']), "url" => "viewthread.php?".api_get_cidreq()."&forum=".intval($_GET['forum'])."&gradebook=".$gradebook."&thread=".intval($_GET['thread']),
"name" => prepare4display($currentThread['thread_title']) "name" => prepare4display($currentThread['thread_title'])
); );
@ -101,14 +101,15 @@ if ($origin == 'learnpath') {
); );
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
Display :: display_header(''); Display::display_header('');
api_display_tool_title($nameTools); api_display_tool_title($nameTools);
} else { } else {
$search = isset($_GET['search']) ? Security::remove_XSS(urlencode($_GET['search'])) : ''; $search = isset($_GET['search']) ? Security::remove_XSS(urlencode($_GET['search'])) : '';
$info_thread = get_thread_information($currentForum['forum_id'], $_GET['thread']); $info_thread = get_thread_information($currentForum['forum_id'], $_GET['thread']);
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
"url" => "index.php?".api_get_cidreq()."&search=".$search, "url" => "index.php?".api_get_cidreq()."&search=".$search,
"name" => $nameTools); "name" => $nameTools
);
$interbreadcrumb[] = array( $interbreadcrumb[] = array(
"url" => "viewforumcategory.php?".api_get_cidreq()."&forumcategory=".$currentForumCategory['cat_id']."&search=".$search, "url" => "viewforumcategory.php?".api_get_cidreq()."&forumcategory=".$currentForumCategory['cat_id']."&search=".$search,
"name" => prepare4display($currentForumCategory['cat_title']) "name" => prepare4display($currentForumCategory['cat_title'])
@ -133,8 +134,8 @@ if ($origin == 'learnpath') {
} }
} }
// the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string // the last element of the breadcrumb navigation is already set in interbreadcrumb, so give empty string
$interbreadcrumb[]=array("url" => "#", "name" => get_lang('QualifyThread')); $interbreadcrumb[] = array("url" => "#", "name" => get_lang('QualifyThread'));
Display :: display_header(''); Display::display_header('');
} }
} }
@ -143,7 +144,7 @@ if ($origin == 'learnpath') {
*/ */
$action = isset($_GET['action']) ? $_GET['action'] : ''; $action = isset($_GET['action']) ? $_GET['action'] : '';
if ($action =='delete' && if ($action == 'delete' &&
isset($_GET['content']) && isset($_GET['content']) &&
isset($_GET['id']) && api_is_allowed_to_edit(false, true) isset($_GET['id']) && api_is_allowed_to_edit(false, true)
) { ) {
@ -162,189 +163,189 @@ if ($action == 'move' && isset($_GET['post'])) {
Display the action messages Display the action messages
*/ */
if (!empty($message)) { if (!empty($message)) {
Display :: display_confirmation_message(get_lang($message)); Display:: display_confirmation_message(get_lang($message));
} }
$currentThread = get_thread_information($currentForum['forum_id'], $_GET['thread']); $currentThread = get_thread_information($currentForum['forum_id'], $_GET['thread']);
$threadId = $currentThread['thread_id']; $threadId = $currentThread['thread_id'];
// Show max qualify in my form // Show max qualify in my form
$maxQualify = showQualify('2', $userIdToQualify, $threadId); $maxQualify = showQualify('2', $userIdToQualify, $threadId);
$score = isset($_POST['idtextqualify']) ? Security::remove_XSS($_POST['idtextqualify']) : '';
if ($score > $maxQualify) { $score = isset($_POST['idtextqualify']) ? Security::remove_XSS($_POST['idtextqualify']) : '';
Display:: display_error_message(
get_lang('QualificationCanNotBeGreaterThanMaxScore'),
false
);
}
if (!empty($score)) { if ($score > $maxQualify) {
$saveResult = saveThreadScore( Display:: display_error_message(
$currentThread, get_lang('QualificationCanNotBeGreaterThanMaxScore'),
$userIdToQualify, false
$threadId, );
$score, }
api_get_utc_datetime(),
api_get_session_id()
);
}
// show qualifications history if (!empty($score)) {
$type = isset($_GET['type']) ? $_GET['type'] : ''; $saveResult = saveThreadScore(
$historyList = getThreadScoreHistory( $currentThread,
$userIdToQualify, $userIdToQualify,
$threadId, $threadId,
$type $score,
api_get_utc_datetime(),
api_get_session_id()
); );
}
$counter = count($historyList); // show qualifications history
$type = isset($_GET['type']) ? $_GET['type'] : '';
$historyList = getThreadScoreHistory(
$userIdToQualify,
$threadId,
$type
);
// Show current qualify in my form $counter = count($historyList);
$qualify = current_qualify_of_thread(
$threadId,
api_get_session_id(),
$_GET['user']
);
$result = get_statistical_information( // Show current qualify in my form
$threadId, $qualify = current_qualify_of_thread(
$_GET['user_id'], $threadId,
api_get_course_int_id() api_get_session_id(),
); $_GET['user']
);
$url = api_get_path(WEB_CODE_PATH).'forum/forumqualify.php?'. $result = get_statistical_information(
api_get_cidreq().'&forum='.intval($_GET['forum']).'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user']); $threadId,
$_GET['user_id'],
$userToQualifyInfo = api_get_user_info($userIdToQualify); api_get_course_int_id()
$form = new FormValidator('forum-thread-qualify', 'post', $url); );
$form->addHeader($userToQualifyInfo['complete_name']);
$form->addLabel(get_lang('Thread'), $currentThread['thread_title']);
$form->addLabel(get_lang('CourseUsers'), $result['user_course']);
$form->addLabel(get_lang('PostsNumber'), $result['post']);
$form->addLabel(get_lang('NumberOfPostsForThisUser'), $result['user_post']);
$form->addLabel(
get_lang('AveragePostPerUser'),
round($result['user_post'] / $result['post'], 2)
);
$form->addText(
'idtextqualify',
array(get_lang('Qualification'), get_lang('MaxScore').' '.$maxQualify),
$qualify
);
$course = api_get_course_info(); $url = api_get_path(WEB_CODE_PATH).'forum/forumqualify.php?'.
api_get_cidreq().'&forum='.intval($_GET['forum']).'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user']);
$userToQualifyInfo = api_get_user_info($userIdToQualify);
$form = new FormValidator('forum-thread-qualify', 'post', $url);
$form->addHeader($userToQualifyInfo['complete_name']);
$form->addLabel(get_lang('Thread'), $currentThread['thread_title']);
$form->addLabel(get_lang('CourseUsers'), $result['user_course']);
$form->addLabel(get_lang('PostsNumber'), $result['post']);
$form->addLabel(get_lang('NumberOfPostsForThisUser'), $result['user_post']);
$form->addLabel(
get_lang('AveragePostPerUser'),
round($result['user_post'] / $result['post'], 2)
);
$form->addText(
'idtextqualify',
array(get_lang('Qualification'), get_lang('MaxScore').' '.$maxQualify),
$qualify
);
$rows = get_thread_user_post($course['code'], $currentThread['thread_id'], $_GET['user']); $course = api_get_course_info();
if (isset($rows)) {
$counter = 1;
foreach ($rows as $row) {
if ($row['status']=='0') {
$style =" id = 'post".$post_en."' class=\"hide-me\" style=\"border:1px solid red; display:none; background-color:#F7F7F7; width:95%; margin: 0px 0px 4px 40px; \" ";
} else {
$style = '';
$post_en = $row['post_parent_id'];
}
if ($row['user_id'] == '0') { $rows = get_thread_user_post($course['code'], $currentThread['thread_id'], $_GET['user']);
$name = prepare4display($row['poster_name']); if (isset($rows)) {
} else { $counter = 1;
$name = api_get_person_name($row['firstname'], $row['lastname']); foreach ($rows as $row) {
} if ($row['status'] == '0') {
if ($counter == 1) { $style = " id = 'post".$post_en."' class=\"hide-me\" style=\"border:1px solid red; display:none; background-color:#F7F7F7; width:95%; margin: 0px 0px 4px 40px; \" ";
echo Display::page_subheader($name); } else {
} $style = '';
$post_en = $row['post_parent_id'];
}
echo "<div ".$style."><table class=\"data_table\">"; if ($row['user_id'] == '0') {
$name = prepare4display($row['poster_name']);
} else {
$name = api_get_person_name($row['firstname'], $row['lastname']);
}
if ($counter == 1) {
echo Display::page_subheader($name);
}
if ($row['visible'] == '0') { echo "<div ".$style."><table class=\"data_table\">";
$titleclass = 'forum_message_post_title_2_be_approved';
$messageclass = 'forum_message_post_text_2_be_approved';
$leftclass = 'forum_message_left_2_be_approved';
} else {
$titleclass = 'forum_message_post_title';
$messageclass = 'forum_message_post_text';
$leftclass = 'forum_message_left';
}
echo "<tr>"; if ($row['visible'] == '0') {
echo "<td rowspan=\"3\" class=\"$leftclass\">"; $titleclass = 'forum_message_post_title_2_be_approved';
$messageclass = 'forum_message_post_text_2_be_approved';
$leftclass = 'forum_message_left_2_be_approved';
} else {
$titleclass = 'forum_message_post_title';
$messageclass = 'forum_message_post_text';
$leftclass = 'forum_message_left';
}
echo '<br /><b>'. api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG).'</b><br />'; echo "<tr>";
echo "<td rowspan=\"3\" class=\"$leftclass\">";
echo "</td>"; echo '<br /><b>'.api_convert_and_format_date($row['post_date'], DATE_TIME_FORMAT_LONG).'</b><br />';
// The post title echo "</td>";
echo "<td class=\"$titleclass\">".prepare4display($row['post_title'])."</td>";
echo "</tr>";
// The post message // The post title
echo "<tr >"; echo "<td class=\"$titleclass\">".prepare4display($row['post_title'])."</td>";
echo "<td class=\"$messageclass\">".prepare4display($row['post_text'])."</td>"; echo "</tr>";
echo "</tr>";
// The check if there is an attachment // The post message
$attachment_list = get_attachment($row['post_id']); echo "<tr >";
echo "<td class=\"$messageclass\">".prepare4display($row['post_text'])."</td>";
echo "</tr>";
if (!empty($attachment_list)) { // The check if there is an attachment
echo '<tr ><td height="50%">'; $attachment_list = get_attachment($row['post_id']);
$realname = $attachment_list['path'];
$user_filename = $attachment_list['filename'];
echo Display::return_icon('attachment.gif', get_lang('Attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span><br />';
echo '</td></tr>';
}
echo "</table></div>"; if (!empty($attachment_list)) {
$counter++; echo '<tr ><td height="50%">';
$realname = $attachment_list['path'];
$user_filename = $attachment_list['filename'];
echo Display::return_icon('attachment.gif', get_lang('Attachment'));
echo '<a href="download.php?file=';
echo $realname;
echo ' "> '.$user_filename.' </a>';
echo '<span class="forum_attach_comment" >'.$attachment_list['comment'].'</span><br />';
echo '</td></tr>';
} }
echo "</table></div>";
$counter++;
} }
}
$form->addButtonSave(get_lang('QualifyThisThread')); $form->addButtonSave(get_lang('QualifyThisThread'));
$form->setDefaults(array('idtextqualify' => $qualify)); $form->setDefaults(array('idtextqualify' => $qualify));
$form->display(); $form->display();
// Show past data // Show past data
if (api_is_allowed_to_edit() && $counter > 0) { if (api_is_allowed_to_edit() && $counter > 0) {
if (isset($_GET['gradebook'])) { if (isset($_GET['gradebook'])) {
$view_gradebook='&gradebook=view'; $view_gradebook = '&gradebook=view';
} }
echo '<h4>'.get_lang('QualificationChangesHistory').'</h4>'; echo '<h4>'.get_lang('QualificationChangesHistory').'</h4>';
if (isset($_GET['type']) && $_GET['type'] === 'false') { if (isset($_GET['type']) && $_GET['type'] === 'false') {
$buttons = '<a class="btn btn-default" href="forumqualify.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&origin='.$origin.'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user_id']).'&type=true&idtextqualify='.$score.$view_gradebook.'#history">'. $buttons = '<a class="btn btn-default" href="forumqualify.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&origin='.$origin.'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user_id']).'&type=true&idtextqualify='.$score.$view_gradebook.'#history">'.
get_lang('MoreRecent').'</a> <a class="btn btn-default disabled" >'.get_lang('Older').'</a>'; get_lang('MoreRecent').'</a> <a class="btn btn-default disabled" >'.get_lang('Older').'</a>';
} else { } else {
$buttons = '<a class="btn btn-default">'.get_lang('MoreRecent').'</a> $buttons = '<a class="btn btn-default">'.get_lang('MoreRecent').'</a>
<a class="btn btn-default" href="forumqualify.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&origin='.$origin.'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user_id']).'&type=false&idtextqualify='.$score.$view_gradebook.'#history">'. <a class="btn btn-default" href="forumqualify.php?'.api_get_cidreq().'&forum='.intval($_GET['forum']).'&origin='.$origin.'&thread='.$threadId.'&user='.intval($_GET['user']).'&user_id='.intval($_GET['user_id']).'&type=false&idtextqualify='.$score.$view_gradebook.'#history">'.
get_lang('Older').'</a>'; get_lang('Older').'</a>';
} }
$table_list = '<br /><div class="btn-group">'.$buttons.'</div>'; $table_list = '<br /><div class="btn-group">'.$buttons.'</div>';
$table_list .= '<br /><table class="table">'; $table_list .= '<br /><table class="table">';
$table_list .= '<tr>'; $table_list .= '<tr>';
$table_list .= '<th width="50%">'.get_lang('WhoChanged').'</th>'; $table_list .= '<th width="50%">'.get_lang('WhoChanged').'</th>';
$table_list .= '<th width="10%">'.get_lang('NoteChanged').'</th>'; $table_list .= '<th width="10%">'.get_lang('NoteChanged').'</th>';
$table_list .= '<th width="40%">'.get_lang('DateChanged').'</th>'; $table_list .= '<th width="40%">'.get_lang('DateChanged').'</th>';
$table_list .= '</tr>'; $table_list .= '</tr>';
for ($i = 0; $i < count($historyList); $i++) { for ($i = 0; $i < count($historyList); $i++) {
$userInfo = api_get_user_info($historyList[$i]['qualify_user_id']); $userInfo = api_get_user_info($historyList[$i]['qualify_user_id']);
$table_list .= '<tr><td>'.$userInfo['complete_name'].'</td>'; $table_list .= '<tr><td>'.$userInfo['complete_name'].'</td>';
$table_list .= '<td>'.$historyList[$i]['qualify'].'</td>'; $table_list .= '<td>'.$historyList[$i]['qualify'].'</td>';
$table_list .= '<td>'.api_convert_and_format_date( $table_list .= '<td>'.api_convert_and_format_date(
$historyList[$i]['qualify_time'], $historyList[$i]['qualify_time'],
DATE_TIME_FORMAT_LONG DATE_TIME_FORMAT_LONG
); );
$table_list .= '</td></tr>'; $table_list .= '</td></tr>';
}
$table_list.= '</table>';
echo $table_list;
} }
$table_list .= '</table>';
echo $table_list;
}
if ($origin!='learnpath') { if ($origin != 'learnpath') {
Display :: display_footer(); Display:: display_footer();
} }

Loading…
Cancel
Save