You are here

function activity_install_activity_defaults in Activity 6

Same name and namespace in other branches
  1. 5.4 activity.module \activity_install_activity_defaults()

Helper function to allow activity contrib modules to set initial default values for token and operation types on module install.

8 calls to activity_install_activity_defaults()
commentactivity_install in contrib/commentactivity/commentactivity.install
Implementation of hook_install().
favorite_nodesactivity_install in contrib/favorite_nodesactivity/favorite_nodesactivity.install
Implementation of hook_install().
flagactivity_install in contrib/flagactivity/flagactivity.install
Implementation of hook_install().
nodeactivity_install in contrib/nodeactivity/nodeactivity.install
Implementation of hook_install().
ogactivity_install in contrib/ogactivity/ogactivity.install
Implementation of hook_install().

... See full list

File

./activity.module, line 1045
activity.module

Code

function activity_install_activity_defaults($module) {

  // We're including the activity contrib module file manually as Drupal
  // will not have access to the functions defined in the contrib module
  // at install time.
  module_load_include('module', $module);
  $info = call_user_func($module . '_activity_info');
  if ($info) {
    variable_set($module . '_token_types', array_keys($info['types']));
    variable_set($module . '_op_types', array_keys($info['ops']));
    foreach ($info['roles'] as $role_name => $role) {
      foreach ($info['types'] as $type_name => $type) {
        foreach ($info['ops'] as $op_name => $op) {
          $token_field = "{$module}_{$type_name}_{$op_name}_{$role_name}";
          $default = is_array($role['#default']) ? $role['#default'][$op_name] : $role['#default'];
          variable_set($token_field, $default ? $default : '');
        }
      }
    }
    return TRUE;
  }
  return FALSE;
}