Prepare friends UI for groups
authorDuck (Jakob Munih) <duck@obala.net>
Wed, 18 Feb 2009 15:44:31 +0000 (16:44 +0100)
committerDuck (Jakob Munih) <duck@obala.net>
Wed, 18 Feb 2009 15:44:31 +0000 (16:44 +0100)
29 files changed:
folks/edit/approve.php [deleted file]
folks/edit/blacklist.php [deleted file]
folks/edit/friends.php [deleted file]
folks/edit/friends/approve.php [new file with mode: 0644]
folks/edit/friends/blacklist.php [new file with mode: 0644]
folks/edit/friends/for.php [new file with mode: 0644]
folks/edit/friends/friends.php [new file with mode: 0644]
folks/edit/friends/from.php [new file with mode: 0644]
folks/edit/friends/groups.php [new file with mode: 0644]
folks/edit/friends/index.php [new file with mode: 0644]
folks/edit/friends/invite.php [new file with mode: 0644]
folks/edit/friends/of.php [new file with mode: 0644]
folks/edit/friends/reject.php [new file with mode: 0644]
folks/edit/groups.php [deleted file]
folks/edit/reject.php [deleted file]
folks/edit/tabs.php
folks/lib/Driver.php
folks/lib/Folks.php
folks/lib/Friends.php
folks/lib/Friends/application.php
folks/lib/Friends/shared.php
folks/lib/Friends/sql.php
folks/lib/api.php
folks/templates/edit/activity.php
folks/templates/edit/blacklist.php [deleted file]
folks/templates/edit/friends.php
folks/templates/edit/groups.php
folks/templates/edit/invite.php [new file with mode: 0644]
folks/templates/edit/tabs.php [new file with mode: 0644]

