<h1>Project "FreeSWITCH user-contributed scripts, etc" received a push.</h1>

<h2>branch: master updated</h2>
<pre>
       via: 8b7b83f0a42fc7cce5deaacd1c3a56f76c392175 (commit)
      from: 7f89d85adb464f103abda4c3cee75a10f9515921 (commit)


</pre>= COMMIT LOG ===========================================================
<div class="highlight"><pre>committer: Mathieu Parent
comments: 
MediaBrotha: adding LDAP backend

<span style="color: #000080; font-weight: bold">diff --git a/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
new file mode 100644
<span style="color: #000080; font-weight: bold">index 0000000..d275ff1</span>
<span style="color: #A00000">--- /dev/null</span>
<span style="color: #00A000">+++ b/sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php</span>
<span style="color: #800080; font-weight: bold">@@ -0,0 +1,88 @@</span>
<span style="color: #00A000">+&lt;?php</span>
<span style="color: #00A000">+/*</span>
<span style="color: #00A000">+Copyright 2011 Mathieu Parent &lt;math.parent@gmail.com&gt; </span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+This file is part of MediaBrotha.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        MediaBrotha is free software: you can</span>
<span style="color: #00A000">+        redistribute it and/or modify it under the terms of the GNU General</span>
<span style="color: #00A000">+        Public License as published by the Free Software Foundation, either</span>
<span style="color: #00A000">+        version 3 of the License, or (at your option) any later version.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        MediaBrotha is distributed in the hope that it</span>
<span style="color: #00A000">+        will be useful, but WITHOUT ANY WARRANTY; without even the implied</span>
<span style="color: #00A000">+        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See</span>
<span style="color: #00A000">+        the GNU General Public License for more details.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        You should have received a copy of the GNU General Public License</span>
<span style="color: #00A000">+        along with MediaBrotha. If not, see</span>
<span style="color: #00A000">+        &lt;http://www.gnu.org/licenses/&gt;.</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+*/</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+require_once(&#39;Net/LDAP2.php&#39;);</span>
<span style="color: #00A000">+/**</span>
<span style="color: #00A000">+ * @author Mathieu Parent</span>
<span style="color: #00A000">+ */</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+class MediaBrotha_Backend_LDAP extends MediaBrotha_Backend {</span>
<span style="color: #00A000">+        private $_ldap;</span>
<span style="color: #00A000">+        public function __construct(array $args = Array()) {</span>
<span style="color: #00A000">+                parent::__construct($args);</span>
<span style="color: #00A000">+                $this-&gt;_ldap = Net_LDAP2::connect($this-&gt;getMetadata(&#39;ldap_connect_config&#39;));</span>
<span style="color: #00A000">+                if (Net_LDAP2::isError($this-&gt;_ldap)) {</span>
<span style="color: #00A000">+                        die(&#39;Could not fetch entry: &#39;.$this-&gt;_ldap-&gt;getMessage());</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        public function register() {</span>
<span style="color: #00A000">+                parent::register();</span>
<span style="color: #00A000">+                MediaBrotha_Core::registerMimeType($this, &#39;text/directory&#39;);</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function capabilities($uri = NULL, $mime_type = NULL, $mime_encoding = NULL) {</span>
<span style="color: #00A000">+                return Array(</span>
<span style="color: #00A000">+                        &#39;browse&#39;,</span>
<span style="color: #00A000">+                );</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        public function isURISafe($uri) {</span>
<span style="color: #00A000">+                return true;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        </span>
<span style="color: #00A000">+        public static function parseLDAPURI($uri, $component = NULL) {</span>
<span style="color: #00A000">+                $uri = preg_replace(&#39;@^ldap:///@&#39;, &#39;ldap://fake_host/&#39;, $uri);</span>
<span style="color: #00A000">+                $components = parse_url($uri, $component);</span>
<span style="color: #00A000">+                if (is_array($components) &amp;&amp; ($components[&#39;host&#39;] === &#39;fake_host&#39;)) {</span>
<span style="color: #00A000">+                        $components[&#39;host&#39;] = NULL;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                return $components;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+</span>
<span style="color: #00A000">+        // Capability browse</span>
<span style="color: #00A000">+        public function fetch($uri) {</span>
<span style="color: #00A000">+                if (($this::parseLDAPURI($uri, PHP_URL_SCHEME) != &#39;ldap&#39;) || !$this-&gt;isURISafe($uri)) {</span>
<span style="color: #00A000">+                        $ldap_connect_config = $this-&gt;getMetadata(&#39;ldap_connect_config&#39;);</span>
<span style="color: #00A000">+                        $uri = &#39;ldap:///&#39;.$ldap_connect_config[&#39;basedn&#39;];</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                $basedn = $this::parseLDAPURI($uri, PHP_URL_PATH);</span>
<span style="color: #00A000">+                if ($basedn &amp;&amp; ($basedn{0} = &#39;/&#39;)) {</span>
<span style="color: #00A000">+                        $basedn = substr($basedn, 1);        </span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+                $this-&gt;_buffer = $this-&gt;_ldap-&gt;search($basedn, NULL,</span>
<span style="color: #00A000">+                        Array());</span>
<span style="color: #00A000">+                return true;</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+        protected function _mediaFromBufferItem($entry) {</span>
<span style="color: #00A000">+                if ($entry) {</span>
<span style="color: #00A000">+                        $media = new MediaBrotha_Media(Array(</span>
<span style="color: #00A000">+                                &#39;uri&#39; =&gt; &#39;ldap:///&#39;.$entry-&gt;dn(),</span>
<span style="color: #00A000">+                                &#39;name&#39; =&gt; $entry-&gt;dn(), //$entry-&gt;getValue(&#39;sn&#39;, &#39;single&#39;),</span>
<span style="color: #00A000">+                        ));</span>
<span style="color: #00A000">+                        $media-&gt;setMimeType(&#39;text/directory&#39;);</span>
<span style="color: #00A000">+                        //        $media-&gt;setMimeEncoding($finfo-&gt;file($file-&gt;getPathname(), FILEINFO_MIME_ENCODING));</span>
<span style="color: #00A000">+                        return $media;</span>
<span style="color: #00A000">+                }</span>
<span style="color: #00A000">+        }</span>
<span style="color: #00A000">+}</span>
<span style="color: #00A000">+</span>
</pre></div>
========================================================================<pre>

Summary of changes:
 sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php |   88 ++++++++++++++++++++
 1 files changed, 88 insertions(+), 0 deletions(-)
 create mode 100644 sathieu/cisco-xml/lib/MediaBrotha/Backend/LDAP.php
</pre>
<p>this email was generated because of /git/your-repo.git/hooks/post-receive by the file /git-core/contrib/hooks/post-receive-email<br />
For more info, see <a href="http://blog.chomperstomp.com/?p=630">http://blog.chomperstomp.com/?p=630</a>
-- <br />
FreeSWITCH user-contributed scripts, etc</p>