Should fix bug when showing "guest" portal news see #4268

skala
Julio Montoya 14 years ago
parent e50854012d
commit 023ee48230
  1. 23
      main/admin/system_announcements.php
  2. 16
      main/inc/lib/system_announcements.lib.php
  3. 2
      main/template/default/layout/hot_courses.tpl
  4. 12
      news_list.php

@ -18,10 +18,8 @@ $cidReset = true;
require_once '../inc/global.inc.php';
// Including additional libraries.
require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
// Setting the section (for the tabs).
$this_section=SECTION_PLATFORM_ADMIN;
@ -33,22 +31,35 @@ api_protect_admin_script(true);
// Setting breadcrumbs.
$interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$tool_name = get_lang('SystemAnnouncements');
$tool_name = null;
if (empty($_GET['lang'])) {
$_GET['lang'] = $_SESSION['user_language_choice'];
}
if (isset($_GET['action'])) {
$interbreadcrumb[] = array ("url" => "system_announcements.php", "name" => get_lang('SystemAnnouncements'));
if ($_GET['action'] == 'add') {
$interbreadcrumb[] = array ("url" => '#', "name" => get_lang('AddAnnouncement'));
}
if ($_GET['action'] == 'edit') {
$interbreadcrumb[] = array ("url" => '#', "name" => get_lang('Edit'));
}
} else {
$tool_name = get_lang('SystemAnnouncements');
}
// Displaying the header.
Display :: display_header($tool_name);
/* MAIN CODE */
if ($_GET['action'] != 'add' && $_GET['action'] != 'edit') {
echo '<div class="actions">';
echo '<a href="?action=add">'.Display::return_icon('add.png', get_lang('langAddAnnouncement'), array(), 32).'</a>';
echo '<a href="?action=add">'.Display::return_icon('add.png', get_lang('AddAnnouncement'), array(), 32).'</a>';
echo '</div>';
}
/* MAIN CODE */
$form_action = '';
$show_announcement_list = true;
if (isset ($_GET['action']) && $_GET['action'] == 'make_visible') {

@ -1,6 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
/**
* @package chamilo.library
*/
@ -10,6 +9,7 @@ require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
define('VISIBLE_GUEST', 1);
define('VISIBLE_STUDENT', 2);
define('VISIBLE_TEACHER', 3);
/**
* This is the system announcements library for Dokeos.
*
@ -577,13 +577,12 @@ class SystemAnnouncementManager {
*/
public static function display_announcements_slider($visible, $id = null) {
$user_selected_language = Database::escape_string(api_get_interface_language());
$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$cut_size = 500;
$cut_size = 500;
$now = api_get_utc_datetime();
$sql = "SELECT * FROM ".$db_table."
$sql = "SELECT * FROM ".$table."
WHERE ( lang = '$user_selected_language' OR lang IS NULL) AND ( '$now' >= date_start AND '$now' <= date_end) ";
switch ($visible) {
@ -606,9 +605,8 @@ class SystemAnnouncementManager {
$sql .= " ORDER BY date_start DESC";
$announcements = Database::query($sql);
$html = '';
if (Database::num_rows($announcements) > 0) {
$html .= '<div class="span9">';
$html .= '<h3>'.get_lang('SystemAnnouncements').'</h3>';
if (Database::num_rows($announcements) > 0) {
$html .= Display::page_subheader(get_lang('SystemAnnouncements'));
$html .= '<div id="container-slider" class="span6"><ul id="slider">';
while ($announcement = Database::fetch_object($announcements)) {
$content = $announcement->content;
@ -620,7 +618,7 @@ class SystemAnnouncementManager {
}
$html .= '<li><h1>'.$announcement->title.'</h1>'.$content.'</li>';
}
$html .= '</ul></div></div>';
$html .= '</ul></div>';
}
return $html;
}

@ -26,7 +26,7 @@ $(document).ready( function() {
<div class="row">
<div class="span9">
<div class="page-header">
<h3>{{"HottestCourses"|get_lang}}</h3>
<h2>{{"HottestCourses"|get_lang}}</h2>
</div>
</div>
{% for hot_course in hot_courses %}

@ -2,19 +2,23 @@
/* For licensing terms, see /license.txt */
// name of the language file that needs to be included
$language_file = array ('admin','courses', 'index');
$language_file = array ('admin','courses', 'index', 'announcements', 'group');
// including necessary files
require_once 'main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
$tool_name = get_lang('SystemAnnouncements');
$actions = '';
if (api_is_platform_admin()) {
$actions .= '<a href="'.api_get_path(WEB_PATH).'main/admin/system_announcements.php">'.Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).'</a>';
$actions = '<a href="'.api_get_path(WEB_PATH).'main/admin/system_announcements.php">'.Display::return_icon('edit.png', get_lang('EditSystemAnnouncement'), array(), 32).'</a>';
}
if (api_is_anonymous()) {
$visibility = VISIBLE_GUEST;
} else {
$visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
}
$visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
$content = SystemAnnouncementManager ::display_announcements_slider($visibility, $_GET['id']);
$tpl = new Template($tool_name);

Loading…
Cancel
Save