+++ /dev/null
-<?php
-if (!defined(SHOUT_BASE)) {
- define(SHOUT_BASE, dirname(__FILE__));
-}
-
-# Check that we are properly initialized
-if (!isset($contexts) || is_a($contexts, 'PEAR_Error')) {
- $notification->push(_("Internal error viewing requested page"),
- 'horde.error');
-}
-
-if (count($contexts) < 1) {
- $notification->push(_("You do not have permission to access this
-system.", 'horde.error'));
- exit();
-} elseif (count($contexts) == 1) {
- header("Location: " .
- Horde::applicationUrl("index.php?context=$contexts[0]§ion=users"));
- exit();
-}
-
-$notification->notify();
-
-# Print the contexts
-$toggle = false;
-foreach($contexts as $context) {
- include SHOUT_TEMPLATES . "/context/contextline.inc";
- $toggle = !$toggle;
-}
\ No newline at end of file
if (count($contexts) == 1) {
$context = $contexts[0];
+} elseif (!$context) {
+ $context = $shout->getHomeContext();
}
#$title = '[#' . $ticket->getId() . '] ' . $ticket->get('summary');
$tabs->preserve('context', $context);
echo "<br />";
+// if (!$section) {
+// $section =
+if (!$section) {
+ $section = $tabs->_tabs[0]['tabname'];
+}
+
echo $tabs->render($section);
switch ($section) {
case "conference":
case "dialplan":
+ case "security":
case "users":
case "moh":
require "$section.php";
*
* @access public
*/
- function getContexts($filter = "all", $filterperms = null)
+ function getContexts($filters = "all", $filterperms = null)
{
# Initialize array to be returned
$retcontexts = array();
}
# Collect the master list of contexts from the backend
- $contexts = $this->_getContexts($filter);
+ $contexts = $this->_getContexts($filters);
# Narrow down the list of contexts to those valid for this user.
return $this->_getUsers($context);
}
// }}}
-
+
+ // {{{ getHomeContext method
+ /**
+ * Returns the name of the user's default context
+ *
+ * @return string User's default context
+ */
+ function getHomeContext()
+ {
+ return $this->_getHomeContext();
+ }
+ // }}}
+
+ // {{{ getExtensions method
+ /**
+ * Get a context's extensions and return as a multi-dimensional associative
+ * array
+ *
+ * @param string $context Context to return extensions for
+ *
+ * @return array Multi-dimensional associative array of extensions data
+ *
+ */
+ function getDialplan($context)
+ {
+ return $this->_getDialplan($context);
+ }
+ // }}}
+
// {{{ factory method
/**
* Attempts to return a concrete Shout_Driver instance based on
*
* @access private
*/
- function _getContexts($filter = "all")
+ function _getContexts($filters = "all")
{
# TODO Add caching mechanism here. Possibly cache results per
# filter $this->contexts['customer'] and return either data
# or possibly a reference to that data
- switch ($filter) {
- case "customer":
- $searchfilter="(objectClass=vofficeCustomer)";
- break;
- case "extensions":
- $searchfilter="(objectClass=asteriskExtensions)";
- break;
- case "moh":
- $searchfilter="(objectClass=asteriskMusicOnHold)";
- break;
- case "conference":
- $searchfilter="(objectClass=asteriskMeetMe)";
- break;
- case "all":
- default:
- $searchfilter="";
- break;
+ if(!is_array($filters)) {
+ $tmp = $filters;
+ $filters = array();
+ $filters[] = $tmp;
}
+
+ $searchfilter = "(|";
+ foreach ($filters as $filter) {
+ switch ($filter) {
+ case "customers":
+ $searchfilter.="(objectClass=vofficeCustomer)";
+ break;
+ case "extensions":
+ $searchfilter.="(objectClass=asteriskExtensions)";
+ break;
+ case "moh":
+ $searchfilter.="(objectClass=asteriskMusicOnHold)";
+ break;
+ case "conference":
+ $searchfilter.="(objectClass=asteriskMeetMe)";
+ break;
+ case "all":
+ default:
+ $searchfilter.="(objectClass=*)";
+ break;
+ }
+ }
+ $searchfilter .= ")";
# Collect all the possible contexts from the backend
$res = ldap_search($this->_LDAP,
*/
function _checkContextType($context, $type) {
switch ($type) {
+ case "users":
+ $searchfilter = "(objectClass=vofficeCustomer)";
+ break;
case "dialplan":
$searchfilter = "(objectClass=asteriskExtensions)";
break;
if (!$res) {
return PEAR::raiseError("Unable to get results from LDAP query");
}
- print_r($res);
+
if ($res['count'] == 1) {
return true;
} else {
return $entries;
}
// }}}
+
+ // {{{ _getHomeContext method
+ /**
+ * Returns the name of the user's default context
+ *
+ * @return string User's default context
+ */
+ function _getHomeContext()
+ {
+ $res = ldap_search($this->_LDAP,
+ SHOUT_USERS_BRANCH.','.$this->_params['basedn'],
+ "(&(mail=".Auth::getAuth().")(objectClass=asteriskUser))",
+ array('context'));
+ if (!$res) {
+ return PEAR::raiseError("Unable to locate any customers " .
+ "underneath ".SHOUT_ASTERISK_BRANCH.",".$this->_params['basedn'] .
+ " matching those search filters");
+ }
+
+ $res = ldap_get_entries($this->_LDAP, $res);
+
+ # Assume the user only has one context. The schema encforces this
+ return $res[0]['context'][0];
+ }
+ // }}}
+
+ // {{{ _getDialplan method
+ /**
+ * Get a context's dialplan and return as a multi-dimensional associative
+ * array
+ *
+ * @param string $context Context to return extensions for
+ *
+ * @return array Multi-dimensional associative array of extensions data
+ *
+ */
+ function _getDialplan($context)
+ {
+ $res = ldap_search($this->_LDAP,
+ SHOUT_ASTERISK_BRANCH.','.$this->_params['basedn'],
+ "(&(objectClass=asteriskExtensions)(context=$context))",
+ array('asteriskExtensionLine', 'asteriskIncludeLine',
+ 'asteriskIgnorePat', 'description',
+ 'asteriskExtensionBareLine'));
+ if (!$res) {
+ return PEAR::raiseError("Unable to locate any extensions " .
+ "underneath ".SHOUT_ASTERISK_BRANCH.",".$this->_params['basedn'] .
+ " matching those search filters");
+ }
+
+ $res = ldap_get_entries($this->_LDAP, $res);
+ $retdialplan = array();
+ $i = 0;
+ while ($i < $res['count']) {
+ # Handle extension lines
+ if (isset($res[$i]['asteriskextensionline'])) {
+ $j = 0;
+ while ($j < $res[$i]['asteriskextensionline']['count']) {
+ @$line = $res[$i]['asteriskextensionline'][$j];
+
+ # Basic sanity check for length. FIXME
+ if (strlen($line) < 5) {
+ break;
+ }
+ # Can't use strtok here because there may be ','s in the arg
+ # string
+
+ # Get the extension
+ $token1 = strpos($line, ',');
+ $token2 = strpos($line, ',', $token1 + 1);
+
+ $extension = substr($line, 0, $token1);
+ if (!isset($retdialplan[$extension])) {
+ $retdialplan[$extension] = array();
+ }
+ $token1++;
+ # Get the priority
+ $priority = substr($line, $token1, $token2 - $token1);
+ $retdialplan[$extension][$priority] = array();
+ $token2++;
+
+ # Get Application and args
+ $application = substr($line, $token2);
+
+ # Merge all that data into the returning array
+ $retdialplan['extensions'][$extension][$priority] =
+ $application;
+ $j++;
+ }
+
+ # Sort the extensions data
+ foreach ($retdialplan['extensions'] as $extension) {
+ ksort($extension);
+ }
+ ksort($retdialplan['extensions']);
+ }
+ # Handle include lines
+ if (isset($res[$i]['asteriskincludeline'])) {
+ $j = 0;
+ while ($j < $res[$i]['asteriskincludeline']['count']) {
+ @$line = $res[$i]['asteriskincludeline'][$j];
+ $retdialplan['include'][$j] = $line;
+ $j++;
+ }
+ }
+
+ # Handle ignorepat
+ if (isset($res[$i]['asteriskignorepat'])) {
+ $j = 0;
+ while ($j < $res[$i]['asteriskignorepat']['count']) {
+ @$line = $res[$i]['asteriskignorepat'][$j];
+ $retdialplan['include'][$j] = $line;
+ $j++;
+ }
+ }
+ # Handle ignorepat
+ if (isset($res[$i]['asteriskextensionbareline'])) {
+ $j = 0;
+ while ($j < $res[$i]['asteriskextensionbareline']['count']) {
+ @$line = $res[$i]['asteriskextensionbareline'][$j];
+ $retdialplan['bareline'][$j] = $line;
+ $j++;
+ }
+ }
+
+ # Increment object
+ $i++;
+ }
+ return $retdialplan;
+ }
+ // }}}
// {{{ getUserPhoneNumbers method
/**
$tabs = &new Horde_UI_Tabs('section', $vars);
if (Shout::checkRights("$permprefix:users") &&
- $shout->checkContextType($context, "conference")) {
+ $shout->checkContextType($context, "users")) {
$tabs->addTab(_("Users"),
Horde::applicationUrl("index.php?context=$context"),
'users');
}
if (Shout::checkRights("$permprefix:dialplan") &&
- $shout->checkContextType($context, "conference")) {
+ $shout->checkContextType($context, "dialplan")) {
$tabs->addTab(_("Dial Plan"),
Horde::applicationUrl('index.php'), 'dialplan');
}
}
if (Shout::checkRights("$permprefix:moh") &&
- $shout->checkContextType($context, "conference")) {
+ $shout->checkContextType($context, "moh")) {
$tabs->addTab(_("Music on Hold"),
Horde::applicationUrl('index.php'), 'moh');
}
-
+
+ if (Auth::isAdmin("shout:superadmin", PERMS_SHOW|PERMS_READ)) {
+ $tabs->addTab(_("Security"),
+ Horde::applicationUrl('index.php'), 'security');
+ }
+
return $tabs;
}
+++ /dev/null
-<?php
-/**
- * SelectContextForm Class
- *
- * $Horde: shout/lib/Users.php,v 1.56 2005/01/03 14:35:44 jan Exp $
- *
- * Copyright 2005 Ben Klang <ben@alkaloid.net>
- *
- * See the enclosed file LICENSE for license information (BSD). If you
- * did not receive this file, see http://www.horde.org/licenses/bsdl.php.
- *
- * @author Ben Klang <ben@alkaloid.net>
- * @package Whups
- */
-class SelectContextForm extends Horde_Form {
-
- var $_useFormToken = false;
-
- function SelectContextForm(&$vars)
- {
- global $shout;
-
- parent::Horde_Form($vars, _("Choose a context"));
-
- $contexts = $shout->getContexts("customer");
- if (count($contexts)) {
- $contexts = &$this->addVariable(_("Context"), 'context', 'enum',
- true, false, null, array($contexts, _("Choose:")));
- if (!Auth::getAuth()) {
- $this->addVariable(_("Your Email Address"), 'user_email',
- 'email', true);
- } else {
- require_once 'Horde/Form/Action.php';
- $contexts->setAction(Horde_Form_Action::factory('submit'));
- }
- } else {
- $this->addVariable(_("Context"), 'context', 'invalid', true,
- false, null, array(_("There are no contexts which you have
-permission to view.")));
- }
- }
-
-}
\ No newline at end of file
<item url="templates/" uploadstatus="2" />
<item url="lib/" uploadstatus="2" />
<item url="lib/Driver/" uploadstatus="2" />
- <item modified_time="1120296144" url="lib/Driver/ldap.php" uploadstatus="2" />
+ <item modified_time="1120357513" url="lib/Driver/ldap.php" uploadstatus="2" />
<item modified_time="1120268017" url="lib/base.php" uploadstatus="2" />
- <item modified_time="1120293699" url="lib/Driver.php" uploadstatus="2" />
- <item modified_time="1120183942" url="contexts.php" uploadstatus="2" />
- <item modified_time="1120294641" url="index.php" uploadstatus="2" />
+ <item modified_time="1120357486" url="lib/Driver.php" uploadstatus="2" />
+ <item modified_time="1120357642" url="index.php" uploadstatus="2" />
<uploadprofiles showtreeviews="true" defaultProfile="Shout" >
<profile remote_host="picasso.v-office.biz" remote_port="" remote_path="/srv/vhost/users/aklang/sites/intranet.v-office.biz/shout" remote_protocol="sftp" user="aklang" name="Shout" >
<uploadeditem upload_time="0" url="config/" />
<uploadeditem upload_time="1120073766" url="config/conf.xml" />
<uploadeditem upload_time="1120183942" url="contexts.php" />
- <uploadeditem upload_time="1120294641" url="index.php" />
+ <uploadeditem upload_time="1120355053" url="dialplan.php" />
+ <uploadeditem upload_time="1120357642" url="index.php" />
<uploadeditem upload_time="1120021874" url="index.php~" />
<uploadeditem upload_time="0" url="lib/" />
- <uploadeditem upload_time="1120293699" url="lib/Driver.php" />
+ <uploadeditem upload_time="1120357486" url="lib/Driver.php" />
<uploadeditem upload_time="1120022560" url="lib/Driver.php~" />
<uploadeditem upload_time="0" url="lib/Driver/" />
- <uploadeditem upload_time="1120296144" url="lib/Driver/ldap.php" />
+ <uploadeditem upload_time="1120357513" url="lib/Driver/ldap.php" />
<uploadeditem upload_time="1120026921" url="lib/Driver/ldap.php~" />
<uploadeditem upload_time="1120288491" url="lib/SelectContext.php" />
- <uploadeditem upload_time="1120294951" url="lib/Shout.php" />
+ <uploadeditem upload_time="1120357628" url="lib/Shout.php" />
<uploadeditem upload_time="1120279975" url="lib/Users.php" />
<uploadeditem upload_time="1120268017" url="lib/base.php" />
<uploadeditem upload_time="1120073766" url="lib/defines.php" />
<uploadeditem upload_time="1120073766" url="templates/content_page" />
<uploadeditem upload_time="0" url="templates/context/" />
<uploadeditem upload_time="1120175005" url="templates/context/contextline.inc" />
- <uploadeditem upload_time="1120293059" url="templates/menu.inc" />
- <uploadeditem upload_time="1120294295" url="users.php" />
+ <uploadeditem upload_time="0" url="templates/dialplan/" />
+ <uploadeditem upload_time="1120377494" url="templates/dialplan/dialplanlist.inc" />
+ <uploadeditem upload_time="1120357382" url="templates/menu.inc" />
+ <uploadeditem upload_time="0" url="templates/users/" />
+ <uploadeditem upload_time="1120378861" url="templates/users/userlist.inc" />
+ <uploadeditem upload_time="1120355014" url="users.php" />
</profile>
</uploadprofiles>
<debuggers>
<defaultDTD>-//w3c//dtd xhtml 1.0 strict//en</defaultDTD>
<item modified_time="1120073766" url="config/conf.xml" uploadstatus="1" />
<item url="config/" uploadstatus="1" />
- <item modified_time="1120294951" url="lib/Shout.php" uploadstatus="1" />
+ <item modified_time="1120357628" url="lib/Shout.php" uploadstatus="1" />
<author>Ben Klang</author>
<email>ben@alkaloid.net</email>
<debuggerclient>Gubed</debuggerclient>
</teamdata>
<events/>
<item modified_time="1120174958" url="templates/common-header.inc" uploadstatus="1" />
- <item modified_time="1120293059" url="templates/menu.inc" uploadstatus="1" />
- <item modified_time="1120294295" url="users.php" uploadstatus="1" />
+ <item modified_time="1120357382" url="templates/menu.inc" uploadstatus="1" />
+ <item modified_time="1120355014" url="users.php" uploadstatus="1" />
<item url="templates/context/" uploadstatus="1" />
<item modified_time="1120175005" url="templates/context/contextline.inc" uploadstatus="1" />
- <item modified_time="1120287842" url="moh.php" />
- <item modified_time="1120288491" url="lib/SelectContext.php" />
+ <item modified_time="1120287842" url="moh.php" uploadstatus="1" />
+ <item url="templates/users/" uploadstatus="1" />
+ <item modified_time="1120378861" url="templates/users/userlist.inc" uploadstatus="1" />
+ <item modified_time="1120355053" url="dialplan.php" uploadstatus="1" />
+ <item modified_time="1120377494" url="templates/dialplan/dialplanlist.inc" uploadstatus="1" />
+ <item url="templates/dialplan/" uploadstatus="1" />
<treestatus>
<openfolder url="lib" />
<openfolder url="lib/Driver" />
<openfolder url="templates" />
<openfolder url="templates/context" />
+ <openfolder url="templates/dialplan" />
+ <openfolder url="templates/users" />
</treestatus>
</project>
</webproject>
<label for="context" accesskey="<?php echo $accesskey ?>">
<select id="context" name="context" onchange="contextSubmit()">
<?php
- foreach ($shout->getContexts() as $item) {
+ foreach ($shout->getContexts("customers") as $item) {
print "<option name=\"$item\"";
if ($item == $context) {
print " selected";
define(SHOUT_BASE, dirname(__FILE__));
}
-// # Check that we are properly initialized
-// if (is_a($contexts, 'PEAR_Error')) {
-// # FIXME change this to a Horde::fatal
-// $notification->push(_("Internal error viewing requested page"),
-// 'horde.error');
-// $notification->notify();
-// require $registry->get('templates', 'horde') . '/common-footer.inc';
-// exit();
-// }
-//
-//
-// print_r($shout->getUsers($context));
\ No newline at end of file
+require SHOUT_TEMPLATES . "/users/userlist.inc";
\ No newline at end of file