From 7818fdef5ad069474d8a88a6bb1d0587ea358b56 Mon Sep 17 00:00:00 2001 From: Noel Dieschburg Date: Fri, 20 May 2011 17:51:28 +0200 Subject: [PATCH 1/5] Subrepository teleperformance --- .hgsub | 1 + .hgsubstate | 1 + 2 files changed, 2 insertions(+) create mode 100644 .hgsub create mode 100644 .hgsubstate diff --git a/.hgsub b/.hgsub new file mode 100644 index 0000000000..1fc0340f14 --- /dev/null +++ b/.hgsub @@ -0,0 +1 @@ +nested = teleperformance diff --git a/.hgsubstate b/.hgsubstate new file mode 100644 index 0000000000..88cf84cb12 --- /dev/null +++ b/.hgsubstate @@ -0,0 +1 @@ +0000000000000000000000000000000000000000 nested From f05587046b9ab289530bbeb615e8afe4c7741ac4 Mon Sep 17 00:00:00 2001 From: Noel Dieschburg Date: Fri, 20 May 2011 18:26:52 +0200 Subject: [PATCH 2/5] sub repo test --- .hgsub | 2 +- .hgsubstate | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.hgsub b/.hgsub index 1fc0340f14..ee646d34c8 100644 --- a/.hgsub +++ b/.hgsub @@ -1 +1 @@ -nested = teleperformance +subrepo = teleperformance diff --git a/.hgsubstate b/.hgsubstate index 88cf84cb12..25799dac47 100644 --- a/.hgsubstate +++ b/.hgsubstate @@ -1 +1 @@ -0000000000000000000000000000000000000000 nested +0000000000000000000000000000000000000000 subrepo From 111f9a592b0d2357d46ab93b500e86465f96b609 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=ABl=20Dieschburg?= Date: Sat, 28 May 2011 01:32:19 +0200 Subject: [PATCH 3/5] Announcements visible only for groups --- .hgsub | 1 - .hgsubstate | 1 - main/admin/system_announcements.php | 16 ++++- main/inc/lib/database.lib.php | 1 + main/inc/lib/group_portal_manager.lib.php | 35 ++++++++-- main/inc/lib/system_announcements.lib.php | 67 +++++++++++++++++-- main/install/db_main.sql | 6 ++ main/install/migrate-db-1.8.6.2-1.8.7-pre.sql | 2 + main/lang/english/agenda.inc.php | 4 +- main/lang/french/agenda.inc.php | 4 +- 10 files changed, 120 insertions(+), 17 deletions(-) delete mode 100644 .hgsub delete mode 100644 .hgsubstate mode change 100755 => 100644 main/lang/english/agenda.inc.php mode change 100755 => 100644 main/lang/french/agenda.inc.php diff --git a/.hgsub b/.hgsub deleted file mode 100644 index ee646d34c8..0000000000 --- a/.hgsub +++ /dev/null @@ -1 +0,0 @@ -subrepo = teleperformance diff --git a/.hgsubstate b/.hgsubstate deleted file mode 100644 index 25799dac47..0000000000 --- a/.hgsubstate +++ /dev/null @@ -1 +0,0 @@ -0000000000000000000000000000000000000000 subrepo diff --git a/main/admin/system_announcements.php b/main/admin/system_announcements.php index f51106a450..21b5154e44 100644 --- a/main/admin/system_announcements.php +++ b/main/admin/system_announcements.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(); -?> \ No newline at end of file +?> diff --git a/main/inc/lib/database.lib.php b/main/inc/lib/database.lib.php index 691289c90d..c89c45645c 100644 --- a/main/inc/lib/database.lib.php +++ b/main/inc/lib/database.lib.php @@ -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'); diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index ba984548a0..9bc5b0463c 100644 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -235,21 +235,15 @@ class GroupPortalManager $toreturn = array(); while ($item = Database::fetch_assoc($res)) { - echo "
";
-        print_r($item);
-      echo "
"; - 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.group_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 diff --git a/main/inc/lib/system_announcements.lib.php b/main/inc/lib/system_announcements.lib.php index 918693d7c3..232a55c2a7 100644 --- a/main/inc/lib/system_announcements.lib.php +++ b/main/inc/lib/system_announcements.lib.php @@ -1,4 +1,5 @@ \ No newline at end of file +?> diff --git a/main/install/db_main.sql b/main/install/db_main.sql index b8f87538a8..b0687da303 100644 --- a/main/install/db_main.sql +++ b/main/install/db_main.sql @@ -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 -- diff --git a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql index 3aa52b7076..5c3b887e8f 100644 --- a/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql +++ b/main/install/migrate-db-1.8.6.2-1.8.7-pre.sql @@ -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 été 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 -- diff --git a/main/lang/english/agenda.inc.php b/main/lang/english/agenda.inc.php old mode 100755 new mode 100644 index 30e64555b5..84578ba741 --- a/main/lang/english/agenda.inc.php +++ b/main/lang/english/agenda.inc.php @@ -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"; -?> \ No newline at end of file +$AnnouncementForGroup = "Only for group"; +$AllGroups = "All the groups"; +?> diff --git a/main/lang/french/agenda.inc.php b/main/lang/french/agenda.inc.php old mode 100755 new mode 100644 index 18bc3b346c..4ac394de8d --- a/main/lang/french/agenda.inc.php +++ b/main/lang/french/agenda.inc.php @@ -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"; -?> \ No newline at end of file +$AnnouncementForGroup = "Seulement visible pour le groupe"; +$AllGroups = "Tous les groupes"; +?> From de8d718e4255b069131e8b4613aaeff88d634ad1 Mon Sep 17 00:00:00 2001 From: Noel Dieschburg Date: Sat, 28 May 2011 01:59:59 +0200 Subject: [PATCH 4/5] System annoucements for groups correcttion in get_parent_groups function --- main/inc/lib/group_portal_manager.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/inc/lib/group_portal_manager.lib.php b/main/inc/lib/group_portal_manager.lib.php index 9bc5b0463c..7734083eb4 100644 --- a/main/inc/lib/group_portal_manager.lib.php +++ b/main/inc/lib/group_portal_manager.lib.php @@ -270,7 +270,7 @@ class GroupPortalManager $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.group_id='$group_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(); From e03493404529f66d49ad47db043d1b324a5f7fdf Mon Sep 17 00:00:00 2001 From: Arnaud Ligot Date: Tue, 31 May 2011 20:05:18 +0200 Subject: [PATCH 5/5] enabling sub reporting --- main/reports/index.php | 31 ++++++++++++++++++++++++++++--- main/reports/reports.php | 31 +++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 5 deletions(-) diff --git a/main/reports/index.php b/main/reports/index.php index bbb14488e4..7189867acd 100644 --- a/main/reports/index.php +++ b/main/reports/index.php @@ -102,9 +102,18 @@ $htmlHeadXtra[] = '