You are here

function coder_upgrade_callback_user in Coder 7.2

Same name in this branch
  1. 7.2 coder_upgrade/conversions/other.inc \coder_upgrade_callback_user()
  2. 7.2 coder_upgrade/conversions/function.inc \coder_upgrade_callback_user()
Same name and namespace in other branches
  1. 7 coder_upgrade/conversions/other.inc \coder_upgrade_callback_user()
  2. 7 coder_upgrade/conversions/function.inc \coder_upgrade_callback_user()

Updates hook_user().

hook_nodeapi, hook_node_type, hook_user, and hook_block removed and replaced with families of related functions Renamed user_delete() to user_cancel(); likewise renamed hook_user_delete() to hook_user_cancel(). (Did this exist?)

2 string references to 'coder_upgrade_callback_user'
coder_upgrade_callback_functions in coder_upgrade/conversions/other.inc
Callback routine for function changes using grammar parser.
coder_upgrade_upgrade_hook_user_alter in coder_upgrade/conversions/function.inc
Implements hook_upgrade_hook_user_alter().

File

coder_upgrade/conversions/other.inc, line 1762
Other conversion routine file for the coder_upgrade module.

Code

function coder_upgrade_callback_user($node, $case_node, $operation = '') {
  cdp("inside " . __FUNCTION__);
  if (!$operation) {
    $case =& $case_node->data;
    if (!is_a($case, 'PGPCase')) {
      cdp("Houston, we've got an unexpected statement");
      return;
    }
    $operation = $case->case
      ->toString();
    $operation = trim($operation, "'\"");
  }
  $hook = '_user_' . str_replace(' ', '_', $operation);
  $parameters = array(
    '$edit',
    '$account',
  );

  // TODO We can end up with multiple copies of same hook if this mapping is accurate???
  switch ($operation) {
    case 'after_update':

      // The user object has been updated and changed. Use this if (probably along with 'insert') if you want to reuse some information from the user object.
      // This block becomes example_user_update
      $hook = '_user_update';
      $parameters = array(
        '&$edit',
        '$account',
        '$category',
      );
      break;
    case 'categories':

      // A set of user information categories is requested.
      // This block becomes example_user_categories
      $parameters = array();
      break;
    case 'delete':

      // The user account is being deleted. The module should remove its custom additions to the user object from the database.
      // This block becomes example_user_cancel
      $hook = '_user_cancel';
      $parameters = array(
        '$edit',
        '$account',
        '$method',
      );
      break;
    case 'form':

      // The user account edit form is about to be displayed. The module should present the form elements it wishes to inject into the form.
      // This block becomes example_user_???
      $hook = '_user_XXX';
      break;
    case 'insert':

      // The user account is being added. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
      // This block becomes example_user_insert
      $parameters = array(
        '&$edit',
        '$account',
        '$category',
      );
      break;
    case 'load':

      // The user account is being loaded. The module may respond to this and insert additional information into the user object.
      // This block becomes example_user_load
      $parameters = array(
        '$users',
      );
      break;
    case 'login':

      // The user just logged in.
      // This block becomes example_user_login
      $parameters = array(
        '&$edit',
        '$account',
      );
      break;
    case 'logout':

      // The user just logged out.
      // This block becomes example_user_logout
      $parameters = array(
        '$account',
      );
      break;
    case 'register':

      // The user account registration form is about to be displayed. The module should present the form elements it wishes to inject into the form.
      // This block becomes example_user_???
      $hook = '_user_XXX';
      break;
    case 'submit':

      // Modify the account before it gets saved.
      // This block becomes example_user_???
      $hook = '_user_presave';
      $parameters = array(
        '&$edit',
        '$account',
        '$category',
      );
      break;
    case 'update':

      // The user account is being changed. The module should save its custom additions to the user object into the database and set the saved fields to NULL in $edit.
      // This block becomes example_user_presave
      $hook = '_user_presave';
      $parameters = array(
        '&$edit',
        '$account',
        '$category',
      );
      break;
    case 'validate':

      // The user account is about to be modified. The module should validate its custom additions to the user object, registering errors as necessary.
      // This block becomes example_user_presave
      $hook = '_user_presave';
      $parameters = array(
        '&$edit',
        '$account',
        '$category',
      );
      break;
    case 'view':

      // The user's account information is being displayed. The module should format its custom additions for display, and add them to the $account->content array.
      // This block becomes example_user_view
      $parameters = array(
        '$account',
        '$build_mode',
      );
      break;
    default:
      cdp("ERROR: Invalid case value");
      return;
  }

  // Create the new hook function.
  coder_upgrade_op_to_hook($node, $case_node, $hook, $parameters);
}