summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Douglass2006-02-12 18:15:46 (GMT)
committer Robert Douglass2006-02-12 18:15:46 (GMT)
commit9145bdd7730207c98b5666422ea10f45ea8ec7d6 (patch)
treed4d50421f7ac57d33591f6e7590c3e713db215e5
parent6db32c421f7ca6a3ad1fff2ee11814c0859956e3 (diff)
INSTALL => INSTALL.txt
Made add/delete user links themable added t()s from #16537 added phptemplate_username function from #39203 please test.
-rw-r--r--INSTALL25
-rw-r--r--INSTALL.txt56
-rw-r--r--buddylist.module19
3 files changed, 71 insertions, 29 deletions
diff --git a/INSTALL b/INSTALL
deleted file mode 100644
index 0428378..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,25 +0,0 @@
-Readme
-------
-This module allows users to put each other on a personal 'Buddy List' ,
-also enabling them to keep up with their friend's postings via the 'My Friend's Blogs' block.
-
-Send comments to adrian@daemon.co.za.
-
-Requirements
-------------
-This module requires Drupal 4.4.0 or CVS from March 25 2004 or later.
-
-Installation
-------------
-1. Create the SQL tables. This depends a little on your system, but the most
- common method is:
- mysql -u username -ppassword drupal < buddylist.mysql
-
- Postgres database initialization file is also included, but not tested.
-
-2. Copy the buddylist.module to the Drupal modules/ directory.
-
-3. Enable buddy list in the "site settings | modules" administration screen.
-
-4. Enable buddy list blocks you want in the "blocks" administration screen.
-
diff --git a/INSTALL.txt b/INSTALL.txt
new file mode 100644
index 0000000..6a32719
--- /dev/null
+++ b/INSTALL.txt
@@ -0,0 +1,56 @@
+Readme
+------
+This module allows users to put each other on a personal 'Buddy List' ,
+also enabling them to keep up with their friend's postings via the 'My Friend's Blogs' block.
+
+Send comments to adrian@daemon.co.za.
+
+Requirements
+------------
+This module requires Drupal 4.4.0 or CVS from March 25 2004 or later.
+
+Installation
+------------
+1. Create the SQL tables. This depends a little on your system, but the most
+ common method is:
+ mysql -u username -ppassword drupal < buddylist.mysql
+
+ Postgres database initialization file is also included, but not tested.
+
+2. Copy the buddylist.module to the Drupal modules/ directory.
+
+3. Enable buddy list in the "site settings | modules" administration screen.
+
+4. Enable buddy list blocks you want in the "blocks" administration screen.
+
+5. Optionally add the following theme function to your PHPTemplate's template.php file:
+
+function phptemplate_username($object) {
+ global $user;
+ /* Use the default theme_username for anonymous users, nodes by this user */
+ if ($user->uid == 0 || $object->uid == $user->uid || $object->uid == 0) {
+ return theme_username($object);
+ }
+ if (!user_access('maintain buddy list')) {
+ return theme_username($object);
+ }
+
+ /* an array, keyed on buddy uids */
+ $buddies = buddylist_get_buddies($user->uid);
+ /* Find out if this buddy is in the user's buddy list */
+ foreach ($buddies as $buddyuid => $buddystructure) {
+ if ($buddyuid == $object->uid) {
+ $output .= theme_username($object);
+ $output .= " (";
+ $output .= theme('remove_from_buddylist_link', $object);
+ $output .= ")";
+ return $output;
+ }
+ }
+ /* The user is not in the buddylist, give a link to add */
+ $output .= theme_username($object);
+ $output .= " (";
+ $output .= theme('add_to_buddylist_link', $object);
+ $output .= ")";
+ return $output;
+}
diff --git a/buddylist.module b/buddylist.module
index d296e1d..064c8a1 100644
--- a/buddylist.module
+++ b/buddylist.module
@@ -93,7 +93,7 @@ function buddylist_setmsg_received($thisuser) {
$check_received = db_query('SELECT received, b.uid as uid, u.name FROM {buddylist} b LEFT JOIN {users} u ON u.uid = b.uid WHERE buddy = %d AND received = 1', $thisuser->uid);
while ($rec = db_fetch_object($check_received)) {
if (($rec->received) and ($thisuser->uid == $user->uid)) {
- drupal_set_message(l($rec->name, 'user/'. $rec->uid) .' has added you to his/her buddylist.');
+ drupal_set_message(t('%linktouser has added you to his/her buddylist.', array('%linktouser' => l($rec->name, 'user/'. $rec->uid))));
db_query('UPDATE {buddylist} SET received = 0 WHERE buddy = '. $user->uid);
}
}
@@ -142,21 +142,32 @@ function buddylist_user($type, &$edit, &$thisuser, $category = NULL) {
// is generated.
$_SESSION['buddylist_op_destination'] = $_SERVER['HTTP_REFERER'];
if (@in_array($thisuser->uid, array_keys(buddylist_get_buddies($user->uid))) && user_access('maintain buddy list')) {
- $actions[] = l(t('Remove %name from my buddy list', array('%name' => theme('placeholder', $thisuser->name))), 'buddy/delete/' . $thisuser->uid, NULL, NULL, NULL, FALSE, TRUE);
+ $actions[] = theme('remove_from_buddylist_link', $thisuser);
}
else {
if ($user->uid != $thisuser->uid && user_access('maintain buddy list')) {
- $actions[] = l(t('Add %name to my buddy list', array('%name' => theme('placeholder', $thisuser->name))), 'buddy/add/' . $thisuser->uid, NULL, NULL, NULL, FALSE, TRUE);
+ $actions[] = theme('add_to_buddylist_link', $thisuser);
}
}
if ($actions) {
$output .= form_item(t('Buddy actions'), theme('item_list', $actions));
}
- return array ('Buddy List' => $output);
+ return array(t('Buddy List') => $output);
}
}
/**
+ * 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' => theme('placeholder', $buddyuser->name))), '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' => theme('placeholder', $buddyuser->name))), 'buddy/add/' . $buddyuser->uid, NULL, drupal_get_destination(), NULL, FALSE, TRUE);
+}
+
+/**
* Implementation for hook_block
*/
function buddylist_block($op = 'list', $delta = 0) {