function coder_upgrade_callback_user in Coder 7
Same name in this branch
- 7 coder_upgrade/conversions/other.inc \coder_upgrade_callback_user()
- 7 coder_upgrade/conversions/function.inc \coder_upgrade_callback_user()
Same name and namespace in other branches
- 7.2 coder_upgrade/conversions/other.inc \coder_upgrade_callback_user()
- 7.2 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/ function.inc, line 1583 - Provides conversion routines applied to functions (or hooks).
Code
function coder_upgrade_callback_user($node, $case_node, $operation = '') {
cdp("inside " . __FUNCTION__);
// http://drupal.org/node/224333#remove_op
// http://drupal.org/node/224333#hook-user-changes
if (!$operation) {
$case =& $case_node->data;
if (!$case instanceof PGPCase || $case->type == T_DEFAULT) {
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',
'$view_mode',
);
break;
default:
cdp("ERROR: Invalid case value");
return;
}
// Create the new hook function.
coder_upgrade_op_to_hook($node, $case_node, $hook, $parameters);
}