From 8c43670cb5031a36c44808a216879132eda09a91 Wed, 4 May 2011 09:56:42 -0700
From: Geoff Appleby <geoff@fraek.ca>
Date: Wed, 4 May 2011 09:53:51 -0700
Subject: [PATCH] Allow other modules to specify special roles which cannot be optimized away.

diff --git a/content_access.module b/content_access.module
index 97c6f80..b40446b 100644
--- a/content_access.module
+++ b/content_access.module
@@ -453,6 +453,8 @@
   }
   // Detect if all are allowed to view
   $all = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
+  $all = array_merge($all, module_invoke_all('content_access_special_roles'));
+
   if (count(array_diff($all, $rids['view'])) == 0) {
     //grant view access to all instead of single roles
     $rids['view'] = array('all');
@@ -461,7 +463,12 @@
   // If authenticated users are involved, remove unnecessary other roles.
   foreach (array('view', 'update', 'delete') as $op) {
     if (in_array(DRUPAL_AUTHENTICATED_RID, $rids[$op])) {
-      $rids[$op] = in_array(DRUPAL_ANONYMOUS_RID, $rids[$op]) ? array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID) : array(DRUPAL_AUTHENTICATED_RID);
+      foreach ($all as $role) {
+        if (in_array($role, $rids[$op])) {
+          $temp_rids[] = $role;
+        }
+      }
+      $rids[$op] = $temp_rids;
     }
   }
 
