? test.patch
Index: program/station_program.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/program/Attic/station_program.install,v
retrieving revision 1.2
diff -u -r1.2 station_program.install
--- program/station_program.install	9 Jan 2007 18:32:00 -0000	1.2
+++ program/station_program.install	6 Aug 2007 14:57:36 -0000
@@ -35,3 +35,33 @@
 function station_program_update_100() {
   return array();
 }
+
+/**
+ * Rename the permissions.
+ * 
+ * First update for the 5.1 branch, using the update naming convention layed
+ * out in: http://drupal.org/node/114774#update-n
+ */
+function station_program_update_5100() {
+  $ret = array();
+
+  // Setup arrays holding regexps to match and the corresponding
+  // strings to replace them with, for use with preg_replace().
+  $old_perms = array(
+    '/edit own program/', 
+  );
+  $new_perms = array(
+    'edit own program content', 
+  );
+
+  // Now, loop over all the roles, and do the necessary transformations.
+  $query = db_query("SELECT rid, perm FROM {permission} ORDER BY rid");
+  while ($role = db_fetch_object($query)) {
+    $fixed_perm = preg_replace($old_perms, $new_perms, $role->perm);
+    if ($fixed_perm != $role->perm) {
+      $ret[] = update_sql("UPDATE {permission} SET perm = '$fixed_perm' WHERE rid = $role->rid");
+    }
+  }
+
+  return $ret;
+}
Index: program/station_program.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/station/program/Attic/station_program.module,v
retrieving revision 1.5.2.3
diff -u -r1.5.2.3 station_program.module
--- program/station_program.module	13 Jun 2007 22:28:16 -0000	1.5.2.3
+++ program/station_program.module	6 Aug 2007 14:55:50 -0000
@@ -50,7 +50,8 @@
 
 function station_program_perm() {
   return array(
-    'edit own program',
+    'edit program content',
+    'edit own program content',
     'administer programs',
   );
 }
@@ -74,18 +75,24 @@
       break;
 
     case 'update':
-      // TODO: figure out how to allow the schedule's decide who can edit...
-      $djs = _station_schedule_program_load_djs($node->nid);
+      if (user_access('edit program content')) {
+        return TRUE;
+      }
 
-      // Node owner and DJs can edit the program.
+      // Node owner and DJs can also edit the program.
+      $djs = _station_schedule_program_load_djs($node->nid);
       if ($node->uid == $user->uid || isset($djs[$user->uid])) {
-        return user_access('edit own program');
+        return user_access('edit own program content');
       }
       break;
 
     case 'delete':
     case 'create':
     default:
+      // If the schedule is enabled, defer to that permision.
+      if (module_exists('station_schedule')) {
+        return user_access('administer schedule');
+      }
       return user_access('administer programs');
   }
 }
