Browse Source

Fix PHP warning, fix URL generation add Agenda Toolbar

jmontoyaa 9 years ago
parent
commit
d1cbfa5428

+ 13 - 22
main/calendar/agenda.php

@@ -34,7 +34,7 @@ if (empty($action)) {
 
 /* 	Resource linker */
 Session::write('source_type', 'Agenda');
-require_once '../resourcelinker/resourcelinker.inc.php';
+//require_once '../resourcelinker/resourcelinker.inc.php';
 $group_id = api_get_group_id();
 $eventId = isset($_REQUEST['id']) ? $_REQUEST['id'] : null;
 $type = $event_type = isset($_GET['type']) ? $_GET['type'] : null;
@@ -85,7 +85,6 @@ if ($event_type == 'course') {
 $course_info = api_get_course_info();
 $agenda->type = $event_type;
 
-$message = null;
 $content = null;
 
 if (api_is_allowed_to_edit(false, true) ||
@@ -139,11 +138,10 @@ if (api_is_allowed_to_edit(false, true) ||
                         $values['users_to_send']
                     );
                 }
-                $message = Display::return_message(get_lang('AddSuccess'), 'confirmation');
+                Display::return_message(get_lang('AddSuccess'), 'confirmation');
                 if ($sendEmail) {
-                    $message .= Display::return_message(get_lang('AdditionalMailWasSentToSelectedUsers'), 'confirmation');
+                    Display::return_message(get_lang('AdditionalMailWasSentToSelectedUsers'), 'confirmation');
                 }
-                Session::write('message', $message);
                 header("Location: $agendaUrl");
                 exit;
             } else {
@@ -194,8 +192,8 @@ if (api_is_allowed_to_edit(false, true) ||
                         $comment
                     );
 
-                    $message = Display::return_message(get_lang('Updated'), 'confirmation');
-                    Session::write('message', $message);
+                    Display::return_message(get_lang('Updated'), 'confirmation');
+
                     header("Location: $agendaUrl");
                     exit;
                 }
@@ -234,8 +232,7 @@ if (api_is_allowed_to_edit(false, true) ||
                     );
                 }
 
-                $message = Display::return_message(get_lang('Updated'), 'confirmation');
-                Session::write('message', $message);
+                Display::return_message(get_lang('Updated'), 'confirmation');
                 header("Location: $agendaUrl");
                 exit;
             } else {
@@ -260,19 +257,20 @@ if (api_is_allowed_to_edit(false, true) ||
                 }
 
                 if (!$is_ical) {
-                    $message = Display::return_message(get_lang('IsNotiCalFormatFile'), 'error');
+                    Display::return_message(get_lang('IsNotiCalFormatFile'), 'error');
                     $form = $agenda->getImportCalendarForm();
                     $content = $form->return_form();
                     break;
                 } else {
-                    $message = Display::return_message(get_lang('AddSuccess'), 'error');
+                    Display::return_message(get_lang('AddSuccess'), 'error');
                     $content = $result;
                 }
-                Session::write('message', $message);
             }
             break;
         case "delete":
-            if (!(api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, $eventId) )) {
+            if (!(api_is_course_coach() &&
+                !api_is_element_in_the_session(TOOL_AGENDA, $eventId))
+            ) {
                 // a coach can only delete an element belonging to his session
                 $content = $agenda->delete_event($eventId);
             }
@@ -301,12 +299,5 @@ if (!empty($actionName)) {
 // Tool introduction
 $introduction = Display::return_introduction_section(TOOL_CALENDAR_EVENT);
 
-$message = Session::read('message');
-Session::erase('message');
-
-$tpl = new Template($actionName);
-$tpl->assign('content', $content);
-$tpl->assign('actions', $actions);
-
-// Loading main Chamilo 1 col template
-$tpl->display_one_col_template();
+echo $actions;
+echo $content;

+ 1 - 7
main/inc/lib/agenda.lib.php

@@ -2061,11 +2061,7 @@ class Agenda
         }
 
         if ($isSubEventEdition) {
-            $form->addElement(
-                'label',
-                null,
-                Display::return_message(get_lang('EditingThisEventWillRemoveItFromTheSerie'), 'warning')
-            );
+            Display::return_message(get_lang('EditingThisEventWillRemoveItFromTheSerie'), 'warning');
         }
 
         $form->addElement('text', 'title', get_lang('ItemTitle'));
@@ -2121,7 +2117,6 @@ class Agenda
         } else {
             $toolbar = 'Agenda';
         }
-
         $form->addHtmlEditor(
             'content',
             get_lang('Description'),
@@ -2160,7 +2155,6 @@ class Agenda
             );
         }
 
-
         if ($id) {
             $form->addButtonUpdate(get_lang('ModifyEvent'));
         } else {

+ 2 - 2
main/user/subscribe_user.php

@@ -894,7 +894,7 @@ function display_extra_profile_fields_filter()
 {
 	// getting all the additional user profile fields
 	$extra = UserManager::get_extra_fields(0,50,5,'ASC');
-
+	$type = isset($_REQUEST['type']) ? Security::remove_XSS($_REQUEST['type'])  : '';
 	$return='<option value="">'.get_lang('SelectFilter').'</option>';
 
 	// looping through the additional user profile fields
@@ -925,7 +925,7 @@ function display_extra_profile_fields_filter()
 	}
 
 	echo '<form id="subscribe_user_filter" name="subscribe_user_filter" method="get" action="'.api_get_self().'?api_get_cidreq" style="float:left;">';
-	echo '	<input type="hidden" name="type" id="type" value="'.Security::remove_XSS($_REQUEST['type']).'" />';
+	echo '	<input type="hidden" name="type" id="type" value="'.$type.'" />';
 	echo   '<select name="subscribe_user_filter_value" id="subscribe_user_filter_value">'.$return.'</select>';
 	echo   '<button type="submit" name="submit_filter" id="submit_filter" value="" class="search">'.get_lang('Filter').'</button>';
 	echo '</form>';

+ 124 - 0
src/Chamilo/CoreBundle/Component/Editor/CkEditor/Toolbar/Agenda.php

@@ -0,0 +1,124 @@
+<?php
+/* For licensing terms, see /license.txt */
+
+namespace Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar;
+
+/**
+ * Agenda toolbar configuration
+ *
+ * @package Chamilo\CoreBundle\Component\Editor\CkEditor\Toolbar *
+ */
+class Agenda extends Basic
+{
+
+    public $plugins = array(
+    );
+
+    /**
+     * Get the toolbar config
+     * @return array
+     */
+    public function getConfig()
+    {
+        if (api_get_setting('editor.more_buttons_maximized_mode') != 'true') {
+            $config['toolbar'] = $this->getNormalToolbar();
+        } else {
+            $config['toolbar_minToolbar'] = $this->getMinimizedToolbar();
+
+            $config['toolbar_maxToolbar'] = $this->getMaximizedToolbar();
+        }
+
+        return $config;
+    }
+
+    /**
+     * Get the toolbar configuration when CKEditor is maximized
+     * @return array
+     */
+    protected function getMaximizedToolbar()
+    {
+        return [
+            ['Save', 'NewPage', 'Templates', '-', 'Preview', 'Print'],
+            ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
+            ['Undo', 'Redo', '-', 'SelectAll', 'Find', '-', 'RemoveFormat'],
+            ['Link', 'Unlink', 'Anchor', 'Glossary'],
+            [
+                'Image',
+                'Mapping',
+                'Video',
+                'Flash',
+                'Youtube',
+                'Oembed',
+                'Audio',
+                'leaflet',
+                'Smiley',
+                'SpecialChar',
+                'Asciimath',
+                'Asciisvg'
+            ],
+            '/',
+            ['Table', '-', 'CreateDiv'],
+            ['BulletedList', 'NumberedList', 'HorizontalRule', '-', 'Outdent', 'Indent', 'Blockquote'],
+            ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
+            ['Bold', 'Italic', 'Underline', 'Strike', '-', 'Subscript', 'Superscript', '-', 'TextColor', 'BGColor'],
+            [
+                api_get_setting(
+                    'editor.allow_spellcheck'
+                ) == 'true' ? 'Scayt' : '',
+            ],
+            ['Styles', 'Format', 'Font', 'FontSize'],
+            ['PageBreak', 'ShowBlocks'],
+            ['Toolbarswitch'],
+        ];
+    }
+
+    /**
+     * Get the default toolbar configuration when the setting more_buttons_maximized_mode is false
+     * @return array
+     */
+    protected function getNormalToolbar()
+    {
+        return [
+            ['Save', 'Maximize', 'PasteFromWord', '-', 'Undo', 'Redo'],
+            ['Link', 'Unlink', 'Anchor'],
+            ['Image', 'Video', 'Flash', 'Oembed', 'Youtube', 'Audio'],
+            ['Table', 'SpecialChar'],
+            '/',
+            ['Format', 'Font', 'FontSize'],
+            ['Bold', 'Italic', 'Underline'],
+            [
+                'JustifyLeft',
+                'JustifyCenter',
+                'JustifyRight',
+                '-',
+                'NumberedList',
+                'BulletedList',
+                '-',
+                'Outdent',
+                'Indent',
+                '-',
+                'TextColor',
+                'BGColor'
+            ],
+            ['ShowBlocks']
+        ];
+    }
+
+    /**
+     * Get the toolbar configuration when CKEditor is minimized
+     * @return array
+     */
+    protected function getMinimizedToolbar()
+    {
+        return [
+            ['Save', 'NewPage', 'Templates', '-', 'PasteFromWord'],
+            ['Undo', 'Redo'],
+            ['Link', 'Image', 'Video', 'Flash', 'Youtube', 'Audio', 'Table', 'Asciimath', 'Asciisvg'],
+            ['BulletedList', 'NumberedList', 'HorizontalRule'],
+            ['JustifyLeft', 'JustifyCenter'],
+            ['Format', 'Font', 'Bold', 'Italic', 'Underline', 'TextColor', 'BGColor'],
+            ['Toolbarswitch']
+        ];
+    }
+
+}

+ 1 - 1
src/Chamilo/CoreBundle/Resources/views/Calendar/month.html.twig

@@ -402,7 +402,7 @@
                                 {% endif %}
 
                                 '{{ "Edit"|trans }}': function () {
-                                    url = "{{ path('web.main') }}calendar/agenda.php?action=edit&type=fromjs&id=" + calEvent.id + '&course_id=' + calEvent.course_id + "";
+                                    url = "{{ path('web.main') }}calendar/agenda.php?action=edit&type=fromjs&id=" + calEvent.id + '&course_id=' + calEvent.course_id + "&{{ api_get_cidreq }}";
                                     window.location.href = url;
                                     $("#dialog-form").dialog("close");
                                 },