$groups = array();
}
-$friend_form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('edit/friends/blacklist.php'),
+ 'img' => Horde::img('delete.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Remove")),
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")));
-Horde::addScriptFile('tables.js', 'horde', true);
+$friend_form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
$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();
+$list = $friends->waitingApprovalFor();
if ($list instanceof PEAR_Error) {
$notification->push($list);
$list = array();
}
-Horde::addScriptFile('tables.js', 'horde', true);
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")),
+ array('url' => Horde::applicationUrl('edit/friends/approve.php'),
+ 'img' => Horde::img('tick.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Approve")),
+ array('url' => Horde::applicationUrl('edit/friends/reject.php'),
+ 'img' => Horde::img('cross.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Reject")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('letter.png', '', '', $registry->getImageDir('letter')),
+ 'id' => 'user_to',
+ 'name' => $registry->get('name', 'letter'));
+}
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
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) {
$list = array();
}
-$form = new Folks_AddFriend_Form($vars, _("Add or remove user"), 'blacklist');
-
-Horde::addScriptFile('tables.js', 'horde', true);
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('edit/friends/add.php'),
+ 'img' => Horde::img('delete.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Remove")),
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('letter.png', '', '', $registry->getImageDir('letter')),
+ 'id' => 'user_to',
+ 'name' => $registry->get('name', 'letter'));
+}
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
$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();
$list = array();
}
-Horde::addScriptFile('tables.js', 'horde', true);
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('letter.png', '', '', $registry->getImageDir('letter')),
+ 'id' => 'user_to',
+ 'name' => $registry->get('name', 'letter'));
+}
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
require_once dirname(__FILE__) . '/../../lib/base.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'));
-}
+$title = _("All");
// Load driver
require_once FOLKS_BASE . '/lib/Friends.php';
$list = array();
}
-Horde::addScriptFile('tables.js', 'horde', true);
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('edit/friends/add.php'),
+ 'img' => Horde::img('delete.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Remove")),
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('letter.png', '', '', $registry->getImageDir('letter')),
+ 'id' => 'user_to',
+ 'name' => $registry->get('name', 'letter'));
+}
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
$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();
$list = array();
}
-Horde::addScriptFile('tables.js', 'horde', true);
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('user.png', '', '', $registry->getImageDir('horde')),
+ 'id' => 'user',
+ 'name' => _("Profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => Horde::applicationUrl('user.php'),
+ 'img' => Horde::img('letter.png', '', '', $registry->getImageDir('letter')),
+ 'id' => 'user_to',
+ 'name' => $registry->get('name', 'letter'));
+};
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
exit;
}
-$friends = Folks_Friends::singleton($conf['friends'], array('user' => $user));
+$friends = Folks_Friends::singleton(null, array('user' => $user));
$result = $friends->removeFriend(Auth::getAuth());
if ($result instanceof PEAR_Error) {
$notification->push($result);
// Add friend to backend
$result = $this->_addFriend($friend, $group);
- if ($friends instanceof PEAR_Error) {
- return $friends;
+ if ($result instanceof PEAR_Error) {
+ return $result;
}
// If we do not need an approval just expire cache
}
/**
- * Get users who have you on friendlist
+ * Get users who have us on their friendlist
*
* @return array users
*/
protected function _addFriend($friend)
{
$approve = $this->needsApproval($friend) ? 1 : 0;
+
$query = 'INSERT INTO ' . $this->_params['friends']
- . ' (user_uid, friend_uid, friend_ask) VALUES (?, ?, ?, ?)';
+ . ' (user_uid, friend_uid, friend_ask) VALUES (?, ?, ?)';
return $this->_write_db->query($query, array($this->_user, $friend, $approve));
}
protected function _getFriends()
{
$query = 'SELECT friend_uid FROM ' . $this->_params['friends']
- . ' WHERE user_uid = ?'
+ . ' WHERE user_uid = ? and friend_ask = ?'
. ' ORDER BY friend_uid ASC';
- return $this->_db->getCol($query, 0, array($this->_user));
+ return $this->_db->getCol($query, 0, array($this->_user, 0));
}
/**
<?php foreach ($list as $user) { ?>
<tr>
<td style="text-align: center">
- <?php echo '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" /><br />' . $user ?>
+ <?php echo '<a href="' . Folks::getUrlFor('user', $user) . '">'
+ . '<img src="' . Folks::getImageUrl($user) . '" class="userMiniIcon" /><br />' . $user ?></a>
</td>
<td>
<?php
}
?>
</td>
- <td>
- <a href="<?php echo Folks::getUrlFor('user', $user) ?>"><?php echo $profile_img . ' ' . _("View profile") ?></a>
- </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; ?>
+ <?php
+ foreach ($actions as $action) {
+ echo '<td>';
+ echo '<a href="' . Util::addParameter($action['url'], $action['id'], $user) . '">'
+ . $action['img'] . ' ' . $action['name'] . '</a>';
+ echo '</td>';
+ }
+ ?>
</tr>
<?php } ?>
</tbody>
$ftabs->addTab($group_name, Horde::applicationUrl('edit/friends/friends.php'), $group_id);
}
+$ftabs->addTab(_("Might know"), Horde::applicationUrl('edit/friends/know.php'), 'know');
$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');