function guestbook_user in Guestbook 5
Same name and namespace in other branches
- 5.2 guestbook.module \guestbook_user()
- 6.2 guestbook.module \guestbook_user()
- 6 guestbook.module \guestbook_user()
Implementation of hook_user().
File
- ./
guestbook.module, line 102
Code
function guestbook_user($op, &$edit, &$user, $category = '') {
$guestbook_mode = variable_get('guestbook_mode', GUESTBOOK_SITE_GUESTBOOK | GUESTBOOK_USER_GUESTBOOKS);
if ($guestbook_mode & GUESTBOOK_USER_GUESTBOOKS) {
switch ($op) {
case 'view':
if (user_access('access user guestbooks') && $user->guestbook_status == 0) {
$title = t("Read @username's guestbook.", array(
'@username' => $user->name,
));
$link = l(t('View recent guestbook entries'), "guestbook/{$user->uid}", array(
'title' => $title,
));
$items[] = array(
'title' => t('Guestbook'),
'value' => $link,
'class' => 'guestbook',
);
return array(
t('Guestbook') => $items,
);
}
break;
case 'form':
if ($category == 'account') {
$form['guestbook'] = array(
'#type' => 'fieldset',
'#title' => t('User guestbook'),
);
$form['guestbook']['guestbook_status'] = array(
'#type' => 'radios',
'#title' => t('Status'),
'#default_value' => $edit['guestbook_status'],
'#options' => array(
t('Enabled'),
t('Disabled'),
),
);
$form['guestbook']['guestbook_send_email'] = array(
'#type' => 'checkbox',
'#title' => t('Send email notification'),
'#description' => t("Uncheck if you don't wish to be notified of new entries to your guestbook."),
'#default_value' => isset($edit['guestbook_send_email']) ? $edit['guestbook_send_email'] : 1,
);
$form['guestbook']['guestbook_intro'] = array(
'#type' => 'textarea',
'#title' => t('Intro text'),
'#default_value' => $edit['guestbook_intro'],
'#cols' => 70,
'#rows' => GUESTBOOK_TEXTAREA_ROWS,
'#description' => t('The text that appears on top of your guestbook.'),
);
return $form;
}
break;
case 'delete':
db_query("DELETE FROM {guestbook} WHERE recipient = %d", $user->uid);
db_query("UPDATE {guestbook} SET author = 0 WHERE author = %d", $user->uid);
db_query("UPDATE {guestbook} SET commentauthor = 0 WHERE commentauthor = %d", $user->uid);
break;
}
}
}