diff --git a/taxonomy_access.admin.inc b/taxonomy_access.admin.inc
index a3d5c51..a545653 100644
--- a/taxonomy_access.admin.inc
+++ b/taxonomy_access.admin.inc
@@ -19,7 +19,7 @@
*/
function taxonomy_access_admin() {
$roles = _taxonomy_access_user_roles();
- $active_rids = db_query('SELECT rid FROM {taxonomy_access_default} WHERE vid = 0')->fetchCol();
+ $active_rids = db_query('SELECT rid FROM {taxonomy_access_default} WHERE vid = :vid', array(':vid' => TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID))->fetchCol();
$header = array(t('Role'), t('Status'), array('data' => t('Operations'), 'colspan' => 2));
$rows = array();
@@ -76,7 +76,7 @@ function taxonomy_access_admin_delete_role($form, &$form_state, $rid) {
$role_global_default = db_query(
'SELECT grant_view, grant_update, grant_delete
FROM {taxonomy_access_default}
- WHERE vid = 0 AND rid = :rid', array(':rid' => $rid))
+ WHERE vid = :vid AND rid = :rid', array(':vid' => TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID, ':rid' => $rid))
->fetchAssoc();
if ($role_global_default) {
$form['rid'] = array(
@@ -128,16 +128,19 @@ function taxonomy_access_admin_build_row(array $grants = NULL) {
foreach (array('view', 'update', 'delete') as $grant) {
$form[$grant] = array(
'#type' => 'select',
- '#options' => array('1' => 'Allow', '0' => 'Ignore', '2' => 'Deny'),
- '#default_value' => is_string($grants['grant_' . $grant]) ? $grants['grant_' . $grant] : '0',
+ '#options' => array(
+ TAXONOMY_ACCESS_NODE_ALLOW => 'Allow',
+ TAXONOMY_ACCESS_NODE_IGNORE => 'Ignore',
+ TAXONOMY_ACCESS_NODE_DENY => 'Deny'),
+ '#default_value' => is_string($grants['grant_' . $grant]) ? $grants['grant_' . $grant] : TAXONOMY_ACCESS_NODE_IGNORE,
'#required' => TRUE,
);
}
foreach (array('create', 'list') as $grant) {
$form[$grant] = array(
'#type' => 'select',
- '#options' => array('1' => 'Allow', '0' => 'Deny'),
- '#default_value' => is_string($grants['grant_' . $grant]) ? $grants['grant_' . $grant] : '0',
+ '#options' => array(TAXONOMY_ACCESS_TERM_ALLOW => 'Allow', TAXONOMY_ACCESS_TERM_DENY => 'Deny'),
+ '#default_value' => is_string($grants['grant_' . $grant]) ? $grants['grant_' . $grant] : TAXONOMY_ACCESS_TERM_DENY,
);
}
return $form;
@@ -167,7 +170,7 @@ function taxonomy_access_admin_form($form, $form_state, $rid) {
if (empty($default_grants[0]) && isset($rid)) {
// Assemble a $row object for Schema API.
$row = new stdClass();
- $row->vid = 0;
+ $row->vid = TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID;
$row->rid = $rid;
// Insert the row with defaults for all grants.
diff --git a/taxonomy_access.create.inc b/taxonomy_access.create.inc
index 1cdce7e..96994f6 100644
--- a/taxonomy_access.create.inc
+++ b/taxonomy_access.create.inc
@@ -17,6 +17,12 @@
*/
/**
+ * @defgroup tac_create Taxonomy Access Control: Add tag (create) permission
+ * @{
+ * One line, one sentence description of the topic/group.
+ */
+
+/**
* Implements the create grant for autocomplete fields.
*
* - Denies access if the user cannot alter the field values.
@@ -524,6 +530,10 @@ function _taxonomy_access_autocomplete_validate($element, &$form_state) {
form_set_value($element, $value, $form_state);
}
+/**
+ * End of "defgroup tac_create".
+ * @}
+ */
/**
* Form element validation handler for taxonomy option fields.
@@ -856,4 +866,3 @@ function _taxonomy_access_disallowed_changes(array $new_field, array $old_field)
// Return FALSE if all changes were valid.
return FALSE;
}
-
diff --git a/taxonomy_access.install b/taxonomy_access.install
index 089f691..56e27d1 100644
--- a/taxonomy_access.install
+++ b/taxonomy_access.install
@@ -21,8 +21,30 @@ function taxonomy_access_last_removed() {
function taxonomy_access_install() {
// Default global perms for roles 1 (anonymous) and 2 (authenticated).
- db_query('INSERT INTO {taxonomy_access_default} (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list) VALUES(0, 1, 1, 0, 0, 1, 1)');
- db_query('INSERT INTO {taxonomy_access_default} (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list) VALUES(0, 2, 1, 0, 0, 1, 1)');
+ db_query(
+ 'INSERT INTO {taxonomy_access_default}
+ (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list)
+ VALUES(
+ TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID,
+ 1,
+ TAXONOMY_ACCESS_TERM_ALLOW,
+ TAXONOMY_ACCESS_TERM_DENY,
+ TAXONOMY_ACCESS_TERM_DENY,
+ TAXONOMY_ACCESS_TERM_ALLOW,
+ TAXONOMY_ACCESS_TERM_ALLOW)'
+ );
+ db_query(
+ 'INSERT INTO {taxonomy_access_default}
+ (vid, rid, grant_view, grant_update, grant_delete, grant_create, grant_list)
+ VALUES(
+ TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID,
+ 2,
+ TAXONOMY_ACCESS_TERM_ALLOW,
+ TAXONOMY_ACCESS_TERM_DENY,
+ TAXONOMY_ACCESS_TERM_DENY,
+ TAXONOMY_ACCESS_TERM_ALLOW,
+ TAXONOMY_ACCESS_TERM_ALLOW)'
+ );
}
diff --git a/taxonomy_access.module b/taxonomy_access.module
index 0918033..9bd11ae 100644
--- a/taxonomy_access.module
+++ b/taxonomy_access.module
@@ -6,6 +6,18 @@
*/
/**
+ * Define constants
+ */
+
+define('TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID', 0);
+define('TAXONOMY_ACCESS_VOCABULARY_DEFAULT_TID', 0);
+define('TAXONOMY_ACCESS_NODE_ALLOW', 1);
+define('TAXONOMY_ACCESS_NODE_IGNORE', 0);
+define('TAXONOMY_ACCESS_NODE_DENY', 2);
+define('TAXONOMY_ACCESS_TERM_ALLOW', 1);
+define('TAXONOMY_ACCESS_TERM_DENY', 0);
+
+/**
* Maximum number of nodes for which to update node access within the module.
*
* If the number of affected nodes is greater, then node_access_needs_rebuild()
@@ -198,6 +210,8 @@ function taxonomy_access_node_grants($user, $op) {
/**
* Implements hook_node_access_records().
+ *
+ * @ingroup tac_node_access
*/
function taxonomy_access_node_access_records($node) {
// Only write grants for published nodes.
@@ -246,6 +260,8 @@ function taxonomy_access_field_attach_validate($entity_type, $entity, &$errors)
*
* @todo
* Fix create permission filtering for autocomplete paths.
+ *
+ * @ingroup tac_list
*/
function taxonomy_access_query_term_access_alter($query) {
@@ -353,7 +369,7 @@ function taxonomy_access_enable_role($rid) {
// If we are adding a role, no global default is set yet, so insert it now.
// Assemble a $row object for Schema API.
$row = new stdClass();
- $row->vid = 0;
+ $row->vid = TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID;
$row->rid = $rid;
// Insert the row with defaults for all grants.
@@ -377,7 +393,7 @@ function taxonomy_access_role_enabled($rid) {
'SELECT 1
FROM {taxonomy_access_default}
WHERE rid = :rid AND vid = :vid',
- array(':rid' => $rid, ':vid' => '0'))
+ array(':rid' => $rid, ':vid' => TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID))
->fetchField();
}
return (bool) $role_status[$rid];
@@ -421,8 +437,8 @@ function taxonomy_access_enable_vocab($vid, $rid) {
db_query(
'SELECT grant_view, grant_update, grant_delete, grant_create, grant_list
FROM {taxonomy_access_default}
- WHERE vid = 0 AND rid = :rid',
- array(':rid' => $rid))
+ WHERE vid = :vid AND rid = :rid',
+ array(':rid' => $rid, ':vid' => TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID))
->fetchAssoc();
$record = _taxonomy_access_format_grant_record($vid, $rid, $global_default, TRUE);
return taxonomy_access_set_default_grants(array($vid => $record));
@@ -470,9 +486,11 @@ function taxonomy_access_disable_vocab($vid, $rid) {
}
-/*****************************************************************************/
-/*********************** NODE ACCESS UPDATE MECHANISM ************************/
-/*****************************************************************************/
+/**
+ * @defgroup tac_affected_nodes Taxonomy Access Control: Node access update mechanism
+ * @{
+ * One line, one sentence description of the topic/group.
+ */
/**
@@ -684,7 +702,7 @@ function _taxonomy_access_get_nodes_for_defaults($vocab_ids, $rid = NULL) {
unset($query);
// If the global default is in the list, fetch those nodes as well.
- if (in_array(0, $vocab_ids)) {
+ if (in_array(TAXONOMY_ACCESS_VOCABULARY_DEFAULT_TID, $vocab_ids)) {
$nids =
array_merge($nids, _taxonomy_access_get_nodes_for_global_default($rid));
}
@@ -850,12 +868,17 @@ function _taxonomy_access_get_vocabulary_terms($vocab_id) {
return $descendants[$vocab_id];
}
+/**
+ * End of "defgroup tac_affected_nodes".
+ * @}
+ */
-
-/*****************************************************************************/
-/******************************* DELETION API ********************************/
-/*****************************************************************************/
+/**
+ * @defgroup tac_grant_api Taxonomy Access Control: Grant record API
+ * @{
+ * One line, one sentence description of the topic/group.
+ */
/**
@@ -905,18 +928,18 @@ function taxonomy_access_delete_role_grants($rid, $update_nodes = TRUE) {
switch ($auth_gd[$op]) {
// If the authenticated user has a Deny grant, then either Allow or
// Ignore for the role is more permissive.
- case 2:
- if ($role_gd[$op] < 2) {
+ case TAXONOMY_ACCESS_NODE_DENY:
+ if ($role_gd[$op] < TAXONOMY_ACCESS_NODE_DENY) {
$all_nodes = TRUE;
}
- break 2;
+ break TAXONOMY_ACCESS_NODE_DENY;
// If the authenticated user has Ignore, Allow is more permissive.
- case 0:
- if ($role_gd[$op] == 1) {
+ case TAXONOMY_ACCESS_NODE_IGNORE:
+ if ($role_gd[$op] == TAXONOMY_ACCESS_NODE_ALLOW) {
$all_nodes = TRUE;
}
- break 2;
+ break TAXONOMY_ACCESS_NODE_DENY;
}
}
@@ -962,7 +985,7 @@ function taxonomy_access_delete_role_grants($rid, $update_nodes = TRUE) {
*/
function taxonomy_access_delete_default_grants($vocab_ids, $rid = NULL, $update_nodes = TRUE) {
// Accept either a single vocabulary ID or an array thereof.
- if ($vocab_ids !== 0 && empty($vocab_ids)) {
+ if ($vocab_ids !== TAXONOMY_ACCESS_VOCABULARY_DEFAULT_TID && empty($vocab_ids)) {
return FALSE;
}
@@ -1034,14 +1057,6 @@ function taxonomy_access_delete_term_grants($term_ids, $rid = NULL, $update_node
return TRUE;
}
-
-
-
-/*****************************************************************************/
-/******************************** UPDATE API *********************************/
-/*****************************************************************************/
-
-
/**
* Formats a record to be written to the module's configuration tables.
*
@@ -1140,11 +1155,16 @@ function taxonomy_access_set_default_grants(array $grant_rows, $update_nodes = T
}
}
+/**
+ * End of "defgroup tac_grant_api".
+ * @}
+ */
-
-/*****************************************************************************/
-/******************************* NODE ACCESS *********************************/
-/*****************************************************************************/
+/**
+ * @defgroup tac_node_access Taxonomy Access Control: Node access implementation
+ * @{
+ * One line, one sentence description of the topic/group.
+ */
/**
* Builds a base query object for the specified TAC grants.
@@ -1233,6 +1253,8 @@ function _taxonomy_access_grant_query(array $grants, $default = FALSE) {
*
* @return
* Array formatted for hook_node_access_records().
+ *
+ * @ingroup tac_node_access
*/
function _taxonomy_access_node_access_records($node_nid, $reset = FALSE) {
@@ -1289,8 +1311,8 @@ function taxonomy_access_global_defaults($reset = FALSE) {
db_query(
'SELECT rid, grant_view, grant_update, grant_delete
FROM {taxonomy_access_default}
- WHERE vid = 0'
- )
+ WHERE vid = :vid',
+ array(':vid' => TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID))
->fetchAll();
foreach ($records as $record) {
$global_grants[] = _taxonomy_access_format_node_access_record($record);
@@ -1315,27 +1337,33 @@ function taxonomy_access_global_defaults($reset = FALSE) {
*/
function _taxonomy_access_format_node_access_record(stdClass $record) {
- // Ignore => 0, Allow => 1, Deny => 2 ('10' in binary).
- // Only a value of 1 is considered an 'Allow';
- // with an 'Allow' and no 'Deny', the value from the BIT_OR will be 1.
- // If a 'Deny' is present, the value will then be 3 ('11' in binary).
return array(
'realm' => 'taxonomy_access_role',
'gid' => $record->rid,
- 'grant_view' => ($record->grant_view == 1) ? 1 : 0,
- 'grant_update' => ($record->grant_update == 1) ? 1 : 0,
- 'grant_delete' => ($record->grant_delete == 1) ? 1 : 0,
- 'priority' => 0,
+ 'grant_view' => ($record->grant_view == TAXONOMY_ACCESS_NODE_ALLOW)
+ ? TAXONOMY_ACCESS_NODE_ALLOW : TAXONOMY_ACCESS_NODE_IGNORE,
+ 'grant_update' => ($record->grant_update == TAXONOMY_ACCESS_NODE_ALLOW)
+ ? TAXONOMY_ACCESS_NODE_ALLOW : TAXONOMY_ACCESS_NODE_IGNORE,
+ 'grant_delete' => ($record->grant_delete == TAXONOMY_ACCESS_NODE_ALLOW)
+ ? TAXONOMY_ACCESS_NODE_ALLOW : TAXONOMY_ACCESS_NODE_IGNORE,
+ 'priority' => TAXONOMY_ACCESS_NODE_IGNORE,
);
}
+/**
+ * End of "defgroup tac_node_access".
+ * @}
+ */
-
-
-/*****************************************************************************/
-/******************************* TERM ACCESS *********************************/
-/*****************************************************************************/
+/**
+ * @defgroup tac_list Taxonomy Access Control: View tag (list) permission
+ * @{
+ * One line, one sentence description of the topic/group.
+ *
+ * One or more additional paragraphs of information, which will appear
+ * on the topic page.
+ */
/**
@@ -1504,6 +1532,11 @@ function _taxonomy_access_term_options($field) {
}
/**
+ * End of "defgroup tac_list".
+ * @}
+ */
+
+/**
* Form element validation handler for taxonomy autocomplete fields.
*
* @see taxonomy_access_autocomplete()
diff --git a/taxonomy_access.test b/taxonomy_access.test
index b2610b4..5c05e04 100644
--- a/taxonomy_access.test
+++ b/taxonomy_access.test
@@ -62,11 +62,11 @@ class TaxonomyAccessTestCase extends DrupalWebTestCase {
$rows = array();
foreach (array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID) as $rid) {
$ignore = array(
- 'view' => 0,
- 'update' => 0,
- 'delete' => 0,
+ 'view' => TAXONOMY_ACCESS_NODE_IGNORE,
+ 'update' => TAXONOMY_ACCESS_NODE_IGNORE,
+ 'delete' => TAXONOMY_ACCESS_NODE_IGNORE,
);
- $rows[] = _taxonomy_access_format_grant_record(0, $rid, $ignore, TRUE);
+ $rows[] = _taxonomy_access_format_grant_record(TAXONOMY_ACCESS_NODE_IGNORE, $rid, $ignore, TRUE);
}
taxonomy_access_set_default_grants($rows);
@@ -78,7 +78,7 @@ class TaxonomyAccessTestCase extends DrupalWebTestCase {
array(':rid' => $rid)
)
->fetchField();
- $this->assertTrue(is_numeric($r) && $r == 0, t("Set global default for role %rid to Ignore", array('%rid' => $rid)));
+ $this->assertTrue(is_numeric($r) && $r == TAXONOMY_ACCESS_NODE_IGNORE, t("Set global default for role %rid to Ignore", array('%rid' => $rid)));
}
}
@@ -292,21 +292,29 @@ class TaxonomyAccessTestCase extends DrupalWebTestCase {
* @param array &$edit
* The form data to post.
* @param int $vid
- * (optional) The vocabulary ID. Defaults to 0 (global default).
- * @param $int tid
- * (optional) The term ID. Defaults to 0 (vocabulary default).
+ * (optional) The vocabulary ID. Defaults to global default.
+ * @param int $tid
+ * (optional) The term ID. Defaults to vocabulary default.
* @param int $view
- * (optional) The view grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The view grant value. Defaults to ignore.
* @param int $update
- * (optional) The update grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The update grant value. Defaults to ignore.
* @param int $delete
- * (optional) The delete grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The delete grant value. Defaults to ignore.
* @param int $create
* (optional) The create grant value (0 or 1). Defaults to 0 (unchecked).
* @param int $list
* (optional) The list grant value (0 or 1). Defaults to 0 (unchecked).
*/
- function addFormRow(&$edit, $vid = 0, $tid = 0, $view = 0, $update = 0, $delete = 0, $create = 0, $list = 0) {
+ function addFormRow(
+ &$edit,
+ $vid = TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID,
+ $tid = TAXONOMY_ACCESS_VOCABULARY_DEFAULT_TID,
+ $view = TAXONOMY_ACCESS_NODE_IGNORE,
+ $update = TAXONOMY_ACCESS_NODE_IGNORE,
+ $delete = TAXONOMY_ACCESS_NODE_IGNORE,
+ $create = 0,
+ $list = 0) {
$new_value = $tid ? "term $tid" : "default $vid";
$edit["new[item]"] = $new_value;
$edit["new[grants][view]"] = $view;
@@ -322,21 +330,29 @@ class TaxonomyAccessTestCase extends DrupalWebTestCase {
* @param array &$edit
* The form data to post.
* @param int $vid
- * (optional) The vocabulary ID. Defaults to 0 (global default).
+ * (optional) The vocabulary ID. Defaults to global default.
* @param int $tid
- * (optional) The term ID. Defaults to 0 (vocabulary default).
+ * (optional) The term ID. Defaults to vocabulary default.
* @param int $view
- * (optional) The view grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The view grant value. Defaults to ignore.
* @param int $update
- * (optional) The update grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The update grant value. Defaults to ignore.
* @param int $delete
- * (optional) The delete grant value (1, 0, or 2). Defaults to 0 (ignore).
+ * (optional) The delete grant value. Defaults to ignore.
* @param int $create
* (optional) The create grant value (0 or 1). Defaults to 0 (unchecked).
* @param int $list
* (optional) The list grant value (0 or 1). Defaults to 0 (unchecked).
*/
- function configureFormRow(&$edit, $vid = 0, $tid = 0, $view = 0, $update = 0, $delete = 0, $create = 0, $list = 0) {
+ function configureFormRow(
+ &$edit,
+ $vid = TAXONOMY_ACCESS_GLOBAL_DEFAULT_VID,
+ $tid = TAXONOMY_ACCESS_VOCABULARY_DEFAULT_TID,
+ $view = TAXONOMY_ACCESS_NODE_IGNORE,
+ $update = TAXONOMY_ACCESS_NODE_IGNORE,
+ $delete = TAXONOMY_ACCESS_NODE_IGNORE,
+ $create = 0,
+ $list = 0) {
$edit["grants[$vid][$tid][view]"] = $view;
$edit["grants[$vid][$tid][update]"] = $update;
$edit["grants[$vid][$tid][delete]"] = $delete;
@@ -542,7 +558,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view allow in the global default.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->configureFormRow($edit, 0, 0, 1);
+ $this->configureFormRow($edit, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_ALLOW);
$this->drupalPost(NULL, $edit, 'Save all');
// Log out.
@@ -562,7 +578,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Set the v1 default to view allow.
$default_config = _taxonomy_access_format_grant_record(
- $this->vocabs['v1']->vid, DRUPAL_ANONYMOUS_RID, array('view' => 1), TRUE
+ $this->vocabs['v1']->vid, DRUPAL_ANONYMOUS_RID, array('view' => TAXONOMY_ACCESS_NODE_ALLOW), TRUE
);
taxonomy_access_set_default_grants(array($default_config));
@@ -570,7 +586,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
$term_configs = array();
foreach (array('v1t1', 'v2t1') as $name) {
$term_configs[] = _taxonomy_access_format_grant_record(
- $this->terms[$name]->vid, DRUPAL_ANONYMOUS_RID, array('view' => 1)
+ $this->terms[$name]->vid, DRUPAL_ANONYMOUS_RID, array('view' => TAXONOMY_ACCESS_NODE_ALLOW)
);
}
taxonomy_access_set_term_grants($term_configs);
@@ -583,7 +599,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view deny in the global default.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->configureFormRow($edit, 0, 0, 2);
+ $this->configureFormRow($edit, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_DENY);
$this->drupalPost(NULL, $edit, 'Save all');
// Log out.
@@ -632,7 +648,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view allow for the v1 default.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->addFormRow($edit, $this->vocabs['v1']->vid, 0, 1);
+ $this->addFormRow($edit, $this->vocabs['v1']->vid, 0, TAXONOMY_ACCESS_NODE_ALLOW);
$this->drupalPost(NULL, $edit, 'Add');
// Log out.
@@ -665,7 +681,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view deny for the v2 default.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->addFormRow($edit, $this->vocabs['v2']->vid, 0, 2);
+ $this->addFormRow($edit, $this->vocabs['v2']->vid, 0, TAXONOMY_ACCESS_NODE_DENY);
$this->drupalPost(NULL, $edit, 'Add');
// Log out.
@@ -699,8 +715,8 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the form to change the configuration: Allow for v2; Deny for v1.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->configureFormRow($edit, $this->vocabs['v2']->vid, 0, 1);
- $this->configureFormRow($edit, $this->vocabs['v1']->vid, 0, 2);
+ $this->configureFormRow($edit, $this->vocabs['v2']->vid, 0, TAXONOMY_ACCESS_NODE_ALLOW);
+ $this->configureFormRow($edit, $this->vocabs['v1']->vid, 0, TAXONOMY_ACCESS_NODE_DENY);
$this->drupalPost(NULL, $edit, 'Save all');
// Log out.
@@ -772,7 +788,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view allow for v1t1.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->addFormRow($edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, 1);
+ $this->addFormRow($edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, TAXONOMY_ACCESS_NODE_ALLOW);
$this->drupalPost(NULL, $edit, 'Add');
// Log out.
@@ -805,7 +821,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Use the admin form to give anonymous view deny for v2t1.
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
- $this->addFormRow($edit, $this->vocabs['v2']->vid, $this->terms['v2t1']->tid, 2);
+ $this->addFormRow($edit, $this->vocabs['v2']->vid, $this->terms['v2t1']->tid, TAXONOMY_ACCESS_NODE_DENY);
$this->drupalPost(NULL, $edit, 'Add');
// Log out.
@@ -840,10 +856,10 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
$this->configureFormRow(
- $edit, $this->vocabs['v2']->vid, $this->terms['v2t1']->tid, 1
+ $edit, $this->vocabs['v2']->vid, $this->terms['v2t1']->tid, TAXONOMY_ACCESS_NODE_ALLOW
);
$this->configureFormRow(
- $edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, 2
+ $edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, TAXONOMY_ACCESS_NODE_DENY
);
$this->drupalPost(NULL, $edit, 'Save all');
@@ -939,7 +955,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
$this->drupalGet(TAXONOMY_ACCESS_CONFIG . '/role/' . DRUPAL_ANONYMOUS_RID . '/edit');
$edit = array();
$edit["new[recursive]"] = 1;
- $this->addFormRow($edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, 1);
+ $this->addFormRow($edit, $this->vocabs['v1']->vid, $this->terms['v1t1']->tid, TAXONOMY_ACCESS_NODE_ALLOW);
$this->drupalPost(NULL, $edit, 'Add');
}
@@ -962,7 +978,7 @@ class TaxonomyAccessConfigTest extends TaxonomyAccessTestCase {
// Update the global default to allow view.
$edit = array();
- $this->configureFormRow($edit, 0, 0, 1);
+ $this->configureFormRow($edit, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_IGNORE, TAXONOMY_ACCESS_NODE_ALLOW);
$this->drupalPost(NULL, $edit, 'Save all');
// Confirm that the edit and disable links appear.
@@ -1094,9 +1110,9 @@ class TaxonomyAccessNodeGrantTest extends TaxonomyAccessTestCase {
// View alone can be used to test V/U/D because the logic is identical.
foreach ($node_grants as $grant) {
- $grant_types['a'][$grant] = 1;
- $grant_types['i'][$grant] = 0;
- $grant_types['d'][$grant] = 2;
+ $grant_types['a'][$grant] = TAXONOMY_ACCESS_NODE_ALLOW;
+ $grant_types['i'][$grant] = TAXONOMY_ACCESS_NODE_IGNORE;
+ $grant_types['d'][$grant] = TAXONOMY_ACCESS_NODE_DENY;
}
// Each vocabulary will have four parent terms in the same fashion: