Allow share owners to be empty, in preparation for system shares (Request #2059).
authorJan Schneider <jan@horde.org>
Wed, 2 Dec 2009 23:29:11 +0000 (00:29 +0100)
committerJan Schneider <jan@horde.org>
Wed, 2 Dec 2009 23:29:11 +0000 (00:29 +0100)
37 files changed:
ansel/config/hooks.php.dist
ansel/faces/search/owner.php
ansel/gallery.php
ansel/lib/Ansel.php
ansel/lib/Api.php
ansel/lib/Faces/Base.php
ansel/lib/Gallery.php
ansel/lib/Tags.php
ansel/lib/View/List.php
ansel/lib/Widget/Actions.php
ansel/lib/Widget/Links.php
ansel/perms.php
ansel/templates/gallery/gallery.inc
ansel/templates/view/image.inc
folks/lib/Friends/shared.php
folks/perms.php
kronolith/calendars/info.php
kronolith/lib/Kronolith.php
kronolith/lib/Tagger.php
kronolith/perms.php
kronolith/search.php
kronolith/templates/calendar_info.php
kronolith/templates/calendar_list.php
kronolith/templates/panel.inc
nag/lib/Api.php
nag/lib/Nag.php
nag/tasklists/info.php
nag/templates/panel.inc
nag/templates/tasklist_info.php
nag/templates/tasklist_list.php
skoli/lib/Forms/DeleteClass.php
skoli/lib/Skoli.php
skoli/templates/panel.inc
turba/addressbooks/delete.php
turba/addressbooks/edit.php
turba/lib/Forms/DeleteAddressBook.php
turba/lib/Turba.php

index 1262313..d1cda7b 100644 (file)
@@ -62,7 +62,7 @@ class Ansel_Hooks
 //                 $g = $GLOBALS['ansel_storage']->getGallery($image->gallery);
 //                 $pwd = $g->get('passwd');
 //                 $no_agelimit = empty($GLOBALS['conf']['ages']['limits']) || $g->get('age') == 0;
-//                 if ($g->get('owner') == Horde_Auth::getAuth() && empty($pwd) && $no_agelimit) {
+//                 if (Horde_Auth::getAuth() && $g->get('owner') == Horde_Auth::getAuth() && empty($pwd) && $no_agelimit) {
 //                     $perms[$image->gallery] = true;
 //                 } else {
 //                     $perms[$image->gallery] = false;
index de12591..69b221e 100644 (file)
@@ -14,10 +14,12 @@ require_once 'tabs.php';
 $page = Horde_Util::getFormData('page', 0);
 $perpage = $prefs->getValue('facesperpage');
 $owner = Horde_Util::getGet('owner', Horde_Auth::getAuth());
-if ($owner == Horde_Auth::getAuth()) {
+if (!$owner) {
+    $title = _("From system galleries");
+} elseif ($owner == Horde_Auth::getAuth()) {
     $title = _("From my galleries");
 } else {
-    $title = sprintf(_("From galleries of %s"));
+    $title = sprintf(_("From galleries of %s"), $owner);
 }
 
 $count = $faces->countOwnerFaces($owner);
index 93cd0d0..949fce3 100644 (file)
@@ -182,7 +182,8 @@ case 'save':
             $gallery->set('age', $gallery_age);
             $gallery->set('download', $gallery_download);
             $gallery->set('view_mode', $gallery_mode);
-            if ($gallery->get('owner') == Horde_Auth::getAuth()) {
+            if (Horde_Auth::getAuth() &&
+                $gallery->get('owner') == Horde_Auth::getAuth()) {
                 $gallery->set('passwd', $gallery_passwd);
             }
 
index 5c8d05f..afdb591 100644 (file)
@@ -706,7 +706,9 @@ class Ansel
             $owner = $gallery->get('owner');
         }
         if (!empty($owner)) {
-            if ($owner == Horde_Auth::getAuth()) {
+            if (!$owner) {
+                $owner_title = _("System Galleries");
+            } elseif ($owner == Horde_Auth::getAuth()) {
                 $owner_title = _("My Galleries");
             } elseif (!empty($GLOBALS['conf']['gallery']['customlabel'])) {
                 $uprefs = Horde_Prefs::singleton($GLOBALS['conf']['prefs']['driver'],
index 4637a73..45b2966 100644 (file)
@@ -42,7 +42,7 @@ class Ansel_Api extends Horde_Registry_Api
             $owners = array();
             $galleries = $GLOBALS['ansel_storage']->listGalleries(Horde_Perms::SHOW, null, null, false);
             foreach ($galleries  as $gallery) {
-                $owners[$gallery->data['share_owner']] = true;
+                $owners[$gallery->data['share_owner'] ? $gallery->data['share_owner'] : '-system-'] = true;
             }
 
             $results = array();
index ad0b027..21dc996 100644 (file)
@@ -250,7 +250,7 @@ class Ansel_Faces_Base
             'filter' => 's.share_owner = ' . $GLOBALS['ansel_db']->quote($owner),
             'order' => 'f.face_id DESC');
 
-        if ($owner != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() || $owner != Horde_Auth::getAuth()) {
             $info['filter'] .= ' AND s.gallery_passwd IS NULL';
         }
 
@@ -278,7 +278,7 @@ class Ansel_Faces_Base
     public function countOwnerFaces($owner)
     {
         $info = array('filter' => 's.share_owner = ' . $GLOBALS['ansel_db']->quote($owner));
-        if ($owner != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() || $owner != Horde_Auth::getAuth()) {
             $info['filter'] .= ' AND s.gallery_passwd IS NULL';
         }
 
index afd2845..92a4627 100644 (file)
@@ -81,7 +81,9 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical
      */
     public function canDownload()
     {
-        if (Horde_Auth::getAuth() == $this->data['share_owner'] || Horde_Auth::isAdmin('ansel:admin')) {
+        if (Horde_Auth::getAuth() &&
+            (Horde_Auth::getAuth() == $this->data['share_owner'] ||
+             Horde_Auth::isAdmin('ansel:admin'))) {
             return true;
         }
 
@@ -748,7 +750,8 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical
      */
     public function isOldEnough()
     {
-        if ($this->data['share_owner'] == Horde_Auth::getAuth() ||
+        if ((Horde_Auth::getAuth() &&
+             $this->data['share_owner'] == Horde_Auth::getAuth()) ||
             empty($GLOBALS['conf']['ages']['limits']) ||
             empty($this->data['attribute_age'])) {
 
@@ -780,7 +783,9 @@ class Ansel_Gallery extends Horde_Share_Object_sql_hierarchical
      */
     public function hasPasswd()
     {
-        if (Horde_Auth::getAuth() == $this->get('owner') || Horde_Auth::isAdmin('ansel:admin')) {
+        if (Horde_Auth::getAuth() &&
+            (Horde_Auth::getAuth() == $this->get('owner') ||
+             Horde_Auth::isAdmin('ansel:admin'))) {
             return false;
         }
 
index f29be24..a36051b 100644 (file)
@@ -216,7 +216,7 @@ class Ansel_Tags {
                     if (!is_a($gal, 'PEAR_Error')) {
                         $owner = $gal->get('owner');
                         if ($gal->hasPermission(Horde_Auth::getAuth(), Horde_Perms::SHOW) &&
-                            (!isset($user) || (isset($user) && $owner == $user))) {
+                            (!isset($user) || (isset($user) && $owner && $owner == $user))) {
                             $imgs[] = $id;
                         }
                     } else {
@@ -248,7 +248,7 @@ class Ansel_Tags {
                         Horde::logMessage($gallery, __FILE__, __LINE__, PEAR_LOG_ERR);
                         continue;
                     }
-                    if ($gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::SHOW)  && (!isset($user) || (isset($user) && $gallery->get('owner') == $user))) {
+                    if ($gallery->hasPermission(Horde_Auth::getAuth(), Horde_Perms::SHOW)  && (!isset($user) || (isset($user) && $gallery->get('owner') && $gallery->get('owner') == $user))) {
                         $results['galleries'][] = $id;
                     }
                 }
index 155988a..abf27c2 100644 (file)
@@ -164,7 +164,7 @@ class Ansel_View_List extends Ansel_View_Base
             }
 
             if ($num_galleries == 0 && empty($this->_params['api'])) {
-                if ($filter == $owner && $owner == Horde_Auth::getAuth()) {
+                if ($owner && $filter == $owner && $owner == Horde_Auth::getAuth()) {
                     $notification->push(_("You have no photo galleries, add one!"),
                                         'horde.message');
                     header('Location: ' . Horde_Util::addParameter(Horde::applicationUrl('gallery.php'), 'actionID', 'add'));
index 62b6cff..adab0f2 100644 (file)
@@ -180,7 +180,8 @@ class Ansel_Widget_Actions extends Ansel_Widget_Base
             }
         }
 
-        if ($this->_view->gallery->get('owner') == Horde_Auth::getAuth()) {
+        if (Horde_Auth::getAuth() &&
+            $this->_view->gallery->get('owner') == Horde_Auth::getAuth()) {
             $html .= '<li>' . Horde::link('#', '', 'popup widget', '', Horde::popupJs(Horde::applicationUrl('perms.php'), array('params' => array('cid' => $this->_view->gallery->id), 'urlencode' => true)) . 'return false;') . Horde::img('perms.png', '', '', $GLOBALS['registry']->getImageDir('horde')) . ' ' . _("Set permissions") . '</a></li>';
         } elseif (!empty($conf['report_content']['driver']) &&
                   (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) ||
index aa2da24..dc8fb7d 100644 (file)
@@ -22,7 +22,7 @@ class Ansel_Widget_Links extends Ansel_Widget_Base
         $feedurl = Horde::url('rss.php', true);
         $owner = $this->_view->gallery->get('owner');
         $html = $this->_htmlBegin();
-        $html .= Horde::link(Ansel::getUrlFor('rss_user', array('owner' => $owner))) . Horde::img('feed.png', '', '', $registry->getImageDir('horde')) . ' ' . sprintf(_("Recent photos by %s"), $owner) . '</a>';
+        $html .= Horde::link(Ansel::getUrlFor('rss_user', array('owner' => $owner))) . Horde::img('feed.png', '', '', $registry->getImageDir('horde')) . ' ' . ($owner ? sprintf(_("Recent photos by %s"), $owner) : _("Recent system photos")) . '</a>';
         $slug = $this->_view->gallery->get('slug');
         $html .= '<br />' . Horde::link(Ansel::getUrlFor('rss_gallery', array('gallery' => $this->_view->gallery->id, 'slug' => $slug))) . ' ' .  Horde::img('feed.png', '', '', $registry->getImageDir('horde')) . ' ' . sprintf(_("Recent photos in %s"), htmlspecialchars($this->_view->gallery->get('name'), ENT_COMPAT, Horde_Nls::getCharset())) . '</a>';
 
index 1e79dad..be33237 100644 (file)
@@ -39,7 +39,8 @@ case 'edit':
 
     if (is_a($share, 'PEAR_Error')) {
         $notification->push($share, 'horde.error');
-    } elseif (isset($share) && Horde_Auth::getAuth() != $share->get('owner')) {
+    } elseif (!Horde_Auth::getAuth() ||
+              (isset($share) && Horde_Auth::getAuth() != $share->get('owner'))) {
         exit('permission denied');
     }
     break;
@@ -50,7 +51,8 @@ case 'editforminherit':
     if (is_a($share, 'PEAR_Error')) {
         $notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
     } else {
-        if (Horde_Auth::getAuth() != $share->get('owner')) {
+        if (!Horde_Auth::getAuth() ||
+            Horde_Auth::getAuth() != $share->get('owner')) {
             exit('permission denied');
         }
         $perm = &$share->getPermission();
index a881b31..520fcb5 100644 (file)
@@ -113,7 +113,7 @@ if ($prefs->isLocked('default_download')) {
   </td>
 </tr>
 <?php } ?>
-<?php if (empty($gallery) || Horde_Auth::getAuth() == $gallery->get('owner')): ?>
+<?php if (Horde_Auth::getAuth() && !empty($gallery) && Horde_Auth::getAuth() == $gallery->get('owner')): ?>
 <tr>
   <td align="right" valign="top"><strong><?php echo _("Gallery Password") ?></strong>&nbsp;</td>
   <td><input name="gallery_passwd" type="password" value="<?php echo htmlspecialchars($gallery_passwd) ?>" size="50" /></td>
index 37898d7..0224544 100644 (file)
@@ -68,9 +68,12 @@ function arrowHandler(e)
         if ($this->gallery->canDownload()) {
             $actionHTML .= (empty($this->_params['api']) && $needSeperator ? ' | ' : '') . Horde::link($this->_urls['download'], '', '', '', '', '', '', array('id' => 'image_download_link')) . _("Download Original Photo"); $needSeperator = true . '</a>';
         }
-        if (empty($this->_params['api']) && $this->gallery->get('owner') != Horde_Auth::getAuth() &&
+        if (empty($this->_params['api']) &&
+            (!Horde_Auth::getAuth() ||
+             $this->gallery->get('owner') != Horde_Auth::getAuth()) &&
             !empty($GLOBALS['conf']['report_content']['driver']) &&
-            (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) ||
+            (($conf['report_content']['allow'] == 'authenticated' && 
+              Horde_Auth::isAuthenticated()) ||
              $conf['report_content']['allow'] == 'all')) {
 
             $actionHTML .=  ($needSeperator ? ' | ' : '' ) . Horde::link($this->_urls['report']) . _("Report") . '</a>';
index 74b7507..b3cd4d4 100644 (file)
@@ -91,8 +91,9 @@ class Folks_Friends_shared extends  Folks_Friends_sql {
         }
 
         // Only owners of a group can delete them
-        if (Horde_Auth::getAuth() != $share->get('owner') &&
-            !Horde_Auth::isAdmin('folks:admin')) {
+        if (!Horde_Auth::getAuth() ||
+            (Horde_Auth::getAuth() != $share->get('owner') &&
+             !Horde_Auth::isAdmin('folks:admin'))) {
             return PEAR::raiseError("You can rename only your own groups.");
         }
 
@@ -122,8 +123,9 @@ class Folks_Friends_shared extends  Folks_Friends_sql {
         }
 
         // Only owners of a group can delete them
-        if (Horde_Auth::getAuth() != $share->get('owner') &&
-            !Horde_Auth::isAdmin('folks:admin')) {
+        if (!Horde_Auth::getAuth() ||
+            (Horde_Auth::getAuth() != $share->get('owner') &&
+             !Horde_Auth::isAdmin('folks:admin'))) {
             return PEAR::raiseError("You can delete only your own groups.");
         }
 
index 928ff9d..007f686 100644 (file)
@@ -31,7 +31,8 @@ case 'edit':
     }
     if (is_a($share, 'PEAR_Error')) {
         $notification->push($share, 'horde.error');
-    } elseif (isset($share) && Horde_Auth::getAuth() != $share->get('owner')) {
+    } elseif (!Horde_Auth::getAuth() ||
+              (isset($share) && Horde_Auth::getAuth() != $share->get('owner'))) {
         exit('permission denied');
     }
     break;
@@ -41,7 +42,8 @@ case 'editform':
     if (is_a($share, 'PEAR_Error')) {
         $notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
     } else {
-        if (Horde_Auth::getAuth() != $share->get('owner')) {
+        if (!Horde_Auth::getAuth() ||
+            Horde_Auth::getAuth() != $share->get('owner')) {
             exit('permission denied');
         }
         $perm = &$share->getPermission();
index 83df7c3..b4865db 100644 (file)
@@ -29,7 +29,8 @@ if (strncmp($calendarId, 'remote_', 7) === 0) {
     $rewrite = isset($conf['urls']['pretty']) &&
         $conf['urls']['pretty'] == 'rewrite';
     $subscribe_url = Horde::url($registry->get('webroot', 'horde') . ($rewrite ? '/rpc/kronolith/' : '/rpc.php/kronolith/'), true, -1)
-      . $calendar->get('owner') . '/' . $calendar->getName() . '.ics';
+        . ($calendar->get('owner') ? $calendar->get('owner') : '-system-')
+        . '/' . $calendar->getName() . '.ics';
 }
 
 if (is_null($calendar)) {
index 42527f7..db02ce2 100644 (file)
@@ -214,10 +214,11 @@ class Kronolith
         // Calendars
         foreach (array(true, false) as $my) {
             foreach ($GLOBALS['all_calendars'] as $id => $calendar) {
-                $owner = $calendar->get('owner') == Horde_Auth::getAuth();
+                $owner = Horde_Auth::getAuth() &&
+                    $calendar->get('owner') == Horde_Auth::getAuth();
                 if (($my && $owner) || (!$my && !$owner)) {
                     $code['conf']['calendars']['internal'][$id] = array(
-                        'name' => ($owner ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ')
+                        'name' => ($owner || !$calendar->get('owner') ? '' : '[' . Horde_Auth::convertUsername($calendar->get('owner'), false) . '] ')
                             . $calendar->get('name'),
                         'desc' => $calendar->get('desc'),
                         'owner' => $owner,
@@ -233,10 +234,11 @@ class Kronolith
                 continue;
             }
             foreach ($GLOBALS['registry']->tasks->listTasklists($my, Horde_Perms::SHOW) as $id => $tasklist) {
-                $owner = $tasklist->get('owner') == Horde_Auth::getAuth();
+                $owner = Horde_Auth::getAuth() &&
+                    $tasklist->get('owner') == Horde_Auth::getAuth();
                 if (($my && $owner) || (!$my && !$owner)) {
                     $code['conf']['calendars']['tasklists']['tasks/' . $id] = array(
-                        'name' => ($owner ? '' : '[' . Horde_Auth::convertUsername($tasklist->get('owner'), false) . '] ')
+                        'name' => ($owner || !$tasklist->get('owner') ? '' : '[' . Horde_Auth::convertUsername($tasklist->get('owner'), false) . '] ')
                             . $tasklist->get('name'),
                         'desc' => $tasklist->get('desc'),
                         'owner' => $owner,
@@ -1317,6 +1319,10 @@ class Kronolith
      */
     public static function listCalendars($owneronly = false, $permission = Horde_Perms::SHOW)
     {
+        if ($owneronly && !Horde_Auth::getAuth()) {
+            return array();
+        }
+
         $calendars = $GLOBALS['kronolith_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
         if (is_a($calendars, 'PEAR_Error')) {
             Horde::logMessage($calendars, __FILE__, __LINE__, PEAR_LOG_ERR);
@@ -1389,7 +1395,8 @@ class Kronolith
      */
     public static function updateShare(&$calendar, $info)
     {
-        if ($calendar->get('owner') != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() ||
+            $calendar->get('owner') != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("You are not allowed to change this calendar."));
         }
 
@@ -1420,12 +1427,13 @@ class Kronolith
      */
     public static function deleteShare($calendar)
     {
-        if ($calendar->getName() == Horde_Auth::getAuth()) {
-            return PEAR::raiseError(_("This calendar cannot be deleted."));
+        if (!Horde_Auth::getAuth() ||
+            $calendar->get('owner') != Horde_Auth::getAuth()) {
+            return PEAR::raiseError(_("You are not allowed to delete this calendar."));
         }
 
-        if ($calendar->get('owner') != Horde_Auth::getAuth()) {
-            return PEAR::raiseError(_("You are not allowed to delete this calendar."));
+        if ($calendar->getName() == Horde_Auth::getAuth()) {
+            return PEAR::raiseError(_("This calendar cannot be deleted."));
         }
 
         // Delete the calendar.
@@ -1824,7 +1832,9 @@ class Kronolith
         $from = $identity->getDefaultFromAddress(true);
 
         $owner = $share->get('owner');
-        $recipients[$owner] = self::_notificationPref($owner, 'owner');
+        if ($owner) {
+            $recipients[$owner] = self::_notificationPref($owner, 'owner');
+        }
 
         foreach ($share->listUsers(Horde_Perms::READ) as $user) {
             if (!isset($recipients[$user])) {
index d51ac87..93a853e 100644 (file)
@@ -207,7 +207,9 @@ class Kronolith_Tagger
                 $filter['calendar'] = array($filter['calendar']);
             }
             foreach ($filter['calendar'] as $calendar) {
-                $owners[] = $GLOBALS['all_calendars'][$calendar]->get('owner');
+                if ($GLOBALS['all_calendars'][$calendar]->get('owner')) {
+                    $owners[] = $GLOBALS['all_calendars'][$calendar]->get('owner');
+                }
             }
             $args = array('tagId' => self::$_tagger->ensureTags($tags),
                           'userId' => $owners,
index 067ed11..9b3865d 100644 (file)
@@ -31,7 +31,8 @@ case 'edit':
     }
     if (is_a($share, 'PEAR_Error')) {
         $notification->push($share, 'horde.error');
-    } elseif (isset($share) && Horde_Auth::getAuth() != $share->get('owner')) {
+    } elseif (!Horde_Auth::getAuth() ||
+              (isset($share) && Horde_Auth::getAuth() != $share->get('owner'))) {
         exit('permission denied');
     }
     break;
@@ -41,7 +42,8 @@ case 'editform':
     if (is_a($share, 'PEAR_Error')) {
         $notification->push(_("Attempt to edit a non-existent share."), 'horde.error');
     } else {
-        if (Horde_Auth::getAuth() != $share->get('owner')) {
+        if (!Horde_Auth::getAuth() ||
+            Horde_Auth::getAuth() != $share->get('owner')) {
             exit('permission denied');
         }
         $perm = &$share->getPermission();
index d5ce412..cc809d1 100644 (file)
@@ -67,7 +67,7 @@ if ($search_mode == 'basic') {
     $current_user = Horde_Auth::getAuth();
     $calendars = array();
     foreach (Kronolith::listCalendars(false, Horde_Perms::READ) as $id => $cal) {
-        if ($cal->get('owner') == $current_user) {
+        if ($cal->get('owner') && $cal->get('owner') == $current_user) {
             $calendars[_("My Calendars:")]['|' . $id] = $cal->get('name');
         } else {
             $calendars[_("Shared Calendars:")]['|' . $id] = $cal->get('name');
index aaf778a..8a34fd1 100644 (file)
@@ -15,7 +15,7 @@
 <p><em><?php echo htmlspecialchars($desc) ?></em></p>
 <?php endif; ?>
 <p>
- <?php printf(_("Local calendar owned by %s."), Kronolith::getUserName($calendar->get('owner'))) ?>
+ <?php echo $calendar->get('owner') ? sprintf(_("Local calendar owned by %s."), Kronolith::getUserName($calendar->get('owner'))) : _("Local system calendar") ?>
  <?php echo _("To subscribe to this calendar from another calendar program, use this URL:") ?>
 </p>
 <p class="calendar-info-url">
index 63796e3..a7d71e8 100644 (file)
@@ -46,7 +46,7 @@
    <td><?php echo htmlspecialchars($calendar->get('name')) ?></td>
    <td><?php echo _("Local") ?></td>
    <td><?php $url = Horde_Util::addParameter($display_url_base, 'display_cal', $calendar->getName(), false); echo Horde::link($url, _("Click or copy this URL to display this calendar")) . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
-   <td><?php $url = $subscribe_url_base . $calendar->get('owner') . '/' . $calendar->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this calendar"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
+   <td><?php $url = $subscribe_url_base . ($calendar->get('owner') ? $calendar->get('owner') : '-system-') . '/' . $calendar->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this calendar"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
    <td><?php echo Horde::link(Horde_Util::addParameter($edit_url_base, 'c', $calendar->getName()), _("Edit")) . $edit_img . '</a>' ?></td>
 <?php if (empty($conf['share']['no_sharing'])): ?>
    <td><?php echo Horde::link(Horde_Util::addParameter($perms_url_base, 'share', $calendar->getName()), _("Change Permissions"), '', '_blank', Horde::popupJs($perms_url_base, array('params' => array('share' => $calendar->getName()), 'urlencode' => true)) . 'return false;') . $perms_img . '</a>' ?></td>
index 6d9b9bb..2a2b87e 100644 (file)
@@ -17,7 +17,7 @@ $current_user = Horde_Auth::getAuth();
 $my_calendars = array();
 $shared_calendars = array();
 foreach (Kronolith::listCalendars() as $id => $cal) {
-    if ($cal->get('owner') == $current_user) {
+    if ($cal->get('owner') && $cal->get('owner') == $current_user) {
         $my_calendars[$id] = $cal;
     } else {
         $shared_calendars[$id] = $cal;
@@ -109,7 +109,7 @@ $ta->attach();
  <h4><?php echo _("Shared Calendars:") ?></h4>
  <ul id="sharedcalendars">
 <?php foreach ($shared_calendars as $id => $cal): ?>
-  <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars(Horde_Auth::convertUsername($cal->get('owner'), false)) . '] ' . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?></li>
+   <li<?php echo Kronolith::getCSSColors($cal) ?>><label><input type="checkbox" class="checkbox" name="display_cal[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_calendars) ? ' checked="checked"' : '') . ' /> ' . ($cal->get('owner') ? '[' . htmlspecialchars(Horde_Auth::convertUsername($cal->get('owner'), false)) . '] ' : '') . htmlspecialchars($cal->get('name')) ?></label> <?php echo $info_img ?></li>
 <?php endforeach; ?>
  </ul>
 <?php endif; ?>
index d353d82..868b8e3 100644 (file)
@@ -206,7 +206,7 @@ class Nag_Api extends Horde_Registry_Api
             $tasklists = Nag::listTasklists(false, Horde_Perms::READ);
             $owners = array();
             foreach ($tasklists as $tasklist) {
-                $owners[$tasklist->get('owner')] = true;
+                $owners[$tasklist->get('owner') ? $tasklist->get('owner') : '-system-'] = true;
             }
 
             $results = array();
index 0c35789..b8ac49c 100644 (file)
@@ -362,6 +362,9 @@ class Nag
      */
     function listTasklists($owneronly = false, $permission = Horde_Perms::SHOW)
     {
+        if ($owneronly && !Horde_Auth::getAuth()) {
+            return array();
+        }
         $tasklists = $GLOBALS['nag_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
         if (is_a($tasklists, 'PEAR_Error')) {
             Horde::logMessage($tasklists, __FILE__, __LINE__, PEAR_LOG_ERR);
@@ -459,7 +462,8 @@ class Nag
      */
     public static function updateTasklist(&$tasklist, $info)
     {
-        if ($tasklist->get('owner') != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() ||
+            $tasklist->get('owner') != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("You are not allowed to change this task list."));
         }
 
@@ -483,7 +487,8 @@ class Nag
             return PEAR::raiseError(_("This task list cannot be deleted."));
         }
 
-        if ($tasklist->get('owner') != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() ||
+            $tasklist->get('owner') != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("You are not allowed to delete this task list."));
         }
 
@@ -828,7 +833,9 @@ class Nag
         $from = $identity->getDefaultFromAddress(true);
 
         $owner = $share->get('owner');
-        $recipients[$owner] = Nag::_notificationPref($owner, 'owner');
+        if (strlen($owner)) {
+            $recipients[$owner] = Nag::_notificationPref($owner, 'owner');
+        }
 
         foreach ($share->listUsers(Horde_Perms::READ) as $user) {
             if (empty($recipients[$user])) {
index 557604b..7377a3a 100644 (file)
@@ -19,7 +19,8 @@ if (is_a($tasklist, 'PEAR_Error')) {
 }
 
 $subscribe_url = Horde::url($registry->get('webroot', 'horde') . '/rpc.php/nag/', true, -1)
-  . $tasklist->get('owner') . '/' . $tasklist->getName() . '.ics';
+    . ($tasklist->get('owner') ? $tasklist->get('owner') : '')
+    . '/' . $tasklist->getName() . '.ics';
 
 $identity = Horde_Prefs_Identity::singleton('none', $tasklist->get('owner'));
 $owner_name = $identity->getValue('fullname');
index f4e20b5..a70cdb2 100644 (file)
@@ -8,7 +8,7 @@ $current_user = Horde_Auth::getAuth();
 $my_tasklists = array();
 $shared_tasklists = array();
 foreach (Nag::listTasklists() as $id => $tl) {
-    if ($tl->get('owner') == $current_user) {
+    if ($tl->get('owner') && $tl->get('owner') == $current_user) {
         $my_tasklists[$id] = $tl;
     } else {
         $shared_tasklists[$id] = $tl;
@@ -81,7 +81,7 @@ document.observe('dom:loaded', function() {
  <h4><?php echo _("Shared Task Lists:") ?></h4>
  <ul id="sharedtasklists">
 <?php foreach ($shared_tasklists as $id => $tl): ?>
-  <li><label><input type="checkbox" class="checkbox" name="display_tasklist[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_tasklists) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars(Horde_Auth::convertUsername($tl->get('owner'), false)) . '] ' . htmlspecialchars($tl->get('name')) ?></label> <?php echo $info_img ?></li>
+   <li><label><input type="checkbox" class="checkbox" name="display_tasklist[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_tasklists) ? ' checked="checked"' : '') . ' /> ' . ($tl->get('owner') ? '[' . htmlspecialchars(Horde_Auth::convertUsername($tl->get('owner'), false)) . '] ' : '') . htmlspecialchars($tl->get('name')) ?></label> <?php echo $info_img ?></li>
 <?php endforeach; ?>
  </ul>
 <?php endif; ?>
index 2538b1a..af753e6 100644 (file)
@@ -3,7 +3,7 @@
 <p><em><?php echo htmlspecialchars($desc) ?></em></p>
 <?php endif; ?>
 <p>
- <?php printf(_("Task List owned by %s."), $owner_name) ?>
+ <?php echo $owner_name ? sprintf(_("Task List owned by %s."), $owner_name) : _("Task List owned by system.") ?>
  <?php echo _("To subscribe to this task list from another program, use this URL: ") ?>
 </p>
 <p class="tasklist-info-url">
index d8537b2..d8c9610 100644 (file)
@@ -27,7 +27,7 @@
   <tr>
    <td><?php echo htmlspecialchars($tasklist->get('name')) ?></td>
    <td><?php $url = Horde_Util::addParameter($display_url_base, 'display_cal', $tasklist->getName(), false); echo Horde::link($url, _("Click or copy this URL to display this task list"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
-   <td><?php $url = $subscribe_url_base . $tasklist->get('owner') . '/' . $tasklist->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this task list"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
+   <td><?php $url = $subscribe_url_base . ($tasklist->get('owner') ? $tasklist->get('owner') : '-system-') . '/' . $tasklist->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this task list"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '</a>' ?></td>
    <td><?php echo Horde::link(Horde_Util::addParameter($edit_url_base, 't', $tasklist->getName()), _("Edit")) . $edit_img . '</a>' ?></td>
 <?php if (empty($conf['share']['no_sharing'])): ?>
    <td><?php echo Horde::link(Horde_Util::addParameter($perms_url_base, 'share', $tasklist->getName()), _("Change Permissions"), '', '_blank', Horde::popupJs($perms_url_base, array('params' => array('share' => $tasklist->getName()), 'urlencode' => true)) . 'return false;') . $perms_img . '</a>' ?></td>
index 9954747..8a87712 100644 (file)
@@ -46,7 +46,8 @@ class Skoli_DeleteClassForm extends Horde_Form {
             return false;
         }
 
-        if ($this->_class->get('owner') != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() ||
+            $this->_class->get('owner') != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("Permission denied"));
         }
 
index 6da54ca..1fd23c3 100644 (file)
@@ -132,7 +132,9 @@ class Skoli {
      */
     function listClasses($owneronly = false, $permission = Horde_Perms::SHOW)
     {
-        global $registry;
+        if ($owneronly && !Horde_Auth::getAuth()) {
+            return array();
+        }
 
         $classes = $GLOBALS['skoli_shares']->listShares(Horde_Auth::getAuth(), $permission, $owneronly ? Horde_Auth::getAuth() : null, 0, 0, 'name');
         if (is_a($classes, 'PEAR_Error')) {
@@ -141,7 +143,7 @@ class Skoli {
         }
 
         // Check if we have access to the attached addressbook.
-        $addressbooks = $registry->call('contacts/sources');
+        $addressbooks = $GLOBALS['registry']->call('contacts/sources');
         foreach ($classes as $key=>$val) {
             if (!isset($addressbooks[$val->get('address_book')])) {
                 unset($classes[$key]);
index c00adf7..e67660e 100644 (file)
@@ -5,7 +5,7 @@ $current_user = Horde_Auth::getAuth();
 $my_classes = array();
 $shared_classes = array();
 foreach (Skoli::listClasses() as $id => $cl) {
-    if ($cl->get('owner') == $current_user) {
+    if ($cl->get('owner') && $cl->get('owner') == $current_user) {
         $my_classes[$id] = $cl;
     } else {
         $shared_classes[$id] = $cl;
@@ -62,7 +62,7 @@ function sbarToggle()
  <h4><?php echo _("Shared Classes:") ?></h4>
  <ul id="sharedclasses">
 <?php foreach ($shared_classes as $id => $cl): ?>
-  <li><label><input type="checkbox" class="checkbox" name="display_class[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_classes) ? ' checked="checked"' : '') . ' /> [' . htmlspecialchars(Horde_Auth::convertUsername($cl->get('owner'), false)) . '] ' . htmlspecialchars($cl->get('name')) ?></label></li>
+   <li><label><input type="checkbox" class="checkbox" name="display_class[]" value="<?php echo htmlspecialchars($id) ?>"<?php echo (in_array($id, $display_classes) ? ' checked="checked"' : '') . ' /> ' . ($cl->get('owner') ? '[' . htmlspecialchars(Horde_Auth::convertUsername($cl->get('owner'), false)) . '] ' : '') . htmlspecialchars($cl->get('name')) ?></label></li>
 <?php endforeach; ?>
  </ul>
 <?php endif; ?>
index c251c07..da9fc40 100644 (file)
@@ -32,7 +32,8 @@ if (is_a($addressbook, 'PEAR_Error')) {
     $notification->push($addressbook, 'horde.error');
     header('Location: ' . Horde::applicationUrl('addressbooks/', true));
     exit;
-} elseif ($addressbook->get('owner') != Horde_Auth::getAuth()) {
+} elseif (!Horde_Auth::getAuth() ||
+          $addressbook->get('owner') != Horde_Auth::getAuth()) {
     $notification->push(_("You are not allowed to delete this addressbook."), 'horde.error');
     header('Location: ' . Horde::applicationUrl('addressbooks/', true));
     exit;
index 85661de..6727ea8 100644 (file)
@@ -25,7 +25,8 @@ if (is_a($addressbook, 'PEAR_Error')) {
     $notification->push($addressbook, 'horde.error');
     header('Location: ' . Horde::applicationUrl('addressbooks/', true));
     exit;
-} elseif ($addressbook->get('owner') != Horde_Auth::getAuth()) {
+} elseif (!Horde_Auth::getAuth() ||
+          $addressbook->get('owner') != Horde_Auth::getAuth()) {
     $notification->push(_("You are not allowed to change this addressbook."), 'horde.error');
     header('Location: ' . Horde::applicationUrl('addressbooks/', true));
     exit;
index e4257ef..6683be4 100644 (file)
@@ -46,7 +46,8 @@ class Turba_DeleteAddressBookForm extends Horde_Form {
             return false;
         }
 
-        if ($this->_addressbook->get('owner') != Horde_Auth::getAuth()) {
+        if (!Horde_Auth::getAuth() ||
+            $this->_addressbook->get('owner') != Horde_Auth::getAuth()) {
             return PEAR::raiseError(_("You do not have permissions to delete this address book."));
         }
 
index eca44b8..c64eadf 100644 (file)
@@ -507,6 +507,9 @@ class Turba {
             // No backends are configured to provide shares
             return array();
         }
+        if ($owneronly && !Horde_Auth::getAuth()) {
+            return array();
+        }
 
         $sources = $GLOBALS['turba_shares']->listShares(
             Horde_Auth::getAuth(), $permission,