1: <?php
2: 3: 4:
5: class extends Horde_Core_Block
6: {
7: 8:
9: public function __construct($app, $params = array())
10: {
11: parent::__construct($app, $params);
12:
13: $this->_name = _("Last comments on my profile");
14: }
15:
16: 17:
18: protected function _params()
19: {
20: return array(
21: 'limit' => array(
22: 'name' => _("Number of comments to display"),
23: 'type' => 'int',
24: 'default' => 10
25: )
26: );
27: }
28:
29: 30:
31: protected function _content()
32: {
33: if (!$GLOBALS['registry']->isAuthenticated()) {
34: return '';
35: }
36:
37: $GLOBALS['cache'] = $GLOBALS['injector']->getInstance('Horde_Cache');
38:
39: $cache_key = 'folks_myscommetns_' . $this->_params['limit'];
40: $threads = $GLOBALS['cache']->get($cache_key, $GLOBALS['conf']['cache']['default_lifetime']);
41: if ($threads) {
42: return $threads;
43: }
44:
45: Horde::addScriptFile('tables.js', 'horde');
46: $html = '<table class="sortable striped" id="my_comment_list" style="width: 100%">'
47: . '<thead><tr><th>' . _("Title") . '</th>'
48: . '<th>' . _("User") . '</th></tr></thead>';
49:
50: try {
51: $threads = $GLOBALS['registry']->call('forums/getThreadsByForumOwner',
52: array($GLOBALS['registry']->getAuth(), 'message_timestamp', 1, false,
53: 'folks', 0, $this->_params['limit']));
54: } catch (Horde_Exception $e) {
55: return $e->getMessage();
56: }
57:
58: $url = Folks::getUrlFor('user', $GLOBALS['registry']->getAuth());
59: foreach ($threads as $message) {
60: $html .= '<tr><td>'
61: . '<a href="' . $url . '" title="' . $message['message_date']. '">'
62: . $message['message_subject'] . '</a> '
63: . '</td><td>'
64: . $message['message_author'] . '</td></tr>';
65: }
66: $html .= '</table>';
67:
68: $GLOBALS['cache']->set($cache_key, $html);
69: return $html;
70: }
71: }
72: