Overview

Packages

  • None
  • Shout

Classes

  • AccountDetailsForm
  • ConferenceDetailsForm
  • DeviceDetailsForm
  • ExtensionDetailsForm
  • MenuForm
  • NumberDetailsForm
  • RecordingDetailsForm
  • Shout
  • Shout_Ajax_Application
  • Shout_Driver
  • Shout_Driver_Ldap
  • Shout_Driver_Sql
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * $Id$
  4:  *
  5:  * Copyright 2010 Alkaloid Networks LLC (http://projects.alkaloid.net)
  6:  *
  7:  * See the enclosed file LICENSE for license information (BSD). If you
  8:  * did not receive this file, see
  9:  * http://www.opensource.org/licenses/bsd-license.php.
 10:  *
 11:  * @author Ben Klang <ben@alkaloid.net>
 12:  * @package Shout
 13:  */
 14: 
 15: class NumberDetailsForm extends Horde_Form {
 16: 
 17:     /**
 18:      * AccountDetailsForm constructor.
 19:      *
 20:      * @param mixed reference $vars
 21:      * @return boolean
 22:      */
 23:     function __construct(&$vars)
 24:     {
 25:         $action = $vars->get('action');
 26:         if ($action == 'edit') {
 27:             $title = _("Edit Number");
 28:         } else {
 29:             $title = _("Add Number");
 30:         }
 31: 
 32:         parent::__construct($vars, $title);
 33: 
 34:         $this->addHidden('', 'action', 'text', true);
 35:         //$this->addHidden('', 'oldaccount', 'text', false);
 36:         $this->addVariable(_("Telephone Number"), 'number', 'phone', true);
 37: 
 38:         $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
 39:         $accounts = $shout->storage->getAccounts();
 40:         $list = array();
 41:         foreach ($accounts as $id => $info) {
 42:             $list[$id] = $info['name'];
 43:         }
 44:         $select = $this->addVariable(_("Account Code"), 'accountcode',
 45:                                      'enum', false, false, null, array($list));
 46:         $action = &Horde_Form_Action::factory('reload');
 47:         $select->setAction($action);
 48:         $select->setOption('trackchange', true);
 49: 
 50:         $accountcode = $vars->get('accountcode');
 51:         if (!empty($accountcode)) {
 52:             $menus = $shout->storage->getMenus($accountcode);
 53:             $list = array('INACTIVE' => '-- None --');
 54:             foreach ($menus as $id => $info) {
 55:                 $list[$id] = $info['name'];
 56:             }
 57:             $this->addVariable(_("Menu"), 'menuName', 'enum', false,
 58:                                          false, null, array($list));
 59:         }
 60:         return true;
 61:     }
 62: 
 63:     /**
 64:      * Process this form, saving its information to the backend.
 65:      */
 66:     function execute()
 67:     {
 68:         $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
 69: 
 70:         $number = $this->_vars->get('number');
 71:         $accountcode = $this->_vars->get('accountcode');
 72:         $menuName = $this->_vars->get('menuName');
 73: 
 74:         return $shout->storage->saveNumber($number, $accountcode, $menuName);
 75:     }
 76: }
 77: 
 78: class NumberDeleteForm extends Horde_Form
 79: {
 80:     function __construct(&$vars)
 81:     {
 82:         die("FIXME");
 83:         $extension = $vars->get('extension');
 84:         $account = $vars->get('account');
 85: 
 86:         $title = _("Delete Extension %s - Account: %s");
 87:         $account_config = $GLOBALS['session']->get('shout', 'accounts/' . $account);
 88:         $title = sprintf($title, $extension, $account_config['name']);
 89:         parent::__construct($vars, $title);
 90: 
 91:         $this->addHidden('', 'account', 'text', true);
 92:         $this->addHidden('', 'extension', 'int', true);
 93:         $this->addHidden('', 'action', 'text', true);
 94:         $this->setButtons(array(_("Delete"), _("Cancel")));
 95:     }
 96: 
 97:     function execute()
 98:     {
 99:         die("FIXME");
100:         $shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
101:         $account = $this->_vars->get('account');
102:         $shout->storage->deleteAccount($account);
103:     }
104: }
105: 
API documentation generated by ApiGen