From 5730407a709d2681ec63db47e6c5e0aac24c10a3 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Thu, 3 Dec 2009 00:29:11 +0100 Subject: [PATCH] Allow share owners to be empty, in preparation for system shares (Request #2059). --- ansel/config/hooks.php.dist | 2 +- ansel/faces/search/owner.php | 6 ++++-- ansel/gallery.php | 3 ++- ansel/lib/Ansel.php | 4 +++- ansel/lib/Api.php | 2 +- ansel/lib/Faces/Base.php | 4 ++-- ansel/lib/Gallery.php | 11 ++++++++--- ansel/lib/Tags.php | 4 ++-- ansel/lib/View/List.php | 2 +- ansel/lib/Widget/Actions.php | 3 ++- ansel/lib/Widget/Links.php | 2 +- ansel/perms.php | 6 ++++-- ansel/templates/gallery/gallery.inc | 2 +- ansel/templates/view/image.inc | 7 +++++-- folks/lib/Friends/shared.php | 10 ++++++---- folks/perms.php | 6 ++++-- kronolith/calendars/info.php | 3 ++- kronolith/lib/Kronolith.php | 30 ++++++++++++++++++++---------- kronolith/lib/Tagger.php | 4 +++- kronolith/perms.php | 6 ++++-- kronolith/search.php | 2 +- kronolith/templates/calendar_info.php | 2 +- kronolith/templates/calendar_list.php | 2 +- kronolith/templates/panel.inc | 4 ++-- nag/lib/Api.php | 2 +- nag/lib/Nag.php | 13 ++++++++++--- nag/tasklists/info.php | 3 ++- nag/templates/panel.inc | 4 ++-- nag/templates/tasklist_info.php | 2 +- nag/templates/tasklist_list.php | 2 +- skoli/lib/Forms/DeleteClass.php | 3 ++- skoli/lib/Skoli.php | 6 ++++-- skoli/templates/panel.inc | 4 ++-- turba/addressbooks/delete.php | 3 ++- turba/addressbooks/edit.php | 3 ++- turba/lib/Forms/DeleteAddressBook.php | 3 ++- turba/lib/Turba.php | 3 +++ 37 files changed, 115 insertions(+), 63 deletions(-) diff --git a/ansel/config/hooks.php.dist b/ansel/config/hooks.php.dist index 1262313ad..d1cda7b4f 100644 --- a/ansel/config/hooks.php.dist +++ b/ansel/config/hooks.php.dist @@ -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; diff --git a/ansel/faces/search/owner.php b/ansel/faces/search/owner.php index de12591e0..69b221e17 100644 --- a/ansel/faces/search/owner.php +++ b/ansel/faces/search/owner.php @@ -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); diff --git a/ansel/gallery.php b/ansel/gallery.php index 93cd0d040..949fce385 100644 --- a/ansel/gallery.php +++ b/ansel/gallery.php @@ -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); } diff --git a/ansel/lib/Ansel.php b/ansel/lib/Ansel.php index 5c8d05f7b..afdb59136 100644 --- a/ansel/lib/Ansel.php +++ b/ansel/lib/Ansel.php @@ -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'], diff --git a/ansel/lib/Api.php b/ansel/lib/Api.php index 4637a7366..45b2966a1 100644 --- a/ansel/lib/Api.php +++ b/ansel/lib/Api.php @@ -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(); diff --git a/ansel/lib/Faces/Base.php b/ansel/lib/Faces/Base.php index ad0b027af..21dc99677 100644 --- a/ansel/lib/Faces/Base.php +++ b/ansel/lib/Faces/Base.php @@ -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'; } diff --git a/ansel/lib/Gallery.php b/ansel/lib/Gallery.php index afd284524..92a4627a1 100644 --- a/ansel/lib/Gallery.php +++ b/ansel/lib/Gallery.php @@ -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; } diff --git a/ansel/lib/Tags.php b/ansel/lib/Tags.php index f29be248b..a36051be2 100644 --- a/ansel/lib/Tags.php +++ b/ansel/lib/Tags.php @@ -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; } } diff --git a/ansel/lib/View/List.php b/ansel/lib/View/List.php index 155988a4c..abf27c2e7 100644 --- a/ansel/lib/View/List.php +++ b/ansel/lib/View/List.php @@ -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')); diff --git a/ansel/lib/Widget/Actions.php b/ansel/lib/Widget/Actions.php index 62b6cffa2..adab0f2af 100644 --- a/ansel/lib/Widget/Actions.php +++ b/ansel/lib/Widget/Actions.php @@ -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 .= '
  • ' . 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") . '
  • '; } elseif (!empty($conf['report_content']['driver']) && (($conf['report_content']['allow'] == 'authenticated' && Horde_Auth::isAuthenticated()) || diff --git a/ansel/lib/Widget/Links.php b/ansel/lib/Widget/Links.php index aa2da2401..dc8fb7d27 100644 --- a/ansel/lib/Widget/Links.php +++ b/ansel/lib/Widget/Links.php @@ -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) . ''; + $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")) . ''; $slug = $this->_view->gallery->get('slug'); $html .= '
    ' . 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())) . ''; diff --git a/ansel/perms.php b/ansel/perms.php index 1e79dad1e..be33237a5 100644 --- a/ansel/perms.php +++ b/ansel/perms.php @@ -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(); diff --git a/ansel/templates/gallery/gallery.inc b/ansel/templates/gallery/gallery.inc index a881b31e8..520fcb512 100644 --- a/ansel/templates/gallery/gallery.inc +++ b/ansel/templates/gallery/gallery.inc @@ -113,7 +113,7 @@ if ($prefs->isLocked('default_download')) { -get('owner')): ?> +get('owner')): ?>   diff --git a/ansel/templates/view/image.inc b/ansel/templates/view/image.inc index 37898d756..02245444a 100644 --- a/ansel/templates/view/image.inc +++ b/ansel/templates/view/image.inc @@ -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 . ''; } - 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") . ''; diff --git a/folks/lib/Friends/shared.php b/folks/lib/Friends/shared.php index 74b7507c5..b3cd4d413 100644 --- a/folks/lib/Friends/shared.php +++ b/folks/lib/Friends/shared.php @@ -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."); } diff --git a/folks/perms.php b/folks/perms.php index 928ff9d85..007f6862f 100644 --- a/folks/perms.php +++ b/folks/perms.php @@ -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(); diff --git a/kronolith/calendars/info.php b/kronolith/calendars/info.php index 83df7c327..b4865db3c 100644 --- a/kronolith/calendars/info.php +++ b/kronolith/calendars/info.php @@ -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)) { diff --git a/kronolith/lib/Kronolith.php b/kronolith/lib/Kronolith.php index 42527f755..db02ce2b0 100644 --- a/kronolith/lib/Kronolith.php +++ b/kronolith/lib/Kronolith.php @@ -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])) { diff --git a/kronolith/lib/Tagger.php b/kronolith/lib/Tagger.php index d51ac87c6..93a853e2c 100644 --- a/kronolith/lib/Tagger.php +++ b/kronolith/lib/Tagger.php @@ -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, diff --git a/kronolith/perms.php b/kronolith/perms.php index 067ed11c6..9b3865dc9 100644 --- a/kronolith/perms.php +++ b/kronolith/perms.php @@ -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(); diff --git a/kronolith/search.php b/kronolith/search.php index d5ce41213..cc809d190 100644 --- a/kronolith/search.php +++ b/kronolith/search.php @@ -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'); diff --git a/kronolith/templates/calendar_info.php b/kronolith/templates/calendar_info.php index aaf778a4d..8a34fd13a 100644 --- a/kronolith/templates/calendar_info.php +++ b/kronolith/templates/calendar_info.php @@ -15,7 +15,7 @@

    - get('owner'))) ?> + get('owner') ? sprintf(_("Local calendar owned by %s."), Kronolith::getUserName($calendar->get('owner'))) : _("Local system calendar") ?>

    diff --git a/kronolith/templates/calendar_list.php b/kronolith/templates/calendar_list.php index 63796e3a1..a7d71e8f1 100644 --- a/kronolith/templates/calendar_list.php +++ b/kronolith/templates/calendar_list.php @@ -46,7 +46,7 @@ get('name')) ?> getName(), false); echo Horde::link($url, _("Click or copy this URL to display this calendar")) . htmlspecialchars(shorten_url($url)) . '' ?> - get('owner') . '/' . $calendar->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this calendar"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '' ?> + 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)) . '' ?> getName()), _("Edit")) . $edit_img . '' ?> getName()), _("Change Permissions"), '', '_blank', Horde::popupJs($perms_url_base, array('params' => array('share' => $calendar->getName()), 'urlencode' => true)) . 'return false;') . $perms_img . '' ?> diff --git a/kronolith/templates/panel.inc b/kronolith/templates/panel.inc index 6d9b9bb25..2a2b87e4d 100644 --- a/kronolith/templates/panel.inc +++ b/kronolith/templates/panel.inc @@ -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();

    diff --git a/nag/lib/Api.php b/nag/lib/Api.php index d353d8228..868b8e3ea 100644 --- a/nag/lib/Api.php +++ b/nag/lib/Api.php @@ -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(); diff --git a/nag/lib/Nag.php b/nag/lib/Nag.php index 0c35789ba..b8ac49cee 100644 --- a/nag/lib/Nag.php +++ b/nag/lib/Nag.php @@ -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])) { diff --git a/nag/tasklists/info.php b/nag/tasklists/info.php index 557604bb3..7377a3a7b 100644 --- a/nag/tasklists/info.php +++ b/nag/tasklists/info.php @@ -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'); diff --git a/nag/templates/panel.inc b/nag/templates/panel.inc index f4e20b50e..a70cdb2f6 100644 --- a/nag/templates/panel.inc +++ b/nag/templates/panel.inc @@ -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() {

    diff --git a/nag/templates/tasklist_info.php b/nag/templates/tasklist_info.php index 2538b1ae8..af753e634 100644 --- a/nag/templates/tasklist_info.php +++ b/nag/templates/tasklist_info.php @@ -3,7 +3,7 @@

    - +

    diff --git a/nag/templates/tasklist_list.php b/nag/templates/tasklist_list.php index d8537b293..d8c96100f 100644 --- a/nag/templates/tasklist_list.php +++ b/nag/templates/tasklist_list.php @@ -27,7 +27,7 @@ get('name')) ?> getName(), false); echo Horde::link($url, _("Click or copy this URL to display this task list"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '' ?> - get('owner') . '/' . $tasklist->getName() . '.ics'; echo Horde::link($url, _("Click or copy this URL to display this task list"), '', '_blank') . htmlspecialchars(shorten_url($url)) . '' ?> + 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)) . '' ?> getName()), _("Edit")) . $edit_img . '' ?> getName()), _("Change Permissions"), '', '_blank', Horde::popupJs($perms_url_base, array('params' => array('share' => $tasklist->getName()), 'urlencode' => true)) . 'return false;') . $perms_img . '' ?> diff --git a/skoli/lib/Forms/DeleteClass.php b/skoli/lib/Forms/DeleteClass.php index 99547477c..8a8771298 100644 --- a/skoli/lib/Forms/DeleteClass.php +++ b/skoli/lib/Forms/DeleteClass.php @@ -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")); } diff --git a/skoli/lib/Skoli.php b/skoli/lib/Skoli.php index 6da54ca1e..1fd23c32b 100644 --- a/skoli/lib/Skoli.php +++ b/skoli/lib/Skoli.php @@ -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]); diff --git a/skoli/templates/panel.inc b/skoli/templates/panel.inc index c00adf785..e67660e42 100644 --- a/skoli/templates/panel.inc +++ b/skoli/templates/panel.inc @@ -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()

    diff --git a/turba/addressbooks/delete.php b/turba/addressbooks/delete.php index c251c073d..da9fc4087 100644 --- a/turba/addressbooks/delete.php +++ b/turba/addressbooks/delete.php @@ -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; diff --git a/turba/addressbooks/edit.php b/turba/addressbooks/edit.php index 85661dea1..6727ea8a8 100644 --- a/turba/addressbooks/edit.php +++ b/turba/addressbooks/edit.php @@ -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; diff --git a/turba/lib/Forms/DeleteAddressBook.php b/turba/lib/Forms/DeleteAddressBook.php index e4257efa4..6683be4de 100644 --- a/turba/lib/Forms/DeleteAddressBook.php +++ b/turba/lib/Forms/DeleteAddressBook.php @@ -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.")); } diff --git a/turba/lib/Turba.php b/turba/lib/Turba.php index eca44b8a7..c64eadf7b 100644 --- a/turba/lib/Turba.php +++ b/turba/lib/Turba.php @@ -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, -- 2.11.0