--- C:\Documents and Settings\Corey\My Documents\web\drupal_4.7.1\modules\acidfree\acidfree.module.bak	Tue Apr 25 10:01:04 2006
+++ C:\Documents and Settings\Corey\My Documents\web\drupal_4.7.1\modules\acidfree\acidfree.module	Tue May 30 15:29:51 2006
@@ -495,6 +495,7 @@
     }
     $perms[] = 'edit own acidfree elements';
     $perms[] = 'acidfree mass import';
+    $perms[] = 'can upload to any gallery';
     return $perms;
 }
 
@@ -1777,6 +1778,20 @@
     }
 
     if ($tree) {
+        // if the user cannot upload to *any* album (other than his own),
+        // then exclude all albums he did not create
+        if (!user_access('can upload to any gallery')) {
+          global $user;
+          $query = "SELECT n.nid FROM {node} n
+            LEFT JOIN {acidfree} a
+            ON n.nid = a.aid
+            WHERE a.class='album' AND n.uid!=$user->uid";
+          $resource = db_query($query);
+          while ($result = db_fetch_array($resource)){
+            $exclude[] = $result['nid'];
+          }
+        }
+
         foreach ($tree as $album) {
             if (!in_array($album->nid, $exclude)) {
                 $options[$album->nid] = str_repeat('-', $album->depth) . $album->title;
