|
|
|
|
@ -24,6 +24,8 @@ require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php'; |
|
|
|
|
$this_section = SECTION_PLATFORM_ADMIN; |
|
|
|
|
$_SESSION['this_section']=$this_section; |
|
|
|
|
|
|
|
|
|
$action = isset($_GET['action']) ? $_GET['action'] : null; |
|
|
|
|
|
|
|
|
|
// Access restrictions |
|
|
|
|
api_protect_admin_script(true); |
|
|
|
|
|
|
|
|
|
@ -33,15 +35,15 @@ $interbreadcrumb[] = array ("url" => 'index.php', "name" => get_lang('PlatformAd |
|
|
|
|
$tool_name = null; |
|
|
|
|
|
|
|
|
|
if (empty($_GET['lang'])) { |
|
|
|
|
$_GET['lang'] = $_SESSION['user_language_choice']; |
|
|
|
|
$_GET['lang'] = isset($_SESSION['user_language_choice']) ? $_SESSION['user_language_choice'] : null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (isset($_GET['action'])) { |
|
|
|
|
if (!empty($action)) { |
|
|
|
|
$interbreadcrumb[] = array ("url" => "system_announcements.php", "name" => get_lang('SystemAnnouncements')); |
|
|
|
|
if ($_GET['action'] == 'add') { |
|
|
|
|
if ($action == 'add') { |
|
|
|
|
$interbreadcrumb[] = array ("url" => '#', "name" => get_lang('AddAnnouncement')); |
|
|
|
|
} |
|
|
|
|
if ($_GET['action'] == 'edit') { |
|
|
|
|
if ($action == 'edit') { |
|
|
|
|
$interbreadcrumb[] = array ("url" => '#', "name" => get_lang('Edit')); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
@ -51,7 +53,7 @@ if (isset($_GET['action'])) { |
|
|
|
|
// Displaying the header. |
|
|
|
|
Display :: display_header($tool_name); |
|
|
|
|
|
|
|
|
|
if ($_GET['action'] != 'add' && $_GET['action'] != 'edit') { |
|
|
|
|
if ($action != 'add' && $action != 'edit') { |
|
|
|
|
echo '<div class="actions">'; |
|
|
|
|
echo '<a href="?action=add">'.Display::return_icon('add.png', get_lang('AddAnnouncement'), array(), 32).'</a>'; |
|
|
|
|
echo '</div>'; |
|
|
|
|
@ -96,6 +98,10 @@ switch($action) { |
|
|
|
|
// Set default time window: NOW -> NEXT WEEK |
|
|
|
|
$values['start'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time())); |
|
|
|
|
$values['end'] = date('Y-m-d H:i:s',api_strtotime(api_get_local_time()) + (7 * 24 * 60 * 60)); |
|
|
|
|
|
|
|
|
|
$values['range'] = |
|
|
|
|
substr(api_get_local_time(api_get_local_time()), 0, 16).' / '. |
|
|
|
|
substr(api_get_local_time(api_get_local_time()) + (7 * 24 * 60 * 60), 0, 16); |
|
|
|
|
$action_todo = true; |
|
|
|
|
break; |
|
|
|
|
case 'edit': |
|
|
|
|
@ -106,6 +112,11 @@ switch($action) { |
|
|
|
|
$values['content'] = $announcement->content; |
|
|
|
|
$values['start'] = api_get_local_time($announcement->date_start); |
|
|
|
|
$values['end'] = api_get_local_time($announcement->date_end); |
|
|
|
|
|
|
|
|
|
$values['range'] = |
|
|
|
|
substr(api_get_local_time($announcement->date_start), 0, 16).' / '. |
|
|
|
|
substr(api_get_local_time($announcement->date_end), 0, 16); |
|
|
|
|
|
|
|
|
|
$values['visible_teacher'] = $announcement->visible_teacher; |
|
|
|
|
$values['visible_student'] = $announcement->visible_student ; |
|
|
|
|
$values['visible_guest'] = $announcement->visible_guest ; |
|
|
|
|
@ -139,7 +150,8 @@ if ($action_todo) { |
|
|
|
|
} else { |
|
|
|
|
$form->add_html_editor('content', get_lang('Content'), true, false, array('ToolbarSet' => 'PortalNews', 'Width' => '100%', 'Height' => '300')); |
|
|
|
|
} |
|
|
|
|
$form->add_timewindow('start','end',get_lang('StartTimeWindow'),get_lang('EndTimeWindow')); |
|
|
|
|
$form->addDateRangePicker('range', get_lang('StartTimeWindow'), true, array('id' => 'date_range')); |
|
|
|
|
|
|
|
|
|
$group = array(); |
|
|
|
|
|
|
|
|
|
$group[]= $form->createElement('checkbox', 'visible_teacher', null, get_lang('Teacher')); |
|
|
|
|
@ -151,8 +163,13 @@ if ($action_todo) { |
|
|
|
|
$form->addElement('hidden', 'id'); |
|
|
|
|
|
|
|
|
|
$group_list = GroupPortalManager::get_groups_list(); |
|
|
|
|
$group_list[0] = get_lang('All'); |
|
|
|
|
$form->addElement('select', 'group',get_lang('AnnouncementForGroup'),$group_list); |
|
|
|
|
$group_list[0] = get_lang('All'); |
|
|
|
|
$form->addElement( |
|
|
|
|
'select', |
|
|
|
|
'group', |
|
|
|
|
get_lang('AnnouncementForGroup'), |
|
|
|
|
$group_list |
|
|
|
|
); |
|
|
|
|
$values['group'] = isset($values['group']) ? $values['group'] : '0'; |
|
|
|
|
|
|
|
|
|
$form->addElement('checkbox', 'send_mail', null, get_lang('SendMail')); |
|
|
|
|
@ -161,21 +178,22 @@ if ($action_todo) { |
|
|
|
|
$form->addElement('checkbox', 'add_to_calendar', null, get_lang('AddToCalendar')); |
|
|
|
|
$text=get_lang('AddNews'); |
|
|
|
|
$class='add'; |
|
|
|
|
$form->addElement('hidden', 'action','add'); |
|
|
|
|
$form->addElement('hidden', 'action', 'add'); |
|
|
|
|
|
|
|
|
|
} elseif (isset($_REQUEST['action']) && $_REQUEST['action']=='edit') { |
|
|
|
|
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'edit') { |
|
|
|
|
$text=get_lang('EditNews'); |
|
|
|
|
$class='save'; |
|
|
|
|
$form->addElement('hidden', 'action','edit'); |
|
|
|
|
$form->addElement('hidden', 'action', 'edit'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$form->addElement('checkbox', 'send_email_test', null, get_lang('SendOnlyAnEmailToMySelfToTest')); |
|
|
|
|
|
|
|
|
|
$form->addElement('style_submit_button', 'submit', $text,'class="'.$class.'"'); |
|
|
|
|
$form->addElement('style_submit_button', 'submit', $text, 'class="'.$class.'"'); |
|
|
|
|
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { |
|
|
|
|
$values['content'] = WCAG_Rendering::HTML_to_text($values['content']); |
|
|
|
|
} |
|
|
|
|
$form->setDefaults($values); |
|
|
|
|
|
|
|
|
|
if ($form->validate()) { |
|
|
|
|
$values = $form->exportValues(); |
|
|
|
|
if ( !isset($values['visible_teacher'])) { |
|
|
|
|
@ -193,18 +211,21 @@ if ($action_todo) { |
|
|
|
|
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { |
|
|
|
|
//$values['content'] = WCAG_Rendering::text_to_HTML($values['content']); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$sendMail = isset($values['send_mail']) ? $values['send_mail'] : null; |
|
|
|
|
|
|
|
|
|
switch ($values['action']) { |
|
|
|
|
case 'add': |
|
|
|
|
$announcement_id = SystemAnnouncementManager::add_announcement( |
|
|
|
|
$values['title'], |
|
|
|
|
$values['content'], |
|
|
|
|
$values['start'], |
|
|
|
|
$values['end'], |
|
|
|
|
$values['range_start'], |
|
|
|
|
$values['range_end'], |
|
|
|
|
$values['visible_teacher'], |
|
|
|
|
$values['visible_student'], |
|
|
|
|
$values['visible_guest'], |
|
|
|
|
$values['lang'], |
|
|
|
|
$values['send_mail'], |
|
|
|
|
$sendMail, |
|
|
|
|
$values['add_to_calendar'], |
|
|
|
|
$values['send_email_test'] |
|
|
|
|
); |
|
|
|
|
@ -222,13 +243,13 @@ if ($action_todo) { |
|
|
|
|
$values['id'], |
|
|
|
|
$values['title'], |
|
|
|
|
$values['content'], |
|
|
|
|
$values['start'], |
|
|
|
|
$values['end'], |
|
|
|
|
$values['range_start'], |
|
|
|
|
$values['range_end'], |
|
|
|
|
$values['visible_teacher'], |
|
|
|
|
$values['visible_student'], |
|
|
|
|
$values['visible_guest'], |
|
|
|
|
$values['lang'], |
|
|
|
|
$values['send_mail'], |
|
|
|
|
$sendMail, |
|
|
|
|
$values['send_email_test'] |
|
|
|
|
) |
|
|
|
|
) { |
|
|
|
|
|