Exemplo n.º 1
0
/**
 * This module is provided to allow modules to add their own CSS files.
 *
 * Note, you can also manage the CSS files from your theme.
 * @see https://www.drupal.org/node/2430561#from-your-theme
 *
 * @param array $render
 *   The renderable array for the PDF.
 * @param object $entity
 *   The entity we're rending.
 */
function hook_entity_print_css_alter(&$render, $entity)
{
    // An example of adding two stylesheets for any commerce_order entity.
    if ($entity->bundle() === 'commerce_order') {
        $render['#attached']['library'][] = 'moudle/table';
        $render['#attached']['library'][] = 'moudle/commerce-order';
    }
}
Exemplo n.º 2
0
/**
 * Overrides the $node->access() and $account->hasPermission() permission to
 * access and edit webform components, e-mails, conditions, and form settings.
 *
 * Return NULL to defer to other modules. If all implementations defer, then
 * access to the node's EDIT tab plus 'edit webform components' permission
 * determines access. To grant access, return TRUE; to deny access, return
 * FALSE. If more than one implementation return TRUE/FALSE, all must be TRUE
 * to grant access.
 *
 * In this way, access to the EDIT tab of the node may be decoupled from
 * access to the WEBFORM tab. When returning TRUE, consider all aspects of
 * access as this will be the only test. For example, 'return TRUE;' would grant
 * annonymous access to creating webform components, which seldom be desired.
 *
 * @see webform_node_update_access().
 *
 * @param object $node
 *   The Webform node to check access on.
 * @param object $account
 *   The user account to check access on.
 * @return boolean|NULL
 *   TRUE or FALSE if the user can access the webform results, or NULL if
 *   access should be deferred to other implementations of this hook or
 *   $node->access('update') plus
 *   $account->hasPermission('edit webform components').
 */
function hook_webform_update_access($node, $account)
{
    // Allow anyone who can see webform_editable_by_user nodes and who has
    // 'my webform component edit access' permission to see, edit, and delete the
    // webform components, e-mails, conditionals, and form settings.
    if ($node->bundle() == 'webform_editable_by_user') {
        return $node->access('view', $account) && $account->hasPermission('my webform component edit access');
    }
}