From aeee358e9d91b2b58e08f905d9f694f79b94da28 Mon Sep 17 00:00:00 2001 From: "Duck (Jakob Munih)" Date: Mon, 23 Feb 2009 19:59:54 +0100 Subject: [PATCH] Fixes --- folks/edit/friends/know.php | 32 ++--------- folks/edit/friends/of.php | 2 +- folks/friends.php | 5 +- folks/lib/Driver.php | 2 +- folks/lib/Friends.php | 51 ++++++++++++++++- folks/lib/Friends/sql.php | 2 +- folks/lib/Report/mail.php | 10 +--- folks/templates/friends/friends.php | 109 ++++++++++++++++++++++++++++++++++-- folks/templates/list/list.php | 27 ++++----- 9 files changed, 181 insertions(+), 59 deletions(-) diff --git a/folks/edit/friends/know.php b/folks/edit/friends/know.php index 32edf90f8..78d2de626 100644 --- a/folks/edit/friends/know.php +++ b/folks/edit/friends/know.php @@ -21,36 +21,12 @@ require_once FOLKS_BASE . '/lib/Friends.php'; $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'), diff --git a/folks/edit/friends/of.php b/folks/edit/friends/of.php index b3f4d4897..6fa4cd32c 100644 --- a/folks/edit/friends/of.php +++ b/folks/edit/friends/of.php @@ -21,7 +21,7 @@ require_once FOLKS_BASE . '/lib/Friends.php'; $friends = Folks_Friends::singleton(); // Get list -$list = $friends->getPossibleFriends(); +$list = $friends->friendOf(); if ($list instanceof PEAR_Error) { $notification->push($list); $list = array(); diff --git a/folks/friends.php b/folks/friends.php index e60fa2502..c7d6ade7c 100644 --- a/folks/friends.php +++ b/folks/friends.php @@ -71,10 +71,11 @@ if ($activities instanceof PEAR_Error) { // 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'; diff --git a/folks/lib/Driver.php b/folks/lib/Driver.php index 0829354f5..fbbe840af 100644 --- a/folks/lib/Driver.php +++ b/folks/lib/Driver.php @@ -228,7 +228,7 @@ class Folks_Driver { $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; } diff --git a/folks/lib/Friends.php b/folks/lib/Friends.php index cb3ad4681..d5544b7ad 100644 --- a/folks/lib/Friends.php +++ b/folks/lib/Friends.php @@ -92,6 +92,10 @@ class Folks_Friends { */ 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); @@ -427,11 +431,56 @@ class Folks_Friends { } /** + * 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; } diff --git a/folks/lib/Friends/sql.php b/folks/lib/Friends/sql.php index 39e5c5f5b..a72e27254 100644 --- a/folks/lib/Friends/sql.php +++ b/folks/lib/Friends/sql.php @@ -176,7 +176,7 @@ class Folks_Friends_sql extends Folks_Friends { * * @return array users */ - public function getPossibleFriends() + public function friendOf() { $query = 'SELECT user_uid FROM ' . $this->_params['friends'] . ' WHERE friend_uid = ? AND friend_ask = ?' diff --git a/folks/lib/Report/mail.php b/folks/lib/Report/mail.php index b5fd0eb2c..f5a7b951a 100644 --- a/folks/lib/Report/mail.php +++ b/folks/lib/Report/mail.php @@ -34,9 +34,7 @@ class Folks_Report_mail extends Folks_Report { $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']; @@ -52,8 +50,6 @@ class Folks_Report_mail extends Folks_Report { } } - 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 diff --git a/folks/templates/friends/friends.php b/folks/templates/friends/friends.php index a1be87c9f..284abdbd1 100644 --- a/folks/templates/friends/friends.php +++ b/folks/templates/friends/friends.php @@ -1,3 +1,6 @@ +renderActive(); ?> +
+ + + +
@@ -8,20 +11,116 @@ - - + $activity) { - echo '' + . '' - . ' ' - . ''; + . ' '; } ?>
' + echo '
' . ' ' . $activity['user'] . '' . Folks::format_datetime($activity_date) . '' . $activity['message'] . '
' . $activity['message'] . '
' . + '' . Folks::format_datetime($activity_date) . '' + . '
+ +
+
+ +

+ + +

+ + + + + + + + + + + + + + + +
+ + get('name', $activity['activity_scope']) ?> + +
+ +
+ +
+ +

+ 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'; +?> + +
+
+ +

+ 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'; +?> + +
+
+ +

+ 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'; +?> + +
+ diff --git a/folks/templates/list/list.php b/folks/templates/list/list.php index 7c40003f8..b90d7f863 100644 --- a/folks/templates/list/list.php +++ b/folks/templates/list/list.php @@ -21,23 +21,21 @@ $sortText = _("Sort Direction"); $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"); @@ -48,7 +46,7 @@ $sortText = _("Sort Direction"); $val) { - echo '' . "\n"; + echo '' . "\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')) . ' '; @@ -63,7 +61,11 @@ foreach ($headers as $key => $val) { foreach ($users as $user): ?> - + + + + + - -- 2.11.0