Browse Source

Fixing agenda calendar view.

Julio Montoya 11 years ago
parent
commit
7f18bf57ad
2 changed files with 17 additions and 8 deletions
  1. 11 4
      main/calendar/agenda.lib.php
  2. 6 4
      main/calendar/agenda_js.php

+ 11 - 4
main/calendar/agenda.lib.php

@@ -1539,6 +1539,7 @@ class Agenda
             $select->addOptGroup($options, get_lang('Groups'));
         }
 
+
         // adding the individual users to the select form
         if (is_array($userList)) {
             $options = array();
@@ -1549,9 +1550,11 @@ class Agenda
                 );
 
                 $selected = in_array($user['user_id'], $sendToUsers) ? true : false;
+
                 if ($selected) {
                     $option['selected'] = 'selected';
                 }
+
                 if ($addOnlyItemsInSendTo) {
                     if ($selected) {
                         $options[] = $option;
@@ -1560,6 +1563,7 @@ class Agenda
                     $options[] = $option;
                 }
             }
+
             $select->addOptGroup($options, get_lang('Users'));
         }
     }
@@ -1774,11 +1778,16 @@ class Agenda
      * @param bool $addOnlyItemsInSendTo
      * @return bool
      */
-    public function showToForm($form, $sendTo = array(), $attributes = array(), $addOnlyItemsInSendTo = false)
-    {
+    public function showToForm(
+        $form,
+        $sendTo = array(),
+        $attributes = array(),
+        $addOnlyItemsInSendTo = false
+    ) {
         if ($this->type != 'course') {
             return false;
         }
+
         $order = 'lastname';
         if (api_is_western_name_order()) {
             $order = 'firstname';
@@ -2276,6 +2285,4 @@ class Agenda
             'groups' => array($groupId)
         );
     }
-
-
 }

+ 6 - 4
main/calendar/agenda_js.php

@@ -193,13 +193,15 @@ $course_code = api_get_course_id();
 
     $form = new FormValidator('form', 'get', null, null, array('id' => 'add_event_form'));
     $form->addElement('html', '<div id="visible_to_input">');
+
     $sendTo = $agenda->parseAgendaFilter($userId);
-    $showAll = false;
-    if ($sendTo == 'everyone') {
-        $showAll = true;
+    $addOnlyItemsInSendTo = true;
+
+    if ($sendTo['everyone']) {
+        $addOnlyItemsInSendTo = false;
     }
 
-    $agenda->showToForm($form, $sendTo, array(), $showAll);
+    $agenda->showToForm($form, $sendTo, array(), $addOnlyItemsInSendTo);
     $form->addElement('html', '</div>');
 
     $form->addElement('html', '<div id="visible_to_read_only" style="display: none">');