1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13:
14:
15: class Jonah_View_TagSearchList extends Jonah_View_Base
16: {
17: 18: 19: 20: 21: 22: 23: 24:
25: public function run()
26: {
27: extract($this->_params, EXTR_REFS);
28: $driver = $GLOBALS['injector']->getInstance('Jonah_Driver');
29:
30:
31: if (!is_null($channel_id)) {
32: $channel = $driver->getChannel($channel_id);
33: if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::SHOW, $channel_id)) {
34: $notification->push(_("You are not authorised for this action."), 'horde.warning');
35: $registry->authenticateFailure();
36: }
37: $channel_ids = array($channel_id);
38: } else {
39: $channel_ids = array();
40: $channels = $driver->getChannels();
41: foreach ($channels as $ch) {
42: if (Jonah::checkPermissions(Jonah::typeToPermName($ch['channel_type']), Horde_Perms::SHOW, $ch['channel_id'])) {
43: $channel_ids[] = $ch['channel_id'];
44: }
45: }
46: }
47:
48: $tag_name = array_shift($driver->getTagNames(array($tag_id)));
49: try {
50: $stories = $driver->searchTagsById(array($tag_id), 10, 0, $channel_ids);
51: } catch (Exception $e) {
52: $notification->push(sprintf(_("Invalid channel requested. %s"), $e->getMessage()), 'horde.error');
53: Horde::url('channels/index.php', true)->redirect();
54: exit;
55: }
56:
57:
58: if (empty($stories)) {
59: $notification->push(_("No available stories."), 'horde.warning');
60: }
61:
62: foreach ($stories as $key => $story) {
63: 64:
65: $channel_id = $story['channel_id'];
66:
67: if (!empty($stories[$key]['published'])) {
68: $stories[$key]['published_date'] = strftime($prefs->getValue('date_format') . ', ' . ($prefs->getValue('twentyFour') ? '%H:%M' : '%I:%M%p'), $stories[$key]['published']);
69: } else {
70: $stories[$key]['published_date'] = '';
71: }
72:
73:
74: $stories[$key]['pdf_link'] = '';
75: $stories[$key]['edit_link'] = '';
76: $stories[$key]['delete_link'] = '';
77: $stories[$key]['view_link'] = Horde::url($story['link'])->link(array('title' => $story['description'])) . htmlspecialchars($story['title']) . '</a>';
78:
79:
80: $url = Horde::url('stories/pdf.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
81: $stories[$key]['pdf_link'] = $url->link(array('title' => _("PDF version"))) . Horde::img('mime/pdf.png') . '</a>';
82:
83:
84: if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::EDIT, $channel_id)) {
85: $url = Horde::url('stories/edit.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
86: $stories[$key]['edit_link'] = $url->link(array('title' => _("Edit story"))) . Horde::img('edit.png') . '</a>';
87: }
88:
89:
90: if (Jonah::checkPermissions(Jonah::typeToPermName(Jonah::INTERNAL_CHANNEL), Horde_Perms::DELETE, $channel_id)) {
91: $url = Horde::url('stories/delete.php')->add(array('id' => $story['id'], 'channel_id' => $channel_id));
92: $stories[$key]['delete_link'] = $url->link(array('title' => _("Delete story"))) . Horde::img('delete.png') . '</a>';
93: }
94:
95:
96: if ($conf['comments']['allow'] &&
97: $registry->hasMethod('forums/numMessages')) {
98: try {
99: $comments = $registry->call('forums/numMessages', array($stories[$key]['id'], 'jonah'));
100: } catch (Exception $e) {}
101: $stories[$key]['comments'] = $comments;
102: }
103: }
104:
105:
106:
107: $view = new Horde_View(array('templatePath' => JONAH_TEMPLATES . '/stories'));
108: $view->stories = $stories;
109: $view->read = true;
110: $view->comments = $conf['comments']['allow'] && $registry->hasMethod('forums/numMessages') && $channel['channel_type'] == Jonah::INTERNAL_CHANNEL;
111: require $registry->get('templates', 'horde') . '/common-header.inc';
112: require JONAH_TEMPLATES . '/menu.inc';
113: echo $view->render('index');
114: require $registry->get('templates', 'horde') . '/common-footer.inc';
115: }
116:
117: }
118:
119: