/**
 * Add to the administration bar content before it is rendered.
 *
 * Only use this hook to add new data to the menu structure. Use
 * hook_admin_bar_output_alter() to *alter* existing data.
 *
 * @param array $content
 *   A structured array suitable for backdrop_render(), potentially containing:
 *   - menu: The administrative bar of links below the path 'admin/*'.
 *   - icon: The icon menu.
 *   - account: The user account name and log out link.
 *   - users: The user counter.
 *   Additionally, these special properties:
 *   - #components: The actual components contained in $content are configurable
 *     and depend on the 'admin_bar.settings.components' configuration value.
 *     #components holds a copy of that for convenience.
 *   - #complete: A Boolean indicating whether the complete menu should be built,
 *     ignoring the current configuration in #components.
 *   Passed by reference.
 *
 * @see hook_admin_bar_output_alter()
 * @see admin_bar_links_menu()
 * @see admin_bar_links_icon()
 * @see admin_bar_links_user()
 * @see theme_admin_bar_links()
 */
function hook_admin_bar_output_build(&$content)
{
    // In case your implementation provides a configurable component, check
    // whether the component should be displayed:
    if (in_array('shortcut.links', $content['#components']) && !$content['#complete']) {
        return;
    }
    // Add new top-level item to the menu.
    if (isset($content['menu'])) {
        $content['menu']['myitem'] = array('#title' => t('My item'), '#attributes' => array('class' => array('mymodule-myitem')), '#href' => 'mymodule/path', '#options' => array('query' => backdrop_get_destination(), 'attributes' => array('class' => array('myitem-link-anchor'))), '#weight' => 50);
    }
    // Add link to the icon menu to manually run cron.
    if (isset($content['icon'])) {
        $content['icon']['myitem']['cron'] = array('#title' => t('Run cron'), '#access' => user_access('administer site configuration'), '#href' => 'admin/reports/status/run-cron');
    }
}
/**
 * Alter a menu link after it has been translated and before it is rendered.
 *
 * This hook is invoked from _menu_link_translate() after a menu link has been
 * translated; i.e., after dynamic path argument placeholders (%) have been
 * replaced with actual values, the user access to the link's target page has
 * been checked, and the link has been localized. It is only invoked if
 * $item['options']['alter'] has been set to a non-empty value (e.g., TRUE).
 * This flag should be set using hook_menu_link_alter().
 *
 * Implementations of this hook are able to alter any property of the menu link.
 * For example, this hook may be used to add a page-specific query string to all
 * menu links, or hide a certain link by setting:
 * @code
 *   'hidden' => 1,
 * @endcode
 *
 * @param $item
 *   Associative array defining a menu link after _menu_link_translate()
 * @param $map
 *   Associative array containing the menu $map (path parts and/or objects).
 *
 * @see hook_menu_link_alter()
 */
function hook_translated_menu_link_alter(&$item, $map)
{
    if ($item['href'] == 'devel/cache/clear') {
        $item['localized_options']['query'] = backdrop_get_destination();
    }
}
/**
 * The user just logged in.
 *
 * @param $edit
 *   The array of form values submitted by the user.
 * @param $account
 *   The user object on which the operation was just performed.
 */
function hook_user_login(&$edit, $account)
{
    $config = config('system.date');
    // If the user has a NULL time zone, notify them to set a time zone.
    if (!$account->timezone && $config->get('user_configurable_timezones') && $config->get('user_empty_timezone_message')) {
        backdrop_set_message(t('Configure your <a href="@user-edit">account time zone setting</a>.', array('@user-edit' => url("user/{$account->uid}/edit", array('query' => backdrop_get_destination(), 'fragment' => 'edit-timezone')))));
    }
}
/**
 * Provide a list of actions that can be executed on a submission.
 *
 * Some actions are displayed in the list of submissions such as edit, view, and
 * delete. All other actions are displayed only when viewing the submission.
 * These additional actions may be specified in this hook. Examples included
 * directly in the Webform module include PDF, print, and resend e-mails. Other
 * modules may extend this list by using this hook.
 *
 * @param $node
 *   The Webform node on which this submission was made.
 * @param $submission
 *   The Webform submission on which the actions may be performed.
 */
function hook_webform_submission_actions($node, $submission)
{
    $actions = array();
    if (webform_results_access($node)) {
        $actions['myaction'] = array('title' => t('Do my action'), 'href' => 'node/' . $node->nid . '/submission/' . $submission->sid . '/myaction', 'query' => backdrop_get_destination());
    }
    return $actions;
}