? 156751_node_operations_and_install_defaults.patch
? install_defaults.patch
Index: private.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/private/Attic/private.module,v
retrieving revision 1.1.2.2.2.2
diff -u -p -r1.1.2.2.2.2 private.module
--- private.module	26 Jul 2008 06:12:52 -0000	1.1.2.2.2.2
+++ private.module	13 Oct 2008 16:12:48 -0000
@@ -16,6 +16,7 @@
  * when it is enabled to ensure that things are set up.
  */
 function private_enable() {
+  db_query("INSERT INTO {private} (nid, private) SELECT n.nid, 0 FROM {node} n");
   node_access_rebuild(TRUE);
 }
 
@@ -207,3 +208,44 @@ function private_theme() {
 function theme_private_node_link($node) {
   return theme('image', drupal_get_path('module', 'private') . '/icon_key.gif', t('Private'), t('This content is private'));
 }
+
+/**
+ * Implementation of hook_node_operations().
+ */
+function private_node_operations() {
+  $operations = array(
+    'private_mark_as_private' => array(
+      'label' => t('Mark nodes as private'),
+      'callback' => 'private_node_mark_private',
+    ),
+    'private_mark_as_public' => array(
+      'label' => t('Mark nodes as public'),
+      'callback' => 'private_node_mark_public',
+    ),
+  );
+  return $operations;
+}
+
+/**
+ * Callback for 'Mark as private' node operation
+ */
+function private_node_mark_private($nids) {
+  foreach ($nids as $nid) {
+    db_query('UPDATE {private} SET private = %d WHERE nid = %d', 1, $nid);
+    if (!db_affected_rows()) {
+      db_query('INSERT INTO {private} (nid, private) VALUES (%d, %d)', $nid, 1);
+    }
+  }
+}
+
+/**
+ * Callback for 'Mark as public' node operation
+ */
+function private_node_mark_public($nids) {
+  foreach ($nids as $nid) {
+    db_query('UPDATE {private} SET private = %d WHERE nid = %d', 0, $nid);
+    if (!db_affected_rows()) {
+      db_query('INSERT INTO {private} (nid, private) VALUES (%d, %d)', $nid, 0);
+    }
+  }
+}
\ No newline at end of file
