Add option to not automatically show all available shares.
authorJan Schneider <jan@horde.org>
Tue, 23 Feb 2010 23:36:23 +0000 (00:36 +0100)
committerJan Schneider <jan@horde.org>
Tue, 23 Feb 2010 23:36:43 +0000 (00:36 +0100)
27 files changed:
horde/config/conf.xml
horde/docs/CHANGES
kronolith/data.php
kronolith/lib/Api.php
kronolith/lib/Application.php
kronolith/lib/Block/month.php
kronolith/lib/Block/monthlist.php
kronolith/lib/Block/prevmonthlist.php
kronolith/lib/Block/summary.php
kronolith/lib/Kronolith.php
kronolith/lib/View/EditEvent.php
kronolith/new.php
kronolith/search.php
kronolith/templates/data/export.inc
kronolith/templates/data/import.inc
kronolith/templates/panel.inc
kronolith/templates/prefs/shareselect.inc
nag/data.php
nag/lib/Api.php
nag/lib/Application.php
nag/lib/Block/summary.php
nag/lib/Block/tree_menu.php
nag/lib/Forms/task.php
nag/templates/data/export.inc
nag/templates/data/import.inc
nag/templates/panel.inc
nag/templates/prefs/tasklistselect.inc

index 505b02f..53063ed 100644 (file)
    regardless of whether or not they are a member. If you disable it, users
    will only be able to share their resources with groups they are members
    of.">false</configboolean>
+   <configboolean name="hidden" required="false" desc="If you enable this
+   option, the shares that a user has access to will NOT be displayed
+   automatically, but only if the user subscribed to
+   them.">false</configboolean>
    <configheader>Share Caching</configheader>
    <configdescription>Enabling share caching improves performance because the
    share backend will only be queried once per session. But it also increases
index ccf96e0..4ecbe06 100644 (file)
@@ -2,6 +2,7 @@
 v4.0-cvs
 --------
 
+[jan] Add option to not automatically show all available shares.
 [jan] Add option to disallow world permissions for user shares.
 [mms] Allow Mozilla DNS prefetching to be turned off when displaying untrusted
       content (Ticket #8836).
index 006a428..62f525b 100644 (file)
@@ -296,6 +296,28 @@ if (is_array($next_step)) {
     $next_step = $data->cleanup();
 }
 
+$import_calendars = $export_calendars = array();
+if (Horde_Auth::getAuth()) {
+    $calendars = Kronolith::listCalendars(false, Horde_Perms::EDIT);
+    foreach ($calendars as $id => $calendar) {
+        if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+            !empty($GLOBALS['conf']['share']['hidden']) &&
+            !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+            continue;
+        }
+        $import_calendars[$id] = $calendar;
+    }
+}
+$calendars = Kronolith::listCalendars(false, Horde_Perms::READ);
+foreach ($calendars as $id => $calendar) {
+    if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+        !empty($GLOBALS['conf']['share']['hidden']) &&
+        !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+        continue;
+    }
+    $export_calendars[$id] = $calendar;
+}
+
 $title = _("Import/Export Calendar");
 require KRONOLITH_TEMPLATES . '/common-header.inc';
 require KRONOLITH_TEMPLATES . '/menu.inc';
index 473f1a1..24c8d4c 100644 (file)
@@ -75,6 +75,11 @@ class Kronolith_Api extends Horde_Registry_Api
             $calendars = Kronolith::listCalendars(false, Horde_Perms::READ);
             $owners = array();
             foreach ($calendars as $calendar) {
+                if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+                    !empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+                    continue;
+                }
                 $owners[$calendar->get('owner')] = true;
             }
 
