[ansel] Problem with sub-galleries and XP-publishing???

Heath S. Hendrickson heath at outerspaceconsultants.com
Fri Mar 19 22:12:46 PST 2004


>>> Also, XP-publishing is still broken for me.  I'm not sure if it's 
>>> related to the same thing, but my guess is that it is...  I'll see 
>>> if I can do a quick fix, otherwise I'll leave it up to Ben to fix.
>>>
>>> h
>>
>> Attached are patches to xppublish.php and 
>> templates/xppublish/list.inc that accomodate the new output of 
>> Ansel::listGalleries().  I had to add a little extra code to deal 
>> with the different array format for groupby=owner, but not that much.
>
> Okay, scap that patch... I missed another place where I needed to make 
> the modifications... I'm thinking it'll just be easier to create a new 
> Ansel function called checkPerms($galleryId, $perm) that will return 
> True/False.  It'll save on processing overhead of calling 
> Ansel::listGalleries(PERM_EDIT) several times when all you need is to 
> know if the user has a certain permission for the gallery.
>
> h
>
Attached is a revised patch that makes use of the 
$gallery->hasPermission() call to check the permissions before selecting 
the gallery and subsequently publishing the photos... I tested it on my 
system and it works.  This way there is no klunky code to deal with 
groupby differences in listGalleries().

The previous patch for templates/xppublish/list.inc is still valid and 
needs to be applied, however.

h
-------------- next part --------------
Index: xppublish.php
===================================================================
RCS file: /usr/local/horde/cvs/ansel/xppublish.php,v
retrieving revision 1.18
diff -u -r1.18 xppublish.php
--- xppublish.php	4 Feb 2004 17:39:58 -0000	1.18
+++ xppublish.php	20 Mar 2004 06:08:26 -0000
@@ -83,12 +83,15 @@
 
 // Check if a gallery was selected from the list.
 if ($cmd == 'select') {
-    if (!$galleryId) {
-        $error = _("No gallery specified.") . "<br />\n";
-    } elseif (!array_key_exists($galleryId, Ansel::listGalleries(PERMS_EDIT))) {
-        $error = _("You cannot add photos in that gallery.");
+    if (!$galleryId || !$ansel_shares->exists($galleryId)) { 
+        $error = _("Invalid gallery specified.") . "<br />\n";
     } else {
-        $error = false;
+        $gallery = &$ansel_shares->getShare($galleryId);
+        if (is_a($gallery, 'PEAR_ERROR') || !$gallery->hasPermission(Auth::getAuth(), PERMS_EDIT)) {
+            $error = _("You cannot add photos in that gallery.");
+        } else {
+            $error = false;
+        }
     }
 
     if ($error) {
@@ -182,11 +185,17 @@
     $galleryId = Util::getFormData('gallery');
     $name = isset($_FILES['imagefile']['name']) ? $_FILES['imagefile']['name'] : null;
     $file = isset($_FILES['imagefile']['tmp_name']) ? $_FILES['imagefile']['tmp_name'] : null;
-    if (empty($galleryId)) {
-        $error = _("No gallery selected.");
-    } elseif (!array_key_exists($galleryId, Ansel::listGalleries(PERMS_EDIT))) {
-        $error = _("You cannot add to this gallery.");
-    } elseif (!$name) {
+    if (!$galleryId || !$ansel_shares->exists($galleryId)) { 
+        $error = _("Invalid gallery specified.") . "<br />\n";
+    } else {
+        $gallery = &$ansel_shares->getShare($galleryId);
+        if (is_a($gallery, 'PEAR_ERROR') || !$gallery->hasPermission(Auth::getAuth(), PERMS_EDIT)) {
+            $error = _("You cannot add photos in that gallery.");
+        } else {
+            $error = false;
+        }
+    }
+    if (!$name || $error) {
         $error = _("No file specified");
     } else {
         $fp = @fopen($file, 'rb');


More information about the ansel mailing list