via: 93112a4f782c3e44108439e6fdeb7789482735d4 (commit)
via: b98a258f545eea7976d80c2bb6450a73caa9dd3c (commit)
via: 55ef55a5a9e951b26c52b3d2f0e5f902e568f1f9 (commit)
via: ca8489d71e127d5ff7beafbd91bcf5f9c683dd8d (commit)
via: 0cb41713987185aec7f42c9cff174b6d2757e460 (commit)
via: c2e63f1d8fc269cf17bd85d534c9099af8a454b6 (commit)
via: ee436d35144c7d85629d2c7356db64d5f392d1ff (commit)
from: 32250fa69ff8b942ca99c4eaabafde285cc27c9a (commit)
= COMMIT LOG ===========================================================
committer: Mitch Capper
comments:
Merge branch 'master' of ssh://git.freeswitch.org/freeswitch-contrib
committer: Mathieu Parent
comments:
MediaBortha: fix HTML form (hidden fields)
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
index 1c0454a..feb98e8 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
@@ -137,23 +137,28 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {
foreach($form as $field) {
if ($field->get('visibility') === 'hidden') {
- continue;
+ $inputElement = $this->_xml->createElement('input');
+ $inputElement = $formElement->appendChild($inputElement);
+ $inputElement->setAttribute('name', $field->get('name'));
+ $inputElement->setAttribute('value', $field->get('value'));
+ $inputElement->setAttribute('type', 'hidden');
+ } else {
+ $trElement = $this->_xml->createElement('tr');
+ $trElement = $tableElement->appendChild($trElement);
+
+ $tdElement1 = $this->_xml->createElement('th');
+ $tdElement1 = $trElement->appendChild($tdElement1);
+ $text1 = $this->_xml->createTextNode($field->get('display_name'));
+ $text1 = $tdElement1->appendChild($text1);
+
+ $tdElement2 = $this->_xml->createElement('td');
+ $tdElement2 = $trElement->appendChild($tdElement2);
+
+ $inputElement = $this->_xml->createElement('input');
+ $inputElement = $tdElement2->appendChild($inputElement);
+ $inputElement->setAttribute('name', $field->get('name'));
+ $inputElement->setAttribute('value', $field->get('value'));
}
- $trElement = $this->_xml->createElement('tr');
- $trElement = $tableElement->appendChild($trElement);
-
- $tdElement1 = $this->_xml->createElement('th');
- $tdElement1 = $trElement->appendChild($tdElement1);
- $text1 = $this->_xml->createTextNode($field->get('display_name'));
- $text1 = $tdElement1->appendChild($text1);
-
- $tdElement2 = $this->_xml->createElement('td');
- $tdElement2 = $trElement->appendChild($tdElement2);
-
- $inputElement = $this->_xml->createElement('input');
- $inputElement = $tdElement2->appendChild($inputElement);
- $inputElement->setAttribute('name', $field->get('name'));
- $inputElement->setAttribute('value', $field->get('value'));
}
$trElement = $this->_xml->createElement('tr');
committer: Mathieu Parent
comments:
MediaBrotha: LDAP search and result
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php
index 2b04351..a1a0e98 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php
@@ -50,16 +50,22 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {
// Browsing
public function mediaFromBufferItem($entry) {
- if ($entry) {
- $media = new MediaBrotha_Media(
+ if (is_a($entry, 'Net_LDAP2_Entry')) {
+ return new MediaBrotha_Media(
'ldap:///'.$entry->dn(),
Array(
'display_name' => $entry->dn(), //$entry->getValue('sn', 'single'),
),
'text/directory'
- //$finfo->file($file->getPathname(), FILEINFO_MIME_ENCODING);
);
- return $media;
+ } else {
+ return new MediaBrotha_Media(
+ 'ldap:///',
+ Array(
+ 'display_name' => $entry[0].': '.$entry[1],
+ ),
+ 'text/directory'
+ );
}
}
@@ -73,8 +79,10 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {
if ($this->_isHandled($media)) {
return Array(
'_default',
+ 'detail',
'browse',
'search',
+ '_search-result',
);
} else {
return parent::getMediaActions($media);
@@ -92,13 +100,48 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {
if ($basedn && ($basedn{0} = '/')) {
$basedn = substr($basedn, 1);
}
- $ldap_search = $this->_ldap->search($basedn, NULL,
- Array());
+ $ldap_search = $this->_ldap->search($basedn, NULL, Array());
return new MediaBrotha_MediaIterator($this, $ldap_search);
+ case 'detail':
+ $uri = $media->getURI();
+ if (($this::parseLDAPURI($uri, PHP_URL_SCHEME) != 'ldap') || !$this->isURISafe($uri)) {
+ return false;
+ }
+ $basedn = $this::parseLDAPURI($uri, PHP_URL_PATH);
+ if ($basedn && ($basedn{0} = '/')) {
+ $basedn = substr($basedn, 1);
+ }
+ $ldap_entry = $this->_ldap->getEntry($basedn);
+ $it = new ArrayIterator();
+ foreach ($ldap_entry->attributes() as $attr) {
+ foreach($ldap_entry->getValue($attr, 'all') as $value) {
+ $it[] = Array($attr, $value);
+ }
+ }
+ return new MediaBrotha_MediaIterator($this, $it);
case '_default':
case 'search':
+ case '_search-result':
$form = new MediaBrotha_Form();
$form->setTitle('search');
+ $form->addField(Array(
+ 'name' => 'backend',
+ 'value' => 'LDAP',
+ 'visibility' => 'hidden',
+ )
+ );
+ $form->addField(Array(
+ 'name' => 'action',
+ 'value' => '_search-result',
+ 'visibility' => 'hidden',
+ )
+ );
+ $form->addField(Array(
+ 'name' => 'uri',
+ 'value' => 'ldap://',
+ 'visibility' => 'hidden',
+ )
+ );
$search_fields = Array(
'sn' => Array('display_name' => 'last name'),
'givenName' => Array('display_name' => 'first name'),
@@ -124,22 +167,15 @@ class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {
}
$form->addField($field);
}
- if (empty($_GET['ldap_search'])) {
- MediaBrotha_Core::addCallback('MediaBrotha_Backend_LDAP::searchCallback');
+ if ($action !== '_search-result') {
return $form;
} else {
- $ldap_search = $this->_ldap->search(NULL, $filter,
- Array('scope' => 'sub'));
+ $ldap_search = $this->_ldap->search(NULL, $filter, Array('scope' => 'sub'));
return new MediaBrotha_MediaIterator($this, $ldap_search);
}
default:
return parent::doMediaAction($action, $media);
}
}
- static public function searchCallback() {
- $_GET['backend'] = 'LDAP';
- $_GET['action'] = 'search';
- $_GET['ldap_search'] = '1';
- }
}
committer: Mathieu Parent
comments:
MediaBrotha: avoid error on first connection because of unset session
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Core.php b/sathieu/cisco-xml/lib/MediaBrotha/Core.php
index 9e53e13..7758a55 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Core.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Core.php
@@ -202,6 +202,8 @@ class MediaBrotha_Core {
if ($v = MediaBrotha_Core::hash2value($h)) {
parse_str($v, $output);
return $output;
+ } else {
+ return Array();
}
}
committer: Mathieu Parent
comments:
MediaBrotha: add ability to pass params by using hidden fields
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Form.php b/sathieu/cisco-xml/lib/MediaBrotha/Form.php
index 08dd4c6..509341a 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Form.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Form.php
@@ -40,6 +40,7 @@ class MediaBrotha_Field {
class MediaBrotha_Form extends ArrayIterator {
private $_title;
+
public function getTitle() {
return $this->_title;
}
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
index d859829..0f31ee1 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
@@ -72,11 +72,20 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {
}
public function renderForm(MediaBrotha_Form $form) {
+ foreach($form as $field) {
+ if ($field->get('visibility') === 'hidden') {
+ $params[$field->get('name')] = $field->get('value');
+ }
+ }
$xml = new CiscoIPPhoneInput();
$xml->setCiscoElement('Title', $form->getTitle());
//$xml->setCiscoElement('Prompt', ...);
- $xml->setCiscoElement('URL', $this->rootURL());
+ $xml->setCiscoElement('URL', $this->rootURL().'?'.MediaBrotha_Core::value2hash(http_build_query($params)));
+ $params = Array();
foreach($form as $field) {
+ if ($field->get('visibility') === 'hidden') {
+ continue;
+ }
$flags = 'A';
$xml->setCiscoElement('InputItem',
Array(
@@ -88,6 +97,19 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {
);
}
+
+ $xml->setCiscoElement('SoftKeyItem',
+ Array('Name' => 'Search',
+ 'URL' => 'SoftKey:Submit',
+ 'Position' => 1));
+ $xml->setCiscoElement('SoftKeyItem',
+ Array('Name' => '<<',
+ 'URL' => 'SoftKey:<<',
+ 'Position' => 2));
+ $xml->setCiscoElement('SoftKeyItem',
+ Array('Name' => 'Exit',
+ 'URL' => 'SoftKey:Exit',
+ 'Position' => 3));
CiscoXMLObject::HttpHeader();
print $xml;
}
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
index c1ea4df..1c0454a 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
@@ -56,6 +56,7 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {
private function _createHTMLDocument($title) {
$this->_xml = new DOMDocument('1.0');
+ $this->_xml->formatOutput = true;
$root = $this->_xml->createElement('html');
$root = $this->_xml->appendChild($root);
@@ -135,6 +136,9 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {
$tableElement = $formElement->appendChild($tableElement);
foreach($form as $field) {
+ if ($field->get('visibility') === 'hidden') {
+ continue;
+ }
$trElement = $this->_xml->createElement('tr');
$trElement = $tableElement->appendChild($trElement);
committer: Mathieu Parent
comments:
MediaBrotha: add ability to force Cisco-XML mode
diff --git a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php
index 0da1cc3..82226f4 100644
--- a/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php
+++ b/sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php
@@ -26,7 +26,7 @@ This file is part of XML services for Cisco IP Phones.
class CiscoIPPhone {
static public function userAgentIsCiscoIPPhone() {
if (isset($_SERVER['HTTP_USER_AGENT'])) {
- return preg_match('/^Allegro-Software-WebClient\//', $_SERVER['HTTP_USER_AGENT']);
+ return preg_match('/^Allegro-Software-WebClient\//', $_SERVER['HTTP_USER_AGENT']) || isset($_GET['forceciscoxml']);
}
}
committer: Mathieu Parent
comments:
MediaBrotha:
- do not display the _default action
- ensure session arrays are set
- limit MenuItem > Name to 64 chars
- Cisco IP Phone need a field flag of 1 char
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php
index 8e56562..f85b59f 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Backend.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend.php
@@ -67,6 +67,16 @@ abstract class MediaBrotha_Backend {
}
// Actions
+ final public function getVisibleMediaActions(MediaBrotha_Media $media) {
+ $actions = Array();
+ foreach ($this->getMediaActions($media) as $action) {
+ if ($action{0} !== '_') {
+ $actions[] = $action;
+ }
+ }
+ return $actions;
+ }
+
public function getMediaActions(MediaBrotha_Media $media) {
return Array();
}
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Core.php b/sathieu/cisco-xml/lib/MediaBrotha/Core.php
index f241c66..9e53e13 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Core.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Core.php
@@ -43,6 +43,12 @@ class MediaBrotha_Core {
if (!session_start()) {
throw new Exception('Unable to start session');
}
+ if (!isset($_SESSION['HASHES'])) {
+ $_SESSION['HASHES'] = Array();
+ }
+ if (!isset($_SESSION['CALLBACK'])) {
+ $_SESSION['CALLBACK'] = Array();
+ }
MediaBrotha_Core::_unhashRequest();
MediaBrotha_Core::loadBackend('Root');
} catch (Exception $e) {
@@ -200,9 +206,6 @@ class MediaBrotha_Core {
}
private static function _unhashRequest() {
- if (!isset($_SESSION['HASHES'])) {
- $_SESSION['HASHES'] = Array();
- }
if (isset($_SERVER["QUERY_STRING"])) {
$tmp = explode('&', $_SERVER["QUERY_STRING"]);
foreach ($tmp as $h) {
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
index 1bf85b7..d859829 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/CiscoXML.php
@@ -43,7 +43,7 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {
($item->getMimeEncoding() ? ('mime_encoding='.urlencode($item->getMimeEncoding()).'&') : '').
'uri='.urlencode($item->getURI()));
$this->_xml->setCiscoElement('MenuItem',
- Array('Name' => $item->getDisplayName(), 'URL' => $url));
+ Array('Name' => $item->getDisplayName(64), 'URL' => $url));
}
public function finish($item) {
$pos = 1;
@@ -52,7 +52,7 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {
'URL' => 'SoftKey:Select',
'Position' => $pos++));
foreach (MediaBrotha_Core::getBackends() as $backend) {
- foreach ($backend->getMediaActions($item) as $action) {
+ foreach ($backend->getVisibleMediaActions($item) as $action) {
$this->_xml->setCiscoElement('SoftKeyItem',
Array('Name' => $action,
'URL' => 'QueryStringParam:'.MediaBrotha_Core::value2hash('action='.$action.'&backend='.$backend->getBackendName()),
@@ -77,12 +77,13 @@ class MediaBrotha_Frontend_CiscoXML extends MediaBrotha_Frontend_HTTP {
//$xml->setCiscoElement('Prompt', ...);
$xml->setCiscoElement('URL', $this->rootURL());
foreach($form as $field) {
+ $flags = 'A';
$xml->setCiscoElement('InputItem',
Array(
'DisplayName' => $field->get('display_name'),
'QueryStringParam' => $field->get('name'),
'DefaultValue' => $field->get('value'),
- 'InputFlags' => '',
+ 'InputFlags' => $flags,
)
);
diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
index f6d4015..c1ea4df 100644
--- a/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
+++ b/sathieu/cisco-xml/lib/MediaBrotha/Frontend/HTML.php
@@ -40,7 +40,7 @@ class MediaBrotha_Frontend_HTML extends MediaBrotha_Frontend_HTTP {
'uri='.urlencode($media->getURI()));
foreach (MediaBrotha_Core::getBackends() as $backend) {
- foreach ($backend->getMediaActions($media) as $action) {
+ foreach ($backend->getVisibleMediaActions($media) as $action) {
$tag = $this->_xml->createElement($tag_name);
$tag = $parent->appendChild($tag);
Summary of changes: sathieu/cisco-xml/lib/Cisco-XML/Cisco-XML.php | 2 +- sathieu/cisco-xml/lib/MediaBrotha/Backend.php | 10 +++ sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php | 66 +++++++++++++++----- sathieu/cisco-xml/lib/MediaBrotha/Core.php | 11 +++- sathieu/cisco-xml/lib/MediaBrotha/Form.php | 1 + .../lib/MediaBrotha/Frontend/CiscoXML.php | 31 ++++++++- .../cisco-xml/lib/MediaBrotha/Frontend/HTML.php | 41 ++++++++----- 7 files changed, 123 insertions(+), 39 deletions(-)
this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email
For more info, see http://blog.chomperstomp.com/?p=630
--
FreeSWITCH user-contributed scripts, etc