<configuration>
<configtab name="storage" desc="Storage">
<configsection name="storage">
- <configheader>Context Storage</configheader>
- <configswitch name="driver" desc="What backend should we use for storing the list of valid contexts/customers?">Sql
+ <configheader>Account Storage</configheader>
+ <configswitch name="driver" desc="What backend should we use for storing the list of valid accounts/customers?">Sql
<case name="Sql" desc="SQL">
<configsection name="params">
<configsql switchname="driverconfig" />
require_once SHOUT_BASE . '/lib/Forms/DeviceForm.php';
-$context = $_SESSION['shout']['context'];
+$account = $_SESSION['shout']['account'];
$action = Horde_Util::getFormData('action');
$vars = Horde_Variables::getDefaultVariables();
-//$tabs = Shout::getTabs($context, $vars);
+//$tabs = Shout::getTabs($account, $vars);
$RENDERER = new Horde_Form_Renderer();
case 'add':
case 'edit':
$vars = Horde_Variables::getDefaultVariables();
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new DeviceDetailsForm($vars);
// Show the list if the save was successful, otherwise back to edit.
// Create a new add/edit form
$devid = Horde_Util::getFormData('devid');
- $devices = $shout->devices->getDevices($context);
+ $devices = $shout->devices->getDevices($account);
$vars = new Horde_Variables($devices[$devid]);
$vars->set('action', $action);
$devid = Horde_Util::getFormData('devid');
$vars = Horde_Variables::getDefaultVariables();
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new DeviceDeleteForm($vars);
$FormValid = $Form->validate($vars, true);
}
$vars = Horde_Variables::getDefaultVariables(array());
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new DeviceDeleteForm($vars);
break;
// Fetch the (possibly updated) list of extensions
try {
- $devices = $shout->devices->getDevices($context);
+ $devices = $shout->devices->getDevices($account);
} catch (Exception $e) {
$notification->push($e);
$devices = array();
$action = Horde_Util::getFormData('action');
$menu = Horde_Util::getFormData('menu');
-$context = $_SESSION['shout']['context'];
+$account = $_SESSION['shout']['account'];
-$menus = $shout->storage->getMenus($context);
+$menus = $shout->storage->getMenus($account);
switch($action) {
case 'edit':
require_once SHOUT_BASE . '/lib/Forms/ExtensionForm.php';
$action = Horde_Util::getFormData('action');
-$context = $_SESSION['shout']['context'];
+$account = $_SESSION['shout']['account'];
-//$tabs = Shout::getTabs($context, $vars);
+//$tabs = Shout::getTabs($account, $vars);
$RENDERER = new Horde_Form_Renderer();
case 'add':
case 'edit':
$vars = Horde_Variables::getDefaultVariables();
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new ExtensionDetailsForm($vars);
$FormValid = $Form->validate($vars, true);
// Create a new add/edit form
$extension = Horde_Util::getFormData('extension');
- $extensions = $shout->extensions->getExtensions($context);
+ $extensions = $shout->extensions->getExtensions($account);
$vars = new Horde_Variables($extensions[$extension]);
if ($action == 'edit') {
$vars->set('oldextension', $extension);
$extension = Horde_Util::getFormData('extension');
$vars = Horde_Variables::getDefaultVariables();
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new ExtensionDeleteForm($vars);
$FormValid = $Form->validate($vars, true);
}
$vars = Horde_Variables::getDefaultVariables(array());
- $vars->set('context', $context);
+ $vars->set('account', $account);
$Form = new ExtensionDeleteForm($vars);
break;
// Fetch the (possibly updated) list of extensions
try {
- $extensions = $shout->extensions->getExtensions($context);
+ $extensions = $shout->extensions->getExtensions($account);
} catch (Exception $e) {
$notification->push($e);
$extensions = array();
{
$vars = $this->_vars;
$shout = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
try {
$shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
- $shout->extensions->addDestination($context, $vars->extension, $vars->type, $vars->destination);
+ $shout->extensions->addDestination($account, $vars->extension, $vars->type, $vars->destination);
- return $shout->extensions->getExtensions($context);
+ return $shout->extensions->getExtensions($account);
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
{
$vars = $this->_vars;
$shout = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
try {
// FIXME: Use Form?
$shout = $GLOBALS['registry']->getApiInstance('shout', 'application');
- $shout->extensions->deleteDestination($context, $vars->extension, $vars->type, $vars->destination);
+ $shout->extensions->deleteDestination($account, $vars->extension, $vars->type, $vars->destination);
- return $shout->extensions->getExtensions($context);
+ return $shout->extensions->getExtensions($account);
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
{
$vars = $this->_vars;
$shout = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
try {
- return $shout->extensions->getExtensions($context);
+ return $shout->extensions->getExtensions($account);
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
Horde::logMessage($e->getMessage(), __FILE__, __LINE__, PEAR_LOG_ERR);
try {
$vars = $this->_vars;
$shout = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
- $menus = $shout->storage->getMenus($context);
+ $account = $_SESSION['shout']['account'];
+ $menus = $shout->storage->getMenus($account);
$menu = $vars->menu;
if (!isset($menus[$menu])) {
Horde::logMessage("User requested a menu that does not exist.", __FILE__, __LINE__, PEAR_LOG_ERR);
return false;
}
$data['meta'] = $menus[$menu];
- $data['actions'] = $shout->dialplan->getMenuActions($context, $menu);
+ $data['actions'] = $shout->dialplan->getMenuActions($account, $menu);
return $data;
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
try {
$vars = $this->_vars;
$GLOBALS['shout'] = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
- $actions = Shout::getMenuActions();
+ $account = $_SESSION['shout']['account'];
+ $actions = Shout::getMenuActions($contex, $menu);
return $actions;
} catch (Exception $e) {
//FIXME: Create a way to notify the user of the failure.
throw new Shout_Exception("Invalid action requested.");
}
$GLOBALS['shout'] = Horde_Registry::appInit('shout');
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
$actions = Shout::getMenuActions();
$action = $actions[$action];
$form = new Horde_Form($vars, $action['description'], 'editActionForm');
$info['required'], $info['readonly'],
$info['description'], $info['params']);
}
+ $form->setButtons(_("Save"));
$this->_responseType = 'html';
$this->dialplan = Shout_Driver::factory('dialplan');
try {
- $contexts = $this->storage->getContexts();
+ $accounts = $this->storage->getAccounts();
} catch (Shout_Exception $e) {
$GLOBALS['notification']->push($e);
- $contexts = false;
+ $accounts = false;
}
- $context = Horde_Util::getFormData('context');
- if (empty($context) && !empty($_SESSION['shout']['context'])) {
- $context = $_SESSION['shout']['context'];
+ $account = Horde_Util::getFormData('account');
+ if (empty($account) && !empty($_SESSION['shout']['account'])) {
+ $account = $_SESSION['shout']['account'];
}
- if (!empty($context) && !in_array($context, $contexts)) {
- // Requested context not available
- $GLOBALS['notification']->push(_("You do not have permission to access that context."), 'horde.error');
- $context = false;
+ if (!empty($account) && !in_array($account, $accounts)) {
+ // Requested account not available
+ $GLOBALS['notification']->push(_("You do not have permission to access that account."), 'horde.error');
+ $account = false;
}
- if (empty($context)) {
- if (count($contexts)) {
- // Default to the user's first context
- $context = reset($contexts);
+ if (empty($account)) {
+ if (count($accounts)) {
+ // Default to the user's first account
+ $account = reset($accounts);
} else {
- // No context requested and/or no contexts available anyway
- $GLOBALS['notification']->push("Please select a context to continue.", 'horde.info');
- $context = false;
+ // No account requested and/or no accounts available anyway
+ $GLOBALS['notification']->push("Please select a account to continue.", 'horde.info');
+ $account = false;
}
}
- $_SESSION['shout']['context'] = $context;
+ $_SESSION['shout']['account'] = $account;
}
/**
self::$_perms['tree']['shout']['superadmin'] = false;
self::$_perms['title']['shout:superadmin'] = _("Super Administrator");
- if (empty($this->contexts)) {
+ if (empty($this->accounts)) {
$this->__construct(array('init' => true));
}
- $contexts = $this->contexts->getContexts();
+ $accounts = $this->accounts->getAccounts();
- self::$_perms['tree']['shout']['contexts'] = false;
- self::$_perms['title']['shout:contexts'] = _("Contexts");
+ self::$_perms['tree']['shout']['accounts'] = false;
+ self::$_perms['title']['shout:accounts'] = _("Accounts");
// Run through every contact source.
- foreach ($contexts as $context) {
- self::$_perms['tree']['shout']['contexts'][$context] = false;
- self::$_perms['title']['shout:contexts:' . $context] = $context;
+ foreach ($accounts as $account) {
+ self::$_perms['tree']['shout']['accounts'][$account] = false;
+ self::$_perms['title']['shout:accounts:' . $account] = $account;
foreach(
array(
'conferences' => 'Conference Rooms',
)
as $module => $modname) {
- self::$_perms['tree']['shout']['contexts'][$context][$module] = false;
- self::$_perms['title']["shout:contexts:$context:$module"] = $modname;
+ self::$_perms['tree']['shout']['accounts'][$account][$module] = false;
+ self::$_perms['title']["shout:accounts:$account:$module"] = $modname;
}
}
}
/**
- * Get a list of contexts from the instantiated driver and filter
- * the returned contexts for those which the current user can see/edit
+ * Get a list of accounts from the instantiated driver and filter
+ * the returned accounts for those which the current user can see/edit
*
- * @param optional string $filter Filter for types of contexts to return.
+ * @param optional string $filter Filter for types of accounts to return.
* One of "system" "customer" or "all"
*
- * @param optional string $filterperms Filter contexts for given permissions
+ * @param optional string $filterperms Filter accounts for given permissions
*
- * @return array Contexts valid for this user
+ * @return array Accounts valid for this user
*
* @access public
*/
- function getContexts($filters = "all", $filterperms = null)
+ function getAccounts($filters = "all", $filterperms = null)
{
throw new Shout_Exception("This function is not implemented.");
}
/**
- * For the given context and type, make sure the context has the
+ * For the given account and type, make sure the account has the
* appropriate properties, that it is effectively of that "type"
*
- * @param string $context the context to check type for
+ * @param string $account the account to check type for
*
- * @param string $type the type to verify the context is of
+ * @param string $type the type to verify the account is of
*
- * @return boolean true of the context is of type, false if not
+ * @return boolean true of the account is of type, false if not
*
* @access public
*/
- function checkContextType($context, $type)
+ function checkAccountType($account, $type)
{
throw new Shout_Exception("This function is not implemented.");
}
/**
- * Get a list of users valid for the current context. Return an array
+ * Get a list of users valid for the current account. Return an array
* indexed by the extension.
*
- * @param string $context Context for which users should be returned
+ * @param string $account Account for which users should be returned
*
* @return array User information indexed by voice mailbox number
*/
- function getUsers($context)
+ function getUsers($account)
{
throw new Shout_Exception("This function is not implemented.");
}
/**
- * Returns the name of the user's default context
+ * Returns the name of the user's default account
*
- * @return string User's default context
+ * @return string User's default account
*/
- function getHomeContext()
+ function getHomeAccount()
{
throw new Shout_Exception("This function is not implemented.");
}
/**
- * Get a context's properties
+ * Get a account's properties
*
- * @param string $context Context to get properties for
+ * @param string $account Account for which to get properties
*
- * @return integer Bitfield of properties valid for this context
+ * @return integer Bitfield of properties valid for this account
*/
- function getContextProperties($context)
+ function getAccountProperties($account)
{
throw new Shout_Exception("This function is not implemented.");
}
/**
- * Get a context's extensions and return as a multi-dimensional associative
+ * Get a account's extensions and return as a multi-dimensional associative
* array
*
- * @param string $context Context to return extensions for
+ * @param string $account account to return extensions for
*
* @return array Multi-dimensional associative array of extensions data
*
*/
- function getDialplan($context)
+ function getDialplan($account)
{
throw new Shout_Exception("This function is not implemented.");
}
* also implements some basic checks, so a typical backend will still
* call this method via parent::
*
- * @param string $context Context to which the user should be added
+ * @param string $account Account to which the user should be added
*
* @param string $extension Extension to be saved
*
* @return TRUE on success, PEAR::Error object on error
* @throws Shout_Exception
*/
- public function saveExtension($context, $extension, $details)
+ public function saveExtension($account, $extension, $details)
{
- if (empty($context) || empty($extension)) {
+ if (empty($account) || empty($extension)) {
throw new Shout_Exception(_("Invalid extension."));
}
- if (!Shout::checkRights("shout:contexts:$context:extensions", PERMS_EDIT, 1)) {
- throw new Shout_Exception(_("Permission denied to save extensions in this context."));
+ if (!Shout::checkRights("shout:accounts:$account:extensions", PERMS_EDIT, 1)) {
+ throw new Shout_Exception(_("Permission denied to save extensions in this account."));
}
}
- public function deleteExtension($context, $extension)
+ public function deleteExtension($account, $extension)
{
- if (empty($context) || empty($extension)) {
+ if (empty($account) || empty($extension)) {
throw new Shout_Exception(_("Invalid extension."));
}
- if (!Shout::checkRights("shout:contexts:$context:extensions",
+ if (!Shout::checkRights("shout:accounts:$account:extensions",
PERMS_DELETE, 1)) {
- throw new Shout_Exception(_("Permission denied to delete extensions in this context."));
+ throw new Shout_Exception(_("Permission denied to delete extensions in this account."));
}
}
* also implements some basic checks, so a typical backend will still
* call this method via parent::
*
- * @param string $context Context to which the user should be added
+ * @param string $account Account to which the user should be added
*
* @param string $extension Extension to be saved
*
* @return TRUE on success, PEAR::Error object on error
* @throws Shout_Exception
*/
- public function saveDevice($context, $devid, &$details)
+ public function saveDevice($account, $devid, &$details)
{
- if (empty($context)) {
+ if (empty($account)) {
throw new Shout_Exception(_("Invalid device information."));
}
- if (!Shout::checkRights("shout:contexts:$context:devices", PERMS_EDIT, 1)) {
- throw new Shout_Exception(_("Permission denied to save devices in this context."));
+ if (!Shout::checkRights("shout:accounts:$account:devices", PERMS_EDIT, 1)) {
+ throw new Shout_Exception(_("Permission denied to save devices in this account."));
}
if (empty($devid) || !empty($details['genauthtok'])) {
- list($devid, $password) = Shout::genDeviceAuth($context);
+ list($devid, $password) = Shout::genDeviceAuth($account);
$details['devid'] = $devid;
$details['password'] = $password;
}
* also implements some basic checks, so a typical backend will still
* call this method via parent::
*
- * @param <type> $context
+ * @param <type> $account
* @param <type> $devid
*/
- public function deleteDevice($context, $devid)
+ public function deleteDevice($account, $devid)
{
- if (empty($context) || empty($devid)) {
+ if (empty($account) || empty($devid)) {
throw new Shout_Exception(_("Invalid device."));
}
- if (!Shout::checkRights("shout:contexts:$context:devices",
+ if (!Shout::checkRights("shout:accounts:$account:devices",
PERMS_DELETE, 1)) {
- throw new Shout_Exception(_("Permission denied to delete devices in this context."));
+ throw new Shout_Exception(_("Permission denied to delete devices in this account."));
}
}
}
/**
- * Get a list of users valid for the contexts
+ * Get a list of users valid for the accounts
*
- * @param string $context Context in which to search
+ * @param string $account Account in which to search
*
* @return array User information indexed by voice mailbox number
*/
- public function getExtensions($context)
+ public function getExtensions($account)
{
static $entries = array();
- if (isset($entries[$context])) {
- return $entries[$context];
+ if (isset($entries[$account])) {
+ return $entries[$account];
}
$this->_params['basedn'];
$filter = '(&';
$filter .= '(objectClass=AsteriskVoiceMail)';
$filter .= '(objectClass=AsteriskUser)';
- $filter .= '(AstContext='.$context.')';
+ $filter .= '(AstContext='.$account.')';
$filter .= ')';
$attributes = array(
// ATTRIBUTES RETURNED FROM ldap_get_entries ARE ALL LOWER CASE!!
// It's a PHP thing.
- $entries[$context] = array();
+ $entries[$account] = array();
$i = 0;
while ($i < $res['count']) {
list($extension) = explode('@', $res[$i]['astvoicemailmailbox'][0]);
- $entries[$context][$extension] = array('extension' => $extension);
+ $entries[$account][$extension] = array('extension' => $extension);
$j = 0;
- $entries[$context][$extension]['mailboxopts'] = array();
+ $entries[$account][$extension]['mailboxopts'] = array();
if (empty($res[$i]['astvoicemailoptions']['count'])) {
$res[$i]['astvoicemailoptions']['count'] = -1;
}
while ($j < $res[$i]['astvoicemailoptions']['count']) {
- $entries[$context][$extension]['mailboxopts'][] =
+ $entries[$account][$extension]['mailboxopts'][] =
$res[$i]['astvoicemailoptions'][$j];
$j++;
}
- $entries[$context][$extension]['mailboxpin'] =
+ $entries[$account][$extension]['mailboxpin'] =
$res[$i]['astvoicemailpassword'][0];
- $entries[$context][$extension]['name'] =
+ $entries[$account][$extension]['name'] =
$res[$i]['cn'][0];
- $entries[$context][$extension]['email'] =
+ $entries[$account][$extension]['email'] =
$res[$i]['astvoicemailemail'][0];
- $entries[$context][$extension]['pageremail'] =
+ $entries[$account][$extension]['pageremail'] =
$res[$i]['astvoicemailpager'][0];
$j = 0;
- $entries[$context][$extension]['numbers'] = array();
+ $entries[$account][$extension]['numbers'] = array();
if (empty($res[$i]['telephonenumber']['count'])) {
$res[$i]['telephonenumber']['count'] = -1;
}
while ($j < $res[$i]['telephonenumber']['count']) {
- $entries[$context][$extension]['numbers'][] =
+ $entries[$account][$extension]['numbers'][] =
$res[$i]['telephonenumber'][$j];
$j++;
}
$j = 0;
- $entries[$context][$extension]['devices'] = array();
+ $entries[$account][$extension]['devices'] = array();
if (empty($res[$i]['astuserchannel']['count'])) {
$res[$i]['astuserchannel']['count'] = -1;
}
while ($j < $res[$i]['astuserchannel']['count']) {
// Trim off the Asterisk channel type from the device string
$device = explode('/', $res[$i]['astuserchannel'][$j], 2);
- $entries[$context][$extension]['devices'][] = $device[1];
+ $entries[$account][$extension]['devices'][] = $device[1];
$j++;
}
}
- ksort($entries[$context]);
+ ksort($entries[$account]);
- return($entries[$context]);
+ return($entries[$account]);
}
/**
* Add a new destination valid for this extension.
* A destination is either a telephone number or a VoIP device.
*
- * @param string $context Context for the extension
+ * @param string $account Account for the extension
* @param string $extension Extension for which to return destinations
* @param string $type Destination type ("device" or "number")
* @param string $destination The destination itself
*
* @return boolean True on success.
*/
- function addDestination($context, $extension, $type, $destination)
+ function addDestination($account, $extension, $type, $destination)
{
// FIXME: Permissions check
- $dn = $this->_getExtensionDn($context, $extension);
+ $dn = $this->_getExtensionDn($account, $extension);
$attr = $this->_getDestAttr($type, $destination);
$res = ldap_mod_add($this->_LDAP, $dn, $attr);
* Get a list of destinations valid for this extension.
* A destination is either a telephone number or a VoIP device.
*
- * @param string $context Context for the extension
+ * @param string $account Account for the extension
* @param string $extension Extension for which to return destinations
*/
- function getDestinations($context, $extension)
+ function getDestinations($account, $extension)
{
// FIXME: LDAP filter injection
$filter = '(&(AstContext=%s)(AstVoicemailMailbox=%s))';
- $filter = sprintf($filter, $context, $extension);
+ $filter = sprintf($filter, $account, $extension);
$attrs = array('telephoneNumber', 'AstUserChannel');
'devices' => $res['astuserchannel']);
}
- function deleteDestination($context, $extension, $type, $destination)
+ function deleteDestination($account, $extension, $type, $destination)
{
- $dn = $this->_getExtensionDn($context, $extension);
+ $dn = $this->_getExtensionDn($account, $extension);
$attr = $this->_getDestAttr($type, $destination);
$res = ldap_mod_del($this->_LDAP, $dn, $attr);
case 'device':
// FIXME: Check that the device is valid and associated with this
- // context.
+ // account.
// FIXME: Allow for different device types
$attr = array('AstUserChannel' => "SIP/" . $destination);
break;
/**
* Save an extension to the LDAP tree
*
- * @param string $context Context to which the user should be added
+ * @param string $account Account to which the user should be added
*
* @param string $extension Extension to be saved
*
* @return TRUE on success, PEAR::Error object on error
* @throws Shout_Exception
*/
- public function saveExtension($context, $extension, $details)
+ public function saveExtension($account, $extension, $details)
{
// Check permissions
- parent::saveExtension($context, $extension, $details);
+ parent::saveExtension($account, $extension, $details);
// FIXME: Fix and uncomment the below
-// // Check to ensure the extension is unique within this context
-// $filter = "(&(objectClass=AstVoicemailMailbox)(context=$context))";
+// // Check to ensure the extension is unique within this account
+// $filter = "(&(objectClass=AstVoicemailMailbox)(context=$account))";
// $reqattrs = array('dn', $ldapKey);
// $res = @ldap_search($this->_LDAP, $this->_params['basedn'],
// $filter, $reqattrs);
// throw new Shout_Exception(_("Duplicate extension found. Not saving changes."));
// }
// FIXME: Quote these strings
- $uid = $extension . '@' . $context;
+ $uid = $extension . '@' . $account;
$entry = array(
'objectClass' => array('top', 'account',
'AsteriskVoicemail', 'AsteriskUser'),
'AstVoicemailEmail' => $details['email'],
'AstVoicemailMailbox' => $extension,
'AstVoicemailPassword' => $details['mailboxpin'],
- 'AstContext' => $context,
+ 'AstContext' => $account,
);
$rdn = 'uid=' . $uid;
$dn = $rdn . ',' . $this->_params['basedn'];
// This is a change to an existing extension
// First, identify the DN to modify
// FIXME: Quote these strings
- $olddn = $this->_getExtensionDn($context, $extension);
+ $olddn = $this->_getExtensionDn($account, $extension);
// If the extension has changed we need to perform an object rename
if ($extension != $details['oldextension']) {
/**
* Deletes an extension from the LDAP tree
*
- * @param string $context Context to delete the user from
+ * @param string $account Account to delete the user from
* @param string $extension Extension of the user to be deleted
*
* @return boolean True on success, PEAR::Error object on error
*/
- public function deleteExtension($context, $extension)
+ public function deleteExtension($account, $extension)
{
// Check permissions
- parent::deleteExtension($context, $extension);
+ parent::deleteExtension($account, $extension);
- $dn = $this->_getExtensionDn($context, $extension);
+ $dn = $this->_getExtensionDn($account, $extension);
$res = @ldap_delete($this->_LDAP, $dn);
if ($res === false) {
/**
*
- * @param <type> $context
+ * @param <type> $account
* @param <type> $extension
*/
- protected function _getExtensionDn($context, $extension)
+ protected function _getExtensionDn($account, $extension)
{
// FIXME: Sanitize filter string against LDAP injection
$filter = '(&(AstVoicemailMailbox=%s)(AstContext=%s))';
- $filter = sprintf($filter, $extension, $context);
+ $filter = sprintf($filter, $extension, $account);
$attributes = array('dn');
$res = ldap_search($this->_LDAP, $this->_params['basedn'],
$this->_connect();
}
- public function getContexts()
+ public function getAccounts()
{
$this->_connect();
- $sql = 'SELECT context_name FROM shout_contexts';
+ $sql = 'SELECT name, accountcode FROM accounts';
$vars = array();
- $msg = 'SQL query in Shout_Driver_Sql#getContexts(): ' . $sql;
+ $msg = 'SQL query in Shout_Driver_Sql#getAccounts(): ' . $sql;
Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_db->query($sql, $vars);
if ($result instanceof PEAR_Error) {
throw new Shout_Exception($row);
}
- $contexts = array();
+ $accounts = array();
while ($row && !($row instanceof PEAR_Error)) {
- $contexts[] = $row['context_name'];
+ $accounts[$accountcode] = $row['name'];
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
}
$result->free();
- return $contexts;
+ return $accounts;
}
- public function getMenus($context)
+ public function getMenus($account)
{
static $menus;
- if (isset($menus[$context])) {
- return $menus[$context];
+ if (isset($menus[$account])) {
+ return $menus[$account];
}
$this->_connect();
- $sql = 'SELECT menu_name, menu_description, menu_soundfile ' .
- 'FROM shout_menus WHERE context_name = ?';
- $vars = array($context);
+ $sql = 'SELECT accounts.accountcode AS account, menus.name AS name, ' .
+ 'menus.description AS description, menus.soundfile AS soundfile ' .
+ 'FROM menus INNER JOIN accounts ON menus.account_id = accounts.id ' .
+ 'WHERE accounts.accountcode = ?';
+ $vars = array($account);
- $msg = 'SQL query in Shout_Driver_Sql#getContexts(): ' . $sql;
+ $msg = 'SQL query in Shout_Driver_Sql#getMenus(): ' . $sql;
Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$result = $this->_db->query($sql, $vars);
if ($result instanceof PEAR_Error) {
throw new Shout_Exception($row);
}
- $menus[$context] = array();
+ $menus[$account] = array();
while ($row && !($row instanceof PEAR_Error)) {
$menu = $row['menu_name'];
- $menus[$context][$menu] = array(
+ $menus[$account][$menu] = array(
'name' => $menu,
'description' => $row['menu_description'],
'soundfile' => $row['menu_soundfile']
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
}
$result->free();
- return $menus[$context];
+ return $menus[$account];
}
- function getMenuActions($context, $menu)
+ function getMenuActions($account, $menu)
{
- return array();
+ static $menuActions;
+ if (!empty($menuActions[$menu])) {
+ return $menuActions[$menu];
+ }
+
+ $sql = "SELECT accounts.accountcode AS account, menus.name AS description, " .
+ "actions.name AS action, menu_entries.digit AS digit, " .
+ "menu_entries.args AS args FROM menu_entries " .
+ "INNER JOIN menus ON menu_entries.menu_id = menus.id " .
+ "INNER JOIN actions ON menu_entries.action_id = actions.id " .
+ "INNER JOIN accounts ON menus.account_id = accounts.id " .
+ "WHERE accounts.accountcode = ? AND menus.name = ?";
+ $values = array($account, $menuid);
+
+ $msg = 'SQL query in Shout_Driver_Sql#getMenuActions(): ' . $sql;
+ Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG);
+ $result = $this->_db->query($sql, $vars);
+ if ($result instanceof PEAR_Error) {
+ throw new Shout_Exception($result);
+ }
+
+ $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ if ($row instanceof PEAR_Error) {
+ throw new Shout_Exception($row);
+ }
+
+ $menuActions[$menu] = array();
+ while ($row && !($row instanceof PEAR_Error)) {
+ $menuActions[$menu][$row['digit']] = array(
+ 'digit' => $row['digit'],
+ 'action' => $row['action'],
+ 'args' => Horde_Yaml::load($row['args'])
+ );
+ $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
+ }
+ $result->free();
+ return $menus[$menu];
}
/**
- * Get a list of devices for a given context
+ * Get a list of devices for a given account
*
- * @param string $context Context in which to search for devicess
+ * @param string $account Account in which to search for devicess
*
- * @return array Array of devices within this context with their information
+ * @return array Array of devices within this account with their information
*
* @access private
*/
- public function getDevices($context)
+ public function getDevices($account)
{
$sql = 'SELECT id, name, alias, callerid, context, mailbox, host, ' .
'permit, nat, secret, disallow, allow ' .
'FROM %s WHERE accountcode = ?';
$sql = sprintf($sql, $this->_params['table']);
- $args = array($context);
+ $args = array($account);
$msg = 'SQL query in Shout_Driver_Sql#getDevices(): ' . $sql;
Horde::logMessage($msg, __FILE__, __LINE__, PEAR_LOG_DEBUG);
$sth = $this->_db->prepare($sql);
/**
* Save a device (add or edit) to the backend.
*
- * @param string $context The context in which this device is valid
+ * @param string $account The account in which this device is valid
* @param string $devid Device ID to save
* @param array $details Array of device details
*/
- public function saveDevice($context, $devid, &$details)
+ public function saveDevice($account, $devid, &$details)
{
// Check permissions and possibly update the authentication tokens
- parent::saveDevice($context, $devid, $details);
+ parent::saveDevice($account, $devid, $details);
// See getDevices() for an explanation of these conversions
$details['alias'] = $details['name'];
$details['name'] = $details['devid'];
unset($details['devid']);
- $details['mailbox'] .= '@' . $context;
+ $details['mailbox'] .= '@' . $account;
// Prepare the SQL query and arguments
$args = array(
$details['name'],
- $context,
+ $account,
$details['callerid'],
$details['mailbox'],
$details['password'],
- $context,
+ $account,
$details['alias'],
);
return true;
}
- public function deleteDevice($context, $devid)
+ public function deleteDevice($account, $devid)
{
- parent::deleteDevice($context, $devid);
+ parent::deleteDevice($account, $devid);
$sql = 'DELETE FROM %s WHERE devid = ?';
$sql = sprintf($sql, $this->_params['table']);
}
/**
- * Get a list of users valid for the contexts
+ * Get a list of users valid for the accounts
*
- * @param string $context Context on which to search
+ * @param string $account Account on which to search
*
* @return array User information indexed by voice mailbox number
*/
- public function getExtensions($context)
+ public function getExtensions($account)
{
throw new Shout_Exception("Not implemented yet.");
}
/**
* Save a user to the LDAP tree
*
- * @param string $context Context to which the user should be added
+ * @param string $account Account to which the user should be added
*
* @param string $extension Extension to be saved
*
*
* @return TRUE on success, PEAR::Error object on error
*/
- public function saveExtension($context, $extension, $userdetails)
+ public function saveExtension($account, $extension, $userdetails)
{
- parent::saveExtension($context, $extension, $details);
+ parent::saveExtension($account, $extension, $details);
throw new Shout_Exception("Not implemented.");
}
/**
* Deletes a user from the LDAP tree
*
- * @param string $context Context to delete the user from
+ * @param string $account Account to delete the user from
* @param string $extension Extension of the user to be deleted
*
* @return boolean True on success, PEAR::Error object on error
*/
- public function deleteExtension($context, $extension)
+ public function deleteExtension($account, $extension)
{
throw new Shout_Exception("Not implemented.");
}
$edit = false;
}
- $context = $vars->get('context');
- parent::__construct($vars, _("$formtitle - Context: $context"));
+ $account = $vars->get('account');
+ parent::__construct($vars, _("$formtitle - Account: $account"));
$this->addHidden('', 'action', 'text', true);
if ($edit) {
$this->addHidden('', 'devid', 'text', true);
global $shout;
$action = $this->_vars->get('action');
- $context = $this->_vars->get('context');
+ $account = $this->_vars->get('account');
$devid = $this->_vars->get('devid');
// For safety, we force the device ID and password rather than rely
$devid = null;
$password = null;
} else { // $action must be 'edit'
- $devices = $shout->devices->getDevices($context);
+ $devices = $shout->devices->getDevices($account);
if (!isset($devices[$devid])) {
// The device requested doesn't already exist. This can't
// be a valid edit.
'password' => $password,
);
- $shout->devices->saveDevice($context, $devid, $details);
+ $shout->devices->saveDevice($account, $devid, $details);
}
}
function __construct(&$vars)
{
$devid = $vars->get('devid');
- $context = $vars->get('context');
+ $account = $vars->get('account');
- $title = _("Delete Device %s - Context: %s");
- $title = sprintf($title, $devid, $context);
+ $title = _("Delete Device %s - Account: %s");
+ $title = sprintf($title, $devid, $account);
parent::__construct($vars, $title);
- $this->addHidden('', 'context', 'text', true);
+ $this->addHidden('', 'account', 'text', true);
$this->addHidden('', 'devid', 'text', true);
$this->addHidden('', 'action', 'text', true);
$this->setButtons(array(_("Delete"), _("Cancel")));
function execute()
{
global $shout;
- $context = $this->_vars->get('context');
+ $account = $this->_vars->get('account');
$devid = $this->_vars->get('devid');
- $shout->devices->deleteDevice($context, $devid);
+ $shout->devices->deleteDevice($account, $devid);
}
}
\ No newline at end of file
{
global $shout;
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
$action = $vars->get('action');
if ($action == 'edit') {
$formtitle = "Edit User";
$formtitle = "Add User";
}
- parent::__construct($vars, _("$formtitle - Context: $context"));
+ parent::__construct($vars, _("$formtitle - Account: $account"));
$extension = $vars->get('extension');
/**
* Process this form, saving its information to the backend.
*
- * @param string $context Context in which to execute this save
- * FIXME: is there a better way to get the $context and $shout->extensions?
+ * @param string $account Account in which to execute this save
+ * FIXME: is there a better way to get the $account and $shout->extensions?
*/
function execute()
{
global $shout;
$extension = $this->_vars->get('extension');
- $context = $this->_vars->get('context');
+ $account = $this->_vars->get('account');
// FIXME: Input Validation (Text::??)
$details = array(
'mailboxpin' => $this->_vars->get('mailboxpin'),
);
- $shout->extensions->saveExtension($context, $extension, $details);
+ $shout->extensions->saveExtension($account, $extension, $details);
}
}
function __construct(&$vars)
{
$extension = $vars->get('extension');
- $context = $vars->get('context');
+ $account = $vars->get('account');
- $title = _("Delete Extension %s - Context: %s");
- $title = sprintf($title, $extension, $context);
+ $title = _("Delete Extension %s - Account: %s");
+ $title = sprintf($title, $extension, $account);
parent::__construct($vars, $title);
- $this->addHidden('', 'context', 'text', true);
+ $this->addHidden('', 'account', 'text', true);
$this->addHidden('', 'extension', 'int', true);
$this->addHidden('', 'action', 'text', true);
$this->setButtons(array(_("Delete"), _("Cancel")));
function execute()
{
global $shout;
- $context = $this->_vars->get('context');
+ $account = $this->_vars->get('account');
$extension = $this->_vars->get('extension');
- $shout->extensions->deleteExtension($context, $extension);
+ $shout->extensions->deleteExtension($account, $extension);
}
}
*/
static public function getMenu($returnType = 'object')
{
- global $conf, $context, $section, $action;
+ global $conf, $account, $section, $action;
require_once 'Horde/Menu.php';
* provisioning can be done automatically. For these reasons, having
* user-friendly usernames and passswords is not terribly important.
*
- * @param string $context Context for this credential pair
+ * @param string $account Account for this credential pair
*
* @return array Array of (string $deviceID, string $devicePassword)
*/
- static public function genDeviceAuth($context)
+ static public function genDeviceAuth($account)
{
- $devid = $context . substr(uniqid(), 6);
+ $devid = $account . substr(uniqid(), 6);
// This simple password generation algorithm inspired by Jon Haworth
// http://www.laughing-buddha.net/jon/php/password/
static public function getMenuActions()
{
global $shout;
- $context = $_SESSION['shout']['context'];
+ $account = $_SESSION['shout']['account'];
return array(
- 'menu' => array(
+ 'jump' => array(
'description' => _("Jump to menu."),
'args' => array (
'menuName' => array(
'name' => _("Menu"),
'type' => 'enum',
'required' => true,
- 'params' => array(self::getNames($shout->dialplan->getMenus($context)))
+ 'params' => array(self::getNames($shout->dialplan->getMenus($account)))
)
)
),
'name' => _("Extension"),
'type' => 'enum',
'required' => true,
- 'params' => array(self::getNames($shout->extensions->getExtensions($context)))
+ 'params' => array(self::getNames($shout->extensions->getExtensions($account)))
)
)
),
- 'voicemail' => array(
+ 'leave_message' => array(
'description' => _("Leave a message."),
'args' => array(
'mailbox' => array(
'name' => _("Mailbox"),
'type' => 'enum',
'required' => true,
- 'params' => array(self::getNames($shout->extensions->getExtensions($context)))
+ 'params' => array(self::getNames($shout->extensions->getExtensions($account)))
)
)
),
'description' => _("Restart the current menu."),
'args' => array()
),
+ // TODO: Actions to implement: Queue
);
}
</a>
</li>
</ul>
- Context: <?php echo $context; ?>
+ Account: <?php echo $account; ?>
</div>
<div id="extensionList">
// Draw the selectActionForm
$('editActionOverlay').show();
- while ((e = $('selectAction').childNodes[0]) != null) {
- $('selectAction').removeChild(e);
- }
+ empty('selectAction');
var p = document.createElement('p');
p.id = 'actionPrompt';
var text = document.createTextNode('<?php echo _("Select Action:"); ?>');
parameters: params,
onSuccess: function(r) {
alert('FIXME');
- while ((e = $('editAction').childNodes[0]) != null) {
- $('editAction').removeChild(e);
- }
+ empty('selectAction');
+ empty('editAction');
$('editActionOverlay').hide();
}
});
var col;
var img;
var text;
- while ((e = $('menuInfo').childNodes[0]) != null) {
- $('menuInfo').removeChild(e);
- }
+ empty('menuInfo');
var meta = menuInfo.get('meta');
return row;
}
+function empty(p)
+{
+ while ((e = $(p).childNodes[0]) != null) {
+ $(p).removeChild(e);
+ }
+}
+
$('editActionOverlay').hide();
new Ajax.Request(ajax_url + 'getMenuInfo',
{
</a>
</li>
</ul>
- Context: <?php echo $context; ?>
+ Account: <?php echo $account; ?>
</div>
<div id="extensionList">
</a>
</li>
</ul>
- Context: <?php echo $context; ?>
+ Account: <?php echo $account; ?>
</div>
<div id="extensionList">
<a name="top"></a>
<?php
$accesskey = $prefs->getValue('widget_accesskey') ?
- Horde::getAccessKey(_("Select _Context")) : '';
+ Horde::getAccessKey(_("Select _Account")) : '';
$menu_view = $prefs->getValue('menu_view');
?>
<div id="menu">
<?php
-// Only show the context selector if there is more than one available context
+// Only show the account selector if there is more than one available account
try {
- $contexts = $shout->storage->getContexts();
+ $accounts = $shout->storage->getAccounts();
} catch (Exception $e) {
- $contexts = array();
+ $accounts = array();
}
-if (count($contexts) > 1) { ?>
+if (count($accounts) > 1) { ?>
<script language="JavaScript" type="text/javascript">
<!--
var loading;
-function contextSubmit(clear)
+function accountSubmit(clear)
{
- if (document.contextMenu.context[document.contextMenu.context.selectedIndex].name != '') {
+ if (document.accountMenu.account[document.accountMenu.account.selectedIndex].name != '') {
if ((loading == null) || (clear != null)) {
loading = true;
- document.contextMenu.submit();
+ document.accountMenu.submit();
}
}
}
// -->
</script>
- <form action="index.php" method="get" name="contextMenu">
+ <form action="index.php" method="get" name="accountMenu">
<span style="float:right">
<?php Horde_Util::pformInput() ?>
- <label for="context" accesskey="<?php echo $accesskey ?>">
- <select id="context" name="context" onchange="contextSubmit()">
+ <label for="account" accesskey="<?php echo $accesskey ?>">
+ <select id="account" name="account" onchange="accountSubmit()">
<?php
- foreach ($contexts as $c) {
+ foreach ($accounts as $c) {
print "<option value=\"$c\"";
- if ($c == $context) {
+ if ($c == $account) {
print " selected";
}
print ">$c</option>\n";
<div style="float:right">
<?php
- $link = Horde::link('#', _("Select Context"), '', '', 'contextSubmit(true);
+ $link = Horde::link('#', _("Select Account"), '', '', 'accountSubmit(true);
return false;');
printf('<ul><li>%s%s<br />%s</a></li></ul>',
$link, Horde::img('folders/folder_open.png'),
($menu_view != 'icon') ?
- Horde::highlightAccessKey(_("Select _Context"), $accesskey) : '');
+ Horde::highlightAccessKey(_("Select _Account"), $accesskey) : '');
?>
</div>
-<?php } // if (count(contexts) > 1) ?>
+<?php } // if (count(accounts) > 1) ?>
<?php echo Shout::getMenu('string') ?>
</div>