Project

General

Profile

Revision ae34fb26

Added by Assos Assos almost 4 years ago

Weekly update of contrib modules

View differences:

drupal7/sites/all/modules/content_access/content_access.module
11 11
  switch ($path) {
12 12
    case 'admin/help#content_access':
13 13
      $output = '<h3>' . t('About') . '</h3>';
14
      $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>';
15
      $output .= '<h3>' . t('Uses') . '</h3>';
16
      $output .= '<dl>';
17
      $output .= '<dt>' . t('Default and custom settings') . '</dt>';
18
      $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>';
19
      $output .= '</dl>';
14
      $output .= '<p>' . t('The <strong>Content Access</strong> module let you content manage access permission in a flexible and transparant way.') . '</p>';
15
      $output .= '<h3>' . t('Use') . '</h3>';
16
      $output .= '<p>' . t('It provides two new permissions: <em>view all</em> (allows anyone to view the content) and <em>view own</em> (allows  only the content creator to see his/her own content). It also gives access to the existing core permissions <em>edit</em> and <em>delete</em> on the same settings page.') . '</p>';
17
      $output .= '<p>' . t('It provides the following modalities:') . '</p><ul>';
18
      $output .= '<li>' . t('Each <em>!content-type</em> can have its own default content access settings by role.',  array('!content-type' => l('content type', 'admin/structure/types'))) . '</li>';
19
      $output .= '<li>' . t('Optionally you can enable  role based access control settings per <em>content node</em>.') . '</li>';
20
      $output .= '<li>' . t('Access control can be further customized per <em>user</em> if you have the <strong>!acl</strong> module enabled.',
21
        array('!acl' => l('ACL', 'https://www.drupal.org/project/acl/'))) . '</li></ul>';
22
      if (function_exists('advanced_help_hint_docs')) {
23
        $output .= '<p>' . advanced_help_hint_docs('content_access', 'https://drupal.org/node/1194974', TRUE) . '</p>';
24
      }
25
      else {
26
        $output .= '<p>' .t('If you install and enable the module <strong>!url</strong>, you will get more help for <strong>Content Access</strong>.',
27
          array('!url' => l('Advanced Help Hint', 'https://www.drupal.org/project/advanced_help_hint'))) . '</p>';
28
      }
20 29
      return $output;
21 30
  }
22 31
}
23

  
32
          
24 33
/**
25 34
 * Implements hook_admin_paths().
26 35
 */
......
219 228
 * Save content_access settings of a content type.
220 229
 */
221 230
function content_access_set_settings($settings, $type_name) {
222
  // Do not store default values so we do not have to care about synching our
231
  // Do not store default values so we do not have to care about syncing our
223 232
  // settings with the permissions.
224 233
  foreach (content_access_get_setting_defaults($type_name) as $setting => $default_value) {
225 234
    if (isset($settings[$setting]) && $settings[$setting] == $default_value) {
......
329 338
 * @param $any_roles
330 339
 *   The roles with which anybody has access (not optimized!)
331 340
 * @param $own_roles
332
 *   The roles with which only the author has acess (optimized!)
341
 *   The roles with which only the author has access (optimized!)
333 342
 */
334 343
function content_access_own_op($node, $any_roles, $own_roles) {
335 344
  static $roles = array();
......
385 394
 * @param $node
386 395
 *   The node object.
387 396
 * @param $settings
388
 *    Optional array used to update the settings cache with the given settings.
397
 *   Optional array used to update the settings cache with the given settings.
389 398
 * @return
390 399
 *   An array of role ids which have access.
391 400
 */
......
587 596
 */
588 597
function content_access_disable_checkboxes($element) {
589 598
  $access_roles = content_access_get_permission_access('access content');
590
  $admin_roles = content_access_get_permission_access('administer nodes');
599
  $admin_roles = content_access_get_permission_access('bypass node access');
591 600

  
592 601
  foreach (element_children($element) as $key) {
593 602
    if (!in_array($key, $access_roles) &&
......
600 609
    }
601 610
    elseif (in_array($key, $admin_roles) ||
602 611
            ($key != DRUPAL_ANONYMOUS_RID && in_array(DRUPAL_AUTHENTICATED_RID, $admin_roles))) {
603
      // Fix the checkbox to be enabled for users with administer node privileges
612
      // Fix the checkbox to be enabled for users with bypass node access privileges
604 613
      $element[$key]['#disabled'] = TRUE;
605 614
      $element[$key]['#default_value'] = TRUE;
606
      $element[$key]['#prefix'] = '<span' . drupal_attributes(array('title' => t("This role has '@perm' permission, so access is granted.", array('@perm' => t('administer nodes'))))) . '>';
615
      $element[$key]['#prefix'] = '<span' . drupal_attributes(array('title' => t("This role has '@perm' permission, so access is granted.", array('@perm' => t('bypass node access'))))) . '>';
607 616
      $element[$key]['#suffix'] = "</span>";
608 617
    }
609 618
  }
......
637 646
  foreach ($result as $node) {
638 647
    acl_node_clear_acls($node->nid, 'content_access');
639 648
  }
640
}
649
}
650

  
651
/**
652
 * Implements hook_node_export_alter().
653
 */
654
function content_access_node_export_alter(array $nodes) {
655
  foreach ($nodes as $node) {
656
    $node->content_access = content_access_get_per_node_settings($node);
657
  }
658
}
659

  
660
/**
661
 * Implements hook_node_export_after_import_alter().
662
 */
663
function content_access_node_export_after_import_alter(array $nodes) {
664
  foreach ($nodes as $node) {
665
    if(empty($node->nid))
666
      continue;
667
    content_access_save_per_node_settings($node, $node->content_access);
668
  }
669
  // Rebuild content access permissions
670
  node_access_rebuild();
671
}

Also available in: Unified diff