Index: guestbook.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/guestbook/Attic/guestbook.module,v
retrieving revision 1.1.10.6
diff -b -U3 -r1.1.10.6 guestbook.module
--- guestbook.module 2 Mar 2007 21:10:09 -0000 1.1.10.6
+++ guestbook.module 25 Apr 2007 16:29:38 -0000
@@ -95,14 +95,23 @@
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('History') => $items);
- }
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page') {
+ $items['guestbook-entries'] = array(
+ 'title' => t('Guestbook entries'),
+ 'value' => guestbook_page($user->uid, arg(2), arg(3)),
+ 'class' => 'entries');
+ return array(t('Guestbook') => $items);
+ }
+ else {
+ $title = t("Read @username's guestbook.", array('@username' => $user->name));
+ $link = l(t('View recent guestbook entries'), "guestbook/$user->uid", array('title' => $title));
+ $items['guestbook'] = array(
+ 'title' => t('Guestbook'),
+ 'value' => $link,
+ 'class' => 'guestbook');
+ return array(t('History') => $items);
+ }
+ }
break;
case 'form':
if ($category == 'account') {
@@ -201,6 +210,13 @@
'#type' => 'fieldset',
'#title' => t('User guestbooks'),
'#description' => t('Users can individually disable their guestbook or add an intro text on the user account page.'));
+ $form['user_guestbooks']['guestbook_user_location'] = array(
+ '#type' => 'radios',
+ '#title' => t('Location of user guestbooks'),
+ '#default_value' => variable_get('guestbook_user_location', 'separate page'),
+ '#options' => array(
+ 'separate page' => t('Separate page'),
+ 'profile page' => t('On profile page')));
// Display options
$form['display_options'] = array(
@@ -475,7 +493,13 @@
case 'allowed':
if ($display == 'link') {
// output only a link to a page with the form
- $output .= '
» '. l(t('Add guestbook entry'), "guestbook/$uid/form") .'
';
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user') {
+ $query = 'destination=user/'. $uid;
+ }
+ else {
+ $query = NULL;
+ }
+ $output .= '» '. l(t('Add guestbook entry'), "guestbook/$uid/form", array(), $query) .'
';
}
else {
$output .= $display == 'page' ? '' : ''. t('Add guestbook entry') .'
';
@@ -519,7 +543,13 @@
if (_guestbook_access('administer', $edit['uid'])) {
db_query("UPDATE {guestbook} SET comment = '%s', commentauthor = %d WHERE id = %d", $edit['comment'], $user->uid, $edit['entry_id']);
}
- return array('guestbook/'. $edit['uid'], $_GET['page'] ? 'page='. $_GET['page'] : NULL);
+
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user') {
+ return array('user/'. $edit['uid'], $_GET['page'] ? 'page='. $_GET['page'] : NULL);
+ }
+ else {
+ return array('guestbook/'. $edit['uid'], $_GET['page'] ? 'page='. $_GET['page'] : NULL);
+ }
}
function theme_guestbook_form_comment_form($form) {
@@ -547,7 +577,7 @@
$form['uid'] = array('#type' => 'value', '#value' => $uid);
return confirm_form(
$form,
- t('Are you sure you want to delete this guestbook entry?\n'),
+ t('Are you sure you want to delete this guestbook entry?'),
'guestbook/'. $uid,
theme('guestbook_entry', $uid, $entry, NULL, true),
t('Delete'), t('Cancel'));
@@ -557,7 +587,13 @@
if (_guestbook_access('administer', $form_values['uid']) && $form_values['confirm']) {
db_query("DELETE FROM {guestbook} WHERE id = %d", $form_values['entry_id']);
}
- return 'guestbook/'. $form_values['uid'];
+
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user') {
+ return array('user/'. $form_values['uid'], $_GET['page'] ? 'page='. $_GET['page'] : NULL);
+ }
+ else {
+ return array('guestbook/'. $form_values['uid'], $_GET['page'] ? 'page='. $_GET['page'] : NULL);
+ }
}
/**
@@ -638,8 +674,16 @@
if ($comment_entry != $entry['id']) {
$pager = $_GET['page'] ? 'page='. $_GET['page'] : NULL;
$output .= '» ';
- $output .= l(t('Delete entry'), "guestbook/$uid/delete/{$entry['id']}", array(), $pager) .' | ';
- $output .= l($entry['comment'] == '' ? t('Add comment') : t('Edit comment'), "guestbook/$uid/comment/{$entry['id']}", array(), $pager, 'comment-entry');
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user') {
+ $delete_query = 'destination=user/'. $uid . ($pager ? '&' : '');
+ $comment_link = "user/$uid/comment/{$entry['id']}";
+ }
+ else {
+ $delete_query = '';
+ $comment_link = "guestbook/$uid/comment/{$entry['id']}";
+ }
+ $output .= l(t('Delete entry'), "guestbook/$uid/delete/{$entry['id']}", array(), $delete_query . $pager) .' | ';
+ $output .= l($entry['comment'] == '' ? t('Add comment') : t('Edit comment'), $comment_link, array(), $pager, 'comment-entry');
$output .= '
';
}
}
@@ -669,7 +713,12 @@
$user_text = t('View user profile.');
}
else if (user_access('access user guestbooks')) {
- $user_link = "guestbook/$account->uid";
- $user_text = t('View user guestbook.');
+ if (variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user') {
+ $user_link = "user/$account->uid";
+ }
+ else {
+ $user_link = "guestbook/$account->uid";
+ }
+ $user_text = t('View user guestbook.');
}
else {
@@ -768,7 +817,7 @@
$guestbook_mode = variable_get('guestbook_mode', GUESTBOOK_SITE_GUESTBOOK | GUESTBOOK_USER_GUESTBOOKS);
$output = '';
- if ($guestbook_mode & GUESTBOOK_USER_GUESTBOOKS && user_access('access user profiles') && $uid != $user->uid) {
+ if ($guestbook_mode & GUESTBOOK_USER_GUESTBOOKS && user_access('access user profiles') && $uid != $user->uid && !(variable_get('guestbook_user_location', 'separate page') == 'profile page' && arg(0) == 'user')) {
$guestbook_user = user_load(array('uid' => $uid, 'status' => 1));
if ($guestbook_user->uid && $guestbook_user->guestbook_status == 0) {
$namelink = l($guestbook_user->name, "user/$uid", array('title' => t('View user profile.')));