function user_relationship_invites_user in User Relationships 6
Same name and namespace in other branches
- 5 plugins/user_relationship_invites/user_relationship_invites.module \user_relationship_invites_user()
- 5.2 plugins/user_relationship_invites/user_relationship_invites.module \user_relationship_invites_user()
Implementation of hook_user().
File
- user_relationship_invites/
user_relationship_invites.module, line 73 - Drupal Module: User Relationship Invites
Code
function user_relationship_invites_user($op, &$edit, &$account, $category = NULL) {
if (!(module_exists('invite') && module_exists('user_relationships_api'))) {
return;
}
switch ($op) {
case 'register':
if (($code = $_SESSION[INVITE_SESSION]) && ($invite = user_relationship_invites_get_invite($code)) && $invite->relationship_type) {
$form = array();
$inviter = $invite->inviter;
$relationship_type = $invite->relationship_type;
// approval is required so ask for it
if (!$relationship_type->is_oneway || $relationship_type->requires_approval) {
$form['relationship_invite_approve'] = array(
'#type' => 'radios',
'#title' => t('Please confirm the %relationship_name request from !name', array(
'!name' => theme('username', $inviter),
'%relationship_name' => $relationship_type->name,
)),
'#default_value' => isset($edit['relationship_invite_approve']) ? $edit['relationship_invite_approve'] : 'approve',
'#options' => array(
'approve' => t('Yes'),
'disapprove' => t('No'),
),
);
}
else {
$form['relationship_invite_approve'] = array(
'#type' => 'value',
'#value' => 'approve',
);
}
$form['invite_code'] = array(
'#type' => 'value',
'#value' => $code,
);
$form['relationship_invite_requester'] = array(
'#type' => 'value',
'#value' => $inviter,
);
$form['relationship_type'] = array(
'#type' => 'value',
'#value' => $relationship_type,
);
return $form;
}
break;
case 'insert':
if (isset($edit['relationship_invite_approve'])) {
db_query("DELETE FROM {user_relationship_invites} WHERE invite_code = '%s'", $edit['invite_code']);
if ($edit['relationship_invite_approve'] == 'approve') {
user_relationships_request_relationship($edit['relationship_invite_requester'], $account, $edit['relationship_type'], TRUE);
}
$edit['invite_code'] = NULL;
$edit['relationship_invite_approve'] = NULL;
$edit['relationship_invite_requester'] = NULL;
$edit['relationship_type'] = NULL;
}
break;
}
}