index 188e2dd..7dba321 100644 (file)
@@ -257,8 +257,9 @@ class Kronolith_Application extends Horde_Registry_Application
         $default_share = Horde_Util::getFormData('default_share');
         if (!is_null($default_share)) {
             $sharelist = Kronolith::listCalendars();
-            if ((is_array($sharelist)) > 0 &&
-                isset($sharelist[$default_share])) {
+            if (isset($sharelist[$default_share]) &&
+                ($sharelist[$default_share]->get('owner') == Horde_Auth::getAuth() ||
+                 in_array($default_share, $GLOBALS['display_calendars']))) {
                 $GLOBALS['prefs']->setValue('default_share', $default_share);
                 return true;
             }
@@ -293,7 +294,6 @@ class Kronolith_Application extends Horde_Registry_Application
     protected function _prefsFbCalsSelect()
     {
         $fb_calsSelected = Horde_Util::getFormData('fb_cals');
-        $fb_cals = Kronolith::listCalendars();
         $fb_calsFiltered = array();
 
         if (isset($fb_calsSelected) && is_array($fb_calsSelected)) {
index ba8420d..ff81f78 100644 (file)
@@ -20,6 +20,11 @@ class Horde_Block_Kronolith_month extends Horde_Block {
                                             'default' => '__all'));
         $params['calendar']['values']['__all'] = _("All Visible");
         foreach (Kronolith::listCalendars() as $id => $cal) {
+            if ($cal->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($cal->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
             $params['calendar']['values'][$id] = $cal->get('name');
         }
 
index 639cb9c..2cffa5f 100644 (file)
@@ -28,6 +28,11 @@ class Horde_Block_Kronolith_monthlist extends Horde_Block {
                                           'default' => 0));
         $params['calendar']['values']['__all'] = _("All Visible");
         foreach (Kronolith::listCalendars() as $id => $cal) {
+            if ($cal->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($cal->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
             $params['calendar']['values'][$id] = $cal->get('name');
         }
 
index 31f27cc..f9164b0 100644 (file)
@@ -25,6 +25,11 @@ class Horde_Block_Kronolith_prevmonthlist extends Horde_Block {
                                           'default' => 0));
         $params['calendar']['values']['__all'] = _("All Visible");
         foreach (Kronolith::listCalendars() as $id => $cal) {
+            if ($cal->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($cal->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
             $params['calendar']['values'][$id] = $cal->get('name');
         }
 
index 9de2468..310e2c0 100644 (file)
@@ -46,6 +46,11 @@ class Horde_Block_Kronolith_summary extends Horde_Block {
                                           'default' => 0));
         $params['calendar']['values']['__all'] = _("All Visible");
         foreach (Kronolith::listCalendars() as $id => $cal) {
+            if ($cal->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($cal->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
             $params['calendar']['values'][$id] = $cal->get('name');
         }
 
index 8d003f5..4888973 100644 (file)
@@ -169,16 +169,16 @@ class Kronolith
      */
     public static function includeJSVars()
     {
-        global $browser, $conf, $prefs, $registry;
+        global $prefs, $registry;
 
         $kronolith_webroot = $registry->get('webroot');
         $horde_webroot = $registry->get('webroot', 'horde');
-        $has_tasks = $GLOBALS['registry']->hasInterface('tasks');
+        $has_tasks = $registry->hasInterface('tasks');
         $app_urls = array();
         if (isset($GLOBALS['conf']['menu']['apps']) &&
             is_array($GLOBALS['conf']['menu']['apps'])) {
             foreach ($GLOBALS['conf']['menu']['apps'] as $app) {
-                $app_urls[$app] = (string) Horde::url($GLOBALS['registry']->getInitialPage($app), true);
+                $app_urls[$app] = (string) Horde::url($registry->getInitialPage($app), true);
             }
         }
 
@@ -195,7 +195,7 @@ class Kronolith
             'app_urls' => $app_urls,
             'name' => $registry->get('name'),
             'has_tasks' => $has_tasks,
-            'is_ie6' => ($browser->isBrowser('msie') && ($browser->getMajor() < 7)),
+            'is_ie6' => ($GLOBALS['browser']->isBrowser('msie') && ($GLOBALS['browser']->getMajor() < 7)),
             'login_view' => $prefs->getValue('defaultview'),
             'default_calendar' => 'internal|' . self::getDefaultCalendar(Horde_Perms::EDIT),
             'week_start' => (int)$prefs->getValue('week_start_monday'),
@@ -225,12 +225,17 @@ class Kronolith
         );
 
         if ($has_tasks) {
-            $code['conf']['tasks'] = $GLOBALS['registry']->tasks->ajaxDefaults();
+            $code['conf']['tasks'] = $registry->tasks->ajaxDefaults();
         }
 
         // Calendars
         foreach (array(true, false) as $my) {
             foreach ($GLOBALS['all_calendars'] as $id => $calendar) {
+                if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+                    !empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+                    continue;
+                }
                 $owner = Horde_Auth::getAuth() &&
                     $calendar->get('owner') == Horde_Auth::getAuth();
                 if (($my && $owner) || (!$my && !$owner)) {
@@ -250,7 +255,12 @@ class Kronolith
             if (!$has_tasks) {
                 continue;
             }
-            foreach ($GLOBALS['registry']->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) {
+            foreach ($registry->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) {
+                if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+                    !empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array('tasks/' . $id, $GLOBALS['display_external_calendars'])) {
+                    continue;
+                }
                 $owner = Horde_Auth::getAuth() &&
                     $tasklist->get('owner') == Horde_Auth::getAuth();
                 if (($my && $owner) || (!$my && !$owner)) {
@@ -273,12 +283,16 @@ class Kronolith
                 if ($api == 'tasks') {
                     continue;
                 }
+                if (!empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array($api . '/' . $id, $GLOBALS['display_external_calendars'])) {
+                    continue;
+                }
                 $calendar = $api . '/' . $id;
                 $code['conf']['calendars']['external'][$calendar] = array(
                     'name' => $name,
                     'fg' => '#000',
                     'bg' => '#ddd',
-                    'api' => $GLOBALS['registry']->get('name', $GLOBALS['registry']->hasInterface($api)),
+                    'api' => $registry->get('name', $registry->hasInterface($api)),
                     'show' => in_array($calendar, $GLOBALS['display_external_calendars']));
             }
         }
index dddef57..06e4049 100644 (file)
@@ -74,7 +74,16 @@ class Kronolith_View_EditEvent {
         if ($this->event->creator == Horde_Auth::getAuth()) {
             $perms |= Kronolith::PERMS_DELEGATE;
         }
-        $calendars = Kronolith::listCalendars(false, $perms);
+        $all_calendars = Kronolith::listCalendars(false, $perms);
+        $calendars = array();
+        foreach ($all_calendars as $id => $calendar) {
+            if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
+            $calendars[$id] = $calendar;
+        }
 
         $buttons = array();
         if (!$this->event->hasPermission(Horde_Perms::EDIT) &&
index 06425ed..b5a11a5 100644 (file)
@@ -64,8 +64,18 @@ if (isset($url)) {
     $cancelurl = Horde::applicationUrl('month.php', true)->add('month', $month);
 }
 
+$all_calendars = Kronolith::listCalendars(false, Horde_Perms::EDIT | Kronolith::PERMS_DELEGATE);
+$calendars = array();
+foreach ($all_calendars as $id => $calendar) {
+    if ($calendar->get('owner') != Horde_Auth::getAuth() &&
+        !empty($GLOBALS['conf']['share']['hidden']) &&
+        !in_array($calendar->getName(), $GLOBALS['display_calendars'])) {
+        continue;
+    }
+    $calendars[$id] = $calendar;
+}
+
 $title = _("Add a new event");
-$calendars = Kronolith::listCalendars(false, Horde_Perms::EDIT | Kronolith::PERMS_DELEGATE);
 Horde::addScriptFile('new.js', 'kronolith');
 Horde::addScriptFile('popup.js', 'horde');
 require KRONOLITH_TEMPLATES . '/common-header.inc';
index 387b53f..cebd69a 100644 (file)
@@ -71,12 +71,20 @@ if ($search_mode == 'basic') {
         if ($cal->get('owner') && $cal->get('owner') == $current_user) {
             $calendars[_("My Calendars:")]['|' . $id] = $cal->get('name');
         } else {
+            if (!empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($cal->getName(), $GLOBALS['display_calendars'])) {
+                continue;
+            }
             $calendars[_("Shared Calendars:")]['|' . $id] = $cal->get('name');
         }
     }
     foreach ($GLOBALS['all_external_calendars'] as $api => $categories) {
         $app = $GLOBALS['registry']->get('name', $GLOBALS['registry']->hasInterface($api));
         foreach ($categories as $id => $name) {
+            if (!empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($api . '/' . $id, $GLOBALS['display_external_calendars'])) {
+                continue;
+            }
             $calendars[$app . ':']['Horde|external_' . $api . '/' . $id] = $name;
         }
     }
index 279ed57..3e89317 100644 (file)
       <option value="<?php echo Horde_Data::EXPORT_ICALENDAR ?>">iCalendar</option>
     </select><br /><br />
 
-    <?php if (count($calendars = Kronolith::listCalendars(false, Horde_Perms::READ)) > 1): ?>
+    <?php if (count($export_calendars) > 1): ?>
     <?php echo Horde::label('exportCal', _("Select the calendar(s) to export from")) ?><br />
     <select id="exportCal" name="exportCal[]" multiple="multiple">
-      <?php foreach ($calendars as $id => $cal) {
+      <?php foreach ($export_calendars as $id => $cal) {
           printf('<option value="%s">%s</option>', htmlspecialchars($id), htmlspecialchars($cal->get('name'))) . "\n";
       } ?>
     </select><br /><br />
index 141c7a3..747f71a 100644 (file)
       <option value="icalendar"><?php echo _("vCalendar/iCalendar") ?></option>
     </select><br />
 
-    <?php if (!$prefs->isLocked('default_share') && count($calendars = Kronolith::listCalendars(false, Horde_Perms::EDIT)) > 1): ?>
+    <?php if (!$prefs->isLocked('default_share') && count($import_calendars ) > 1): ?>
     <?php echo Horde::label('importCal', _("Select the calendar to import to:")) ?><br />
     <select id="importCal" name="importCal">
-      <?php foreach ($calendars as $id => $cal) {
+      <?php foreach ($import_calendars as $id => $cal) {
           printf('<option value="%s">%s</option>', htmlspecialchars($id), htmlspecialchars($cal->get('name'))) . "\n";
       } ?>
     </select><br /><br />
index a79e2ba..64aa186 100644 (file)
@@ -20,10 +20,29 @@ foreach (Kronolith::listCalendars() as $id => $cal) {
     if ($cal->get('owner') && $cal->get('owner') == $current_user) {
         $my_calendars[$id] = $cal;
     } else {
+        if (!empty($conf['share']['hidden']) &&
+            !in_array($cal->getName(), $display_calendars)) {
+            continue;
+        }
         $shared_calendars[$id] = $cal;
     }
 }
 
+$externals = array();
+foreach ($all_external_calendars as $api => $categories) {
+    if (count($categories)) {
+        $app = $registry->get('name', $registry->hasInterface($api));
+        $externals[$app] = array();
+        foreach ($categories as $id => $name) {
+            if (!empty($conf['share']['hidden']) &&
+                !in_array($api . '/' . $id, $display_external_calendars)) {
+                continue;
+            }
+            $externals[$app][$api . '/' . $id] = $name;
+        }
+    }
+}
+
 $tagger = Kronolith::getTagger();
 ?>
 <div id="pageControls">
@@ -113,33 +132,33 @@ $ta->attach();
  </ul>
 <?php endif; ?>
 
-<?php if (count($GLOBALS['all_external_calendars'])): ?>
+<?php if (count($externals)): ?>
  <h4><?php echo _("External Events:") ?></h4>
  <ul id="externalcalendars">
-<?php foreach ($GLOBALS['all_external_calendars'] as $api => $categories): ?>
+ <?php foreach ($externals as $app => $categories): ?>
  <?php if (count($categories)): ?>
-  <li class="category"><?php echo htmlspecialchars($GLOBALS['registry']->get('name', $GLOBALS['registry']->hasInterface($api))) ?></li>
-  <?php foreach ($categories as $id => $name): ?>
-   <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="external_<?php echo htmlspecialchars($api . '/' . $id) ?>"<?php echo (in_array($api . '/' . $id, $GLOBALS['display_external_calendars']) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($name) ?></label></li>
-  <?php endforeach; ?>
+  <li class="category"><?php echo htmlspecialchars($app) ?></li>
+   <?php foreach ($categories as $id => $name): ?>
+   <li><label><input type="checkbox" class="checkbox" name="display_cal[]" value="external_<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_external_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($name) ?></label></li>
+   <?php endforeach; ?>
  <?php endif; ?>
-<?php endforeach; ?>
+ <?php endforeach; ?>
  </ul>
 <?php endif; ?>
 
-<?php if (count($GLOBALS['all_remote_calendars'])): ?>
+<?php if (count($all_remote_calendars)): ?>
  <h4><?php echo _("Remote Calendars:") ?></h4>
  <ul id="remotecalendars">
-<?php foreach ($GLOBALS['all_remote_calendars'] as $id => $cal): ?>
+<?php foreach ($all_remote_calendars as $id => $cal): ?>
   <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="remote_<?php echo htmlspecialchars($cal['url']) ?>"<?php echo (in_array($cal['url'], $display_remote_calendars) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($cal['name']) ?></label> <?php echo $info_img ?></li>
 <?php endforeach; ?>
  </ul>
 <?php endif; ?>
 
-<?php if (!empty($GLOBALS['conf']['holidays']['enable'])): ?>
+<?php if (!empty($conf['holidays']['enable'])): ?>
  <h4><?php echo _("Holidays:") ?></h4>
  <ul id="holidays">
-<?php foreach ($GLOBALS['all_holidays'] as $holiday): ?>
+<?php foreach ($all_holidays as $holiday): ?>
   <li<?php echo Kronolith::getCSSColors($holiday) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="holiday_<?php echo htmlspecialchars($holiday['id']) ?>"<?php echo (in_array($holiday['id'], $display_holidays) ? ' checked="checked"' : '') . ' /> ' . htmlspecialchars($holiday['title']) ?></label></li>
 <?php endforeach; ?>
  </ul>
index cf9979c..6e23c56 100644 (file)
@@ -1,6 +1,15 @@
 <?php
 if (!$prefs->isLocked('default_share')):
-    $sharelist = Kronolith::listCalendars();
+    $all_shares = Kronolith::listCalendars();
+    $sharelist = array();
+    foreach ($all_shares as $id => $share) {
+        if ($share->get('owner') != Horde_Auth::getAuth() &&
+            !empty($GLOBALS['conf']['share']['hidden']) &&
+            !in_array($share->getName(), $GLOBALS['display_calendars'])) {
+            continue;
+        }
+        $sharelist[$id] = $share;
+    }
     if (($default_share = $prefs->getValue('default_share')) == null ||
         !isset($sharelist[$default_share])) {
         $default_share = Horde_Auth::getAuth();
@@ -9,8 +18,8 @@ if (!$prefs->isLocked('default_share')):
 
     <?php echo Horde::label('default_share', _("Your default calendar")) ?><br />
     <select id="default_share" name="default_share">
-    <?php foreach ($sharelist as $id => $share): ?>
+     <?php foreach ($sharelist as $id => $share): ?>
      <option value="<?php echo htmlspecialchars($id) ?>"<?php if ($id == $default_share) echo ' selected="selected"' ?>><?php echo htmlspecialchars($share->get('name')) ?></option>
-    <?php endforeach; ?>
+     <?php endforeach; ?>
     </select>
 <?php endif; ?>
index d6162f9..69c2ff5 100644 (file)
@@ -223,6 +223,28 @@ if (is_array($next_step)) {
     $next_step = $data->cleanup();
 }
 
+$import_tasklists = $export_tasklists = array();
+if (Horde_Auth::getAuth()) {
+    $tasklists = Nag::listTasklists(false, Horde_Perms::EDIT);
+    foreach ($tasklists as $id => $tasklist) {
+        if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+            !empty($GLOBALS['conf']['share']['hidden']) &&
+            !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+            continue;
+        }
+        $import_tasklists[$id] = $tasklist;
+    }
+}
+$tasklists = Nag::listTasklists(false, Horde_Perms::READ);
+foreach ($tasklists as $id => $tasklist) {
+    if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+        !empty($GLOBALS['conf']['share']['hidden']) &&
+        !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+        continue;
+    }
+    $export_tasklists[$id] = $tasklist;
+}
+
 $title = _("Import/Export Tasks");
 require NAG_TEMPLATES . '/common-header.inc';
 require NAG_TEMPLATES . '/menu.inc';
index 8ef354d..93c6632 100644 (file)
@@ -195,13 +195,16 @@ class Nag_Api extends Horde_Registry_Api
         $parts = explode('/', $path);
 
         if (empty($path)) {
-            //
-            // This request is for a list of all users who have tasklists visible
-            // to the requesting user.
-            //
+            // This request is for a list of all users who have tasklists
+            // visible to the requesting user.
             $tasklists = Nag::listTasklists(false, Horde_Perms::READ);
             $owners = array();
             foreach ($tasklists as $tasklist) {
+                if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+                    !empty($GLOBALS['conf']['share']['hidden']) &&
+                    !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+                    continue;
+                }
                 $owners[$tasklist->get('owner') ? $tasklist->get('owner') : '-system-'] = true;
             }
 
index f05ce13..cceefa3 100644 (file)
@@ -106,8 +106,9 @@ class Nag_Application extends Horde_Registry_Application
             $default_tasklist = Horde_Util::getFormData('default_tasklist');
             if (!is_null($default_tasklist)) {
                 $tasklists = Nag::listTasklists();
-                if (is_array($tasklists) &&
-                    isset($tasklists[$default_tasklist])) {
+                if (isset($tasklists[$default_tasklist]) &&
+                    ($tasklists[$default_tasklist]->get('owner') == Horde_Auth::getAuth() ||
+                     in_array($default_tasklist, $GLOBALS['display_tasklists']))) {
                     $GLOBALS['prefs']->setValue('default_tasklist', $default_tasklist);
                     return true;
                 }
index b9a5d26..b7b20a9 100644 (file)
@@ -32,6 +32,11 @@ class Horde_Block_nag_summary extends Horde_Block {
 
         $tasklists = array();
         foreach (Nag::listTasklists() as $id => $tasklist) {
+            if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+                continue;
+            }
             $tasklists[$id] = $tasklist->get('name');
         }
 
index b5b2bd6..844b667 100644 (file)
@@ -27,6 +27,11 @@ class Horde_Block_nag_tree_menu extends Horde_Block {
                              'url' => $add));
 
         foreach (Nag::listTasklists() as $name => $tasklist) {
+            if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+                continue;
+            }
             $tree->addNode($parent . $name . '__new',
                            $parent . '__new',
                            sprintf(_("in %s"), $tasklist->get('name')),
index 94202b7..15cb0d7 100644 (file)
@@ -26,13 +26,18 @@ class Nag_TaskForm extends Horde_Form {
         $tasklists = Nag::listTasklists(false, Horde_Perms::EDIT);
         $tasklist_enums = array();
         foreach ($tasklists as $tl_id => $tl) {
+            if ($tl->get('owner') != Horde_Auth::getAuth() &&
+                !empty($GLOBALS['conf']['share']['hidden']) &&
+                !in_array($tl->getName(), $GLOBALS['display_tasklists'])) {
+                continue;
+            }
             $tasklist_enums[$tl_id] = $tl->get('name');
         }
 
         $tasklist = $vars->get('tasklist_id');
         if (empty($tasklist)) {
-            reset($tasklists);
-            $tasklist = key($tasklists);
+            reset($tasklist_enums);
+            $tasklist = key($tasklist_enums);
         }
         $tasks = Nag::listTasks(null, null, null, array($tasklist), Nag::VIEW_FUTURE_INCOMPLETE);
         $task_enums = array('' => _("No parent task"));
@@ -74,7 +79,7 @@ class Nag_TaskForm extends Horde_Form {
 
         $this->addVariable(_("Name"), 'name', 'text', true);
         if (!$GLOBALS['prefs']->isLocked('default_tasklist') &&
-            count($tasklists) > 1) {
+            count($tasklist_enums) > 1) {
             $v = &$this->addVariable(_("Task List"), 'tasklist_id', 'enum', true, false, false, array($tasklist_enums));
             $v->setAction(Horde_Form_Action::factory('reload'));
         }
index 1e9cbf7..ff17bd6 100644 (file)
   </select>
  </p>
 
- <?php if (count($tasklists = Nag::listTasklists(false, Horde_Perms::READ)) > 1): ?>
+ <?php if (count($export_tasklists) > 1): ?>
  <p>
   <?php echo Horde::label('exportList', _("Select the task list(s) to export from:")) ?><br />
   <select id="exportList" name="exportList[]" multiple="multiple">
-    <?php foreach ($tasklists as $id => $tasklist) {
+    <?php foreach ($export_tasklists as $id => $tasklist) {
         printf('<option value="%s">%s</option>', htmlspecialchars($id), htmlspecialchars($tasklist->get('name'))) . "\n";
     } ?>
   </select>
index 182f5ac..bb45abd 100644 (file)
   </select>
  </p>
 
-<?php if (!$prefs->isLocked('default_tasklist') && count($tasklists = Nag::listTasklists(false, Horde_Perms::EDIT)) > 1): ?>
+<?php if (!$prefs->isLocked('default_tasklist') && count($import_tasklists) > 1): ?>
  <p>
   <?php echo Horde::label('tasklist_target', _("Which tasklist should the tasks be added to?")) ?><br />
   <select id="tasklist_target" name="tasklist_target">
   <?php
   $default = Nag::getDefaultTasklist(Horde_Perms::EDIT);
-  foreach ($tasklists as $id => $tasklist) {
+  foreach ($import_tasklists as $id => $tasklist) {
       $sel = ($id == $default) ? ' selected="selected"' : '';
       printf('<option value="%s"%s>%s</option>',
              htmlspecialchars($id), $sel, htmlspecialchars($tasklist->get('name'))) . "\n";
index a70cdb2..c7e15d1 100644 (file)
@@ -11,6 +11,10 @@ foreach (Nag::listTasklists() as $id => $tl) {
     if ($tl->get('owner') && $tl->get('owner') == $current_user) {
         $my_tasklists[$id] = $tl;
     } else {
+        if (!empty($conf['share']['hidden']) &&
+            !in_array($tl->getName(), $display_tasklists)) {
+            continue;
+        }
         $shared_tasklists[$id] = $tl;
     }
 }
index 52abc0f..2d77197 100644 (file)
@@ -1,6 +1,15 @@
 <?php
 if (!$prefs->isLocked('default_tasklist')):
-    $tasklists = Nag::listTasklists();
+    $all_tasklists = Nag::listTasklists();
+    $tasklists = array();
+    foreach ($all_tasklists as $id => $tasklist) {
+        if ($tasklist->get('owner') != Horde_Auth::getAuth() &&
+            !empty($GLOBALS['conf']['share']['hidden']) &&
+            !in_array($tasklist->getName(), $GLOBALS['display_tasklists'])) {
+            continue;
+        }
+        $tasklists[$id] = $tasklist;
+    }
     if (($default_tasklist = $prefs->getValue('default_tasklist')) == null ||
         !isset($tasklists[$default_tasklist])) {
         $default_tasklist = Horde_Auth::getAuth();