diff --git a/buddylist.module b/buddylist.module
index 84afa616961761ce83f341c6bf86bd5e8ba69082..9a45087aff308d486abcdd6fb474ec2ead87d39d 100644
--- a/buddylist.module
+++ b/buddylist.module
@@ -2,14 +2,14 @@
// $Id$
if (module_exists('views')) {
- include_once('buddylist_views.inc');
+ include_once(drupal_get_path('module', 'buddylist'). '/buddylist_views.inc');
}
define('BUDDYLIST_ADD_SUBJECT', variable_get('buddylist_add_subject', "[@site] You are @adder_name's newest @buddy"));
-define('BUDDYLIST_REMOVE_SUBJECT', variable_get('buddylist_remove_subject', "[@site] You have been removed from @adder_name's @buddy list"));
-define('BUDDYLIST_REQUEST_SUBJECT', variable_get('buddylist_request_subject', "[@site] @adder_name has requested to add you to his/her @buddy list"));
-define('BUDDYLIST_APPROVAL_SUBJECT', variable_get('buddylist_approval_subject', "[@site] @addee_name has approved your @buddy list add request"));
+define('BUDDYLIST_REMOVE_SUBJECT', variable_get('buddylist_remove_subject', "[@site] You have been removed from @adder_name's @buddylist"));
+define('BUDDYLIST_REQUEST_SUBJECT', variable_get('buddylist_request_subject', "[@site] @adder_name has requested to add you to his/her @buddylist"));
+define('BUDDYLIST_APPROVAL_SUBJECT', variable_get('buddylist_approval_subject', "[@site] @addee_name has approved your @buddylist add request"));
/**
* returns an array of common translation placeholders
@@ -43,15 +43,15 @@ function buddylist_help($section) {
Users can also track what their @buddies are posting to the site.
Furthermore, they can track their @buddies' @buddies and thereby explore their social network.
If the administrator has enabled the profile module, users can add @buddies via their @buddies' user profiles.
-On the \"View\" tab of each user's profile, there is a \"@Buddy list\" section. Select the 'add @buddy' action to add the user to your @buddy list.
-If a user is already in your @buddy list, the 'delete' action will remove the @buddy. Administrators can also enable the @buddylist block.
-This block allows you to see a list of your @buddies. If the Friends Of A Friend (FOAF) module is enabled, it will be possible to share @buddy lists with other FOAF-aware social networking applications.
+On the \"View\" tab of each user's profile, there is a \"@Buddylist\" section. Select the 'add @buddy' action to add the user to your @buddylist.
+If a user is already in your @buddylist, the 'delete' action will remove the @buddy. Administrators can also enable the @buddylist block.
+This block allows you to see a list of your @buddies. If the Friends Of A Friend (FOAF) module is enabled, it will be possible to share @buddylists with other FOAF-aware social networking applications.
You can:
For more information, read the configuration and customization handbook Buddylist page
",
@@ -202,34 +202,34 @@ function buddylist_menu($may_cache) {
'weight' => 0,
'callback arguments' => array('buddylist_pending_requests', $id)
);
-
+
$items[] = array(
'path' => 'buddylist/'. $id .'/buddies/requested/accept',
'title' => t('Accept Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
- 'callback' => 'drupal_get_form',
+ 'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_pending_requested_accept',$id),
);
-
+
$items[] = array(
'path' => 'buddylist/'. $id .'/buddies/requested/deny',
'title' => t('Deny Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
- 'callback' => 'drupal_get_form',
+ 'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_pending_requested_deny',$id),
);
-
+
$items[] = array(
'path' => 'buddylist/'. $id .'/buddies/request/cancel',
'title' => t('Cancel Request'),
'access' => $editAccess,
'type' => MENU_CALLBACK,
- 'callback' => 'drupal_get_form',
+ 'callback' => 'drupal_get_form',
'callback arguments' => array('buddylist_cancel_request',$id),
);
-
+
}
// other callbacks
@@ -323,20 +323,20 @@ function buddylist_admin_settings() {
);
$form['block_settings']['buddylist_status_block_title'] = array(
'#type' => 'textfield',
- '#title' => t('"My @buddy list status" block title', buddylist_translation()),
- '#default_value' => variable_get('buddylist_status_block_title', t("My @buddy list status", buddylist_translation())),
+ '#title' => t('"My @buddylist status" block title', buddylist_translation()),
+ '#default_value' => variable_get('buddylist_status_block_title', t("My @buddylist status", buddylist_translation())),
'#size' => 70,
'#maxlength' => 128,
- '#description' => t('This will be the title for the @buddy list status block. If none is specified, "My @buddy list status" will be used.', buddylist_translation()),
+ '#description' => t('This will be the title for the @buddylist status block. If none is specified, "My @buddylist status" will be used.', buddylist_translation()),
);
$form['block_settings']['buddylist_list_block_title'] = array(
'#type' => 'textfield',
'#title' => t('"My @buddies list" block title', buddylist_translation()),
'#weight' => 1,
- '#default_value' => variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation())),
+ '#default_value' => variable_get('buddylist_list_block_title', t('My @buddylist', buddylist_translation())),
'#size' => 70,
'#maxlength' => 128,
- '#description' => t('This will be the title for the "My @buddy list" block. If none is specified, "My @buddy list" will be used.', buddylist_translation()),
+ '#description' => t('This will be the title for the "My @buddylist" block. If none is specified, "My @buddylist" will be used.', buddylist_translation()),
);
$form['block_settings']['buddylist_block_if_no_buddies'] = array(
'#type' => 'checkbox',
@@ -573,7 +573,7 @@ function buddylist_block($op = 'list', $delta = 0) {
global $user;
if ($op == 'list') {
- $block[0]['info'] = variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation()));
+ $block[0]['info'] = variable_get('buddylist_list_block_title', t('My @buddylist', buddylist_translation()));
$block[1]['info'] = variable_get('buddylist_block_title', t('My @buddies\' recent posts', buddylist_translation()));
if (variable_get('buddylist_require_approval', 0)) {
$block[2]['info'] = variable_get('buddylist_status_block_title', t('My @buddy status', buddylist_translation()));
@@ -605,7 +605,7 @@ function buddylist_block($op = 'list', $delta = 0) {
}
}
// this is the same output whether buddylist or not
- $block['subject'] = variable_get('buddylist_list_block_title', t('My @buddy list', buddylist_translation()));
+ $block['subject'] = variable_get('buddylist_list_block_title', t('My @buddylist', buddylist_translation()));
// check if a "more" link should generated by seeing if there are more buddies than the specified $upperlimit
if (count($buddies) > variable_get('buddylist_blocklisting_size', 5)) {
@@ -629,7 +629,7 @@ function buddylist_block($op = 'list', $delta = 0) {
$result = db_query(db_rewrite_sql('SELECT COUNT(n.nid) AS node_count FROM {buddylist} b LEFT JOIN {node} n ON n.uid=b.buddy LEFT JOIN {users} u ON n.uid = u.uid WHERE n.status = 1 AND b.uid=%d'), $user->uid);
$countresult = db_fetch_object($result);
- if (variable_get('buddylist_posts_block', 7) < $countresult->node_count) {
+ if (module_exists('tracker') && variable_get('buddylist_posts_block', 7) < $countresult->node_count) {
$block['content'] .= ''. l(t('more'), 'buddylist/'. $user->uid .'/buddies/recent', array('title' => t('View more.'))) .'
';
}
return $block;
@@ -736,11 +736,11 @@ function buddylist_setmsg_received($thisuser) {
* expose add and remove links to theming.
*/
function theme_remove_from_buddylist_link($buddyuser) {
- return l(t('Remove %name from my @buddy list', array('%name' => $buddyuser->name) + buddylist_translation()), 'buddy/delete/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
+ return l(t('Remove %name from my @buddylist', array('%name' => $buddyuser->name) + buddylist_translation()), 'buddy/delete/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
}
function theme_add_to_buddylist_link($buddyuser) {
- return l(t('Add %name to my @buddy list', array('%name' => $buddyuser->name) + buddylist_translation()), 'buddy/add/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
+ return l(t('Add %name to my @buddylist', array('%name' => $buddyuser->name) + buddylist_translation()), 'buddy/add/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
}
function theme_buddylist_accept_request_link($requestee_uid, $requester_uid) {
@@ -770,6 +770,12 @@ function buddylist_buddylisting_page($uid = NULL, $mode = 'buddies') {
exit();
}
+ $viewing_own_account = ($user->uid == $uid);
+
+ if (user_access('maintain buddy list') && $viewing_own_account) {
+ buddylist_setmsg_received($thisuser);
+ }
+
drupal_set_title(t('%username\'s @buddylist', array('%username' => $thisuser->name) + buddylist_translation()));
$buddies_per_page = 20;
@@ -888,7 +894,7 @@ function buddylist_pending_requested_accept($requestee_uid, $requester_uid) {
t("Are you sure you want to accept the request from !name?", array('!name' => theme('username', $requester_account))),
t('Yes'), t('No'),
'buddylist_request_accept_confirm');
-
+
return $output;
}
@@ -902,7 +908,7 @@ function buddylist_cancel_request($requestee_uid, $requester_uid){
t("Are you sure you want to cancel the request to !name?", array('!name' => theme('username', $requester_account))),
t('Yes'), t('No'),
'buddylist_cancel_request_confirm');
-
+
return $output;
}
@@ -926,7 +932,7 @@ function buddylist_pending_requested_deny($requestee_uid, $requester_uid) {
t("Are you sure you want to deny the request from !name?", array('!name' => theme('username', $requester_account))),
t('Yes'), t('No'),
'buddylist_request_deny_confirm');
-
+
return $output;
}
@@ -939,32 +945,32 @@ function buddylist_pending_requested_accept_submit($form_id, $form_values) {
if (db_num_rows($result) == 0) {
// The other user cancelled since viewing this page
- drupal_set_message(t('!linktouser has cancelled the request to join your @buddylist.', array('!linktouser' => theme('username', $requester_account)) + buddylist_translation()));
+ drupal_set_message(t('!linktouser has cancelled the request to join your @buddylist.', array('!linktouser' => theme('username', $requester_account)) + buddylist_translation()));
return 'buddylist/'. $requestee_account->uid .'/buddies/requests';
}
-
+
db_query('DELETE FROM {buddylist_pending_requests} WHERE requestee_uid = %d AND requester_uid = %d', $requestee_account->uid, $requester_account->uid);
-
+
// Make sure, for some weird reason, we don't already have these guys marked as buddies of each other in the database
$result = db_query('SELECT * FROM {buddylist} WHERE uid = %d AND buddy = %d', $requestee_account->uid, $requester_account->uid);
-
+
$time = time();
-
+
if (!db_num_rows($result)) {
db_query('INSERT INTO {buddylist} (uid, buddy, timestamp, received) VALUES (%d, %d, %d, %d)', $requestee_account->uid, $requester_account->uid, $time, 1);
}
-
+
$result = db_query('SELECT * FROM {buddylist} WHERE uid = %d AND buddy = %d', $requester_account->uid, $requestee_account->uid);
if (!db_num_rows($result)) {
db_query('INSERT INTO {buddylist} (uid, buddy, timestamp, received) VALUES (%d, %d, %d, %d)', $requester_account->uid, $requestee_account->uid, $time, 1);
}
-
+
if (variable_get('buddylist_send_approval', FALSE)) {
buddylist_mail_user('approval', $requester_account, $requestee_account);
}
- drupal_set_message(t('Congratulations! !linktouser is now your buddy.', array('!linktouser' => theme('username', $requester_account)) + buddylist_translation()));
-
+ drupal_set_message(t('Congratulations! !linktouser is now your buddy.', array('!linktouser' => theme('username', $requester_account)) + buddylist_translation()));
+
return 'buddylist/'. $requestee_account->uid .'/buddies/requests';
}
@@ -974,32 +980,32 @@ function buddylist_pending_requested_deny_submit($form_id, $form_values) {
// Delete pending request from {buddylist_penging_requests}
db_query('DELETE FROM {buddylist_pending_requests} WHERE requestee_uid = %d AND requester_uid = %d', $requestee_account->uid, $requester_account->uid);
-
+
drupal_set_message(t("!user's request to be your buddy has been denied.", array('!user' => theme('username', $requester_account)) + buddylist_translation()));
-
+
return 'buddylist/'. $requestee_account->uid .'/buddies/requests';
}
function buddylist_confirm_form($requester_account, $requestee_account) {
$form = array();
-
+
$form['requester_account'] = array(
'#type' => 'value',
'#value' => $requester_account
);
-
+
$form['requestee_account'] = array(
'#type' => 'value',
'#value' => $requestee_account
);
-
+
return $form;
}
function buddylist_confirm_form_submit($form_id, $form_values) {
$requestee_account = user_load(array('uid' => $form_values['requestee_uid'])); // most likely global user, unless admin looking
-
-
+
+
// Delete pending request from {buddylist_penging_requests}
db_query('DELETE FROM {buddylist_pending_requests} WHERE requestee_uid = %d AND requester_uid = %d', $form_values['requestee_uid'], $form_values['requester_uid']);
@@ -1412,17 +1418,17 @@ function buddylist_addbuddy($uid) {
drupal_set_message(t('This user does not exist'));
}
elseif (in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
- drupal_set_message(t('This user is already on your @buddy list', buddylist_translation()));
+ drupal_set_message(t('This user is already on your @buddylist', buddylist_translation()));
}
elseif ($user->uid == $uid) {
- drupal_set_message(t('Cannot add yourself to @buddy list', buddylist_translation()));
+ drupal_set_message(t('Cannot add yourself to @buddylist', buddylist_translation()));
}
else {
$form['uid'] = array('#type' => 'hidden', '#value' => $uid);
$form['name'] = array('#type' => 'hidden', '#value' => $buddy->name);
$output = confirm_form(
$form,
- t('Add user %name to your @buddy list?', array('%name' => $buddy->name) + buddylist_translation()),
+ t('Add user %name to your @buddylist?', array('%name' => $buddy->name) + buddylist_translation()),
$_GET['destination'],
'',
t('Add'), t('Cancel'),
@@ -1459,14 +1465,14 @@ function buddylist_deletebuddy($uid) {
drupal_set_message('This user does not exist');
}
else if (!in_array($uid, array_keys(buddylist_get_buddies($user->uid)))) {
- drupal_set_message('This user is not on your @buddy list', buddylist_translation());
+ drupal_set_message('This user is not on your @buddylist', buddylist_translation());
}
else {
$form['uid'] = array('#type' => 'hidden', '#value' => $uid);
$form['name'] = array('#type' => 'hidden', '#value' => $buddy->name);
$output = confirm_form(
$form,
- t('Remove user %name from your @buddy list?', array('%name' => $buddy->name) + buddylist_translation()),
+ t('Remove user %name from your @buddylist?', array('%name' => $buddy->name) + buddylist_translation()),
$_GET['destination'],
'',
t('Remove'), t('Cancel'),
@@ -1497,7 +1503,7 @@ function buddylist_add($id) {
if (variable_get('buddylist_send_add', FALSE)) {
buddylist_mail_user('add', $user_to_add);
}
- drupal_set_message(t('%username has been added to your @buddy list', array('%username' => $user_to_add->name) + buddylist_translation()));
+ drupal_set_message(t('%username has been added to your @buddylist', array('%username' => $user_to_add->name) + buddylist_translation()));
}
else {
drupal_set_message(t('%username is already on your @buddylist', array('%username' => $user_to_add->name) + buddylist_translation()));
@@ -1517,7 +1523,7 @@ function buddylist_add_request($id) {
if (variable_get('buddylist_send_request', FALSE)) {
buddylist_mail_user('request', $user_to_add);
}
- drupal_set_message(t('Your request to add %username to your @buddy list has been submitted. %username will be notified.', array('%username' => $user_to_add->name) + buddylist_translation()));
+ drupal_set_message(t('Your request to add %username to your @buddylist has been submitted. %username will be notified.', array('%username' => $user_to_add->name) + buddylist_translation()));
}
else {
if ($already_requested) {
@@ -1645,7 +1651,7 @@ function buddylist_mail_remove_default() {
return <<You can add a @buddy by visiting a user's profile page.
MESSAGE;
}
-