$friends = Folks_Friends::singleton();
// Get friends
-$my_list = $friends->getFriends();
-if ($my_list instanceof PEAR_Error) {
- $notification->push($my_list);
- $my_list = array();
+$list = $friends->getPossibleFriends(20);
+if ($list instanceof PEAR_Error) {
+ $notification->push($list);
+ $list = array();
}
-// Get all friends of frends and make a top list of common users
-$possibilities = array();
-foreach ($my_list as $friend) {
- $friends = Folks_Friends::singleton(null, array('user' => $friend));
- $friend_friends = $friends->getFriends();
- if ($friend_friends instanceof PEAR_Error) {
- continue;
- }
- foreach ($friend_friends as $friend_friend) {
- if ($friend_friend == Auth::getAuth() ||
- in_array($friend_friend, $my_list)) {
- continue;
- } elseif (isset($possibilities[$friend_friend])) {
- $possibilities[$friend_friend] += 1;
- } else {
- $possibilities[$friend_friend] = 0;
- }
- }
-}
-
-arsort($possibilities);
-$list = array_slice($possibilities, 0, 20, true);
-$list = array_keys($list);
-
// Prepare actions
$actions = array(
array('url' => Horde::applicationUrl('edit/friends/add.php'),
$friends = Folks_Friends::singleton();
// Get list
-$list = $friends->getPossibleFriends();
+$list = $friends->friendOf();
if ($list instanceof PEAR_Error) {
$notification->push($list);
$list = array();
// Users online
$online = $folks_driver->getOnlineUsers();
if ($online instanceof PEAR_Error) {
- return $online;
+ $notification->push($online);
+ $online = array();
}
-Horde::addScriptFile('tables.js', 'horde', true);
+Horde::addScriptFile('stripe.js', 'horde', true);
require FOLKS_TEMPLATES . '/common-header.inc';
require FOLKS_TEMPLATES . '/menu.inc';
$new = unserialize($new);
} else {
$new = $this->getUsers(array('sort_by' => 'signup_at',
- 'sort_dir' => 1), 0, $limit);
+ 'sort_dir' => 0), 0, $limit);
if ($new instanceof PEAR_Error) {
return $new;
}
*/
static public function singleton($driver = null, $params = null)
{
+ if (empty($params['user'])) {
+ $params['user'] = Auth::getAuth();
+ }
+
$signature = $driver . ':' . $params['user'];
if (!array_key_exists($signature, self::$instances)) {
self::$instances[$signature] = self::factory($driver, $params);
}
/**
+ * Return all friends of out frends
+ * and make a top list of common users
+ *
+ * @param int $limit Users
+ *
+ * @return array users
+ */
+ public function getPossibleFriends($limit = 0)
+ {
+ $possibilities = array();
+
+ $my_list = $this->getFriends();
+ if ($my_list instanceof PEAR_Error) {
+ return $my_list;
+ }
+
+ foreach ($my_list as $friend) {
+ $friends = Folks_Friends::singleton(null, array('user' => $friend));
+ $friend_friends = $friends->getFriends();
+ if ($friend_friends instanceof PEAR_Error) {
+ continue;
+ }
+ foreach ($friend_friends as $friend_friend) {
+ if ($friend_friend == $this->_user ||
+ in_array($friend_friend, $my_list)) {
+ continue;
+ } elseif (isset($possibilities[$friend_friend])) {
+ $possibilities[$friend_friend] += 1;
+ } else {
+ $possibilities[$friend_friend] = 0;
+ }
+ }
+ }
+
+ arsort($possibilities);
+
+ if ($limit) {
+ $possibilities = array_slice($possibilities, 0, $limit, true);
+ $possibilities = array_keys($possibilities);
+ }
+
+ return $possibilities;
+ }
+
+ /**
* Get users who have us on their friendlist
*
* @return array users
*/
- public function getPossibleFriends()
+ public function friendOf()
{
return false;
}
*
* @return array users
*/
- public function getPossibleFriends()
+ public function friendOf()
{
$query = 'SELECT user_uid FROM ' . $this->_params['friends']
. ' WHERE friend_uid = ? AND friend_ask = ?'
$mail = new Horde_Mime_Mail($this->getTitle(), $this->getMessage($message), $to, $this->getUserEmail());
//FIXME: This address should be configurable
- try {
- $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']);
- } catch (Horde_Mime_Exception $e) {}
+ $mail->addHeader('Sender', 'horde-problem@' . $conf['report_content']['maildomain']);
$mail_driver = $conf['mailer']['type'];
$mail_params = $conf['mailer']['params'];
}
}
- try {
- return $mail->send($mail_driver, $mail_params);
- } catch (Horde_Mime_Exception $e) {}
+ return $mail->send($mail_driver, $mail_params);
}
-}
+}
\ No newline at end of file
+<?php echo $form->renderActive(); ?>
+<br />
+
<table style="width: 100%">
<tr valign="top">
<td>
<table id="friendactivities" class="striped sortable" style="width: 100%">
<thead>
<tr>
- <th><?php echo _("Username") ?></th>
- <th><?php echo _("Date") ?></th>
+ <th><?php echo _("User") ?></th>
<th><?php echo _("Activity") ?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($firendActivities as $activity_date => $activity) {
- echo '<tr><td><a href="' . Folks::getUrlFor('user', $activity['user']) . '">'
+ echo '<tr>'
+ . '<td><a href="' . Folks::getUrlFor('user', $activity['user']) . '">'
. '<img src="' . Folks::getImageUrl($activity['user']) . '" class="userMiniIcon" /> '
. $activity['user'] . '</a></td>'
- . ' <td>' . Folks::format_datetime($activity_date) . '</td> '
- . '<td>' . $activity['message'] . '</td></tr>';
+ . ' <td>' . $activity['message'] . '<br />' .
+ '<span class="small">' . Folks::format_datetime($activity_date) . '</span>'
+ . '</td></tr>';
}
?>
</table>
+
+<br />
+<br />
+
+<h1 class="header">
+<span style="float: right"><a href="<?php echo Horde::applicationUrl('edit/activity.php') ?>"><?php echo _("Edit activities") ?></a></span>
+<?php echo _("Your activities") ?>
+</h1>
+<table id="activities" class="striped sortable" style="width: 100%">
+<thead>
+<tr>
+ <th><?php echo _("Application") ?></th>
+ <th><?php echo _("Activity") ?></th>
+</tr>
+</thead>
+<tbody>
+<?php foreach ($activities as $activity) { ?>
+<tr>
+ <td><a href="<?php echo $registry->get('webroot', $activity['activity_scope']) ?>" />
+ <img src="<?php echo $registry->getImageDir($activity['activity_scope']) . '/' . $activity['activity_scope'] ?>.png" />
+ <?php echo $registry->get('name', $activity['activity_scope']) ?></a>
+ </td>
+ <td>
+ <?php echo $activity['activity_message']; unset($activity['activity_message']); ?><br >
+ <span class="small"><?php echo Folks::format_datetime($activity['activity_date']) ?></span>
+ </td>
+</tr>
+<?php } ?>
+</tbody>
+</table>
+
+</td>
+<td>
+
+<h1 class="header"><?php echo _("Online friends") ?></h1>
+<?php
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('user.php'),
+ 'id' => 'user',
+ 'name' => _("View profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => $registry->callByPackage('letter', 'compose', ''),
+ 'id' => 'user_to',
+ 'name' => _("Send message"));
+}
+$list = array_intersect($friend_list, array_flip($online));
+require FOLKS_TEMPLATES . '/block/users.php';
+?>
+
+<br />
+<br />
+
+<h1 class="header"><?php echo _("People you might know") ?></h1>
+<?php
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('edit/friends/add.php'),
+ 'id' => 'user',
+ 'name' => _("Add friend")),
+ array('url' => Horde::applicationUrl('user.php'),
+ 'id' => 'user',
+ 'name' => _("View profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => $registry->callByPackage('letter', 'compose', ''),
+ 'id' => 'user_to',
+ 'name' => _("Send message"));
+}
+$list = $friends->getPossibleFriends(20);
+require FOLKS_TEMPLATES . '/block/users.php';
+?>
+
+<br />
+<br />
+
+<h1 class="header"><?php echo $title ?></h1>
+<?php
+// Prepare actions
+$actions = array(
+ array('url' => Horde::applicationUrl('user.php'),
+ 'id' => 'user',
+ 'name' => _("View profile")));
+if ($registry->hasInterface('letter')) {
+ $actions[] = array('url' => $registry->callByPackage('letter', 'compose', ''),
+ 'id' => 'user_to',
+ 'name' => _("Send message"));
+}
+$list = $friend_list;
+require FOLKS_TEMPLATES . '/block/users.php';
+?>
+
+</td>
+</tr>
+</table>
+
$headers = array();
$headers['user_uid'] = array('stext' => _("Sort by Username"),
- 'text' => _("Username"));
+ 'text' => _("Username"));
$headers['user_gender'] = array('stext' => _("Sort by Gender"),
- 'text' => _("Gender"));
+ 'text' => _("Gender"));
$headers['user_birthday'] = array('stext' => _("Sort by Age"),
- 'text' => _("Age"));
+ 'text' => _("Age"));
$headers['user_city'] = array('stext' => _("Sort by City"),
- 'text' => _("City"));
+ 'text' => _("City"));
$headers['user_homepage'] = array('stext' => _("Sort by Homepage"),
- 'text' => _("Homepage"));
+ 'text' => _("Homepage"));
$headers['user_description'] = array('stext' => _("Sort by Description"),
- 'text' => _("Description"));
-$headers['user_picture'] = array('stext' => _("Sort by Picture"),
- 'text' => _("Picture"));
+ 'text' => _("Description"));
$headers['count_galleries'] = array('stext' => _("Sort by Albums"),
- 'text' => _("Albums"));
+ 'text' => _("Albums"));
$headers['count_video'] = array('stext' => _("Sort by Video"),
- 'text' => _("Video"));
+ 'text' => _("Video"));
$sortImg = ($criteria['sort_dir'] == 'DESC') ? 'za.png' : 'az.png';
$sortText = _("Sort Direction");
<tr>
<?php
foreach ($headers as $key => $val) {
- echo '<th class="widget" align="left" nowrap="nowrap">' . "\n";
+ echo '<th class="widget leftAlign nowrap">' . "\n";
if ($criteria['sort_by'] == $key) {
echo Horde::link(Util::addParameter($list_url, 'sort_dir', ($criteria['sort_dir'] == 'DESC') ? 'ASC' : 'DESC'), $val['text'], null, null, null, $val['text']);
echo Horde::img($sortImg, $sortText, null, $registry->getImageDir('horde')) . '</a> ';
foreach ($users as $user):
?>
<tr>
- <td><a href="<?php echo Folks::getUrlFor('user', $user['user_uid']) ?>"><?php echo $user['user_uid'] ?></a></td>
+ <td style="text-align: center">
+ <a href="<?php echo Folks::getUrlFor('user', $user['user_uid']) ?>">
+ <img src="<?php echo Folks::getImageUrl($user['user_uid']) ?>" class="userMiniIcon" />
+ <?php echo $user['user_uid'] ?></a>
+ </td>
<td><?php if ($user['user_gender']) { echo $user['user_gender'] == 1 ? _("Male") : _("Female"); } ?></td>
<td><?php
$age = Folks::calcAge($user['user_birthday']);
<td><?php echo $user['user_city'] ?></td>
<td><?php echo $user['user_url'] ? _("Yes") : _("No") ?></td>
<td><?php echo $user['user_description'] ? _("Yes") : _("No") ?></td>
- <td><?php echo $user['user_picture'] || $user['user_video'] ? _("Yes") : _("No") ?></td>
<td><?php echo $user['count_galleries'] ? _("Yes") : _("No") ?></td>
<td><?php echo $user['count_videos'] ? _("Yes") : _("No") ?></td>
</td>