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:  * View for handling deletion of channels.
 4:  *
 5:  * Copyright 2003-2012 Horde LLC (http://www.horde.org/)
 6:  *
 7:  * See the enclosed file LICENSE for license information (BSD). If you
 8:  * did not receive this file, see http://cvs.horde.org/co.php/jonah/LICENSE
 9:  *
10:  * @author Chuck Hagenbuch <chuck@horde.org>
11:  * @author Marko Djukic <marko@oblo.com>
12:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
13:  * @package Jonah
14:  */
15: class Jonah_View_ChannelDelete extends Jonah_View_Base
16: {
17:     /**
18:      * Expects:
19:      *   $vars
20:      *   $registry
21:      *   $notification
22:      */
23:     public function run()
24:     {
25:         extract($this->_params, EXTR_REFS);
26: 
27:         /* Set up the form variables and the form. */
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:         /* If not yet submitted set up the form vars from the fetched channel. */
41:         if (empty($form_submit)) {
42:             $vars = new Horde_Variables($channel);
43:         }
44: 
45:         /* Check permissions and deny if not allowed. */
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: 
API documentation generated by ApiGen