? hook_access.patch
? link_add.patch
? module_dep.patch
Index: shazamgallery.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/shazamgallery/shazamgallery.module,v
retrieving revision 1.22
diff -u -p -r1.22 shazamgallery.module
--- shazamgallery.module	3 Mar 2006 14:19:16 -0000	1.22
+++ shazamgallery.module	22 Mar 2006 22:56:30 -0000
@@ -29,6 +29,27 @@ function shazamgallery_perm() {
 }
 
 /**
+ * Implementation of hook_access
+ */
+function shazamgallery_access($op, $node) {
+  global $user;
+
+  if ($op == 'create') {
+    return user_access('create gallery');
+  }
+
+  if ($op == 'update' || $op == 'delete') {
+    if (user_access('edit own gallery') && ($user->uid == $node->uid)) {
+      return TRUE;
+    }
+  }
+
+  if ($op == 'add to gallery') {
+    return user_access('create images');
+  }
+}
+
+/**
  * Implementation of hook_settings
  */
 function shazamgallery_settings() {
@@ -194,9 +215,13 @@ function shazamgallery_form_alter($form_
     if ('image_node_form' == $form_id) {
       $node = $form['#node'];
 
-      //Todo: make the default per-parent-gallery
-      $parents = shazamgallery_get_parents($node->nid);
-
+      if ($node->nid) {
+        //Todo: make the default per-parent-gallery
+        $parents = shazamgallery_get_parents($node->nid);
+      }
+      elseif (arg(3) == 'gallery' && is_numeric(arg(4))) {
+        $parents = array(arg(4));
+      }
       $options = array('<'.t('none').'>');
       foreach (shazamgallery_get_galleries() as $gallery) {
         $options[$gallery->nid] = $gallery->title;
@@ -256,6 +281,13 @@ function shazamgallery_link($type, $node
   $links = array();
   $types = variable_get('shazamgallery_nodes', array('image'));
 
+  if ($node && $node->type == 'gallery' && 
+    shazamgallery_access('add to gallery', $node)) {
+    foreach ($types as $type) {
+      $links[] = l(t('add %s', array('%s' => $type)), "node/add/$type/gallery/$node->nid");
+    }
+  }
+
   if ($type == "page" && user_access('access content')) {
     if (_image_get_vid()) {
       $links[] = l(t("image galleries"), "gallery");
@@ -265,6 +297,7 @@ function shazamgallery_link($type, $node
   return $links;
 }
 
+
 /**
  * Implementation of hook_block.
  *
