function user_patterns_build in Patterns 7.2
Same name and namespace in other branches
- 7 patterns_components/components/user.inc \user_patterns_build()
File
- patterns_components/
components/ user.inc, line 509
Code
function user_patterns_build($action, $form_id, &$data = NULL, &$a) {
$status = PATTERNS_SUCCESS;
$msg = '';
$result = NULL;
if ($form_id == 'user_register_form') {
if (isset($data['uid'])) {
unset($data['uid']);
}
// Ste: added
// if (!isset($data['user'])) {
// $data['user'] = (object) $data;
// }
}
elseif ($form_id == 'user_profile_form') {
// Make sure that required fields are not left empty.
if (empty($data['mail'])) {
$data['mail'] = db_query("SELECT mail FROM {users} WHERE uid = :uid", array(
'uid' => $data['uid'],
))
->fetchField();
}
if (empty($data['name'])) {
$data['name'] = db_query("SELECT name FROM {users} WHERE uid = :uid", array(
'uid' => $data['uid'],
))
->fetchField();
}
static $old_q;
// TODO: What is this?
$old_q = $_GET['q'];
$_GET['q'] = 'user/' . $data['uid'] . '/edit';
}
elseif ($id == 'user_cancel_confirm_form') {
$data['confirm'] = 1;
switch ($data['method']) {
case '1':
$data['user_cancel_method'] = 'user_cancel_block';
break;
case '2':
$data['user_cancel_method'] = 'user_cancel_block_unpublish';
break;
case '3':
$data['user_cancel_method'] = 'user_cancel_reassign';
break;
case '4':
$data['user_cancel_method'] = 'user_cancel_delete';
break;
}
}
elseif ($form_id == 'user_admin_roles' || $form_id == 'user_admin_role_delete_confirm' || $form_id == 'user_admin_role') {
if ($action === PATTERNS_DELETE) {
$data['op'] = t('Delete');
}
elseif ($data['rid']) {
$data['op'] = t('Save role');
}
else {
$data['op'] = t('Add role');
}
}
$result = $data;
return patterns_results($status, $msg, $result);
}