1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14:
15: class Jonah_View_ChannelDelete extends Jonah_View_Base
16: {
17: 18: 19: 20: 21: 22:
23: public function run()
24: {
25: extract($this->_params, EXTR_REFS);
26:
27:
28: $form_submit = $vars->get('submitbutton');
29: $channel_id = $vars->get('channel_id');
30:
31: try {
32: $channel = $GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id);
33: } catch (Exception $e) {
34: Horde::logMessage($e, 'ERR');
35: $notification->push(_("Invalid channel specified for deletion."), 'horde.message');
36: Horde::url('channels')->redirect();
37: exit;
38: }
39:
40:
41: if (empty($form_submit)) {
42: $vars = new Horde_Variables($channel);
43: }
44:
45:
46: if (!Jonah::checkPermissions(Jonah::typeToPermName($channel['channel_type']), Horde_Perms::DELETE, $channel_id)) {
47: $notification->push(_("You are not authorised for this action."), 'horde.warning');
48: $registry->authenticateFailure();
49: }
50:
51: $title = sprintf(_("Delete News Channel \"%s\"?"), $vars->get('channel_name'));
52: $form = new Horde_Form($vars, $title);
53: $form->setButtons(array(_("Delete"), _("Do not delete")));
54: $form->addHidden('', 'channel_id', 'int', true, true);
55: $msg = _("Really delete this News Channel? All stories created in this channel will be lost!");
56: $form->addVariable($msg, 'confirm', 'description', false);
57: if ($form_submit == _("Delete")) {
58: if ($form->validate($vars)) {
59: $form->getInfo($vars, $info);
60: try {
61: $delete = $GLOBALS['injector']->getInstance('Jonah_Driver')->deleteChannel($info);
62: $notification->push(_("The channel has been deleted."), 'horde.success');
63: Horde::url('channels')->redirect();
64: exit;
65: } catch (Exception $e) {
66: $notification->push(sprintf(_("There was an error deleting the channel: %s"), $e->getMessage()), 'horde.error');
67: }
68: }
69: } elseif (!empty($form_submit)) {
70: $notification->push(_("Channel has not been deleted."), 'horde.message');
71: Horde::url('channels')->redirect();
72: exit;
73: }
74:
75: require $registry->get('templates', 'horde') . '/common-header.inc';
76: require JONAH_TEMPLATES . '/menu.inc';
77: $form->renderActive(null, $vars, Horde::selfUrl(), 'post');
78: require $registry->get('templates', 'horde') . '/common-footer.inc';
79: }
80:
81: }
82: