summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominik Kiss2008-01-05 13:56:28 (GMT)
committer Dominik Kiss2008-01-05 13:56:28 (GMT)
commite39349d55e469ca09d4da745cdbe198608c6fdce (patch)
tree92ea39b38aa6153362b45840ac4391e68731ce8f
parentaec7b5a38d95251db245c638b473f0bc3a23895f (diff)
major changes
-rw-r--r--buddy_api/buddy_api.info2
-rw-r--r--buddy_api/buddy_api.install9
-rw-r--r--buddy_api/buddy_api.module17
-rw-r--r--buddy_api/buddy_api.views.inc24
-rw-r--r--buddy_api/buddy_api.workflowng.inc65
-rw-r--r--buddylist_ui/README.txt7
-rw-r--r--buddylist_ui/buddylist_ui.info4
-rw-r--r--buddylist_ui/buddylist_ui.install10
-rw-r--r--buddylist_ui/buddylist_ui.module178
9 files changed, 177 insertions, 139 deletions
diff --git a/buddy_api/buddy_api.info b/buddy_api/buddy_api.info
index 5195559..1f96e1d 100644
--- a/buddy_api/buddy_api.info
+++ b/buddy_api/buddy_api.info
@@ -1,4 +1,4 @@
; $Id:
name = Buddy API
description = API which provides functions to create buddy connections, for example: buddylist
-package = Buddylist
+package = Buddylist Package \ No newline at end of file
diff --git a/buddy_api/buddy_api.install b/buddy_api/buddy_api.install
index 6d63821..a8ba0f8 100644
--- a/buddy_api/buddy_api.install
+++ b/buddy_api/buddy_api.install
@@ -75,3 +75,12 @@ function buddy_api_install() {
drupal_set_message(t('Table installation for the buddy_api module was unsuccessful. The tables may need to be installed by hand. See the README.txt file for a list of the installation queries.'), 'error');
}
}
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function buddy_api_uninstall() {
+ db_query('DROP TABLE {buddylist}');
+ db_query('DROP TABLE {buddylist_pending_requests}');
+ db_query("DELETE FROM {variable} WHERE name = 'buddylist_api_translation'");
+}
diff --git a/buddy_api/buddy_api.module b/buddy_api/buddy_api.module
index 407941b..6876821 100644
--- a/buddy_api/buddy_api.module
+++ b/buddy_api/buddy_api.module
@@ -39,7 +39,7 @@ function buddy_api_translation() {
'@Buddylist' => t('Buddylist'),
'@buddies' => t('buddies'),
'@Buddies' => t('Buddies'),);
- return variable_get('buddylist_ui_translation', $translations);
+ return variable_get('buddylist_api_translation', $translations);
}
/**
@@ -57,6 +57,7 @@ function buddy_api_remove($userA, $userB, $buddyinfo = array()) {
db_query('DELETE FROM {buddylist} WHERE uid = %d AND buddy = %d', $userA->uid, $userB->uid);
// if it is a two way connection, remove the userB -> userA connection too
+
if (!$buddyinfo['oneway']) {
db_query('DELETE FROM {buddylist} WHERE uid = %d AND buddy = %d', $userB->uid, $userA->uid);
}
@@ -308,7 +309,7 @@ function buddy_api_invoke($op, $userA, $userB, $buddyinfo = array()) {
*/
function buddy_api_info_defaults($op, $userA, $userB, &$buddyinfo) {
$msg = buddy_api_messages($op, $userA, $userB, $buddyinfo);
- $buddyinfo += array('oneway' => TRUE, 'message' => $msg);
+ $buddyinfo += array('oneway' => 0, 'message' => $msg);
}
/**
@@ -322,11 +323,11 @@ function buddy_api_info_defaults($op, $userA, $userB, &$buddyinfo) {
*/
function buddy_api_messages($op, $userA, $userB, $buddyinfo) {
$msgs = array();
- $msgs['remove'] = t('%username has been removed from your @buddylist.', array('%username' => $userB->name) + buddy_api_translation());;
- $msgs['add'] = t('%username has been added to your @buddylist.', array('%username' => $userB->name) + buddy_api_translation());;
- $msgs['add_request'] = t('Your request to add %username to your @buddylist has been submitted. %username will be notified.', array('%username' => $userB->name) + buddy_api_translation());;
- $msgs['cancel_request'] = t('The request to add %username has been cancelled.', array('%username' => $userB->name) + buddy_api_translation());;
- $msgs['request_accept'] = t('Congratulations! %username is now your buddy.', array('%username' => $userA->name) + buddy_api_translation());;
- $msgs['request_deny'] = t('The request from %username to be your @buddy has been denied.', array('%username' => $userA->name) + buddy_api_translation());;
+ $msgs['remove'] = t('@username has been removed from your @buddylist.', array('@username' => $userB->name) + buddy_api_translation());
+ $msgs['add'] = t('@username has been added to your @buddylist.', array('@username' => $userB->name) + buddy_api_translation());
+ $msgs['add_request'] = t('Your request to add @username to your @buddylist has been submitted. @username will be notified.', array('@username' => $userB->name) + buddy_api_translation());
+ $msgs['cancel_request'] = t('The request to add @username has been cancelled.', array('@username' => $userB->name) + buddy_api_translation());
+ $msgs['request_accept'] = t('Congratulations! @username is now your buddy.', array('@username' => $userB->name) + buddy_api_translation());
+ $msgs['request_deny'] = t('The request from @username to be your @buddy has been denied.', array('@username' => $userB->name) + buddy_api_translation());
return $msgs[$op];
} \ No newline at end of file
diff --git a/buddy_api/buddy_api.views.inc b/buddy_api/buddy_api.views.inc
index 6621273..877ebd1 100644
--- a/buddy_api/buddy_api.views.inc
+++ b/buddy_api/buddy_api.views.inc
@@ -267,14 +267,16 @@ function buddy_api_views_handler_deny_link($fieldinfo, $fielddata, $value, $data
*/
function buddy_api_views_default_views() {
// Default View for buddylist
- $view = new stdClass();
+ $view = new stdClass();
$view->name = 'buddy_api_buddylist';
$view->description = 'list of buddies';
$view->access = array (
);
$view->view_args_php = 'global $user;
// Make the first argument the uid of the current user if not already set
-if (!$args[0]) {
+if(arg(0) == "user" && is_numeric(arg(1))){
+ $args[0] = arg(1);
+}else{
$args[0] = $user->uid;
}
return $args;';
@@ -337,12 +339,10 @@ return $args;';
);
$view->exposed_filter = array (
);
- $view->requires = array(users, node);
-
-
+ $view->requires = array(baj_users, node);
// Default View for received requests (incoming requests)
- $view1 = new stdClass();
+ $view1 = new stdClass();
$view1->name = 'buddy_api_received_requests';
$view1->description = 'list of received requests';
$view1->access = array (
@@ -353,7 +353,7 @@ if (!$args[0]) {
$args[0] = $user->uid;
}
return $args;';
- $view1->page = TRUE;
+ $view1->page = FALSE;
$view1->page_title = 'Received requests';
$view1->page_header = '';
$view1->page_header_format = '1';
@@ -362,7 +362,7 @@ return $args;';
$view1->page_empty = '';
$view1->page_empty_format = '1';
$view1->page_type = 'table';
- $view1->url = 'received_requests';
+ $view1->url = '';
$view1->use_pager = TRUE;
$view1->nodes_per_page = '25';
$view1->block = TRUE;
@@ -421,9 +421,9 @@ return $args;';
$view1->exposed_filter = array (
);
$view1->requires = array(baj_users2, baj_buddylist_pending_requests2);
-
+
// Default View for sent requests (outgoing requests)
- $view2 = new stdClass();
+ $view2 = new stdClass();
$view2->name = 'buddy_api_sent_requests';
$view2->description = 'list of sent requests';
$view2->access = array (
@@ -434,7 +434,7 @@ if (!$args[0]) {
$args[0] = $user->uid;
}
return $args;';
- $view2->page = TRUE;
+ $view2->page = FALSE;
$view2->page_title = 'Sent Requests';
$view2->page_header = '';
$view2->page_header_format = '1';
@@ -443,7 +443,7 @@ return $args;';
$view2->page_empty = '';
$view2->page_empty_format = '1';
$view2->page_type = 'table';
- $view2->url = 'sentrequests';
+ $view2->url = '';
$view2->use_pager = TRUE;
$view2->nodes_per_page = '25';
$view2->block = TRUE;
diff --git a/buddy_api/buddy_api.workflowng.inc b/buddy_api/buddy_api.workflowng.inc
index 1e5090e..95f9d1d 100644
--- a/buddy_api/buddy_api.workflowng.inc
+++ b/buddy_api/buddy_api.workflowng.inc
@@ -74,7 +74,7 @@ function buddy_api_event_info() {
*/
function buddy_api_configuration() {
$configurations = array (
- 'buddy_api_request_accept_mail' =>
+ 'buddy_api_request_accept_mail' =>
array (
'#type' => 'configuration',
'#altered' => false,
@@ -88,28 +88,28 @@ function buddy_api_configuration() {
'#name' => 'workflow_ng_action_mail_to_user',
'#settings' =>
array (
- 'from' => '[userA:site-mail]',
+ 'from' => '[userB:site-mail]',
'from_args' =>
array (
- 0 => 'userA',
+ 0 => 'userB',
),
- 'subject' => '[userB:site-name]: [userB:user] has approved your buddylist add request',
+ 'subject' => '[userA:site-name]: [userA:user] has approved your buddylist add request',
'subject_args' =>
array (
- 0 => 'userB',
+ 0 => 'userA',
),
- 'message' => 'Hi [userA:user],
+ 'message' => 'Hi [userB:user],
-[userB:user] has approved your request to join his/her buddylist.
+[userA:user] has approved your request to join his/her buddylist.
Here\'s a link to your new buddies profile:
- [userB:site-url]/index.php?q=user/[userB:uid]
+ [userA:site-url]/index.php?q=user/[userA:uid]
Enjoy your new freedom!
Regards,
-The [userB:site-name] team
+The [userA:site-name] team
',
'message_args' =>
array (
@@ -120,7 +120,7 @@ The [userB:site-name] team
'#label' => 'Send a mail to a user',
'#argument map' =>
array (
- 'userA' => 'user',
+ 'userB' => 'user',
),
),
'#description' => NULL,
@@ -150,14 +150,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => 'MAIL: [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST MAIL: [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -181,7 +181,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -216,14 +216,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -247,7 +247,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -282,14 +282,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -313,7 +313,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -348,14 +348,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -379,7 +379,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -395,14 +395,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -426,7 +426,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -442,14 +442,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -473,7 +473,7 @@ The [userB:site-name] team
'#settings' =>
array (
'message' => '[buddyinfo:notification]',
- 'used arguments' =>
+ 'message_args' =>
array (
0 => 'buddyinfo',
),
@@ -508,14 +508,14 @@ The [userB:site-name] team
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => '[userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
@@ -588,18 +588,19 @@ The [userA:site-name] team',
array (
'severity' => '0',
'type' => 'workflow-ng',
- 'message' => 'MAIL: [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
- 'link' => '',
+ 'message' => 'BUDDYLIST MAIL: [userA:user] ([userA:uid]): [buddyinfo:notification] ([userB:uid])',
'message_args' =>
array (
0 => 'userA',
1 => 'userB',
2 => 'buddyinfo',
),
+ 'link' => '',
'link_args' =>
array (
),
),
+ '#label' => 'Log to watchdog',
),
'#name' => 'buddy_api_request_mail',
),
diff --git a/buddylist_ui/README.txt b/buddylist_ui/README.txt
index 6da368e..e9c789d 100644
--- a/buddylist_ui/README.txt
+++ b/buddylist_ui/README.txt
@@ -78,3 +78,10 @@ USE OF VIEWS:
friends of user with id 4 you have to call the view with arg 4:
index.php?q=buddylisting/4
buddylisting = name of view
+
+********************************************************************
+TRANSLATION:
+
+- use Localization module to translate strings
+- rename the views (Buddylist, Pending Requests, Sent Requests)
+
diff --git a/buddylist_ui/buddylist_ui.info b/buddylist_ui/buddylist_ui.info
index 8af85d8..7e6bdcf 100644
--- a/buddylist_ui/buddylist_ui.info
+++ b/buddylist_ui/buddylist_ui.info
@@ -1,5 +1,5 @@
; $Id:
name = Buddylist UI
description = Userinterface for Buddy API
-dependencies = buddy_api workflow_ng views usernode
-package = Buddylist
+dependencies = buddy_api views usernode
+package = Buddylist Package
diff --git a/buddylist_ui/buddylist_ui.install b/buddylist_ui/buddylist_ui.install
new file mode 100644
index 0000000..7d76d44
--- /dev/null
+++ b/buddylist_ui/buddylist_ui.install
@@ -0,0 +1,10 @@
+<?php
+// buddylist_ui.install
+
+
+/**
+ * Implementation of hook_uninstall().
+ */
+function buddylist_ui_uninstall() {
+ db_query("DELETE FROM {variable} WHERE name LIKE 'buddylist_%'");
+}
diff --git a/buddylist_ui/buddylist_ui.module b/buddylist_ui/buddylist_ui.module
index 209f5e0..5f6035f 100644
--- a/buddylist_ui/buddylist_ui.module
+++ b/buddylist_ui/buddylist_ui.module
@@ -88,24 +88,35 @@ function buddylist_ui_menu($may_cache) {
'callback' => 'drupal_get_form',
'callback arguments' => array ('buddylist_ui_cancel_request', $id),
);
-
+
+ // user page: buddylist overview
$items[] = array (
- 'path' => 'buddylist/buddylistpage',
- 'title' => t('Buddylist'), // isnīt shown
- 'callback' => 'buddylist_ui_central_page',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'path' => 'buddylist',
+ 'title' => t('My @buddylist', buddylist_ui_translation()),
+ 'callback' => 'theme',
+ 'callback arguments' => array('buddylist_ui_page_buddylist', $id),
+ 'type' => MENU_SUGGESTED_ITEM,
'weight' => 0,
'access' => $editAccess,
);
+
+ // user page: buddylist
+ $items[] = array (
+ 'path' => 'buddylist/confirmed',
+ 'title' => t('My @Buddies', buddylist_ui_translation()),
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => 0,
+ );
+ // user page: pending requests
$items[] = array(
'path' => 'buddylist/requests',
- 'title' => t('Pending requests'),
+ 'title' => t('My @Buddy Requests', buddylist_ui_translation()),
'access' => $editAccess,
'callback' => 'theme',
'type' => MENU_LOCAL_TASK,
'weight' => 1,
- 'callback arguments' => array('buddylist_ui_pending_requests', $id)
+ 'callback arguments' => array('buddylist_ui_page_pending_requests', $id)
);
// admin backend
@@ -123,23 +134,6 @@ function buddylist_ui_menu($may_cache) {
}
/**
- * central page for buddylist actions
- * @return string, html formatted output
- */
-function buddylist_ui_central_page() {
- drupal_set_title(t("Buddylist"));
- $view = views_get_view('buddy_api_buddylist');
- $title = views_get_title($view);
- $view_buddylist = views_build_view('embed', $view, array(), FALSE);
- if (!strlen($view_buddylist)){
- $output .= '<p>'. t('NONE') .'</p>';
- }
- $output .= $view_buddylist;
-
- return theme_box($title, $output, $region = 'main');
-}
-
-/**
* budbuddylist_ui_admin_settings administration settings page
*/
function buddylist_ui_admin_settings() {
@@ -305,23 +299,19 @@ function buddylist_ui_get_buddy_actions(& $viewing_user, & $viewed_user) {
return $actions;
}
- if (in_array($viewed_user->uid, array_keys(buddy_api_get_requestees($viewing_user->uid, 'uid')))) {
- $actions[] = t('You have requested to add this user to your @buddylist. (See !your_pending_requests)', array (
- '!your_pending_requests' => l(t('your pending requests'
- ), 'buddylist/requests')) + buddylist_ui_translation());
+ if (in_array($viewed_user->uid, array_keys(buddy_api_get_requestees($viewing_user->uid)))) {
+ $actions[] = theme('buddylist_ui_action_sent_request', $viewed_user);
}
else
- if (in_array($viewed_user->uid, array_keys(buddy_api_get_buddies($viewing_user->uid, 'uid')))) {
- $actions[] = theme('remove_from_buddylist_ui_link', $viewed_user);
+ if (in_array($viewed_user->uid, array_keys(buddy_api_get_buddies($viewing_user->uid)))) {
+ $actions[] = theme('buddylist_ui_action_remove_buddy', $viewed_user);
}
else
- if (in_array($viewing_user->uid, array_keys(buddy_api_get_requestees($viewed_user->uid, 'uid')))) {
- $actions[] = t('This user has requested to add you to your @buddylist. (See !your_pending_requests)', array (
- '!your_pending_requests' => l(t('your pending requests'
- ), 'buddylist/requests')) + buddylist_ui_translation());
+ if (in_array($viewing_user->uid, array_keys(buddy_api_get_requestees($viewed_user->uid)))) {
+ $actions[] = theme('buddylist_ui_action_confirm_request', $viewed_user);
}
else {
- $actions[] = theme('add_to_buddylist_ui_link', $viewed_user);
+ $actions[] = theme('buddylist_ui_action_add_buddy', $viewed_user);
}
return $actions;
@@ -337,19 +327,30 @@ function buddylist_ui_user($type, & $edit, & $thisuser, $category = NULL) {
$output = array ();
if ($type == 'view') {
- if ($list = buddylist_ui_get_buddylist($thisuser)) {
- $output[] = array ('title' => t('@Buddies', buddylist_ui_translation()), 'value' => $list, 'class' => 'buddylist');
+ //
+ $view = views_get_view('buddy_api_buddylist');
+ $view_received_requests = views_build_view('embed', $view, array(), FALSE);
+ if (!strlen($view_received_requests)){
+ $view_received_requests .= '<p>'. t('NONE') .'</p>';
}
+ $themed_received_requests = theme_box('', $view_received_requests, $region = 'main');
+ //
+ if(strlen($themed_received_requests) > 0 && (user_access('view buddy lists') || $user->uid == $thisuser->uid)){
+ $output[] = array ('title' => t('@Buddies', buddylist_ui_translation()), 'value' => $themed_received_requests);
+ }
+ /*if ($list = buddylist_ui_get_buddylist($thisuser)) {
+ $output[] = array ('title' => t('@Buddies', buddylist_ui_translation()), 'value' => $list, 'class' => 'buddylist');
+ }*/
/*if ($list = buddylist_ui_get_buddylist($thisuser, TRUE)) {
$output[] = array ('title' => t('@buddy of', buddylist_ui_translation()), 'value' => $list, 'class' => 'buddyoflist');
}*/
if ($actions = buddylist_ui_get_buddy_actions($user, $thisuser)) {
- $output[] = array ('title' => t('@Buddy actions', buddylist_ui_translation()), 'value' => theme('item_list', $actions), 'class' => 'buddylist_actions');
+ $output[] = array ('title' => t('Buddy actions'), 'value' => theme('item_list', $actions), 'class' => 'buddylist_actions');
}
if (count($output) > 0) {
return array (
- t('@Buddylist',
- buddylist_ui_translation()) => $output);
+ t('@Buddylist', buddylist_ui_translation()) => $output
+ );
}
}
else
@@ -359,48 +360,12 @@ function buddylist_ui_user($type, & $edit, & $thisuser, $category = NULL) {
}
else
if ($type == 'load') {
- // do NOT call this function with 'object' (it would bei an endless loop)
- $thisuser->buddies = buddy_api_get_buddies($thisuser->uid, 'uid');
+ // Do not load buddies as objects to avoid recursion
+ $thisuser->buddies = buddy_api_get_buddies($thisuser->uid);
}
}
/**
- * Return a formatted list of buddies for the given user
- * @param $user
- * @param $buddy_of If set to TRUE, a formatted list of users is returned, for whom this user is a buddy.
- * @return
- */
-function buddylist_ui_get_buddylist($user, $buddy_of = FALSE) {
-
- if (user_access('view buddy lists') && !$buddy_of) {
- $i = 0;
-
- if ($buddies = buddy_api_get_buddies($user->uid, 'object')) {
- foreach ($buddies as $buddy) {
- $listbuddies[] = $buddy;
- $i++;
- }
- return theme('user_list', $listbuddies);
- }
- }
- else
- if (user_access('view buddy lists')) {
- // This portion of code is used to see if this $thisuser is a buddy of others and, if s/he is, returns a list
- // of people s/he is a buddy of.
- // Note the distinction between having a buddy and being someone else's buddy (i.e., 'buddyof')
- // Of course, this distinction doesn't exist if approval is required to add a buddy (in which case, buddy relationships are symmetric)
- $sql = 'SELECT b.uid, u.name FROM {buddylist} b INNER JOIN {users} u ON b.uid = u.uid WHERE b.buddy = %d ORDER BY u.access DESC';
- $result = db_query_range($sql, $user->uid, 0, variable_get('buddylist_prof_buddies', 5));
- while ($row = db_fetch_object($result)) {
- $listbuddyof[$row->uid] = $row;
- }
- if ($listbuddyof) {
- return theme('user_list', $listbuddyof);
- }
- }
-}
-
-/**
* @param $uid
* @return
*/
@@ -413,7 +378,7 @@ function buddylist_ui_addbuddy($uid) {
if (empty ($buddy->name)) {
drupal_set_message(t('This user does not exist'));
}
- elseif (in_array($uid, array_keys(buddy_api_get_buddies($user->uid, 'uid')))) {
+ elseif (in_array($uid, array_keys(buddy_api_get_buddies($user->uid)))) {
drupal_set_message(t('This user is already on your @buddylist', buddylist_ui_translation()));
}
elseif ($user->uid == $uid) {
@@ -471,7 +436,7 @@ function buddylist_ui_deletebuddy($uid) {
drupal_set_message('This user does not exist');
}
else
- if (!in_array($uid, array_keys(buddy_api_get_buddies($user->uid, 'uid')))) {
+ if (!in_array($uid, array_keys(buddy_api_get_buddies($user->uid)))) {
drupal_set_message('This user is not on your @buddylist', buddylist_ui_translation());
}
else {
@@ -503,7 +468,7 @@ function buddylist_ui_deletebuddy_submit($form_id, $form_values) {
* @param $buddyuser
* @return
*/
-function theme_add_to_buddylist_ui_link($buddyuser) {
+function theme_buddylist_ui_action_add_buddy($buddyuser) {
return l(t('Add %name to my @buddylist', array (
'%name' => $buddyuser->name
) + buddylist_ui_translation()), 'buddy/add/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
@@ -513,14 +478,59 @@ function theme_add_to_buddylist_ui_link($buddyuser) {
* @param $buddyuser
* @return
*/
-function theme_remove_from_buddylist_ui_link($buddyuser) {
+function theme_buddylist_ui_action_remove_buddy($buddyuser) {
return l(t('Remove %name from my @buddylist', array (
'%name' => $buddyuser->name
) + buddylist_ui_translation()), 'buddy/delete/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
}
-function theme_buddylist_ui_pending_requests($id) {
- drupal_set_title('Pending Requests');
+/**
+ * @param $buddyuser
+ * @return
+ */
+function theme_buddylist_ui_action_sent_request($buddyuser) {
+ return t('You have requested to add %name to your @buddylist. (See !your_pending_requests)', array (
+ '%name' => $buddyuser->name,
+ '!your_pending_requests' => l(t('your pending requests'
+ ), 'buddylist/requests')) + buddylist_ui_translation());
+}
+
+/**
+ * @param $buddyuser
+ * @return
+ */
+function theme_buddylist_ui_action_confirm_request($buddyuser) {
+ return t('%name has requested to add you to your @buddylist. (See !your_pending_requests)', array (
+ '%name' => $buddyuser->name,
+ '!your_pending_requests' => l(t('your pending requests'
+ ), 'buddylist/requests')) + buddylist_ui_translation());
+}
+
+/**
+ * Main page for displaying confirmed buddylist
+ *
+ * @return string, html formatted output
+ */
+function theme_buddylist_ui_page_buddylist() {
+ drupal_set_title(t('@Buddylist', buddylist_ui_translation()));
+ $view = views_get_view('buddy_api_buddylist');
+ $title = views_get_title($view);
+ $view_buddylist = views_build_view('embed', $view, array(), FALSE);
+ if (!strlen($view_buddylist)){
+ $output .= '<p>'. t('NONE') .'</p>';
+ }
+ $output .= $view_buddylist;
+
+ return theme_box($title, $output, $region = 'main');
+}
+
+/**
+ * Main page for displaying pending buddy requests (sent & received)
+ *
+ * @return string, html formatted output
+ */
+function theme_buddylist_ui_page_pending_requests($id) {
+ drupal_set_title(t('Pending Requests'));
$view = views_get_view('buddy_api_received_requests');
$title = views_get_title($view);