Fixes
authorDuck (Jakob Munih) <duck@obala.net>
Mon, 23 Feb 2009 18:59:54 +0000 (19:59 +0100)
committerDuck (Jakob Munih) <duck@obala.net>
Mon, 23 Feb 2009 18:59:54 +0000 (19:59 +0100)
folks/edit/friends/know.php
folks/edit/friends/of.php
folks/friends.php
folks/lib/Driver.php
folks/lib/Friends.php
folks/lib/Friends/sql.php
folks/lib/Report/mail.php
folks/templates/friends/friends.php
folks/templates/list/list.php

index 32edf90..78d2de6 100644 (file)
@@ -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'),
index b3f4d48..6fa4cd3 100644 (file)
@@ -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();
index e60fa25..c7d6ade 100644 (file)
@@ -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';
index 0829354..fbbe840 100644 (file)
@@ -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;
             }
index cb3ad46..d5544b7 100644 (file)
@@ -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;
     }
index 39e5c5f..a72e272 100644 (file)
@@ -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 = ?'
index b5fd0eb..f5a7b95 100644 (file)
@@ -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
index a1be87c..284abdb 100644 (file)
@@ -1,3 +1,6 @@
+<?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>
+
index 7c40003..b90d7f8 100644 (file)
@@ -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");
 <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>&nbsp;';
@@ -63,7 +61,11 @@ foreach ($headers as $key => $val) {
 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']);
@@ -74,7 +76,6 @@ foreach ($users as $user):
     <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>