skala
jkbockstael 14 years ago
commit 02d1f524d0
  1. 16
      main/admin/system_announcements.php
  2. 1
      main/inc/lib/database.lib.php
  3. 35
      main/inc/lib/group_portal_manager.lib.php
  4. 67
      main/inc/lib/system_announcements.lib.php
  5. 6
      main/install/db_main.sql
  6. 2
      main/install/migrate-db-1.8.6.2-1.8.7-pre.sql
  7. 4
      main/lang/english/agenda.inc.php
  8. 4
      main/lang/french/agenda.inc.php
  9. 31
      main/reports/index.php
  10. 31
      main/reports/reports.php

@ -20,6 +20,7 @@ require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
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;
@ -121,6 +122,8 @@ if (isset ($_GET['action']) && $_GET['action'] == 'edit') {
$values['visible_guest'] = $announcement->visible_guest ;
$values['lang'] = $announcement->lang;
$values['action'] = 'edit';
$groups = SystemAnnouncementManager :: get_announcement_groups($announcement->id);
$values['group'] = isset($groups[0]['group_id']) ? $groups[0]['group_id'] : 0;
$action_todo = true;
}
@ -152,6 +155,12 @@ if ($action_todo) {
$form->addElement('checkbox', 'visible_student', null, get_lang('Student'));
$form->addElement('checkbox', 'visible_guest', null, get_lang('Guest'));
$form->addElement('hidden', 'id');
$group_list = GroupPortalManager::get_groups_list();
$group_list[0] = get_lang('AllGroups');
$form->addElement('select', 'group',get_lang('AnnouncementForGroup'),$group_list);
$values['group'] = isset($values['group']) ? $values['group'] : '0';
$form->addElement('checkbox', 'send_mail', get_lang('SendMail'));
if (isset($_REQUEST['action']) && $_REQUEST['action']=='add') {
@ -197,8 +206,10 @@ if ($action_todo) {
switch($values['action'])
{
case 'add':
if(SystemAnnouncementManager::add_announcement($values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail']))
$announcement_id = SystemAnnouncementManager::add_announcement($values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail']);
if ($announcement_id !== false )
{
SystemAnnouncementManager::announcement_for_groups($announcement_id, array($values['group']));
Display :: display_confirmation_message(get_lang('AnnouncementAdded'));
} else {
$show_announcement_list = false;
@ -208,6 +219,7 @@ if ($action_todo) {
case 'edit':
if (SystemAnnouncementManager::update_announcement($values['id'],$values['title'],$values['content'],$values['start'],$values['end'],$values['visible_teacher'],$values['visible_student'],$values['visible_guest'], $values['lang'],$values['send_mail']))
{
SystemAnnouncementManager::announcement_for_groups($values['id'], array($values['group']));
Display :: display_confirmation_message(get_lang('AnnouncementUpdated'));
}
else
@ -274,4 +286,4 @@ if ($show_announcement_list)
FOOTER
*/
Display :: display_footer();
?>
?>

@ -26,6 +26,7 @@ define('TABLE_MAIN_CLASS_USER', 'class_user');
define('TABLE_MAIN_CATEGORY', 'course_category');
define('TABLE_MAIN_COURSE_MODULE', 'course_module');
define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS', 'sys_announcement');
define('TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS', 'announcement_rel_group');
define('TABLE_MAIN_LANGUAGE', 'language');
define('TABLE_MAIN_SETTINGS_OPTIONS', 'settings_options');
define('TABLE_MAIN_SETTINGS_CURRENT', 'settings_current');

@ -235,21 +235,15 @@ class GroupPortalManager
$toreturn = array();
while ($item = Database::fetch_assoc($res)) {
echo "<pre>";
print_r($item);
echo "</pre>";
foreach ($item as $key => $value ){
if ($key == 'id_1') {
$toreturn[$value]['name'] = $item['name_1'];
} else {
$temp = explode('_',$key);
echo "ppp : $index_key - $string_key ppp";
$index_key = $temp[1];
$string_key = $temp[0];
$previous_key = $string_key.'_'.$index_key-1;
if ( $string_key == 'id' && isset($item[$key]) ) {
echo $previous_key;
$toreturn[$item[$previous_key]]['hrms'][$index_key]['name'] = $item['name_'.$index_id];
}
}
@ -257,6 +251,35 @@ class GroupPortalManager
}
return $toreturn;
}
public static function get_parent_groups($group_id){
$t_rel_group = Database :: get_main_table(TABLE_MAIN_GROUP_REL_GROUP);
$max_level = 10;
$select_part = "SELECT ";
$cond_part='';
for ($i=1; $i <= $max_level; $i++) {
$g_number=$i;
$rg_number=$i-1;
if ( $i == $max_level) {
$select_part .= "rg$rg_number.group_id as id_$rg_number ";
} else {
$select_part .="rg$rg_number.group_id as id_$rg_number, ";
}
if ($i == 1){
$cond_part .= "FROM $t_rel_group rg0 LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
}else {
$cond_part .= " LEFT JOIN $t_rel_group rg$i on rg$rg_number.group_id = rg$i.subgroup_id ";
}
}
$sql = $select_part.' '. $cond_part . "WHERE rg0.subgroup_id='$group_id'";
$res = Database::query($sql);
$temp_arr = Database::fetch_array($res, 'NUM');
$toreturn = array();
foreach ($temp_arr as $elt) {
if (isset($elt))
$toreturn[] = $elt;
}
return $toreturn;
}
/**
* Gets the tags from a given group

@ -1,4 +1,5 @@
<?php
require_once api_get_path(LIBRARY_PATH).'group_portal_manager.lib.php';
/* For licensing terms, see /license.txt */
define('VISIBLE_GUEST', 1);
define('VISIBLE_STUDENT', 2);
@ -20,8 +21,19 @@ class SystemAnnouncementManager
{
$user_selected_language = api_get_interface_language();
$db_table = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS);
$sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date FROM ".$db_table." WHERE (lang='$user_selected_language' OR lang IS NULL) AND ((NOW() BETWEEN date_start AND date_end) OR date_end='0000-00-00') ";
$tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
$temp_user_groups = GroupPortalManager::get_groups_by_user(api_get_user_id(),0);
$groups =array();
foreach ($temp_user_groups as $user_group) {
$groups = array_merge($groups, array($user_group['id']));
$groups = array_merge($groups, GroupPortalManager::get_parent_groups($user_group['id']));
}
$groups_string = '('.implode($groups,',').')';
$sql = "SELECT *, DATE_FORMAT(date_start,'%d-%m-%Y %h:%i:%s') AS display_date"
." FROM $db_table"
." WHERE (lang='$user_selected_language'"
." OR lang IS NULL)"
." AND ((NOW() BETWEEN date_start AND date_end) OR date_end='0000-00-00') ";
switch ($visible) {
case VISIBLE_GUEST :
$sql .= " AND visible_guest = 1 ";
@ -33,6 +45,8 @@ class SystemAnnouncementManager
$sql .= " AND visible_teacher = 1 ";
break;
}
$sql .= " OR id IN (SELECT announcement_id FROM $tbl_announcement_group "
." WHERE group_id in $groups_string) ";
$sql .= " ORDER BY date_start DESC LIMIT 0,7";
$announcements = Database::query($sql);
@ -229,7 +243,7 @@ class SystemAnnouncementManager
* @param int Whether the announcement should be visible to anonymous users (1) or not (0)
* @param string The language for which the announvement should be shown. Leave null for all langages
* @param int Whether to send an e-mail to all users (1) or not (0)
* @return bool True on success, false on failure
* @return mixed insert_id on success, false on failure
*/
public static function add_announcement($title, $content, $date_start, $date_end, $visible_teacher = 0, $visible_student = 0, $visible_guest = 0, $lang = null, $send_mail=0)
{
@ -277,8 +291,51 @@ class SystemAnnouncementManager
Debug::log_s(mysql_error());
return false;
}
return true;
return Database::insert_id();
}
/**
* Makes the announcement id visible only foir groups in groups_array
* @param int announcement id
* @param array array of group id
**/
public static function announcement_for_groups($announcement_id, $group_array){
$tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
//first delete all group associations for this announcement
$res = Database::query("DELETE FROM $tbl_announcement_group where announcement_id=".intval($announcement_id));
if ($res === false) {
Debug::log_s(mysql_error());
return false;
}
foreach ($group_array as $group_id) {
if (intval($group_id) != 0 ) {
$res = Database::query("INSERT into $tbl_announcement_group set announcement_id=".intval($announcement_id)
.", group_id=".intval($group_id));
if ($res === false) {
Debug::log_s(mysql_error());
return false;
}
}
}
return true;
}
/**
* Gets the groups of this announce
* @param int announcement id
* @return array array of group id
**/
public static function get_announcement_groups($announcement_id){
$tbl_announcement_group = Database :: get_main_table(TABLE_MAIN_SYSTEM_ANNOUNCEMENTS_GROUPS);
$tbl_group = Database :: get_main_table(TABLE_MAIN_GROUP);
//first delete all group associations for this announcement
$res = Database::query("SELECT g.id as group_id , g.name as group_name FROM $tbl_group g , $tbl_announcement_group ag"
." WHERE announcement_id=".intval($announcement_id)
." AND ag.group_id = g.id");
$groups = Database::fetch_array($res);
return $groups;
}
/**
* Updates an announcement to the database
* @param integer $id : id of the announcement
@ -423,4 +480,4 @@ class SystemAnnouncementManager
}
}
}
?>
?>

@ -2431,6 +2431,12 @@ CREATE TABLE group_rel_group (
ALTER TABLE group_rel_group ADD INDEX ( group_id );
ALTER TABLE group_rel_group ADD INDEX ( subgroup_id );
ALTER TABLE group_rel_group ADD INDEX ( relation_type );
CREATE TABLE announcement_rel_group (
group_id int NOT NULL,
announcement_id int NOT NULL,
PRIMARY KEY (group_id, announcement_id)
);
--
-- Table structure for table message attachment
--

@ -134,6 +134,8 @@ CREATE TABLE `event_type_message` (`id` int(11) NOT NULL AUTO_INCREMENT, `event_
CREATE TABLE `user_rel_event_type` (`id` int(11) NOT NULL AUTO_INCREMENT, `user_id` int(11) NOT NULL, `event_type_id` int(11) NOT NULL, PRIMARY KEY (`id`));
INSERT INTO `event_type` VALUES (1, 'course_deleted','courseDeletedTitle','courseDeletedComment'),(2,'course_created','courseCreatedTitle','courseCreatedComment'),(3,'user_deleted','userDeletedTitle','userDeletedComment'),(4,'user_created','userCreatedTitle','userCreatedComment'), (5, 'session_created','sessionCreatedTitle','sessionCreatedComment'), (6,'session_deleted','sessionDeletedTitle','sessionDeletedComment'), (7,'session_category_created','sessionCategoryCreatedTitle','sessionCategoryCreatedComment'),(8,'session_category_deleted','sessionCategoryDeletedTitle','sessionCategoryDeletedComment'),(9,'settings_changed','settingsChangedTitle','settingsChangedComment'),(10,'user_subscribed','userSubscribedTitle','userSubscribedComment'), (11,'user_unsubscribed','userUnsubscribedTitle','userUnsubscribedComment');
INSERT INTO `event_type_message` (`id`,`event_type_id`, `language_id`, `message`,`subject`) VALUES (1,4,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a é créé.\r\nEmail : %mail%\r\n\r\nBien à vous.',''),(2,1,10,'Delete formation',''),(3,2,10,'Create formation',''),(4,3,10,'Bonjour, \r\n\r\nL\'utilisateur %username% (%firstname% %lastname%) a été supprimé.\r\n\r\nBien à vous.',''),(6,5,10,'Create session test',''),(7,6,10,'Delete session',''),(8,7,10,'Create category session',''),(9,8,10,'Delete category session',''),(10,9,10,'Change setting',''),(11,10,10,'Subscribe',''),(12,11,10,'Unsubscribe','');
CREATE TABLE announcement_rel_group (group_id int NOT NULL, announcement_id int NOT NULL, PRIMARY KEY (group_id, announcement_id));
--
-- Table structure for LP custom storage API
--

@ -77,4 +77,6 @@ $IsNotiCalFormatFile = "This file is not in iCal format";
$RepeatEvent = "Repeat event";
$RepeatDate = "Repeat date";
$EndDateMustBeMoreThanStartDate = "End date must be more than the start date";
?>
$AnnouncementForGroup = "Only for group";
$AllGroups = "All the groups";
?>

@ -77,4 +77,6 @@ $IsNotiCalFormatFile = "Ce fichier n'est pas au format iCal";
$RepeatEvent = "Évènement répétitif";
$RepeatDate = "Répéter la date";
$EndDateMustBeMoreThanStartDate = "La date de fin doit être supérieure à la date de début";
?>
$AnnouncementForGroup = "Seulement visible pour le groupe";
$AllGroups = "Tous les groupes";
?>

@ -102,9 +102,18 @@ $htmlHeadXtra[] = ' <style type="text/css">
overflow : auto;
display: none;
}
#result {
.result {
padding-top: 15px;
}
#result2 {
margin: 50px;
}
#result3 {
margin: 100px;
}
#result4 {
margin: 150px;
}
select.link, select.link:hover {
color: black;
}
@ -164,7 +173,13 @@ foreach($reports_template as $key => $value)
</div>
<div id="result">
<div id="result" class="result">
</div>
<div id="result2" class="result">
</div>
<div id="result3" class="result">
</div>
<div id="result4" class="result">
</div>
<script type="text/javascript">
$(function(){
@ -181,7 +196,8 @@ foreach($reports_template as $key => $value)
success: function(data){
$("#wizardContent").hide();
$("#wizardShowButton").show();
$("#result").html(data);
$(".result").html('');
$("#result").html(data);
},
beforeSubmit: function(data){$("#data").html("data sent to the server: " + $.param(data));},
resetForm: false
@ -189,6 +205,15 @@ foreach($reports_template as $key => $value)
}
);
});
function setSubDataUri(elem, uri) {
$.ajax({
url: uri,
success: function(data) {
elem.closest('.result').nextAll().html('');
elem.closest('.result').next().html(data);
}
});
}
</script>
<?

@ -31,6 +31,9 @@ $tool_name=get_lang('Reports');
// loading templates
reports_loadTemplates();
// random suffix for div id (to enable multiple report per page)
$idsuffix = rand();
// "Link" type
if ($_REQUEST['format'] == 'link') {
// converting post vars to get uri
@ -48,7 +51,22 @@ if ($_REQUEST['format'] == 'directlink') {
$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/'.$js.'" type="text/javascript" language="javascript"></script>'."\n";
$htmlCSSXtra[] = 'dataTable.css';
?>
<script type="text/javascript">
function setSubDataUri(elem, uri) {
$.ajax({
url: uri,
success: function(data) {
elem.closest('.result').nextAll().html('');
elem.closest('.result').next().html(data);
}
});
}
</script>
<?php
Display::display_header($tool_name);
echo '<div id="result" class="result">';
}
// outputing a link to csv file instead of outputing csv data directly
@ -100,7 +118,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
echo '<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#reportsData").dataTable({
$("#reportsData'.$idsuffix.'").dataTable({
"oLanguage":
{
"sProcessing": "Traitement en cours...",
@ -122,7 +140,7 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
});
} );
</script>';
echo '<table id="reportsData" class="display">'; // FIXME style
echo '<table id="reportsData'.$idsuffix.'" class="display">'; // FIXME style
// counting fields
$nfields = multiquery_num_fields($result);
@ -160,7 +178,16 @@ if ($_REQUEST['format'] == 'html' || $_REQUEST['format'] == 'directlink') {
}
echo '</tbody></table>';
if ($_REQUEST['format'] == 'directlink') {
echo '</div>
<div id="result2" class="result" style="margin: 50px;">
</div>
<div id="result3" class="result" style="margin: 100px;">
</div>
<div id="result4" class="result" style="margin: 150px;">
</div>';
Display::display_footer();
}
} else if ($_REQUEST['format'] == 'csv') {
$nfields = multiquery_num_fields($result);

Loading…
Cancel
Save