diff --git a/folks/edit/approve.php b/folks/edit/approve.php
deleted file mode 100644 (file)
index d63cd1d..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * $Id: approve.php 974 2008-10-07 19:46:00Z duck $
- *
- * Copyright Obala d.o.o. (www.obala.si)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Duck <duck@obala.net>
- * @package Folks
- */
-
-define('FOLKS_BASE', dirname(__FILE__) . '/..');
-require_once FOLKS_BASE . '/lib/base.php';
-require_once FOLKS_BASE . '/lib/Friends.php';
-
-if (!Auth::isAuthenticated()) {
-    Horde::authenticationFailureRedirect();
-}
-
-$user = Util::getGet('user');
-if (empty($user)) {
-    $notification->push(_("You must supply a username."));
-    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-    exit;
-}
-
-$friends = Folks_Friends::singleton();
-$result = $friends->approveFriend($user);
-if ($result instanceof PEAR_Error) {
-    $notification->push($result);
-    $notification->push($result->getDebugInfo());
-    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-    exit;
-}
-
-$notification->push(sprintf(_("User \"%s\" was confirmed as a friend."), $user), 'horde.success');
-
-$title = sprintf(_("%s approved you as a friend on %s"),
-                    Auth::getAuth(),
-                    $registry->get('name', 'horde'));
-
-$body = sprintf(_("User %s confirmed you as a friend on %s.. \nTo see to his profile, go to: %s \n"),
-                Auth::getAuth(),
-                $registry->get('name', 'horde'),
-                Folks::getUrlFor('user', Auth::getAuth(), true, -1));
-
-$friends->sendNotification($user, $title, $body);
-
-$link = '<a href="' . Folks::getUrlFor('user', $user) . '">' . $user . '</a>';
-$folks_driver->logActivity(sprintf(_("Added user %s as a friend."), $link));
-
-header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-exit;
\ No newline at end of file
diff --git a/folks/edit/blacklist.php b/folks/edit/blacklist.php
deleted file mode 100644 (file)
index d241a21..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-/**
- * $Id: blacklist.php 1234 2009-01-28 18:44:02Z duck $
- *
- * Copyright Obala d.o.o. (www.obala.si)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Duck <duck@obala.net>
- * @package Folks
- */
-
-define('FOLKS_BASE', dirname(__FILE__) . '/..');
-require_once FOLKS_BASE . '/lib/base.php';
-require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
-require_once 'tabs.php';
-
-$title = _("Blacklist");
-$remove_url = Util::addParameter(Horde::applicationUrl('edit/blacklist.php'), 'user', null);
-$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
-$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
-
-// Load driver
-require_once FOLKS_BASE . '/lib/Friends.php';
-$friends = Folks_Friends::singleton();
-
-// Perform action
-$user = Util::getGet('user');
-if ($user) {
-    if ($friends->isBlacklisted($user)) {
-        $result = $friends->removeBlacklisted($user);
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } else {
-            $notification->push(sprintf(_("User \"%s\" was removed from your blacklist."), $user), 'horde.success');
-        }
-    } else {
-        $result = $friends->addBlacklisted($user);
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } else {
-            $notification->push(sprintf(_("User \"%s\" was added to your blacklist."), $user), 'horde.success');
-        }
-    }
-}
-
-// Get blacklist
-$blacklist = $friends->getBlacklist();
-if ($blacklist instanceof PEAR_Error) {
-    $notification->push($blacklist);
-    $blacklist = array();
-}
-
-$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
-
-Horde::addScriptFile('tables.js', 'horde', true);
-
-require FOLKS_TEMPLATES . '/common-header.inc';
-require FOLKS_TEMPLATES . '/menu.inc';
-
-echo $tabs->render('blacklist');
-require FOLKS_TEMPLATES . '/edit/blacklist.php';
-
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends.php b/folks/edit/friends.php
deleted file mode 100644 (file)
index e3362e6..0000000
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-/**
- * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
- *
- * Copyright Obala d.o.o. (www.obala.si)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Duck <duck@obala.net>
- * @package Folks
- */
-
-define('FOLKS_BASE', dirname(__FILE__) . '/..');
-require_once FOLKS_BASE . '/lib/base.php';
-require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
-require_once 'tabs.php';
-
-$title = _("Friends");
-$remove_url = Horde::applicationUrl('edit/friends.php');
-$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
-$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
-$letter_url = '';
-if ($registry->hasInterface('letter')) {
-    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
-    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
-}
-
-// Load driver
-require_once FOLKS_BASE . '/lib/Friends.php';
-$friends = Folks_Friends::singleton();
-
-// Perform action
-$user = Util::getGet('user');
-if ($user) {
-    if ($friends->isFriend($user)) {
-        $result = $friends->removeFriend($user);
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } else {
-            $notification->push(sprintf(_("User \"%s\" was removed from your friend list."), $user), 'horde.success');
-        }
-    } else {
-        $result = $friends->addFriend($user);
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } elseif ($friends->needsApproval($user)) {
-            $notification->push(sprintf(_("A confirmation was send to \"%s\"."), $user), 'horde.warning');
-            $title = sprintf(_("%s added you as a friend on %s"),
-                                        Auth::getAuth(),
-                                        $GLOBALS['registry']->get('name', 'horde'));
-            $body = sprintf(_("User %s added you to his firends list on %s. \nTo approve, go to: %s \nTo reject, go to: %s \nTo see to his profile, go to: %s \n"),
-                            Auth::getAuth(),
-                            $registry->get('name', 'horde'),
-                            Util::addParameter(Horde::applicationUrl('edit/approve.php', true, -1), 'user', Auth::getAuth()),
-                            Util::addParameter(Horde::applicationUrl('edit/reject.php', true, -1), 'user', Auth::getAuth()),
-                            Folks::getUrlFor('user', Auth::getAuth(), true, -1));
-            $friends->sendNotification($user, $title, $body);
-        } else {
-            $notification->push(sprintf(_("User \"%s\" was added as your friend."), $user), 'horde.success');
-        }
-    }
-
-    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-    exit;
-}
-
-// Get friends
-$friend_list = $friends->getFriends();
-if ($friend_list instanceof PEAR_Error) {
-    $notification->push($friend_list);
-    $friend_list = array();
-}
-
-// Get friends we are waiting approval from
-$waitingFrom = $friends->waitingApprovalFrom();
-if ($waitingFrom instanceof PEAR_Error) {
-    $notification->push($waitingFrom);
-    $waitingFrom = array();
-}
-
-// Get friends we are waiting approval from
-$waitingFor = $friends->waitingApprovalFor();
-if ($waitingFor instanceof PEAR_Error) {
-    $notification->push($waitingFor);
-    $waitingFor = array();
-}
-
-// Get users who have you on friendlist
-$possibilities = $friends->getPossibleFriends();
-if ($possibilities instanceof PEAR_Error) {
-    $notification->push($waiting);
-    $possibilities = array();
-}
-
-$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
-
-Horde::addScriptFile('tables.js', 'horde', true);
-
-require FOLKS_TEMPLATES . '/common-header.inc';
-require FOLKS_TEMPLATES . '/menu.inc';
-
-echo $tabs->render('friends');
-require FOLKS_TEMPLATES . '/edit/friends.php';
-
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/approve.php b/folks/edit/friends/approve.php
new file mode 100644 (file)
index 0000000..820e286
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+/**
+ * $Id: approve.php 974 2008-10-07 19:46:00Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Friends.php';
+
+if (!Auth::isAuthenticated()) {
+    Horde::authenticationFailureRedirect();
+}
+
+$user = Util::getGet('user');
+if (empty($user)) {
+    $notification->push(_("You must supply a username."));
+    header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+    exit;
+}
+
+$friends = Folks_Friends::singleton();
+$result = $friends->approveFriend($user);
+if ($result instanceof PEAR_Error) {
+    $notification->push($result);
+    $notification->push($result->getDebugInfo());
+    header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+    exit;
+}
+
+$notification->push(sprintf(_("User \"%s\" was confirmed as a friend."), $user), 'horde.success');
+
+$title = sprintf(_("%s approved you as a friend on %s"),
+                    Auth::getAuth(),
+                    $registry->get('name', 'horde'));
+
+$body = sprintf(_("User %s confirmed you as a friend on %s.. \nTo see to his profile, go to: %s \n"),
+                Auth::getAuth(),
+                $registry->get('name', 'horde'),
+                Folks::getUrlFor('user', Auth::getAuth(), true, -1));
+
+$friends->sendNotification($user, $title, $body);
+
+$link = '<a href="' . Folks::getUrlFor('user', $user) . '">' . $user . '</a>';
+$folks_driver->logActivity(sprintf(_("Added user %s as a friend."), $link));
+
+header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+exit;
\ No newline at end of file
diff --git a/folks/edit/friends/blacklist.php b/folks/edit/friends/blacklist.php
new file mode 100644 (file)
index 0000000..b0e861f
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * $Id: blacklist.php 1234 2009-01-28 18:44:02Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Blacklist");
+$remove_url = Util::addParameter(Horde::applicationUrl('edit/friends/blacklist.php'), 'user', null);
+$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Perform action
+$user = Util::getGet('user');
+if ($user) {
+    if ($friends->isBlacklisted($user)) {
+        $result = $friends->removeBlacklisted($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was removed from your blacklist."), $user), 'horde.success');
+            header('Location: ' . Horde::applicationUrl('edit/friends/blacklist.php'));
+            exit;
+        }
+    } else {
+        $result = $friends->addBlacklisted($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was added to your blacklist."), $user), 'horde.success');
+            header('Location: ' . Horde::applicationUrl('edit/friends/blacklist.php'));
+            exit;
+        }
+    }
+}
+
+// Get blacklist
+$list = $friends->getBlacklist();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $blacklist = array();
+}
+
+// Users online
+$online = $folks_driver->getOnlineUsers();
+if ($online instanceof PEAR_Error) {
+    return $online;
+}
+
+// Get groups
+$groups = $friends->getGroups();
+if ($groups instanceof PEAR_Error) {
+    $notification->push($groups);
+    $groups = array();
+}
+
+$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('blacklist');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/for.php b/folks/edit/friends/for.php
new file mode 100644 (file)
index 0000000..3410d87
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Users waiting our approval");
+
+$letter_url = '';
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+if ($registry->hasInterface('letter')) {
+    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
+    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
+}
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Get list
+$list = $friends->waitingApprovalFrom();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $list = array();
+}
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friendsof');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/friends.php b/folks/edit/friends/friends.php
new file mode 100644 (file)
index 0000000..85b1eb5
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Friends");
+$remove_url = Horde::applicationUrl('edit/friends/index.php');
+$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+$letter_url = '';
+if ($registry->hasInterface('letter')) {
+    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
+    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
+}
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Perform action
+$user = Util::getGet('user');
+if ($user) {
+    if ($friends->isFriend($user)) {
+        $result = $friends->removeFriend($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was removed from your friend list."), $user), 'horde.success');
+        }
+    } else {
+        $result = $friends->addFriend($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } elseif ($friends->needsApproval($user)) {
+            $notification->push(sprintf(_("A confirmation was send to \"%s\"."), $user), 'horde.warning');
+            $title = sprintf(_("%s added you as a friend on %s"),
+                                        Auth::getAuth(),
+                                        $GLOBALS['registry']->get('name', 'horde'));
+            $body = sprintf(_("User %s added you to his firends list on %s. \nTo approve, go to: %s \nTo reject, go to: %s \nTo see to his profile, go to: %s \n"),
+                            Auth::getAuth(),
+                            $registry->get('name', 'horde'),
+                            Util::addParameter(Horde::applicationUrl('edit/friends/approve.php', true, -1), 'user', Auth::getAuth()),
+                            Util::addParameter(Horde::applicationUrl('edit/friends/reject.php', true, -1), 'user', Auth::getAuth()),
+                            Folks::getUrlFor('user', Auth::getAuth(), true, -1));
+            $friends->sendNotification($user, $title, $body);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was added as your friend."), $user), 'horde.success');
+        }
+    }
+
+    header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+    exit;
+}
+
+// Get friends
+$list = $friends->getFriends();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $list = array();
+}
+
+$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friends');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/from.php b/folks/edit/friends/from.php
new file mode 100644 (file)
index 0000000..1bc6b19
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Friends we are waiting approval from");
+
+$letter_url = '';
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+if ($registry->hasInterface('letter')) {
+    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
+    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
+}
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Get list
+$list = $friends->waitingApprovalFrom();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $list = array();
+}
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friendsof');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/groups.php b/folks/edit/friends/groups.php
new file mode 100644 (file)
index 0000000..4d91c03
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+/**
+ * $Id: blacklist.php 1234 2009-01-28 18:44:02Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/base.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Groups");
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Get groups
+$groups = $friends->getGroups();
+if ($groups instanceof PEAR_Error) {
+    $notification->push($groups);
+    $groups = array();
+}
+
+// Handle action
+$action = Util::getFormData('action');
+switch ($action) {
+
+    case 'delete':
+
+        $g = Util::getFormdata('g');
+        $result = $friends->removeGroup($g);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } elseif ($result) {
+            $notification->push(sprintf(_("Group \"%s\" has been deleted."), $groups[$g]), 'horde.success');
+        }
+
+        header('Location: ' . Horde::applicationUrl('edit/groups.php'));
+        exit;
+
+    break;
+
+    case 'edit':
+
+        $g = Util::getFormdata('g');
+        $form = new Horde_Form($vars, _("Rename group"), 'editgroup');
+        $form->addHidden('action', 'action', 'text', 'edit');
+        $form->addHidden('g', 'g', 'text', 'edit');
+        $form->setButtons(array(_("Rename"), _("Cancel")), _("Reset"));
+        $v = $form->addVariable(_("Old name"), 'old_name', 'text', false, true);
+        $v->setDefault($groups[$g]);
+        $v = $form->addVariable(_("New name"), 'new_name', 'text', true);
+        $v->setDefault($groups[$g]);
+
+        if (Util::getFormData('submitbutton') == _("Cancel")) {
+            $notification->push(sprintf(_("Group \"%s\" has not been renamed."), $groups[$g]), 'horde.warning');
+            header('Location: ' . Horde::applicationUrl('edit/groups.php'));
+            exit;
+        } elseif (Util::getFormData('submitbutton') == _("Rename")) {
+            $new_name = Util::getFormData('new_name');
+            $result = $friends->renameGroup($g, $new_name);
+            if ($result instanceof PEAR_Error) {
+                $notification->push($result);
+            } else {
+                $notification->push(sprintf(_("Group \"%s\" has been renamed to \"%s\"."), $groups[$g], $new_name), 'horde.success');
+                header('Location: ' . Horde::applicationUrl('edit/groups.php'));
+                exit;
+            }
+        }
+
+    break;
+
+    default:
+
+        // Manage adding groups
+        $form = new Horde_Form($vars, _("Add group"), 'addgroup');
+        $translated = Horde::loadConfiguration('groups.php', 'groups', 'folks');
+        asort($translated);
+        $form->addHidden('action', 'action', 'text', 'add');
+        $form->addVariable(_("Name"), 'translated_name', 'radio', false, false, null, array($translated, true));
+        $form->addVariable(_("Name"), 'custom_name', 'text', false, false, _("Enter custom name"));
+
+        if ($form->validate()) {
+            $form->getInfo(null, $info);
+            if (empty($info['custom_name'])) {
+                $name = $info['translated_name'];
+            } else {
+                $name = $info['custom_name'];
+            }
+            $result = $friends->addGroup($name);
+            if ($result instanceof PEAR_Error) {
+                $notification->push($result);
+            } else {
+                if (empty($info['custom_name'])) {
+                    $name = $translated[$info['translated_name']];
+                }
+                $notification->push(sprintf(_("Group \"%s\" was success added."), $name), 'horde.success');
+                header('Location: ' . Horde::applicationUrl('edit/groups.php'));
+                exit;
+            }
+        }
+
+    break;
+}
+
+$remove_url = Util::addParameter(Horde::applicationUrl('edit/friends/groups.php'), 'action', 'delete');
+$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
+$edit_url = Util::addParameter(Horde::applicationUrl('edit/friends/groups.php'), 'action', 'edit');
+$edit_img = Horde::img('edit.png', '', '', $registry->getImageDir('horde'));
+$perms_url = Horde::applicationUrl('perms.php');
+$perms_img = Horde::img('perms.png', '', '', $registry->getImageDir('horde'));
+$members_url = Horde::applicationUrl('edit/friends/friends.php');
+$members_img = Horde::img('group.png', '', '', $registry->getImageDir('horde'));
+
+Horde::addScriptFile('popup.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('groups');
+require FOLKS_TEMPLATES . '/edit/groups.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/index.php b/folks/edit/friends/index.php
new file mode 100644 (file)
index 0000000..e018c63
--- /dev/null
@@ -0,0 +1,84 @@
+<?php
+/**
+ * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Friends");
+$remove_url = Horde::applicationUrl('edit/friends.php');
+$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+$letter_url = '';
+if ($registry->hasInterface('letter')) {
+    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
+    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
+}
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Perform action
+$user = Util::getGet('user');
+if ($user) {
+    if ($friends->isFriend($user)) {
+        $result = $friends->removeFriend($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was removed from your friend list."), $user), 'horde.success');
+        }
+    } else {
+        $result = $friends->addFriend($user);
+        if ($result instanceof PEAR_Error) {
+            $notification->push($result);
+        } elseif ($friends->needsApproval($user)) {
+            $notification->push(sprintf(_("A confirmation was send to \"%s\"."), $user), 'horde.warning');
+            $title = sprintf(_("%s added you as a friend on %s"),
+                                        Auth::getAuth(),
+                                        $GLOBALS['registry']->get('name', 'horde'));
+            $body = sprintf(_("User %s added you to his firends list on %s. \nTo approve, go to: %s \nTo reject, go to: %s \nTo see to his profile, go to: %s \n"),
+                            Auth::getAuth(),
+                            $registry->get('name', 'horde'),
+                            Util::addParameter(Horde::applicationUrl('edit/approve.php', true, -1), 'user', Auth::getAuth()),
+                            Util::addParameter(Horde::applicationUrl('edit/reject.php', true, -1), 'user', Auth::getAuth()),
+                            Folks::getUrlFor('user', Auth::getAuth(), true, -1));
+            $friends->sendNotification($user, $title, $body);
+        } else {
+            $notification->push(sprintf(_("User \"%s\" was added as your friend."), $user), 'horde.success');
+        }
+    }
+
+    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
+    exit;
+}
+
+// Get friends
+$list = $friends->getFriends();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $list = array();
+}
+
+$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friends');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/invite.php b/folks/edit/friends/invite.php
new file mode 100644 (file)
index 0000000..0239ea0
--- /dev/null
@@ -0,0 +1,61 @@
+<?php
+/**
+ * $Id: blacklist.php 1234 2009-01-28 18:44:02Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/base.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("Invite friend");
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Manage adding groups
+$form = new Horde_Form($vars, $title, 'addgroup');
+$translated = Horde::loadConfiguration('groups.php', 'groups', 'folks');
+asort($translated);
+$form->addVariable(_("Friend's e-mail"), 'email', 'email', true);
+$form->addVariable(_("Subject"), 'subject', 'text', false);
+$form->addVariable(_("Body"), 'subject', 'longtext', false);
+
+if ($form->validate()) {
+    $form->getInfo(null, $info);
+
+    // Fix title
+    if (empty($info['subject'])) {
+        $info['subject'] = sprintf(_("%s Invited to join %s."), Auth::getAuth(), $registry->get('name', 'horde'));
+    }
+
+    // Add body
+    $info['body'] = sprintf(_("%s Invited to join %s."), Auth::getAuth(), $registry->get('name', 'horde'))
+                    . ' '
+                    . sprintf(_("Sign up at %s"), Horde::applicationUrl('account/signup.php', true));
+
+    $result = Folks::sendMail($info['email'], $info['subject'], $info['body']);
+    if ($result instanceof PEAR_Error) {
+        $notification->push($result);
+    } else {
+        $notification->push(sprintf(_("Friend \"%s\" was invited to join %s."), $info['email'], $registry->get('name', 'horde')), 'horde.success');
+    }
+}
+
+Horde::addScriptFile('popup.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friends');
+require FOLKS_TEMPLATES . '/edit/invite.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/of.php b/folks/edit/friends/of.php
new file mode 100644 (file)
index 0000000..8bf6540
--- /dev/null
@@ -0,0 +1,46 @@
+<?php
+/**
+ * $Id: friends.php 976 2008-10-07 21:24:47Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Forms/AddFriend.php';
+require_once FOLKS_BASE . '/edit/tabs.php';
+
+$title = _("We are friends of");
+
+$letter_url = '';
+$profile_img = Horde::img('user.png', '', '', $registry->getImageDir('horde'));
+if ($registry->hasInterface('letter')) {
+    $letter_url = $registry->get('webroot', 'letter') . '/compose.php';
+    $letter_img = Horde::img('letter.png', '', '', $registry->getImageDir('letter'));
+}
+
+// Load driver
+require_once FOLKS_BASE . '/lib/Friends.php';
+$friends = Folks_Friends::singleton();
+
+// Get list
+$list = $friends->getPossibleFriends();
+if ($list instanceof PEAR_Error) {
+    $notification->push($list);
+    $list = array();
+}
+
+Horde::addScriptFile('tables.js', 'horde', true);
+
+require FOLKS_TEMPLATES . '/common-header.inc';
+require FOLKS_TEMPLATES . '/menu.inc';
+
+echo $tabs->render('friendsof');
+require FOLKS_TEMPLATES . '/edit/friends.php';
+
+require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/friends/reject.php b/folks/edit/friends/reject.php
new file mode 100644 (file)
index 0000000..3f17323
--- /dev/null
@@ -0,0 +1,50 @@
+<?php
+/**
+ * $Id: reject.php 974 2008-10-07 19:46:00Z duck $
+ *
+ * Copyright Obala d.o.o. (www.obala.si)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author Duck <duck@obala.net>
+ * @package Folks
+ */
+
+require_once dirname(__FILE__) . '/../../lib/base.php';
+require_once FOLKS_BASE . '/lib/Friends.php';
+
+if (!Auth::isAuthenticated()) {
+    Horde::authenticationFailureRedirect();
+}
+
+$user = Util::getGet('user');
+if (empty($user)) {
+    $notification->push(_("You must supply a username."));
+    header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+    exit;
+}
+
+$friends = Folks_Friends::singleton($conf['friends'], array('user' => $user));
+$result = $friends->removeFriend(Auth::getAuth());
+if ($result instanceof PEAR_Error) {
+    $notification->push($result);
+    header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+    exit;
+}
+
+$notification->push(sprintf(_("User \"%s\" was rejected as a friend."), $user), 'horde.success');
+
+$title = sprintf(_("%s rejected you as a friend on %s"),
+                    Auth::getAuth(),
+                    $registry->get('name', 'horde'));
+
+$body = sprintf(_("User %s rejected you as a friend on %s.. \nTo see to his profile, go to: %s \n"),
+                Auth::getAuth(),
+                $registry->get('name', 'horde'),
+                Folks::getUrlFor('user', Auth::getAuth(), true, -1));
+
+$friends->sendNotification($user, $title, $body);
+
+header('Location: ' . Horde::applicationUrl('edit/friends/index.php'));
+exit;
\ No newline at end of file
diff --git a/folks/edit/groups.php b/folks/edit/groups.php
deleted file mode 100644 (file)
index eba47dc..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-<?php
-/**
- * $Id: blacklist.php 1234 2009-01-28 18:44:02Z duck $
- *
- * Copyright Obala d.o.o. (www.obala.si)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Duck <duck@obala.net>
- * @package Folks
- */
-
-define('FOLKS_BASE', dirname(__FILE__) . '/..');
-require_once FOLKS_BASE . '/lib/base.php';
-require_once 'tabs.php';
-
-$title = _("Groups");
-
-// Load driver
-require_once FOLKS_BASE . '/lib/Friends.php';
-$friends = Folks_Friends::singleton();
-
-// Get groups
-$groups = $friends->getGroups();
-if ($groups instanceof PEAR_Error) {
-    $notification->push($groups);
-    $groups = array();
-}
-
-// Handle action
-$action = Util::getFormData('action');
-switch ($action) {
-
-    case 'delete':
-
-        $g = Util::getFormdata('g');
-        $result = $friends->removeGroup($g);
-        if ($result instanceof PEAR_Error) {
-            $notification->push($result);
-        } elseif ($result) {
-            $notification->push(sprintf(_("Group \"%s\" has been deleted."), $groups[$g]), 'horde.success');
-        }
-
-        header('Location: ' . Horde::applicationUrl('edit/groups.php'));
-        exit;
-
-    break;
-
-    case 'edit':
-
-        $g = Util::getFormdata('g');
-        $form = new Horde_Form($vars, _("Rename group"), 'editgroup');
-        $form->addHidden('action', 'action', 'text', 'edit');
-        $form->addHidden('g', 'g', 'text', 'edit');
-        $form->setButtons(array(_("Rename"), _("Cancel")), _("Reset"));
-        $v = $form->addVariable(_("Old name"), 'old_name', 'text', false, true);
-        $v->setDefault($groups[$g]);
-        $v = $form->addVariable(_("New name"), 'new_name', 'text', true);
-        $v->setDefault($groups[$g]);
-
-        if (Util::getFormData('submitbutton') == _("Cancel")) {
-            $notification->push(sprintf(_("Group \"%s\" has not been renamed."), $groups[$g]), 'horde.warning');
-            header('Location: ' . Horde::applicationUrl('edit/groups.php'));
-            exit;
-        } elseif (Util::getFormData('submitbutton') == _("Rename")) {
-            $new_name = Util::getFormData('new_name');
-            $result = $friends->renameGroup($g, $new_name);
-            if ($result instanceof PEAR_Error) {
-                $notification->push($result);
-            } else {
-                $notification->push(sprintf(_("Group \"%s\" has been renamed to \"%s\"."), $groups[$g], $new_name), 'horde.success');
-                header('Location: ' . Horde::applicationUrl('edit/groups.php'));
-                exit;
-            }
-        }
-
-    break;
-
-    default:
-
-        // Manage adding groups
-        $form = new Horde_Form($vars, _("Add group"), 'addgroup');
-        $translated = Horde::loadConfiguration('groups.php', 'groups', 'folks');
-        asort($translated);
-        $form->addHidden('action', 'action', 'text', 'add');
-        $form->addVariable(_("Name"), 'translated_name', 'radio', false, false, null, array($translated, true));
-        $form->addVariable(_("Name"), 'custom_name', 'text', false, false, _("Enter custom name"));
-
-        if ($form->validate()) {
-            $form->getInfo(null, $info);
-            if (empty($info['custom_name'])) {
-                $name = $info['translated_name'];
-            } else {
-                $name = $info['custom_name'];
-            }
-            $result = $friends->addGroup($name);
-            if ($result instanceof PEAR_Error) {
-                $notification->push($result);
-            } else {
-                if (empty($info['custom_name'])) {
-                    $name = $translated[$info['translated_name']];
-                }
-                $notification->push(sprintf(_("Group \"%s\" was success added."), $name), 'horde.success');
-                header('Location: ' . Horde::applicationUrl('edit/groups.php'));
-                exit;
-            }
-        }
-
-    break;
-}
-
-$remove_url = Util::addParameter(Horde::applicationUrl('edit/groups.php'), 'action', 'delete');
-$remove_img = Horde::img('delete.png', '', '', $registry->getImageDir('horde'));
-$edit_url = Util::addParameter(Horde::applicationUrl('edit/groups.php'), 'action', 'edit');
-$edit_img = Horde::img('edit.png', '', '', $registry->getImageDir('horde'));
-$perms_url = Horde::applicationUrl('perms.php');
-$perms_img = Horde::img('perms.png', '', '', $registry->getImageDir('horde'));
-
-Horde::addScriptFile('popup.js', 'horde', true);
-
-require FOLKS_TEMPLATES . '/common-header.inc';
-require FOLKS_TEMPLATES . '/menu.inc';
-
-echo $tabs->render('groups');
-require FOLKS_TEMPLATES . '/edit/groups.php';
-
-require $registry->get('templates', 'horde') . '/common-footer.inc';
\ No newline at end of file
diff --git a/folks/edit/reject.php b/folks/edit/reject.php
deleted file mode 100644 (file)
index 6a16ffb..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/**
- * $Id: reject.php 974 2008-10-07 19:46:00Z duck $
- *
- * Copyright Obala d.o.o. (www.obala.si)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author Duck <duck@obala.net>
- * @package Folks
- */
-
-define('FOLKS_BASE', dirname(__FILE__) . '/..');
-require_once FOLKS_BASE . '/lib/base.php';
-require_once FOLKS_BASE . '/lib/Friends.php';
-
-if (!Auth::isAuthenticated()) {
-    Horde::authenticationFailureRedirect();
-}
-
-$user = Util::getGet('user');
-if (empty($user)) {
-    $notification->push(_("You must supply a username."));
-    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-    exit;
-}
-
-$friends = Folks_Friends::singleton($conf['friends'], array('user' => $user));
-$result = $friends->removeFriend(Auth::getAuth());
-if ($result instanceof PEAR_Error) {
-    $notification->push($result);
-    header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-    exit;
-}
-
-$notification->push(sprintf(_("User \"%s\" was rejected as a friend."), $user), 'horde.success');
-
-$title = sprintf(_("%s rejected you as a friend on %s"),
-                    Auth::getAuth(),
-                    $registry->get('name', 'horde'));
-
-$body = sprintf(_("User %s rejected you as a friend on %s.. \nTo see to his profile, go to: %s \n"),
-                Auth::getAuth(),
-                $registry->get('name', 'horde'),
-                Folks::getUrlFor('user', Auth::getAuth(), true, -1));
-
-$friends->sendNotification($user, $title, $body);
-
-header('Location: ' . Horde::applicationUrl('edit/friends.php'));
-exit;
\ No newline at end of file
index fbed6c1..6f406f2 100644 (file)
@@ -19,12 +19,13 @@ require_once 'Horde/Variables.php';
 
 $vars = Variables::getDefaultVariables();
 $tabs = new Horde_UI_Tabs('what', $vars);
