1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12:
13: class Jonah_View_ChannelEdit extends Jonah_View_Base
14: {
15: 16: 17: 18: 19: 20:
21: public function run()
22: {
23: extract($this->_params, EXTR_REFS);
24:
25: $form = new Jonah_Form_Feed($vars);
26:
27:
28: $formname = $vars->get('formname');
29: $channel_id = $vars->get('channel_id');
30:
31:
32: if (!$formname && $channel_id) {
33: $vars = new Horde_Variables($GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id));
34: }
35:
36:
37: $channel_type = $vars->get('channel_type');
38:
39:
40: if (!Jonah::checkPermissions(Jonah::typeToPermName($channel_type), Horde_Perms::EDIT, $channel_id)) {
41: $notification->push(_("You are not authorised for this action."), 'horde.warning');
42: $registry->authenticateFailure();
43: }
44:
45:
46: $form->setExtraFields($channel_id);
47: if ($formname && empty($changed_type)) {
48: if ($form->validate($vars)) {
49: $form->getInfo($vars, $info);
50: try {
51: $save = $GLOBALS['injector']->getInstance('Jonah_Driver')->saveChannel($info);
52: $notification->push(sprintf(_("The feed \"%s\" has been saved."), $info['channel_name']), 'horde.success');
53: Horde::url('channels')->redirect();
54: exit;
55: } catch (Exception $e) {
56: $notification->push(sprintf(_("There was an error saving the feed: %s"), $e->getMessage()), 'horde.error');
57: }
58: }
59: }
60:
61: $renderer = new Horde_Form_Renderer();
62: $title = $form->getTitle();
63: require $registry->get('templates', 'horde') . '/common-header.inc';
64: require JONAH_TEMPLATES . '/menu.inc';
65: $form->renderActive($renderer, $vars, Horde::url('channels/edit.php'), 'post');
66: require $registry->get('templates', 'horde') . '/common-footer.inc';
67: }
68:
69: }