diff --git a/translations/content_access.pot b/translations/content_access.pot
deleted file mode 100644
index 6bd5483..0000000
--- a/translations/content_access.pot
+++ /dev/null
@@ -1,273 +0,0 @@
-#
-# LANGUAGE translation of Drupal (general)
-# Copyright YEAR NAME <EMAIL@ADDRESS>
-# Generated from files:
-#  content_access.admin.inc,v 1.1.2.21 2009/03/17 16:04:15 fago
-#  content_access_test_help.php,v 1.1.4.2 2009/01/02 15:01:01 fago
-#  content_access.rules.inc: n/a
-#  content_access.module,v 1.1.2.9.2.18 2009/03/17 17:10:43 fago
-#  content_access.info,v 1.1.4.1 2008/06/30 08:56:27 fago
-#
-#, fuzzy
-msgid ""
-msgstr ""
-"Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2009-05-09 14:16+0200\n"
-"PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
-"Last-Translator: NAME <EMAIL@ADDRESS>\n"
-"Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
-
-#: content_access.admin.inc:17
-msgid "Access control for %title"
-msgstr ""
-
-#: content_access.admin.inc:31
-msgid "User access control lists"
-msgstr ""
-
-#: content_access.admin.inc:32
-msgid "These settings allow you to grant access to specific users."
-msgstr ""
-
-#: content_access.admin.inc:39
-msgid "Grant !op access"
-msgstr ""
-
-#: content_access.admin.inc:47;136 tests/content_access_test_help.php:68;115
-msgid "Submit"
-msgstr ""
-
-#: content_access.admin.inc:52
-msgid "Reset to defaults"
-msgstr ""
-
-#: content_access.admin.inc:59
-msgid "Warning: Your content is not published, so this settings are not taken into account as long as the content remains unpublished."
-msgstr ""
-
-#: content_access.admin.inc:86;183 tests/content_access_test_help.php:69;116
-msgid "Your changes have been saved."
-msgstr ""
-
-#: content_access.admin.inc:93
-msgid "The permissions have been reseted to the content type defaults."
-msgstr ""
-
-#: content_access.admin.inc:112
-msgid "Per content node access control settings"
-msgstr ""
-
-#: content_access.admin.inc:114
-msgid "Optionally you can enable per content node access control settings. If enabled, a new tab for the content access settings appears when viewing content. You have to configure permission to access these settings at the !permissions page."
-msgstr ""
-
-#: content_access.admin.inc:114
-msgid "permissions"
-msgstr ""
-
-#: content_access.admin.inc:118
-msgid "Enable per content node access control settings"
-msgstr ""
-
-#: content_access.admin.inc:124
-msgid "Advanced"
-msgstr ""
-
-#: content_access.admin.inc:130
-msgid "Give content node grants priority"
-msgstr ""
-
-#: content_access.admin.inc:132
-msgid "If you are only using this access control module, you can safely ignore this. If you are using multiple access control modules you can adjust the priority of this module."
-msgstr ""
-
-#: content_access.admin.inc:179
-msgid "Permissions have been successfully rebuilt for the content type @types."
-msgstr ""
-
-#: content_access.admin.inc:255
-msgid "Role based access control settings"
-msgstr ""
-
-#: content_access.admin.inc:257
-msgid "Note that users need at least the %access_content permission to be able to deal in any way with content."
-msgstr ""
-
-#: content_access.admin.inc:257;329
-msgid "access content"
-msgstr ""
-
-#: content_access.admin.inc:258
-msgid "Furthermore note that content which is not @published is treated in a different way by drupal: It can be viewed only by its author or users with the %administer_nodes permission."
-msgstr ""
-
-#: content_access.admin.inc:258
-msgid "published"
-msgstr ""
-
-#: content_access.admin.inc:258;336
-msgid "administer nodes"
-msgstr ""
-
-#: content_access.admin.inc:265
-msgid "View any content"
-msgstr ""
-
-#: content_access.admin.inc:273
-msgid "Edit any content"
-msgstr ""
-
-#: content_access.admin.inc:281
-msgid "Delete any content"
-msgstr ""
-
-#: content_access.admin.inc:292
-msgid "View own content"
-msgstr ""
-
-#: content_access.admin.inc:300
-msgid "Edit own content"
-msgstr ""
-
-#: content_access.admin.inc:308
-msgid "Delete own content"
-msgstr ""
-
-#: content_access.admin.inc:329
-msgid "This role is lacking the permission '@perm', so it has no access."
-msgstr ""
-
-#: content_access.admin.inc:336
-msgid "This role has '@perm' permission, so access is granted."
-msgstr ""
-
-#: content_access.admin.inc:353
-msgid "Permission is granted due to the content type's access control settings."
-msgstr ""
-
-#: content_access.admin.inc:382
-msgid "Permissions have been successfully rebuilt for the content type @types."
-msgid_plural "Permissions have been successfully rebuilt for the content types @types."
-msgstr[0] ""
-msgstr[1] ""
-
-#: content_access.rules.inc:32
-msgid "Can't set per content permissions for content type @type. Make sure to have per content settings activated for content types you want to alter access control for."
-msgstr ""
-
-#: content_access.rules.inc:45
-msgid "Grant content permissions by role"
-msgstr ""
-
-#: content_access.rules.inc:47;54;61;71;79;225
-msgid "Content"
-msgstr ""
-
-#: content_access.rules.inc:52
-msgid "Revoke content permissions by role"
-msgstr ""
-
-#: content_access.rules.inc:59
-msgid "Reset content permissions"
-msgstr ""
-
-#: content_access.rules.inc:69
-msgid "Grant access for a user"
-msgstr ""
-
-#: content_access.rules.inc:72;80
-msgid "User"
-msgstr ""
-
-#: content_access.rules.inc:77
-msgid "Revoke access for a user"
-msgstr ""
-
-#: content_access.rules.inc:156
-msgid "Operations to grant access for"
-msgstr ""
-
-#: content_access.rules.inc:164
-msgid "Note that this action is not going to revoke access for not chosen operations."
-msgstr ""
-
-#: content_access.rules.inc:167
-msgid "Grant access for @user."
-msgstr ""
-
-#: content_access.rules.inc:191
-msgid "Operations to revoke access for"
-msgstr ""
-
-#: content_access.rules.inc:199
-msgid "Note that this action is only able to revoke access that has been previously granted with the help of the content access module."
-msgstr ""
-
-#: content_access.rules.inc:202
-msgid "Revoke access for @user."
-msgstr ""
-
-#: content_access.rules.inc:223
-msgid "Check role based settings"
-msgstr ""
-
-#: content_access.rules.inc:227
-msgid "Evaluates to TRUE, if content access allows all selected operations for the given roles."
-msgstr ""
-
-#: content_access.module:29;16 content_access.info:0
-msgid "Access control"
-msgstr ""
-
-#: content_access.module:30
-msgid "Configure content access control."
-msgstr ""
-
-#: content_access.module:494
-msgid "Content access: No access is granted."
-msgstr ""
-
-#: content_access.module:498
-msgid "Content access: author of the content can access"
-msgstr ""
-
-#: content_access.module:500
-msgid "Content access: %role can access"
-msgstr ""
-
-#: content_access.module:56
-msgid "grant content access"
-msgstr ""
-
-#: content_access.module:56
-msgid "grant own content access"
-msgstr ""
-
-#: content_access.module:0
-msgid "content_access"
-msgstr ""
-
-#: content_access.info:0
-msgid "Content Access"
-msgstr ""
-
-#: content_access.info:0
-msgid "Provides flexible content access control"
-msgstr ""
-
-#: tests/content_access_test_help.php:45
-msgid "Rebuild permissions"
-msgstr ""
-
-#: tests/content_access_test_help.php:59
-msgid "Save content type"
-msgstr ""
-
-#: tests/content_access_test_help.php:60
-msgid "The content type %type has been added."
-msgstr ""
-
diff --git a/translations/de.po b/translations/de.po
deleted file mode 100644
index 4703796..0000000
--- a/translations/de.po
+++ /dev/null
@@ -1,272 +0,0 @@
-#
-# German translation of Content Access
-#
-# Generated from files:
-#  content_access.admin.inc,v 1.1.2.19 2009/01/02 18:28:24 fago
-#  content_access_test_help.php,v 1.1.4.2 2009/01/02 15:01:01 fago
-#  content_access.rules.inc: n/a
-#  content_access.module,v 1.1.2.9.2.17 2009/01/02 18:35:29 fago
-#  content_access.info,v 1.1.4.1 2008/06/30 08:56:27 fago
-#
-msgid ""
-msgstr ""
-"Project-Id-Version: German translation of content_access module\n"
-"POT-Creation-Date: 2009-02-05 23:22+0100\n"
-"PO-Revision-Date: 2009-07-26 00:57+0100\n"
-"Last-Translator: Alexander Haß\n"
-"Language-Team: \n"
-"MIME-Version: 1.0\n"
-"Content-Type: text/plain; charset=utf-8\n"
-"Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"X-Poedit-Language: German\n"
-"X-Poedit-Country: GERMANY\n"
-
-#: content_access.admin.inc:17
-msgid "Access control for %title"
-msgstr "Zugriffskontrolle für %title"
-
-#: content_access.admin.inc:31
-msgid "User access control lists"
-msgstr "Liste der Nutzer Zugriffsrechte"
-
-#: content_access.admin.inc:32
-msgid "These settings allow you to grant access to specific users."
-msgstr "Diese Einstellungen erlauben es Zugriffsrechte für einzelne Nutzer einzustellen."
-
-#: content_access.admin.inc:39
-msgid "Grant !op access"
-msgstr "Gewähre !op Recht"
-
-#: content_access.admin.inc:47;136
-#: tests/content_access_test_help.php:68;115
-msgid "Submit"
-msgstr "Speichern"
-
-#: content_access.admin.inc:52
-msgid "Reset to defaults"
-msgstr "Zurücksetzen"
-
-#: content_access.admin.inc:59
-msgid "Warning: Your content is not published, so this settings are not taken into account as long as the content remains unpublished."
-msgstr "Warnung: Dieser Inhalt ist noch nicht veröffentlicht, daher werden diese Einstellungen keinen Einfluss haben, bis er veröffentlicht wird."
-
-#: content_access.admin.inc:112
-msgid "Per content node access control settings"
-msgstr "Einstellungen für Zugriffskontrolle pro einzelnem Inhalt (node)"
-
-#: content_access.admin.inc:114
-msgid "Optionally you can enable per content node access control settings. If enabled, a new tab for the content access settings appears when viewing content. You have to configure permission to access these settings at the !permissions page."
-msgstr "Es kann die Zugriffskontrolle für jeden einzelnen Inhalt (node) eingestellt werden. Falls dies ausgfewählt wird, erscheint ein neuer Reiter über dem Inhalt. Um darauf zu zu greifen müssen die Rechte auf der !permissions Seite gesetzt werden."
-
-#: content_access.admin.inc:114
-msgid "permissions"
-msgstr "Rechte"
-
-#: content_access.admin.inc:118
-msgid "Enable per content node access control settings"
-msgstr "Erlaube Zugriffskontrolle für einzelne Nodes"
-
-#: content_access.admin.inc:124
-msgid "Advanced"
-msgstr "Erweitert"
-
-#: content_access.admin.inc:130
-msgid "Give content node grants priority"
-msgstr "Priorisiere die Zugriffsrechte des Inhalts"
-
-#: content_access.admin.inc:132
-msgid "If you are only using this access control module, you can safely ignore this. If you are using multiple access control modules you can adjust the priority of this module."
-msgstr "Falls nur das \"Content Access\" Modul eingesetzt wird kannst du diese Option ignorieren. Andernfalls kann hier die Priorität dieses Moduls gewählt werden."
-
-#: content_access.admin.inc:179
-msgid "Permissions have been successfully rebuilt for the content type @types."
-msgstr "Die Zugriffsrechte wurden erfolgreich neu berechnet für alle Inhalte vom typ @types"
-
-#: content_access.admin.inc:255
-msgid "Role based access control settings"
-msgstr "Einstellungen für die Rollenbasierte Zugriffskontrolle"
-
-#: content_access.admin.inc:257
-msgid "Note that users need at least the %access_content permission to be able to deal in any way with content."
-msgstr "Beachte, dass Nutzer mindestens %access_content rechte haben müssen um den Inhalt irgendwie zu bearbeiten"
-
-#: content_access.admin.inc:257;329
-msgid "access content"
-msgstr "Inhalt lesen"
-
-#: content_access.admin.inc:258
-msgid "Furthermore note that content which is not @published is treated in a different way by drupal: It can be viewed only by its author or users with the %administer_nodes permission."
-msgstr "Beachte, dass die Inhalte die nicht @published sind anders behandelt werden: Sie können nur von ihrem Author oder von Nutzern mit dem Recht %administer_nodes gesehen werden."
-
-#: content_access.admin.inc:258
-msgid "published"
-msgstr "Veröffentlicht"
-
-#: content_access.admin.inc:258;336
-msgid "administer nodes"
-msgstr "Inhalt verwalten"
-
-#: content_access.admin.inc:265
-msgid "View any content"
-msgstr "Jeden Inhalt sehen"
-
-#: content_access.admin.inc:273
-msgid "Edit any content"
-msgstr "Jeden Inhalt bearbeiten"
-
-#: content_access.admin.inc:281
-msgid "Delete any content"
-msgstr "Jeden Inhalt löschen"
-
-#: content_access.admin.inc:292
-msgid "View own content"
-msgstr "Eigenen Inhalt sehen"
-
-#: content_access.admin.inc:300
-msgid "Edit own content"
-msgstr "Eigenen Inhalt bearbeiten"
-
-#: content_access.admin.inc:308
-msgid "Delete own content"
-msgstr "Eigenen Inhalt löschen"
-
-#: content_access.admin.inc:329
-msgid "This role is lacking the permission '@perm', so it has no access."
-msgstr "Diese Rolle hat nicht das Recht '@perm', also keinen Zugriff"
-
-#: content_access.admin.inc:336
-msgid "This role has '@perm' permission, so access is granted."
-msgstr "Diese Rolle hat das Recht '@perm', also wird Zugriff gewährt"
-
-#: content_access.admin.inc:353
-msgid "Permission is granted due to the content type's access control settings."
-msgstr "Das Recht wird aufgrund der Zugriffsrechte des Inhaltstypen gewährt"
-
-#: content_access.admin.inc:382
-msgid "Permissions have been successfully rebuilt for the content type @types."
-msgid_plural "Permissions have been successfully rebuilt for the content types @types."
-msgstr[0] "Die Rechte für den Inhaltstypen @types wurden erfolgreich neu berechnet."
-msgstr[1] "Die Rechte für die Inhaltstypen @types wurden erfolgreich neu berechnet."
-
-#: content_access.rules.inc:32
-msgid "Can't set per content permissions for content type @type. Make sure to have per content settings activated for content types you want to alter access control for."
-msgstr "Die Rechte für eine einzelne Node vom Typ @type können nicht gesetzt werden. Dies muss in den Einstellungen des Inhaltstypen aktivert werden."
-
-#: content_access.rules.inc:45
-msgid "Grant content permissions by role"
-msgstr "Gewähre Zugriffsrechte für Rollen"
-
-#: content_access.rules.inc:47;54;61;71;79;225
-msgid "Content"
-msgstr "Inhalt"
-
-#: content_access.rules.inc:52
-msgid "Revoke content permissions by role"
-msgstr "Entferne Zugriffsrechte für Rollen"
-
-#: content_access.rules.inc:59
-msgid "Reset content permissions"
-msgstr "Zugriffsrechte zurücksetzen"
-
-#: content_access.rules.inc:69
-msgid "Grant access for a user"
-msgstr "Gewähre Zugriffsrechte für einen Nutzer"
-
-#: content_access.rules.inc:72;80
-msgid "User"
-msgstr "Benutzer"
-
-#: content_access.rules.inc:77
-msgid "Revoke access for a user"
-msgstr "Entferne Zugriffsrechte für einen Nutzer"
-
-#: content_access.rules.inc:156
-msgid "Operations to grant access for"
-msgstr "Operationen für die Zugriffsrechte gewährt werden können"
-
-#: content_access.rules.inc:164
-msgid "Note that this action is not going to revoke access for not chosen operations."
-msgstr "Beachte, dass diese Aktion die Zugriffsrechte für die nicht ausgewählten Aktionen nicht entfernt"
-
-#: content_access.rules.inc:167
-msgid "Grant access for @user."
-msgstr "Gewähre Zugriffsrechte für @user"
-
-#: content_access.rules.inc:191
-msgid "Operations to revoke access for"
-msgstr "Operationen für die Zugriffsrechte entfernt werden können"
-
-#: content_access.rules.inc:199
-msgid "Note that this action is only able to revoke access that has been previously granted with the help of the content access module."
-msgstr "Beachte, dass diese Aktion nur Zugriffsrechte entfernen kann, die vorher auch mit dem \"Content Access\" Modul gewährt worden sind."
-
-#: content_access.rules.inc:202
-msgid "Revoke access for @user."
-msgstr "Entferne Zugriffsrechte für @user"
-
-#: content_access.rules.inc:223
-msgid "Check role based settings"
-msgstr "Überprüfe Rollenbasierte Einstellungen"
-
-#: content_access.rules.inc:227
-msgid "Evaluates to TRUE, if content access allows all selected operations for the given roles."
-msgstr "Wird WAHR, falls das Modul \"content access\" für alle gewählten Operationen zugriff gewährt "
-
-#: content_access.module:29;16
-#: content_access.info:0
-msgid "Access control"
-msgstr "Zugriffskontrolle"
-
-#: content_access.module:30
-msgid "Configure content access control."
-msgstr "Konfiguriere Inhaltsbasierte Zugriffskontrolle"
-
-#: content_access.module:494
-msgid "Content access: No access is granted."
-msgstr "Zugriffskontrolle: Kein Zugriff gewährt"
-
-#: content_access.module:498
-msgid "Content access: author of the content can access"
-msgstr "Zugriffskontrolle: Autor hat Zugriff"
-
-#: content_access.module:500
-msgid "Content access: %role can access"
-msgstr "Zugriffskontrolle: %role hat Zugriff"
-
-#: content_access.module:56
-msgid "grant content access"
-msgstr "Gewähre Zugriff auf Inhalt"
-
-#: content_access.module:56
-msgid "grant own content access"
-msgstr "Gewähre Zugriff auf eigenen Inhalt"
-
-#: content_access.module:0
-msgid "content_access"
-msgstr "content_access"
-
-#: content_access.info:0
-msgid "Content Access"
-msgstr "Zugriffskontolle"
-
-#: content_access.info:0
-msgid "Provides flexible content access control"
-msgstr "Erlaubt flexible Zugriffskontrolle auf Inhalte"
-
-#: tests/content_access_test_help.php:45
-msgid "Rebuild permissions"
-msgstr "Berechtigungen neu aufbauen"
-
-#: tests/content_access_test_help.php:59
-msgid "Save content type"
-msgstr "Inhaltstyp speichern"
-
-#: tests/content_access_test_help.php:60
-msgid "The content type %type has been added."
-msgstr "Der Inhaltstyp %type wurde hinzugefügt"
-
-#: tests/content_access_test_help.php:69;116
-msgid "Your changes have been saved."
-msgstr "Die Änderungen wurden gespeichert"
-
