+++ /dev/null
-<?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
+++ /dev/null
-<?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
+++ /dev/null
-<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
--- /dev/null
+<?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
+++ /dev/null
-<?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
+++ /dev/null
-<?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
$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')) {
{
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();
+ }
}
/**
{
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);
}
/**
$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;
}
/**
+ * 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
}
/**
- * 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;
+ }
}
/**
/**
* Get avaiable groups
*/
- public function getGroups()
+ protected function _getGroups()
{
if (!$GLOBALS['registry']->hasMethod('getGroups', $this->_params['app'])) {
return array();
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;
$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;
/**
* Get user groups
*/
- public function getGroups()
+ protected function _getGroups()
{
return array(_("Whitelist"));
}
{
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();
}
{
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);
}
{
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);
}
{
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();
}
{
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);
}
{
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);
}
{
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());
}
if (empty($activities)) {
echo '<ul class="notices"><li>';
echo _("There is no activity logged for your account.");
- echo '</li>';
+ echo '</li></ul>';
return;
}
?>
<?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 } ?>
+++ /dev/null
-<?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
+<?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> ';
- }
-}
-<?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>';
}
?>
--- /dev/null
+<?php require dirname(__FILE__) . '/tabs.php'; ?>
+
+<?php echo $form->renderActive(null, null, null, 'post')?>
\ No newline at end of file
--- /dev/null
+<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();
+