1: <?php
2: 3: 4: 5:
6: class Folks_Block_Friends extends Horde_Core_Block
7: {
8: 9:
10: public function __construct($app, $params = array())
11: {
12: parent::__construct($app, $params);
13:
14: $this->_name = _("Friends");
15: }
16:
17: 18:
19: protected function _params()
20: {
21: return array(
22: 'display' => array(
23: 'name' => _("Show friends that are"),
24: 'type' => 'enum',
25: 'default' => 'online',
26: 'values' => array(
27: 'all' => _("All"),
28: 'online' => _("Online"),
29: 'offline' => _("Offline")
30: )
31: )
32: );
33: }
34:
35: 36:
37: protected function _content()
38: {
39: require_once dirname(__FILE__) . '/../base.php';
40:
41: $friends_driver = Folks_Friends::singleton();
42: $friends = $friends_driver->getFriends();
43: if ($friends instanceof PEAR_Error) {
44: return $friends;
45: }
46:
47: $users = $GLOBALS['folks_driver']->getOnlineUsers();
48: if ($users instanceof PEAR_Error) {
49: return $users;
50: }
51:
52: if (empty($this->_params['display']) || $this->_params['display'] == 'all') {
53: $list = $friends;
54: } else {
55: $list = array();
56: foreach ($friends as $friend) {
57: if ($this->_params['display'] == 'online') {
58: if (array_key_exists($friend, $users)) {
59: $list[] = $friend;
60: }
61: } elseif ($this->_params['display'] == 'offline') {
62: if (!array_key_exists($friend, $users)) {
63: $list[] = $friend;
64: }
65: }
66: }
67: }
68:
69:
70: $actions = array(
71: array('url' => Horde::url('user.php'),
72: 'id' => 'user',
73: 'name' => _("View profile")));
74: if ($GLOBALS['registry']->hasInterface('letter')) {
75: $actions[] = array('url' => $GLOBALS['registry']->callByPackage('letter', 'compose', ''),
76: 'id' => 'user_to',
77: 'name' => _("Send message"));
78: }
79:
80: Horde::addScriptFile('stripe.js', 'horde');
81:
82: ob_start();
83: require FOLKS_TEMPLATES . '/block/users.php';
84: return ob_get_clean();
85: }
86: }
87: