content_access.module 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. <?php
  2. /**
  3. * @file Content access module file.
  4. */
  5. /**
  6. * Implements hook_help().
  7. */
  8. function content_access_help($path, $arg) {
  9. switch ($path) {
  10. case 'admin/help#content_access':
  11. $output = '<h3>' . t('About') . '</h3>';
  12. $output .= '<p>' . t('Content Access module provides flexible way to control how and who should read or control your site content. Content Access can define custom access control rules for content types and even for every piece of content.') . '</p>';
  13. $output .= '<h3>' . t('Uses') . '</h3>';
  14. $output .= '<dl>';
  15. $output .= '<dt>' . t('Default and custom settings') . '</dt>';
  16. $output .= '<dd>' . t("Each <a href='@content-type'>content type</a> can have its own default content access settings configured as: <em>View any content</em> to allow anyone to view content from this content type, <em>View own content</em> to allow only content creators to see their own content, <em>Edit any content</em> to allow anyone to edit content from this content type, <em>Edit own content</em> to allow only content creators to edit their own content, <em>Delete any content</em> to allow anyone to delete content from this content type, <em>Delete own content </em> to allow content creators to delete their own content. This default settings for each content type can be further customized per every piece of content per user if you have <a href='@acl'>ACL</a> module enabled.", array('@content-type' => url('admin/structure/types'), '@acl' => 'http://drupal.org/project/acl/')) . '</dd>';
  17. $output .= '</dl>';
  18. return $output;
  19. }
  20. }
  21. /**
  22. * Implements hook_admin_paths().
  23. */
  24. function content_access_admin_paths() {
  25. $paths = array(
  26. 'node/*/access' => TRUE,
  27. );
  28. return $paths;
  29. }
  30. /**
  31. * Implements hook_menu().
  32. */
  33. function content_access_menu() {
  34. $items = array();
  35. $items['node/%node/access'] = array(
  36. 'title' => 'Access control',
  37. 'page callback' => 'drupal_get_form',
  38. 'page arguments' => array('content_access_page', 1),
  39. 'access callback' => 'content_access_node_page_access',
  40. 'access arguments' => array(1),
  41. 'file' => 'content_access.admin.inc',
  42. 'theme callback' => '_node_custom_theme',
  43. 'type' => MENU_LOCAL_TASK,
  44. 'weight' => 3,
  45. 'context' => MENU_CONTEXT_PAGE | MENU_CONTEXT_INLINE,
  46. );
  47. $items['admin/structure/types/manage/%node_type/access'] = array(
  48. 'title' => 'Access control',
  49. 'description' => 'Configure content access control.',
  50. 'page callback' => 'drupal_get_form',
  51. 'page arguments' => array('content_access_admin_settings', 4),
  52. 'access callback' => 'content_access_admin_settings_access',
  53. 'access arguments' => array(),
  54. 'type' => MENU_LOCAL_TASK,
  55. 'file' => 'content_access.admin.inc',
  56. 'theme callback' => '_node_custom_theme',
  57. 'weight' => 1,
  58. );
  59. return $items;
  60. }
  61. /**
  62. * Implements hook_perm().
  63. */
  64. function content_access_permission() {
  65. return array(
  66. 'grant content access' => array(
  67. 'title' => t('Grant content access'),
  68. 'description' => t('View and modify content access for any nodes'),
  69. ),
  70. 'grant own content access' => array(
  71. 'title' => t('Grant own content access'),
  72. 'description' => t('View and modify content access for own nodes'),
  73. ),
  74. );
  75. }
  76. /**
  77. * Get access tab page for the viewed node.
  78. */
  79. function content_access_node_page_access($node) {
  80. global $user;
  81. return content_access_get_settings('per_node', $node->type) && user_access('grant content access') ||
  82. content_access_get_settings('per_node', $node->type) && (user_access('grant own content access') && ($user->uid == $node->uid));
  83. }
  84. /**
  85. * Content access settings for content type.
  86. */
  87. function content_access_admin_settings_access() {
  88. return user_access('administer nodes') && user_access('administer content types');
  89. }
  90. /**
  91. * Implements hook_node_grants().
  92. */
  93. function content_access_node_grants($account, $op) {
  94. return array(
  95. 'content_access_author' => array($account->uid),
  96. 'content_access_rid' => array_keys($account->roles),
  97. );
  98. }
  99. /**
  100. * Implements hook_node_access_records().
  101. */
  102. function content_access_node_access_records($node) {
  103. if (content_access_disabling() || !$node->status) {
  104. return;
  105. }
  106. // Apply per node settings if necessary.
  107. if (content_access_get_settings('per_node', $node->type)) {
  108. $grants = array();
  109. foreach (array('view', 'update', 'delete') as $op) {
  110. foreach (content_access_get_rids_per_node_op($op, $node) as $rid) {
  111. $grants[$rid]['grant_' . $op] = 1;
  112. }
  113. }
  114. foreach ($grants as $rid => $grant) {
  115. $grants[$rid] = content_access_proccess_grant($grant, $rid, $node);
  116. }
  117. // Care for the author grant.
  118. $grant = array();
  119. foreach (array('view', 'update', 'delete') as $op) {
  120. // Get all roles that have access to use $op on this node.
  121. $any_roles = drupal_map_assoc(content_access_per_node_setting($op, $node));
  122. $any_roles = $any_roles ? $any_roles : array();
  123. $any_roles += ($op != 'view') ? content_access_get_settings($op, $node->type) : array();
  124. $grant['grant_' . $op] = content_access_own_op($node, $any_roles, content_access_get_rids_per_node_op($op . '_own', $node));
  125. }
  126. if (array_filter($grant)) {
  127. $grant['realm'] = 'content_access_author';
  128. $grants[] = content_access_proccess_grant($grant, $node->uid, $node);
  129. }
  130. }
  131. else {
  132. // Apply the content type defaults.
  133. $grants = content_access_get_type_grant($node);
  134. }
  135. if (empty($grants)) {
  136. // This means we grant no access.
  137. $grants[] = content_access_proccess_grant(array(), 0, $node);
  138. }
  139. else {
  140. content_access_optimize_grants($grants, $node);
  141. }
  142. return $grants;
  143. }
  144. /**
  145. * Implements hook_node_delete().
  146. */
  147. function content_access_node_delete($node) {
  148. db_delete('content_access')
  149. ->condition('nid', $node->nid)
  150. ->execute();
  151. }
  152. /**
  153. * Used by the ACL module.
  154. */
  155. function content_access_enabled() {
  156. return !content_access_disabling();
  157. }
  158. /**
  159. * Implements hook_disable().
  160. */
  161. function content_access_disable() {
  162. content_access_disabling(TRUE);
  163. }
  164. /**
  165. * Remembers if we have disabled access.
  166. */
  167. function content_access_disabling($set = NULL) {
  168. static $disabling = FALSE;
  169. if (isset($set)) {
  170. $disabling = $set;
  171. }
  172. return $disabling;
  173. }
  174. /**
  175. * Return content_access' settings.
  176. *
  177. * @param $setting
  178. * One of the content_access_available_settings(), e.g. 'view' or 'per_node'.
  179. * If 'all' is passed, all available settings are returned.
  180. * @param $type_name
  181. * The name of the content type to return settings for.
  182. *
  183. * @return
  184. * The value of the given setting or an array of all settings.
  185. */
  186. function content_access_get_settings($setting, $type_name) {
  187. $settings = variable_get('content_access_' . $type_name, array());
  188. $settings += content_access_get_setting_defaults($type_name);
  189. if ($setting == 'all') {
  190. return $settings;
  191. }
  192. return isset($settings[$setting]) ? $settings[$setting] : NULL;
  193. }
  194. /**
  195. * Save content_access settings of a content type.
  196. */
  197. function content_access_set_settings($settings, $type_name) {
  198. // Do not store default values so we do not have to care about synching our
  199. // settings with the permissions.
  200. foreach (content_access_get_setting_defaults($type_name) as $setting => $default_value) {
  201. if (isset($settings[$setting]) && $settings[$setting] == $default_value) {
  202. unset($settings[$setting]);
  203. }
  204. }
  205. variable_set('content_access_' . $type_name, $settings);
  206. }
  207. /**
  208. * Return an array containing all available content_access settings.
  209. */
  210. function content_access_available_settings() {
  211. return array('view', 'update', 'delete', 'view_own', 'update_own', 'delete_own', 'per_node', 'priority');
  212. }
  213. /**
  214. * Defines default values for settings.
  215. */
  216. function content_access_get_setting_defaults($type) {
  217. $defaults = array();
  218. $defaults['view'] = $defaults['view_own'] = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
  219. foreach (array('update', 'delete') as $op) {
  220. $defaults[$op] = content_access_get_permission_access(content_access_get_permission_by_op($op, $type));
  221. $defaults[$op . '_own'] = content_access_get_permission_access(content_access_get_permission_by_op($op . '_own', $type));
  222. }
  223. $defaults['priority'] = 0;
  224. $defaults['per_node'] = FALSE;
  225. return $defaults;
  226. }
  227. /**
  228. * Returns an array of role ids that contain the given permission.
  229. */
  230. function content_access_get_permission_access($perm, $reset = FALSE) {
  231. $roles = &drupal_static(__FUNCTION__, array());
  232. if ($reset) {
  233. $roles = array();
  234. }
  235. if (!isset($roles[$perm]) && $perm) {
  236. $roles[$perm] = array_keys(user_roles(0, $perm));
  237. }
  238. return isset($roles[$perm]) ? $roles[$perm] : array();
  239. }
  240. /**
  241. * Gets the name of a permission for the given operation, if there is a suiting one.
  242. */
  243. function content_access_get_permission_by_op($op, $type) {
  244. switch ($op) {
  245. default:
  246. return FALSE;
  247. case 'update':
  248. return 'edit any ' . $type . ' content';
  249. case 'update_own':
  250. return 'edit own ' . $type . ' content';
  251. case 'delete':
  252. return 'delete any ' . $type . ' content';
  253. case 'delete_own':
  254. return 'delete own ' . $type . ' content';
  255. }
  256. }
  257. /**
  258. * Returns the default grants for a given node type.
  259. */
  260. function content_access_get_type_grant($node) {
  261. // Cache per type default grants in a static array
  262. static $defaults = array();
  263. if (!isset($defaults[$node->type])) {
  264. $grants = array();
  265. // Only process the 'view' op as node_access() will take care of edit and delete
  266. foreach (content_access_get_settings('view', $node->type) as $rid) {
  267. $grants[$rid]['grant_view'] = 1;
  268. $grants[$rid] = content_access_proccess_grant($grants[$rid], $rid, $node);
  269. }
  270. $defaults[$node->type] = $grants;
  271. }
  272. // Care for the author grant.
  273. $grant = $grants = array();
  274. $grant['grant_view'] = content_access_own_op($node, content_access_get_settings('view', $node->type), content_access_get_settings('view_own', $node->type));
  275. if ($grant['grant_view']) {
  276. $grant['realm'] = 'content_access_author';
  277. $grants = array('author' => content_access_proccess_grant($grant, $node->uid, $node));
  278. }
  279. return $defaults[$node->type] + $grants;
  280. }
  281. /**
  282. * Process a grant, which means add priority, realm and other properties.
  283. */
  284. function content_access_proccess_grant($grant, $gid, $node) {
  285. $grant += array('grant_view' => 0, 'grant_update' => 0, 'grant_delete' => 0, 'realm' => 'content_access_rid');
  286. $grant['gid'] = $gid;
  287. $grant['priority'] = content_access_get_settings('priority', $node->type);
  288. return $grant;
  289. }
  290. /**
  291. * Determines the grant for the node author and the given allowed roles of a operation.
  292. *
  293. * @param $any_roles
  294. * The roles with which anybody has access (not optimized!)
  295. * @param $own_roles
  296. * The roles with which only the author has acess (optimized!)
  297. */
  298. function content_access_own_op($node, $any_roles, $own_roles) {
  299. static $roles = array();
  300. if (!isset($roles[$node->uid])) {
  301. $roles[$node->uid] = $node->uid ? array(DRUPAL_AUTHENTICATED_RID) : array(DRUPAL_ANONYMOUS_RID);
  302. $result = db_query('SELECT rid FROM {users_roles} WHERE uid = :uid', array(':uid' => $node->uid));
  303. foreach ($result as $role) {
  304. $roles[$node->uid][] = $role->rid;
  305. }
  306. }
  307. if (array_intersect($roles[$node->uid], $any_roles)) {
  308. // If there is access due to "any permissions" there is no need to at an author grant.
  309. return 0;
  310. }
  311. return array_intersect($roles[$node->uid], $own_roles) ? 1 : 0;
  312. }
  313. /**
  314. * Returns optimized role ids for the given operation and node to
  315. * grant access for.
  316. *
  317. * If to a role access is granted by permissions, it's not necessary
  318. * to write a grant for it. So it won't be returned.
  319. *
  320. * @param $op
  321. * One of the supported operations.
  322. * @param $node
  323. * The node object.
  324. */
  325. function content_access_get_rids_per_node_op($op, $node) {
  326. $rids = content_access_per_node_setting($op, $node);
  327. if ($permission = content_access_get_permission_by_op($op, $node->type)) {
  328. $perm_roles = content_access_get_permission_access($permission);
  329. $rids = array_diff($rids, $perm_roles);
  330. if (in_array(DRUPAL_AUTHENTICATED_RID, $perm_roles)) {
  331. return in_array(DRUPAL_ANONYMOUS_RID, $rids) ? array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID) : array(DRUPAL_AUTHENTICATED_RID);
  332. }
  333. }
  334. return $rids;
  335. }
  336. /**
  337. * Returns the per node role settings. If no per node settings are available,
  338. * it will return the content type settings.
  339. *
  340. * @param $op
  341. * One of the supported operations.
  342. * @param $node
  343. * The node object.
  344. * @param $settings
  345. * Optional array used to update the settings cache with the given settings.
  346. * @return
  347. * An array of role ids which have access.
  348. */
  349. function content_access_per_node_setting($op, $node, $settings = NULL) {
  350. static $grants = array();
  351. if (isset($settings)) {
  352. // Update settings cache
  353. $grants[$node->nid] = $settings;
  354. return;
  355. }
  356. if (!isset($grants[$node->nid]) || $grants[$node->nid] === FALSE) {
  357. $grants[$node->nid] = content_access_get_per_node_settings($node);
  358. }
  359. // Return the content type defaults if no per node settings are available
  360. return isset($grants[$node->nid][$op]) ? $grants[$node->nid][$op] : content_access_get_settings($op, $node->type);
  361. }
  362. /**
  363. * Gets the per node settings of a node.
  364. *
  365. * @note
  366. * This function won't apply defaults, so if there are no other settings
  367. * it will return an empty array.
  368. */
  369. function content_access_get_per_node_settings($node) {
  370. foreach (db_query("SELECT settings FROM {content_access} WHERE nid = :nid", array(':nid' => $node->nid)) as $record) {
  371. $settings = $record->settings;
  372. if (!$settings) {
  373. return array();
  374. }
  375. return unserialize($settings);
  376. }
  377. }
  378. /**
  379. * Saves custom per node settings in the own content_access table.
  380. */
  381. function content_access_save_per_node_settings($node, $settings) {
  382. $count = db_select('content_access')
  383. ->condition('nid', $node->nid)
  384. ->countQuery()->execute()->fetchField();
  385. if ($count > 0) {
  386. db_update('content_access')
  387. ->condition('nid', $node->nid)
  388. ->fields(array('settings' => serialize($settings)))
  389. ->execute();
  390. }
  391. else {
  392. db_insert('content_access')
  393. ->fields(array('nid' => $node->nid, 'settings' => serialize($settings)))
  394. ->execute();
  395. }
  396. // Make content_access_per_node_setting() use the new settings
  397. content_access_per_node_setting(NULL, $node, $settings);
  398. }
  399. /**
  400. * Deletes all custom per node settings, so that content type defaults are used again.
  401. */
  402. function content_access_delete_per_node_settings($node) {
  403. db_delete('content_access')
  404. ->condition('nid', $node->nid)
  405. ->execute();
  406. // Clear the cache.
  407. content_access_per_node_setting(NULL, $node, FALSE);
  408. // Delete possible acl settings
  409. if (module_exists('acl')) {
  410. // @todo why content_access.admin.inc is not loaded before?
  411. module_load_include('inc', 'content_access', 'content_access.admin');
  412. foreach (array('view', 'update', 'delete') as $op) {
  413. $acl_id = content_access_get_acl_id($node, $op);
  414. acl_delete_acl($acl_id);
  415. }
  416. }
  417. }
  418. /**
  419. * Removes grants that doesn't change anything.
  420. *
  421. * @note
  422. * The grants are compared with the normal access control settings.
  423. */
  424. function content_access_optimize_grants(&$grants, $node) {
  425. $rids = array('view' => array(), 'update' => array(), 'delete' => array());
  426. foreach ($grants as $key => $grant) {
  427. foreach (array('view', 'update', 'delete') as $op) {
  428. if (is_numeric($key) && !empty($grant['grant_' . $op])) {
  429. $rids[$op][] = $key;
  430. }
  431. }
  432. }
  433. // Detect if all are allowed to view
  434. $all = array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID);
  435. if (count(array_diff($all, $rids['view'])) == 0) {
  436. //grant view access to all instead of single roles
  437. $rids['view'] = array('all');
  438. $grants['all'] = array('realm' => 'all', 'gid' => 0, 'grant_view' => 1, 'grant_update' => 0, 'grant_delete' => 0, 'priority' => content_access_get_settings('priority', $node->type));
  439. }
  440. // If authenticated users are involved, remove unnecessary other roles.
  441. foreach (array('view', 'update', 'delete') as $op) {
  442. if (in_array(DRUPAL_AUTHENTICATED_RID, $rids[$op])) {
  443. $rids[$op] = in_array(DRUPAL_ANONYMOUS_RID, $rids[$op]) ? array(DRUPAL_ANONYMOUS_RID, DRUPAL_AUTHENTICATED_RID) : array(DRUPAL_AUTHENTICATED_RID);
  444. }
  445. }
  446. // Now let's remove unnecessary grants, if any.
  447. foreach ($grants as $key => $grant) {
  448. if (!is_numeric($key)) {
  449. continue;
  450. }
  451. foreach (array('view', 'update', 'delete') as $op) {
  452. if ($grant['grant_' . $op] && in_array($key, $rids[$op])) {
  453. //it's still here, so we can't remove this grant
  454. continue 2;
  455. }
  456. }
  457. //ok, remove it
  458. unset($grants[$key]);
  459. }
  460. }
  461. /**
  462. * Implements hook_node_type_delete().
  463. */
  464. function content_access_node_type_delete($info) {
  465. variable_del('content_access_' . $info->type);
  466. }
  467. /**
  468. * Implements hook_node_type_update().
  469. *
  470. * Updates settings on node type name change.
  471. */
  472. function content_access_node_type_update($info) {
  473. if (!empty($info->old_type) && $info->old_type != $info->type) {
  474. $settings = content_access_get_settings('all', $info->old_type);
  475. content_access_set_settings($settings, $info->type);
  476. variable_del('content_access_' . $info->old_type);
  477. }
  478. }
  479. /**
  480. * Implements hook_node_access_explain().
  481. */
  482. function content_access_node_access_explain($row) {
  483. static $roles;
  484. if (!isset($roles)) {
  485. $roles = user_roles();
  486. }
  487. if (!$row->gid && $row->realm == 'content_access_rid') {
  488. return t('Content access: No access is granted.');
  489. }
  490. switch ($row->realm) {
  491. case 'content_access_author':
  492. return t('Content access: author of the content can access');
  493. case 'content_access_rid':
  494. return t('Content access: %role can access', array('%role' => $roles[$row->gid]));
  495. }
  496. }
  497. /**
  498. * Implements hook_form_alter().
  499. */
  500. function content_access_form_alter(&$form, $form_state, $form_id) {
  501. if ($form_id == 'user_admin_perm') {
  502. module_load_include('inc', 'content_access', 'content_access.admin');
  503. $form['#submit'][] = 'content_access_user_admin_perm_submit';
  504. }
  505. }
  506. /**
  507. * Returns an array of possible operations on content and their labels.
  508. */
  509. function _content_access_get_operations($type = NULL) {
  510. $operations = array(
  511. 'view' => t('View any @type content', array('@type' => $type)),
  512. 'view_own' => t('View own @type content', array('@type' => $type)),
  513. 'update' => t('Edit any @type content', array('@type' => $type)),
  514. 'update_own' => t('Edit own @type content', array('@type' => $type)),
  515. 'delete' => t('Delete any @type content', array('@type' => $type)),
  516. 'delete_own' => t('Delete own @type content', array('@type' => $type)),
  517. );
  518. return $operations;
  519. }
  520. /**
  521. * Formapi #process callback, that disables checkboxes for roles without access to content
  522. */
  523. function content_access_disable_checkboxes($element) {
  524. $access_roles = content_access_get_permission_access('access content');
  525. $admin_roles = content_access_get_permission_access('administer nodes');
  526. foreach (element_children($element) as $key) {
  527. if (!in_array($key, $access_roles) &&
  528. $key == DRUPAL_ANONYMOUS_RID &&
  529. !in_array(DRUPAL_AUTHENTICATED_RID, $access_roles)) {
  530. $element[$key]['#disabled'] = TRUE;
  531. $element[$key]['#default_value'] = FALSE;
  532. $element[$key]['#prefix'] = '<span' . drupal_attributes(array('title' => t("This role is lacking the permission '@perm', so it has no access.", array('@perm' => t('access content'))))) . '>';
  533. $element[$key]['#suffix'] = "</span>";
  534. }
  535. elseif (in_array($key, $admin_roles) ||
  536. ($key != DRUPAL_ANONYMOUS_RID && in_array(DRUPAL_AUTHENTICATED_RID, $admin_roles))) {
  537. // Fix the checkbox to be enabled for users with administer node privileges
  538. $element[$key]['#disabled'] = TRUE;
  539. $element[$key]['#default_value'] = TRUE;
  540. $element[$key]['#prefix'] = '<span' . drupal_attributes(array('title' => t("This role has '@perm' permission, so access is granted.", array('@perm' => t('administer nodes'))))) . '>';
  541. $element[$key]['#suffix'] = "</span>";
  542. }
  543. }
  544. return $element;
  545. }
  546. /**
  547. * Gets node's access permissions.
  548. */
  549. function _content_access_get_node_permissions($type) {
  550. return array_filter(array_map('content_access_get_permission_by_op', array_flip(_content_access_get_operations()), array_fill(0, 6, $type)));
  551. }
  552. /**
  553. * Gets the content access acl id of the node.
  554. */
  555. function content_access_get_acl_id($node, $op) {
  556. $acl_id = acl_get_id_by_name('content_access', $op . '_' . $node->nid);
  557. if (!$acl_id) {
  558. $acl_id = acl_create_new_acl('content_access', $op . '_' . $node->nid);
  559. }
  560. return $acl_id;
  561. }
  562. /**
  563. * Detaches all our ACLs for the nodes of the given type.
  564. */
  565. function _content_access_remove_acls($type) {
  566. $result = db_query("SELECT n.nid FROM {node} n WHERE type = :type", array('type' => $type));
  567. foreach ($result as $node) {
  568. acl_node_clear_acls($node->nid, 'content_access');
  569. }
  570. }