Fix forum template see BT#12987

pull/2487/head
jmontoyaa 9 years ago
parent 3bd75b822c
commit 0af1c76669
  1. 32
      main/forum/forumfunction.inc.php
  2. 12
      main/forum/index.php
  3. 143
      main/template/default/forum/list.tpl

@ -110,9 +110,11 @@ function handle_forum_and_forumcategories($lp_id = null)
$get_content = 'forumcategory';
}
$content = '';
// Adding a forum category
if (($action_forum_cat == 'add' && $get_content == 'forumcategory') || $post_submit_cat) {
show_add_forumcategory_form(array(), $lp_id); //$lp_id when is called from learning path
$content = show_add_forumcategory_form([], $lp_id); //$lp_id when is called from learning path
}
// Adding a forum
@ -122,13 +124,13 @@ function handle_forum_and_forumcategories($lp_id = null)
} else {
$inputvalues = array();
}
show_add_forum_form($inputvalues, $lp_id);
$content = show_add_forum_form($inputvalues, $lp_id);
}
// Edit a forum category
if (($action_forum_cat == 'edit' && $get_content == 'forumcategory') || (isset($_POST['SubmitEditForumCategory'])) ? true : false) {
$forum_category = get_forum_categories($get_id);
show_edit_forumcategory_form($forum_category);
$content = show_edit_forumcategory_form($forum_category);
}
// Delete a forum category
@ -148,25 +150,25 @@ function handle_forum_and_forumcategories($lp_id = null)
GradebookUtils::remove_resource_from_course_gradebook($link_info['id']);
}
}
$return_message = deleteForumCategoryThread($get_content, $get_id);
echo Display::return_message($return_message, 'confirmation', false);
deleteForumCategoryThread($get_content, $get_id);
}
// Change visibility of a forum or a forum category.
if ($action_forum_cat == 'invisible' || $action_forum_cat == 'visible') {
$return_message = change_visibility($get_content, $get_id, $action_forum_cat);
echo Display::return_message($return_message, 'confirmation', false);
Display::addFlash(Display::return_message($return_message, 'confirmation', false));
}
// Change lock status of a forum or a forum category.
if ($action_forum_cat == 'lock' || $action_forum_cat == 'unlock') {
$return_message = change_lock_status($get_content, $get_id, $action_forum_cat);
echo Display::return_message($return_message, 'confirmation', false);
Display::addFlash(Display::return_message($return_message, 'confirmation', false));
}
// Move a forum or a forum category.
if ($action_forum_cat == 'move' && isset($_GET['direction'])) {
$return_message = move_up_down($get_content, $_GET['direction'], $get_id);
echo Display::return_message($return_message, 'confirmation', false);
Display::addFlash(Display::return_message($return_message, 'confirmation', false));
}
return $content;
}
/**
@ -211,7 +213,7 @@ function show_add_forumcategory_form($inputvalues = array(), $lp_id)
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
return $form->returnForm();
}
}
@ -413,14 +415,14 @@ function show_add_forum_form($inputvalues = array(), $lp_id)
if ($check) {
$values = $form->getSubmitValues();
$return_message = store_forum($values);
echo Display::return_message($return_message, 'confirmation');
Display::addFlash(Display::return_message($return_message, 'confirmation'));
}
Security::clear_token();
} else {
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
return $form->returnForm();
}
}
@ -507,7 +509,7 @@ function show_edit_forumcategory_form($inputvalues = array())
$token = Security::get_token();
$form->addElement('hidden', 'sec_token');
$form->setConstants(array('sec_token' => $token));
$form->display();
return $form->returnForm();
}
}
@ -600,7 +602,7 @@ function store_forumcategory($values, $courseInfo = array(), $showMessage = true
}
if ($showMessage) {
echo Display::return_message($return_message, 'confirmation');
Display::addFlash(Display::return_message($return_message, 'confirmation'));
}
return $last_id;
@ -839,7 +841,6 @@ function deleteForumCategoryThread($content, $id)
$tool_constant = null;
$return_message = '';
if ($content == 'forumcategory') {
$tool_constant = TOOL_FORUM_CATEGORY;
$return_message = get_lang('ForumCategoryDeleted');
@ -899,6 +900,9 @@ function deleteForumCategoryThread($content, $id)
);
// Check if this returns a true and if so => return $return_message, if not => return false;
if (!empty($return_message)) {
Display::addFlash(Display::return_message($return_message, 'confirmation', false));
}
return $return_message;
}

@ -103,16 +103,15 @@ if ($actions === 'add') {
'name' => get_lang('ForumCategories'),
);
}
Display::display_header('');
// Tool introduction
$introduction = Display::return_introduction_section(TOOL_FORUM);
$form_count = 0;
$formContent = '';
if (api_is_allowed_to_edit(false, true)) {
//if is called from a learning path lp_id
$lp_id = isset($_REQUEST['lp_id']) ? intval($_REQUEST['lp_id']) : null;
handle_forum_and_forumcategories($lp_id);
$formContent = handle_forum_and_forumcategories($lp_id);
}
// Notification
@ -129,7 +128,6 @@ if ($actions == 'notify' && isset($_GET['content']) && isset($_GET['id'])) {
get_whats_new();
$whatsnew_post_info = Session::read('whatsnew_post_info');
$tpl = new Template($nameTools, false, false, false, false, true, false);
/* TRACKING */
Event::event_access_tool(TOOL_FORUM);
/*
@ -522,9 +520,11 @@ if (is_array($forumCategories)) {
}
}
$tpl = new Template($nameTools);
$tpl->assign('introduction_section', $introduction);
$tpl->assign('actions', $actions);
$tpl->assign('data', $listForumCategory);
$tpl->assign('form_content', $formContent);
$layout = $tpl->get_template('forum/list.tpl');
$tpl->display($layout);
Display:: display_footer();

@ -1,81 +1,88 @@
{% extends template ~ "/layout/layout_1_col.tpl" %}
{% block content %}
{{ introduction_section }}
{{ form_content }}
{% if data is not empty %}
{% for item in data %}
<div class="category-forum" id="category_{{ item.id }}">
<div class="pull-right">
{{ item.tools }}
</div>
<h3>
{{ 'forum_blue.png'|img(32) }}
<a href="{{ item.url }}" title="{{ item.title }}">{{ item.title }}{{ item.icon_session }}</a>
</h3>
<div class="forum-description">
{{ item.description }}
{% for item in data %}
<div class="category-forum" id="category_{{ item.id }}">
<div class="pull-right">
{{ item.tools }}
</div>
<h3>
{{ 'forum_blue.png'|img(32) }}
<a href="{{ item.url }}" title="{{ item.title }}">{{ item.title }}{{ item.icon_session }}</a>
</h3>
<div class="forum-description">
{{ item.description }}
</div>
</div>
</div>
{% for subitem in item.forums %}
<div class="forum_display">
<div class="panel panel-default forum">
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<div class="number-post">
<a href="{{ forum.url }}" title="{{forum.title}}">
{% if subitem.forum_image is not empty %}
<img src="{{ subitem.forum_image }}" width="48px">
{% else %}
{% if subitem.forum_of_group == 0 %}
{{ 'forum_group.png'|img(48) }}
{% for subitem in item.forums %}
<div class="forum_display">
<div class="panel panel-default forum">
<div class="panel-body">
<div class="row">
<div class="col-md-3">
<div class="number-post">
<a href="{{ forum.url }}" title="{{forum.title}}">
{% if subitem.forum_image is not empty %}
<img src="{{ subitem.forum_image }}" width="48px">
{% else %}
{{ 'forum.png'|img(48) }}
{% if subitem.forum_of_group == 0 %}
{{ 'forum_group.png'|img(48) }}
{% else %}
{{ 'forum.png'|img(48) }}
{% endif %}
{% endif %}
{% endif %}
</a>
<p>{{ 'ForumThreads'| get_lang }}: {{ subitem.number_threads }} </p>
</div>
</div>
<div class="col-md-9">
<div class="pull-right">
<div class="toolbar">
{{ subitem.tools }}
</a>
<p>{{ 'ForumThreads'| get_lang }}: {{ subitem.number_threads }} </p>
</div>
</div>
<h3 class="title">
{{ 'forum_yellow.png'|img(32) }}
<a href="{{ subitem.url }}" title="{{ subitem.title }}" class="{{ subitem.visibility != '1' ? 'text-muted': '' }}">{{ subitem.title }}</a>
{% if subitem.forum_of_group != 0 %}
<a class="forum-goto" href="../group/group_space.php?{{ _p.web_cid_query }}&gidReq={{ subitem.forum_of_group }}">
{{ "forum.png"|img(22) }} {{ "GoTo"|get_lang }} {{ subitem.forum_group_title }}
</a>
{% endif %}
{{ subitem.icon_session }}
</h3>
{% if subitem.last_poster_id is not empty %}
<div class="forum-date">
<i class="fa fa-comments" aria-hidden="true"></i>
{{ subitem.last_poster_date }}
{{ "By"|get_lang }}
{{ subitem.last_poster_user }}
<div class="col-md-9">
<div class="pull-right">
<div class="toolbar">
{{ subitem.tools }}
</div>
</div>
{% endif %}
<div class="description">
{{ subitem.description }}
<h3 class="title">
{{ 'forum_yellow.png'|img(32) }}
<a href="{{ subitem.url }}" title="{{ subitem.title }}" class="{{ subitem.visibility != '1' ? 'text-muted': '' }}">{{ subitem.title }}</a>
{% if subitem.forum_of_group != 0 %}
<a class="forum-goto" href="../group/group_space.php?{{ _p.web_cid_query }}&gidReq={{ subitem.forum_of_group }}">
{{ "forum.png"|img(22) }} {{ "GoTo"|get_lang }} {{ subitem.forum_group_title }}
</a>
{% endif %}
{{ subitem.icon_session }}
</h3>
{% if subitem.last_poster_id is not empty %}
<div class="forum-date">
<i class="fa fa-comments" aria-hidden="true"></i>
{{ subitem.last_poster_date }}
{{ "By"|get_lang }}
{{ subitem.last_poster_user }}
</div>
{% endif %}
<div class="description">
{{ subitem.description }}
</div>
{{ subitem.alert }}
{% if subitem.moderation is not empty %}
<span class="label label-warning">
{{ "PostsPendingModeration"|get_lang }}: {{ subitem.moderation }}
</span>
{% endif %}
</div>
{{ subitem.alert }}
{% if subitem.moderation is not empty %}
<span class="label label-warning">
{{ "PostsPendingModeration"|get_lang }}: {{ subitem.moderation }}
</span>
{% endif %}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
{% endfor %}
{% else %}
<div class="alert alert-warning">
{{ 'NoForumInThisCategory'|get_lang }}
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% else %}
<div class="alert alert-warning">
{{ 'NoForumInThisCategory'|get_lang }}
</div>
{% endif %}
{% endblock %}

Loading…
Cancel
Save