From 166b447f414dc08b0f9a67cff6fe9e692fc3da9f Mon Sep 17 00:00:00 2001 From: "Duck (Jakob Munih)" Date: Mon, 23 Feb 2009 19:57:20 +0100 Subject: [PATCH] Add block template --- folks/lib/Block/friends.php | 50 ++++++++++++++++++++++++----------------- folks/lib/Block/new.php | 22 ++++++++++++++---- folks/lib/Block/random.php | 26 ++++++++++++++------- folks/lib/Block/recent.php | 25 ++++++++++++++------- folks/templates/block/users.php | 25 +++++++++++++++++++++ 5 files changed, 107 insertions(+), 41 deletions(-) create mode 100644 folks/templates/block/users.php diff --git a/folks/lib/Block/friends.php b/folks/lib/Block/friends.php index 3a7534823..1139a5515 100644 --- a/folks/lib/Block/friends.php +++ b/folks/lib/Block/friends.php @@ -29,7 +29,7 @@ class Horde_Block_Folks_friends extends Horde_Block { */ function _params() { - $params = array('display' => array('name' => _("Show friends that are"), + return array('display' => array('name' => _("Show friends that are"), 'type' => 'enum', 'default' => 'online', 'values' => array('all' => _("All"), @@ -58,30 +58,38 @@ class Horde_Block_Folks_friends extends Horde_Block { return $users; } - $online = ''; - $offline = ''; - - foreach ($friends as $friend) { - if (array_key_exists($friend, $users)) { - $online .= '' . $friend . ' '; - } else { - $offline .= '' . $friend . ' '; + if (empty($this->_params['display']) || $this->_params['display'] == 'all') { + $list = $friends; + } else { + $list = array(); + foreach ($friends as $friend) { + if ($this->_params['display'] == 'online') { + if (array_key_exists($friend, $users)) { + $list[] = $friend; + } + } elseif ($this->_params['display'] == 'offline') { + if (!array_key_exists($friend, $users)) { + $list[] = $friend; + } + } } } - switch ($this->_params['display']) { - - case 'online': - return $online; - break; + // Prepare actions + $actions = array( + array('url' => Horde::applicationUrl('user.php'), + 'id' => 'user', + 'name' => _("View profile"))); + if ($GLOBALS['registry']->hasInterface('letter')) { + $actions[] = array('url' => $GLOBALS['registry']->callByPackage('letter', 'compose', ''), + 'id' => 'user_to', + 'name' => _("Send message")); + } - case 'offline': - return $offline; - break; + Horde::addScriptFile('stripe.js', 'horde', true); - default: - return $online . $offline; - break; - } + ob_start(); + require FOLKS_TEMPLATES . '/block/users.php'; + return ob_get_clean(); } } \ No newline at end of file diff --git a/folks/lib/Block/new.php b/folks/lib/Block/new.php index cf8b5b4ca..244abc8a2 100644 --- a/folks/lib/Block/new.php +++ b/folks/lib/Block/new.php @@ -48,12 +48,26 @@ class Horde_Block_Folks_new extends Horde_Block { return $new; } - $html = ''; + $list = array(); + foreach ($new as $u) { + $list[] = $u['user_uid']; + } - foreach ($new as $user) { - $html .= '' . $user['user_uid'] . ' '; + // Prepare actions + $actions = array( + array('url' => Horde::applicationUrl('user.php'), + 'id' => 'user', + 'name' => _("View profile"))); + if ($GLOBALS['registry']->hasInterface('letter')) { + $actions[] = array('url' => $GLOBALS['registry']->callByPackage('letter', 'compose', ''), + 'id' => 'user_to', + 'name' => _("Send message")); } - return $html; + Horde::addScriptFile('stripe.js', 'horde', true); + + ob_start(); + require FOLKS_TEMPLATES . '/block/users.php'; + return ob_get_clean(); } } \ No newline at end of file diff --git a/folks/lib/Block/random.php b/folks/lib/Block/random.php index 1582bb352..bf9436ac4 100644 --- a/folks/lib/Block/random.php +++ b/folks/lib/Block/random.php @@ -48,17 +48,27 @@ class Horde_Block_Folks_random extends Horde_Block { { require_once dirname(__FILE__) . '/../base.php'; - $recent = $GLOBALS['folks_driver']->getRandomUsers($this->_params['limit'], $this->_params['online'] == 'online'); - if ($recent instanceof PEAR_Error) { - return $recent; + $list = $GLOBALS['folks_driver']->getRandomUsers($this->_params['limit'], + $this->_params['online'] == 'online'); + if ($list instanceof PEAR_Error) { + return $list; } - $html = ''; - - foreach ($recent as $user) { - $html .= '' . $user . ' '; + // Prepare actions + $actions = array( + array('url' => Horde::applicationUrl('user.php'), + 'id' => 'user', + 'name' => _("View profile"))); + if ($GLOBALS['registry']->hasInterface('letter')) { + $actions[] = array('url' => $GLOBALS['registry']->callByPackage('letter', 'compose', ''), + 'id' => 'user_to', + 'name' => _("Send message")); } - return ''; + Horde::addScriptFile('stripe.js', 'horde', true); + + ob_start(); + require FOLKS_TEMPLATES . '/block/users.php'; + return ob_get_clean(); } } \ No newline at end of file diff --git a/folks/lib/Block/recent.php b/folks/lib/Block/recent.php index df3e016ff..7a57e855f 100644 --- a/folks/lib/Block/recent.php +++ b/folks/lib/Block/recent.php @@ -43,17 +43,26 @@ class Horde_Block_Folks_recent extends Horde_Block { { require_once dirname(__FILE__) . '/../base.php'; - $recent = $GLOBALS['folks_driver']->getRecentVisitors($this->_params['limit']); - if ($recent instanceof PEAR_Error) { - return $recent; + $list = $GLOBALS['folks_driver']->getRecentVisitors($this->_params['limit']); + if ($list instanceof PEAR_Error) { + return $list; } - $html = ''; - - foreach ($recent as $user) { - $html .= '' . $user . ''; + // Prepare actions + $actions = array( + array('url' => Horde::applicationUrl('user.php'), + 'id' => 'user', + 'name' => _("View profile"))); + if ($GLOBALS['registry']->hasInterface('letter')) { + $actions[] = array('url' => $GLOBALS['registry']->callByPackage('letter', 'compose', ''), + 'id' => 'user_to', + 'name' => _("Send message")); } - return $html; + Horde::addScriptFile('stripe.js', 'horde', true); + + ob_start(); + require FOLKS_TEMPLATES . '/block/users.php'; + return ob_get_clean(); } } \ No newline at end of file diff --git a/folks/templates/block/users.php b/folks/templates/block/users.php new file mode 100644 index 000000000..735a8835b --- /dev/null +++ b/folks/templates/block/users.php @@ -0,0 +1,25 @@ + + + + + + +
+ + +
+ + + + +
+isOnline($user)) { + echo '' . _("Online") . ''; + } else { + echo '' . _("Offline") . ''; + } +?> + +
+
-- 2.11.0