You are here

entity_print.install in Entity Print 7

Same filename and directory in other branches
  1. 8.2 entity_print.install
  2. 8 entity_print.install

Entity print install file.

File

entity_print.install
View source
<?php

/**
 * @file
 * Entity print install file.
 */

/**
 * Introduce per entity type and per bundle permissions.
 */
function entity_print_update_7001() {

  // Get roles.
  $roles = user_roles();
  $loaded_roles = array();

  // Load roles by name to get the rid and the role name.
  foreach ($roles as $role) {
    $loaded_roles[] = user_role_load_by_name($role);
  }

  // Prepare permission array.
  $rid_permissions = array();
  foreach ($loaded_roles as $loaded_role) {
    $rid_permissions[] = array(
      'rid' => $loaded_role->rid,
      'permissions' => user_role_permissions(array(
        $loaded_role->rid => $loaded_role->name,
      )),
    );
  }

  // Set / unset permissions.
  foreach ($rid_permissions as $rid_permission) {
    $permissions = reset($rid_permission['permissions']);
    if (array_key_exists('entity print access', $permissions)) {
      user_role_change_permissions($rid_permission['rid'], array(
        'entity print access' => FALSE,
        'bypass entity print access' => TRUE,
      ));
    }
  }
}

Functions

Namesort descending Description
entity_print_update_7001 Introduce per entity type and per bundle permissions.