Overview

Packages

  • Jonah
  • None

Classes

  • Jonah
  • Jonah_Api
  • Jonah_Block_Latest
  • Jonah_Driver
  • Jonah_Driver_Sql
  • Jonah_Exception
  • Jonah_Factory_Driver
  • Jonah_Form_Feed
  • Jonah_Form_Story
  • Jonah_Test
  • Jonah_View_ChannelDelete
  • Jonah_View_ChannelEdit
  • Jonah_View_ChannelList
  • Jonah_View_StoryDelete
  • Jonah_View_StoryEdit
  • Jonah_View_StoryList
  • Jonah_View_StoryPdf
  • Jonah_View_StoryView
  • Jonah_View_TagSearchList
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
 4:  *
 5:  * See the enclosed file LICENSE for license information (BSD). If you
 6:  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE.
 7:  *
 8:  * @author Chuck Hagenbuch <chuck@horde.org>
 9:  * @author Marko Djukic <marko@oblo.com>
10:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
11:  * @package Jonah
12:  */
13: class Jonah_View_ChannelEdit extends Jonah_View_Base
14: {
15:     /**
16:      * expects
17:      *   $notification
18:      *   $registry
19:      *   $vars
20:      */
21:     public function run()
22:     {
23:         extract($this->_params, EXTR_REFS);
24: 
25:         $form = new Jonah_Form_Feed($vars);
26: 
27:         /* Set up some variables. */
28:         $formname = $vars->get('formname');
29:         $channel_id = $vars->get('channel_id');
30: 
31:         /* Form not yet submitted and is being edited. */
32:         if (!$formname && $channel_id) {
33:             $vars = new Horde_Variables($GLOBALS['injector']->getInstance('Jonah_Driver')->getChannel($channel_id));
34:         }
35: 
36:         /* Get the vars for channel type. */
37:         $channel_type = $vars->get('channel_type');
38: 
39:         /* Check permissions and deny if not allowed. */
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:         /* Output the extra fields required for this channel type. */
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: }
API documentation generated by ApiGen