<?php

/**
 * @file
 * Install, update and uninstall functions for the workflow_admin_ui module.
 */

/**
 * Implements hook_enable().
 */
function workflow_admin_ui_enable() {
  drupal_set_message(_workflow_admin_ui_participate());
}

/**
 * Helper function. Used both by update and enable.
 */
function _workflow_admin_ui_participate() {
  return t("Please review which roles may 'participate in workflows' <a href='!url'>on the Permissions page</a>.",
    array('!url' => url('admin/people/permissions', array('fragment' => 'module-workflow'))));
}

/**
 * Gives all user roles the ability to participate in workflows.
 *
 * This is only done for updating. New installs must set the roles themselves.
 */
function workflow_admin_ui_update_7001(&$sandbox) {
  $perms = array('participate in workflow' => 1);
  foreach (user_roles() as $rid => $name) {
    user_role_change_permissions($rid, $perms);
  }
  return _workflow_admin_ui_participate();
}