-$tabs->addTab(_("Edit my profile"), 'edit.php', 'edit');
-$tabs->addTab(_("Privacy"), 'privacy.php', 'privacy');
-$tabs->addTab(_("Blacklist"), 'blacklist.php', 'blacklist');
-$tabs->addTab(_("Friends"), 'friends.php', 'friends');
-$tabs->addTab(_("Activity"), 'activity.php', 'activity');
-$tabs->addTab(_("Password"), 'password.php', 'password');
+$tabs->addTab(_("Edit my profile"), Horde::applicationUrl('edit.php'), 'edit');
+$tabs->addTab(_("Privacy"), Horde::applicationUrl('edit/privacy.php'), 'privacy');
+$tabs->addTab(_("Blacklist"), Horde::applicationUrl('edit/friends/blacklist.php'), 'blacklist');
+$tabs->addTab(_("Friends"),  Horde::applicationUrl('edit/friends/index.php'), 'friends');
+$tabs->addTab(_("Groups"),  Horde::applicationUrl('edit/friends/groups.php'), 'groups');
+$tabs->addTab(_("Activity"),  Horde::applicationUrl('edit/activity.php'), 'activity');
+$tabs->addTab(_("Password"), Horde::applicationUrl('edit/password.php'), 'password');
 
 if ($conf['comments']['allow'] != 'never'
         && $registry->hasMethod('forums/doComments')) {
index f803b1a..2416818 100644 (file)
@@ -201,8 +201,11 @@ class Folks_Driver {
     {
         require_once FOLKS_BASE . '/lib/Friends.php';
         $friends = Folks_Friends::singleton(null, array('user' => $user));
-
-        return $friends->getFriends();
+        if ($friends) {
+            return array();
+        } else {
+            return $friends->getFriends();
+        }
     }
 
     /**
index 3eaaffd..ee0e116 100644 (file)
@@ -226,18 +226,20 @@ class Folks {
     {
         global $conf;
 
-        require_once FOLKS_BASE . '/lib/version.php';
-        require_once 'Horde/MIME/Mail.php';
+        $mail = new Horde_Mime_Mail($subject, $body, $to, $conf['support'], NLS::getCharset());
 
-        $mail = new MIME_Mail($subject, $body, $to, $conf['support'], NLS::getCharset());
+        require_once FOLKS_BASE . '/lib/version.php';
         $mail->addHeader('User-Agent', 'Folks ' . FOLKS_VERSION);
+
         foreach ($attaches as $file) {
             if (file_exists($file)) {
                 $mail->addAttachment($file, null, null, NLS::getCharset());
             }
         }
 
-        return $mail->send($conf['mailer']['type'], $conf['mailer']['params']);
+        list($mail_driver, $mail_params) = Horde::getMailerConfig();
+
+        return $mail->send($mail_driver, $mail_params);
     }
 
     /**
@@ -290,11 +292,6 @@ class Folks {
         $menu->add(Horde::applicationUrl('services.php'), _("Services"), 'horde.png', $img);
         $menu->add(Horde::applicationUrl('search.php'), _("Search"), 'search.png', $img);
         $menu->add(self::getUrlFor('list', 'online'), _("List"), 'group.png', $img);
-        // $menu->add(self::getUrlFor('list', 'list'), _("List"), 'group.png', $img);
-        // $menu->add(self::getUrlFor('list', 'online'), _("Online"), 'group.png', $img);
-        // $menu->add(self::getUrlFor('list', 'popularity'), _("Popularity"), 'group.png', $img);
-        // $menu->add(self::getUrlFor('list', 'activity'), _("Activity"), 'group.png', $img);
-        // $menu->add(self::getUrlFor('list', 'birthday'), _("Birthday"), 'guest.png', $img);
 
         if ($returnType == 'object') {
             return $menu;
index 0cd7224..f3b463f 100644 (file)
@@ -115,6 +115,19 @@ class Folks_Friends {
     }
 
     /**
+     * Queries the current object to find out if it supports the given
+     * capability.
+     *
+     * @param string $capability  The capability to test for.
+     *
+     * @return boolean  Whether or not the capability is supported.
+     */
+    public function hasCapability($capability)
+    {
+        return !empty($this->_capabilities[$capability]);
+    }
+
+    /**
      * Check if a users requies his approval to be added as a friend
      *
      * @param string $user   Usersame
@@ -408,31 +421,33 @@ class Folks_Friends {
     }
 
     /**
-     * Get user groups
-     */
-    public function getGroups()
-    {
-        return array();
-    }
-
-    /**
-     * Delete user friend group
+     * Get user owning group
      *
-     * @param string $group   Group to delete
+     * @param integer Get group ID
+     *
+     * @param string Owner
      */
-    public function removeGroup($group)
+    public function getGroupOwner($group)
     {
-        return false;
+        return $this->_user;
     }
 
     /**
-     * Add group
-     *
-     * @param string $group   Group name
+     * Get user groups
      */
-    public function addGroup($name)
+    public function getGroups()
     {
-        return false;
+        $groups = $this->_cache->get('folksGroups' . $this->_user, $GLOBALS['conf']['cache']['default_lifetime']);
+        if ($groups) {
+            return unserialize($groups);
+        } else {
+            $groups = $this->_getGroups();
+            if ($groups instanceof PEAR_Error) {
+                return $groups;
+            }
+            $this->_cache->set('folksGroups' . $this->_user, serialize($groups));
+            return $groups;
+        }
     }
 
     /**
index 9f4b660..037f2b9 100644 (file)
@@ -107,7 +107,7 @@ class Folks_Friends_application extends Folks_Friends {
     /**
      * Get avaiable groups
      */
-    public function getGroups()
+    protected function _getGroups()
     {
         if (!$GLOBALS['registry']->hasMethod('getGroups', $this->_params['app'])) {
             return array();
index 02174be..df86780 100644 (file)
@@ -26,191 +26,47 @@ class Folks_Friends_shared extends  Folks_Friends_sql {
     private $_shares;
 
     /**
-     * friends list ID
+     * An array of capabilities, so that the driver can report which
+     * operations it supports and which it doesn't.
      *
-     * @var int
-     */
-    private $_whitelist;
-
-    /**
-     * Black list ID
-     *
-     * @var int
-     */
-    private $_blacklist;
-
-    /**
-     * Get whitelist ID
-     */
-    protected function _id($id)
-    {
-        switch ($id) {
-
-        case self::BLACKLIST;
-            return $this->_blacklist;
-
-        case self::WHITELIST;
-            return $this->_whitelist;
-
-        default:
-            return $id;
-
-        }
-    }
-
-    /**
-     * Get user friends and blacklist group id
-     */
-    private function _getIds()
-    {
-        if ($this->_whitelist && $this->_blacklist) {
-            return;
-        }
-
-        $GLOBALS['folks_shares'] = Horde_Share::singleton('folks');
-        $groups = $GLOBALS['folks_shares']->listShares($this->_user, PERMS_READ);
-        if ($groups instanceof PEAR_Error) {
-            return $groups;
-        }
-
-        foreach ($groups as $id => $group) {
-            if ($group->get('name') == '__FRIENDS__') {
-                $this->_whitelist = $group->getId();
-            }
-        }
-    }
-
-    /**
-     * Get user blacklist
-     *
-     * @return array of users blacklist
-     */
-    protected function _getBlacklist()
-    {
-        $this->_getIds();
-
-        // No blacklist even created
-        if (empty($this->_blacklist)) {
-            return array();
-        }
-
-        return parent::_getBlacklist();
-    }
-
-    /**
-     * Add user to a blacklist list
-     *
-     * @param string $user   Usersame
-     */
-    protected function _addBlacklisted($user)
-    {
-        $this->_getIds();
-
-        // Create blacklist
-        if (empty($this->_blacklist)) {
-            $group_id = $this->addGroup('_BLACKLIST_', self::BLACKLIST);
-            if ($group_id instanceof PEAR_Error) {
-                return $group_id;
-            }
-            $this->_blacklist = $group_id;
-        }
-
-        return parent::_addBlacklisted($user);
-    }
-
-    /**
-     * Remove user from blacklist list
-     *
-     * @param string $user   Usersame
-     */
-    protected function _removeBlacklisted($user)
-    {
-        $this->_getIds();
-
-        if (empty($this->_blacklist)) {
-            return false;
-        }
-
-        parent::_removeBlacklisted($user);
-    }
-
-    /**
-     * Add user to a friend list
-     *
-     * @param string $friend   Friend's usersame
-     * @param string $group   Group to add friend to
+     * @var array
      */
-    protected function _addFriend($friend, $group = null)
-    {
-        $this->_getIds();
-
-        if (empty($this->_whitelist)) {
-            $group_id = $this->addGroup('_FRIENDS_', self::WHITELIST);
-            if ($group_id instanceof PEAR_Error) {
-                return $group_id;
-            }
-            $this->_whitelist = $group_id;
-        }
-
-        parent::_addFriend($friend, $group);
-    }
-
-    /**
-     * Remove user from a fiend list
-     *
-     * @param string $friend   Friend's usersame
-     * @param string $group   Group to remove friend from
-     */
-    protected function _removeFriend($friend, $group = null)
-    {
-        $this->_getIds();
-
-        if (empty($this->_whitelist)) {
-            return true;
-        }
-
-        parent::_removeFriend($friend, $group);
-    }
+    protected $_capabilities = array('groups_add' => true);
 
     /**
-     * Get user friends
+     * Get user owning group
      *
-     * @param string $group  Get friens only from this group
+     * @param integer Get group ID
      *
-     * @return array of users (in group)
+     * @param string Owner
      */
-    protected function _getFriends($group = null)
+    public function getGroupOwner($group)
     {
-        $this->_getIds();
+        $GLOBALS['folks_shares'] = Horde_Share::singleton('folks');
 
-        if (empty($this->_whitelist)) {
-            return array();
+        $share = $GLOBALS['folks_shares']->getShareById($group);
+        if ($share instanceof PEAR_Error) {
+            return $share;
         }
 
-        parent::_getFriends($group);
+        return $share->get('owner');
     }
 
     /**
      * Get user groups
      */
-    public function getGroups()
+    protected function _getGroups()
     {
         $GLOBALS['folks_shares'] = Horde_Share::singleton('folks');
+
         $groups = $GLOBALS['folks_shares']->listShares($this->_user, PERMS_READ);
         if ($groups instanceof PEAR_Error) {
             return $groups;
         }
 
-        /** TODO: USE TRANSLATEDN NAMES ??? */
-
         $list = array();
         foreach ($groups as $group) {
-            if ($group->get('name') == '__FRIENDS__') {
-                $this->_whitelist = $id;
-                $list[$group->getId()] = _("Friends");
-            } else {
-                $list[$group->getId()] = $group->get('name');
-            }
+            $list[$group->getId()] = $group->get('name');
         }
 
         return $list;
@@ -274,6 +130,7 @@ class Folks_Friends_shared extends  Folks_Friends_sql {
         $query = 'DELETE FROM ' . $this->_params['friends']
                     . ' WHERE user_uid = ' . $share->_shareOb->_write_db->quote($this->_user)
                     . ' AND group_id = ' . $share->_shareOb->_write_db->quote($share->getId());
+
         $result = $share->_shareOb->_write_db->exec($query);
         if ($result instanceof PEAR_Error) {
             return $result;
index 65d85d5..3b905ab 100644 (file)
@@ -187,7 +187,7 @@ class Folks_Friends_sql extends Folks_Friends {
     /**
      * Get user groups
      */
-    public function getGroups()
+    protected function _getGroups()
     {
         return array(_("Whitelist"));
     }
index d4506af..29dc7c0 100644 (file)
@@ -202,7 +202,7 @@ function _folks_getFriends($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->getFriends();
 }
@@ -218,7 +218,7 @@ function _folks_addFriend($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->addFriend($user);
 }
@@ -234,7 +234,7 @@ function _folks_removeFriend($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->removeFriend($user);
 }
@@ -250,7 +250,7 @@ function _folks_getBlacklist($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->getBlacklist();
 }
@@ -264,7 +264,7 @@ function _folks_addBlacklisted($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->addBlacklisted($user);
 }
@@ -278,7 +278,7 @@ function _folks_removeBlacklisted($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->removeBlacklisted($user);
 }
@@ -294,7 +294,7 @@ function _folks_isBlacklisted($user = null)
 {
     require_once dirname(__FILE__) . '/Friends.php';
 
-    $friends = Folks_Friends::singleton(null, array('user' => $user));
+    $friends = Folks_Friends::singleton('sql', array('user' => $user));
 
     return $friends->isBlacklisted(Auth::getAuth());
 }
index 2aa128c..a20a653 100644 (file)
@@ -5,7 +5,7 @@ echo $form->renderActive();
 if (empty($activities)) {
     echo '<ul class="notices"><li>';
     echo _("There is no activity logged for your account.");
-    echo '</li>';
+    echo '</li></ul>';
     return;
 }
 ?>
@@ -27,7 +27,7 @@ if (empty($activities)) {
         <?php echo $registry->get('name', $activity['activity_scope']) ?></a>
     </td>
     <td><?php echo Folks::format_datetime($activity['activity_date']) ?></td>
-    <td><?php echo $activity['activity_message']; unset($activity['activity_message']); var_dump($activity['activity_scope']); ?></td>
+    <td><?php echo $activity['activity_message']; unset($activity['activity_message']); ?></td>
     <td><a href="<?php echo Util::addParameter($delete_url, $activity) ?>" title="<?php echo _("Delete") ?>"/><?php echo $delete_img ?></a></td>
 </tr>
 <?php } ?>
diff --git a/folks/templates/edit/blacklist.php b/folks/templates/edit/blacklist.php
deleted file mode 100644 (file)
index 055a699..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-if (empty($blacklist)) {
-    echo '<ul class="notices"><li>';
-    echo _("There are no users in your blacklist.");
-    echo '</li></ul>';
-} else  {
-?>
-<h1 class="header"><?php echo $title ?></h1>
-<table id="blacklist" class="sortable striped">
-<thead>
-<tr>
-    <th><?php echo _("Username") ?></th>
-    <th><?php echo _("Action") ?></th>
-</tr>
-</thead>
-<tbody>
-<?php foreach ($blacklist as $user) { ?>
-<tr>
-    <td><?php echo '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" /> ' . $user ?></td>
-    <td><a href="<?php $remove_url . $user ?>"><?php echo _("Remove") ?></a></td>
-</tr>
-<?php } ?>
-</tbody>
-</table>
-
-<?php
-}
-echo $form->renderActive();
\ No newline at end of file
index a84f987..0600212 100644 (file)
@@ -1,67 +1,52 @@
+<?php require dirname(__FILE__) . '/tabs.php'; ?>
+
+<h1 class="header"><?php echo $title ?></h1>
+
 <?php
-if (empty($friend_list)) {
-    echo '<ul class="notices"><li>';
-    echo _("There are no users listed as your friend.");
-    echo '</li>';
-} else {
+
+if (empty($list)) {
+    echo '<ul class="notices"><li>' . _("No user listed") . '</li></ul>';
+    return true;
+}
 ?>
-<h1 class="header"><?php echo $title ?></h1>
-<table id="friendlist" class="striped sortable">
+
+<table id="friendlist" class="striped sortable" style="width: 100%">
 <thead>
 <tr>
     <th><?php echo _("Username") ?></th>
+    <th><?php echo _("Status") ?></th>
     <th><?php echo _("Action") ?></th>
 </tr>
 </thead>
 <tbody>
-<?php foreach ($friend_list as $user) { ?>
+<?php foreach ($list as $user) { ?>
 <tr>
-    <td><?php echo '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" /> ' . $user ?></td>
+    <td style="text-align: center">
+        <?php echo '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" /><br />' . $user ?>
+    </td>
+    <td>
+    <?php
+        if ($folks_driver->isOnline($user)) {
+            echo '<span class="online">' . _("Online") . '</span>';
+        } else {
+            echo '<span class="offline">' . _("Offline") . '</span>';
+        }
+    ?>
+    </td>
     <td>
-        <a href="<?php echo Util::addParameter($remove_url, 'user', $user) ?>"><?php echo $remove_img  . ' ' . _("Remove") ?></a>
         <a href="<?php echo Folks::getUrlFor('user', $user) ?>"><?php echo $profile_img  . ' ' . _("View profile") ?></a>
-        <?php if ($letter_url): ?>
-        <a href="<?php echo Util::addParameter($letter_url, 'user_to', $user) ?>"><?php echo $letter_img  . ' ' . _("Send message") ?></a>
-        <?php endif; ?>
     </td>
+    <?php if (!empty($remove_url)): ?>
+        <td>
+        <a href="<?php echo Util::addParameter($remove_url, 'user', $user) ?>"><?php echo $remove_img  . ' ' . _("Remove") ?></a>
+        </td>
+    <?php endif; ?>
+    <?php if (!empty($letter_url)): ?>
+        <td>
+            <a href="<?php echo Util::addParameter($letter_url, 'user_to', $user) ?>"><?php echo $letter_img  . ' ' . _("Send message") ?></a>
+        </td>
+    <?php endif; ?>
 </tr>
 <?php } ?>
 </tbody>
 </table>
-
-<?php
-}
-
-echo '<br />';
-echo $form->renderActive();
-
-if (!empty($waitingFrom)) {
-    echo '<br /><h1 class="header">' . _("We are waiting this users to approve our friendship") .'</h1>';
-    foreach ($waitingFrom as $user) {
-        echo ' <a href="' . Folks::getUrlFor('user', $user) . '">'
-                . '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" />'
-                . ' ' . $user . '</a> ';
-    }
-}
-
-if (!empty($waitingFor)) {
-    echo '<br /><h1 class="header">' . _("Users winting us to approve their friendship") .'</h1>';
-    foreach ($waitingFor as $user) {
-        echo ' <a href="' . Folks::getUrlFor('user', $user) . '">'
-                . '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" />'
-                . ' ' . $user . '</a> '
-                . ' <a href="' . Util::addParameter(Horde::applicationUrl('edit/approve.php'), 'user', $user) . '" title="' . _("Approve") . '">'
-                . '<img src="' . $registry->getImageDir('horde') . '/tick.png" /></a> '
-                . ' <a href="' . Util::addParameter(Horde::applicationUrl('edit/reject.php'), 'user', $user) . '" title="' . _("Reject") . '">'
-                . '<img src="' . $registry->getImageDir('horde') . '/cross.png" /></a>';
-    }
-}
-
-if (!empty($possibilities)) {
-    echo '<br /><h1 class="header">' . _("Users that has you listed as a friend") .'</h1>';
-    foreach ($possibilities as $user) {
-        echo ' <a href="' . Folks::getUrlFor('user', $user) . '">'
-                . '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" />'
-                . ' ' . $user . '</a> ';
-    }
-}
index a34663b..c590649 100644 (file)
@@ -1,20 +1,32 @@
-<?php echo $form->renderActive(null, null, '', 'post'); ?>
+<?php
+if ($friends->hasCapability('groups_add')) {
+    echo $form->renderActive(null, null, '', 'post');
+}
+
+?>
 
 <h1 class="header"><?php echo $title ?></h1>
-<table id="groups" class="sortable striped">
+<table id="groups" class="sortable striped" style="width: 100%">
 <thead>
 <tr>
     <th><?php echo _("Group") ?></th>
-    <th><?php echo _("Actions") ?></th>
+    <th><?php echo _("Owner") ?></th>
+    <th colsan="3"><?php echo _("Action") ?></th>
 </tr>
 </thead>
 <tbody>
 <?php
-foreach ($groups as $group_id => $grouo_name) {
-    echo '<tr><td>' . $grouo_name . '</td>';
-    echo '<td><a href="' . Util::addParameter($edit_url, 'g', $group_id) . '">' . $edit_img . ' ' . _("Rename") . '</a></td>';
-    echo '<td><a href="#" onclick="if (confirm(\'' . _("Do you really want to delete this group?") . '\')) {window.location=\'' .  Util::addParameter($remove_url, 'g', $group_id) . '\'}">' . $remove_img . ' ' . _("Delete") . '</a></td>';
-    echo '<td><a href="#" onclick="popup(\'' . Util::addParameter($perms_url, 'cid', $group_id) . '\')">' . $perms_img . ' ' .  _("Permissions") . '</a></td>';
+
+foreach ($groups as $group_id => $group_name) {
+    echo '<tr><td>' . $group_name . '</td>';
+    $owner = $friends->getGroupOwner($group_id);
+    echo '<td style="text-align: center"><a href="' . Folks::getUrlFor('user', $owner) .'"><img src="' . Folks::getImageUrl($owner) . '" class="userMiniIcon" /><br />' . $owner . '</a></td>';
+    echo '<td><a href="' . Util::addParameter($members_url, 'g', $group_id) . '">' . $members_img . ' ' . _("Members") . '</a></td>';
+    if ($friends->hasCapability('groups_add')) {
+        echo '<td><a href="' . Util::addParameter($edit_url, 'g', $group_id) . '">' . $edit_img . ' ' . _("Rename") . '</a></td>';
+        echo '<td><a href="#" onclick="if (confirm(\'' . _("Do you really want to delete this group?") . '\')) {window.location=\'' .  Util::addParameter($remove_url, 'g', $group_id) . '\'}">' . $remove_img . ' ' . _("Delete") . '</a></td>';
+        echo '<td><a href="#" onclick="popup(\'' . Util::addParameter($perms_url, 'cid', $group_id) . '\')">' . $perms_img . ' ' .  _("Permissions") . '</a></td>';
+    }
     echo '</tr>';
 }
 ?>
diff --git a/folks/templates/edit/invite.php b/folks/templates/edit/invite.php
new file mode 100644 (file)
index 0000000..5542bf3
--- /dev/null
@@ -0,0 +1,3 @@
+<?php require dirname(__FILE__) . '/tabs.php'; ?>
+
+<?php echo $form->renderActive(null, null, null, 'post')?>
\ No newline at end of file
diff --git a/folks/templates/edit/tabs.php b/folks/templates/edit/tabs.php
new file mode 100644 (file)
index 0000000..3af326a
--- /dev/null
@@ -0,0 +1,35 @@
+<h1 class="header"><?php echo _("Friends") ?></h1>
+<br />
+<br />
+
+<?php
+
+// Users online
+$online = $folks_driver->getOnlineUsers();
+if ($online instanceof PEAR_Error) {
+    return $online;
+}
+
+// Get groups
+$groups = $friends->getGroups();
+if ($groups instanceof PEAR_Error) {
+    $notification->push($groups);
+    $groups = array();
+}
+
+$vars = Variables::getDefaultVariables();
+$ftabs = new Horde_UI_Tabs('ftab', $vars);
+
+$ftabs->addTab(_("All"), Horde::applicationUrl('edit/friends/index.php'), 'all');
+$ftabs->addTab(_("Invite"), Horde::applicationUrl('edit/friends/invite.php'), 'invite');
+
+foreach ($groups as $group_id => $group_name) {
+    $ftabs->addTab($group_name, Horde::applicationUrl('edit/friends/friends.php'), $group_id);
+}
+
+$ftabs->addTab(_("Wainting for"), Horde::applicationUrl('edit/friends/for.php'), 'for');
+$ftabs->addTab(_("Wainting from"), Horde::applicationUrl('edit/friends/from.php'), 'from');
+$ftabs->addTab(_("I am friend of"), Horde::applicationUrl('edit/friends/of.php'), 'of');
+
+echo $ftabs->render();
+