chwala webdav with nextcloud

Mihai Badici <[email protected]> Wed, 30 Oct 2024 22:09:19 +0200
Newsgroups gmane.comp.kde.devel.kroupware
Message-ID <9cb54a90-04b2-4134-a873-1e46faceab41__32467.4164455914$1730318990$gmane$org@badici.ro>
This is a multi-part message in MIME format.
--===============4913940137077888018==
Content-Type: multipart/alternative;
 boundary="------------U5tlvx8xHG2JLIqdiu2JtRc4"
Content-Language: en-US

This is a multi-part message in MIME format.
--------------U5tlvx8xHG2JLIqdiu2JtRc4
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

I remember I had this working in the past.

Now Nextcloud made the things complicated because by default it assign 
to  ldap users some random id's . But in advanced configuration it is 
still possible to change the id's to user's uid or mail ( seems to be 
distructive if you already use nextcloud but should work for new 
installations.

After changing the mapping I still have problems because in this config:

$config['fileapi_sources'] = array(


  'private-nextcloud' => array(
        'driver'   => 'webdav',
        'baseuri'  => 'http://localhost/cloud/remote.php/dav/files/',
        'username' => '%u',
        'password' => '%p',
    ),

the %u is not expanded in baseuri to the user name.

I was able to solve that changing in functioninit()

$this->client = newClient(array(
'baseUri' => rtrim($this->config['baseuri'], '/') . 
'/'.$this->config['username'].'/',

   but this need to be removed in

functionget_relative_url($url)
{
$url= $this->client->getAbsoluteUrl($url);

// added by me:

$url=trim(str_replace($this->config['username'],'',$url),'/');
returntrim(str_replace($this->config['baseuri'], '', $url), '/');
    }

I think this can be useful for accessing private webdav folders so maybe 
can be added in the official driver, probably the simplest way is to 
allow wildcards in baseuri, this should keep the driver itself unchanged.

Mihai

--------------U5tlvx8xHG2JLIqdiu2JtRc4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I remember I had this working in the past.</p>
    <p>Now Nextcloud made the things complicated because by default it
      assign to  ldap users some random id's . But in advanced
      configuration it is still possible to change the id's to user's
      uid or mail ( seems to be distructive if you already use nextcloud
      but should work for new installations.</p>
    <p>After changing the mapping I still have problems because in this
      config:</p>
    <p><span style="font-family:monospace"><span
          style="color:#000000;background-color:#ffffff;">$config['fileapi_sources']
          = array(
        </span><br>
        <br>
        <br>
         'private-nextcloud' =&gt; array(
        <br>
               'driver'   =&gt; 'webdav',
        <br>
               'baseuri'  =&gt;
        '<a class="moz-txt-link-freetext" href="http://localhost/cloud/remote.php/dav/files/">http://localhost/cloud/remote.php/dav/files/</a>',
        <br>
               'username' =&gt; '%u',
        <br>
               'password' =&gt; '%p',
        <br>
           ),<br>
        <br>
      </span></p>
    <p>the %u is not expanded in baseuri to the user name. <span
        style="font-family:monospace"><br>
      </span></p>
    <p>I was able to solve that changing in function<span
        style="font-family:monospace"> init()</span></p>
    <p><span style="font-family:monospace"><span
          style="color:#000000;background-color:#ffffff;">  </span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;client =
        </span><span
style="font-weight:bold;color:#54ffff;background-color:#ffffff;">new</span><span
          style="color:#000000;background-color:#ffffff;"> </span><span
          style="color:#b2b2b2;background-color:#ffffff;">Client(</span><span
          style="color:#18b218;background-color:#ffffff;">array</span><span
          style="color:#b2b2b2;background-color:#ffffff;">(</span><span
          style="color:#000000;background-color:#ffffff;">
        </span><br>
                   <span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'baseUri'</span><span
          style="color:#000000;background-color:#ffffff;">  =&gt; </span><span
          style="color:#b2b2b2;background-color:#ffffff;">rtrim(</span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;config[</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'baseuri'</span><span
          style="color:#000000;background-color:#ffffff;">], </span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'/'</span><span
          style="color:#000000;background-color:#ffffff;">) . </span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'/'</span><span
          style="color:#000000;background-color:#ffffff;">.</span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;config[</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'username'</span><span
          style="color:#000000;background-color:#ffffff;">].</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'/'</span><span
          style="color:#000000;background-color:#ffffff;">,
        </span><br>
           <br>
      </span></p>
    <p>  but this need to be removed in <br>
    </p>
    <p><span style="font-family:monospace"><span
style="font-weight:bold;color:#54ffff;background-color:#ffffff;">function</span><span
          style="color:#000000;background-color:#ffffff;"> </span><span
          style="color:#b2b2b2;background-color:#ffffff;">get_relative_url(</span><span
          style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;">)</span><br>
      </span><span style="font-family:monospace"><span
          style="color:#000000;background-color:#ffffff;"> {
        </span><br>
               <span style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;"> = </span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;client-&gt;</span><span
          style="color:#b2b2b2;background-color:#ffffff;">getAbsoluteUrl(</span><span
          style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;">);</span></span></p>
    <p><span style="font-family:monospace"><span
          style="color:#000000;background-color:#ffffff;">// added by
          me: </span><br>
      </span></p>
    <p><span style="font-family:monospace">         <span
          style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;">=</span><span
          style="color:#b2b2b2;background-color:#ffffff;">trim(str_replace(</span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;config[</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'username'</span><span
          style="color:#000000;background-color:#ffffff;">],</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">''</span><span
          style="color:#000000;background-color:#ffffff;">,</span><span
          style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;">),</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'/'</span><span
          style="color:#000000;background-color:#ffffff;">);
        </span><br>
               <span style="color:#b218b2;background-color:#ffffff;">return</span><span
          style="color:#000000;background-color:#ffffff;"> </span><span
          style="color:#b2b2b2;background-color:#ffffff;">trim(str_replace(</span><span
          style="color:#18b2b2;background-color:#ffffff;">$this</span><span
          style="color:#000000;background-color:#ffffff;">-&gt;config[</span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'baseuri'</span><span
          style="color:#000000;background-color:#ffffff;">], </span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">''</span><span
          style="color:#000000;background-color:#ffffff;">, </span><span
          style="color:#18b2b2;background-color:#ffffff;">$url</span><span
          style="color:#000000;background-color:#ffffff;">), </span><span
style="font-weight:bold;color:#ffff54;background-color:#ffffff;">'/'</span><span
          style="color:#000000;background-color:#ffffff;">);
        </span><br>
           }
        <br>
        <br>
        I think this can be useful for accessing private webdav folders
        so maybe can be added in the official driver, probably the
        simplest way is to allow wildcards in baseuri, this should keep
        the driver itself unchanged.</span></p>
    <p><span style="font-family:monospace">Mihai<br>
      </span><span style="font-family:monospace"><br>
      </span></p>
  </body>
</html>

--------------U5tlvx8xHG2JLIqdiu2JtRc4--

--===============4913940137077888018==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
users mailing list
[email protected]
https://lists.kolab.org/mailman/listinfo/users

--===============4913940137077888018==--