From ccfd028919ee06611ebe0525a0a701830bd77516 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Tue, 14 Jun 2016 17:04:29 -0700 Subject: readme for the module directory, also provide an undocumented way to reset the timestamp on connection photos to force a refresh without messing with the database directly. --- Zotlabs/Module/Connedit.php | 22 ++++++++----- Zotlabs/Module/README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 94 insertions(+), 8 deletions(-) create mode 100644 Zotlabs/Module/README.md diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php index 33deac4c8..3feba5370 100644 --- a/Zotlabs/Module/Connedit.php +++ b/Zotlabs/Module/Connedit.php @@ -16,14 +16,14 @@ require_once('include/zot.php'); require_once('include/widgets.php'); require_once('include/photos.php'); -/* @brief Initialize the connection-editor - * - * - */ - class Connedit extends \Zotlabs\Web\Controller { + /* @brief Initialize the connection-editor + * + * + */ + function init() { if(! local_channel()) @@ -51,7 +51,7 @@ class Connedit extends \Zotlabs\Web\Controller { * */ - function post() { + function post() { if(! local_channel()) return; @@ -357,7 +357,7 @@ class Connedit extends \Zotlabs\Web\Controller { * */ - function get() { + function get() { $sort_type = 0; $o = ''; @@ -418,7 +418,13 @@ class Connedit extends \Zotlabs\Web\Controller { goaway(z_root() . '/connedit/' . $contact_id); } - + if($cmd === 'resetphoto') { + q("update xchan set xchan_photo_date = '2001-01-01 00:00:00' where xchan_hash = '%s' limit 1", + dbesc($orig_record[0]['xchan_hash']) + ); + $cmd = 'refresh'; + } + if($cmd === 'refresh') { if($orig_record[0]['xchan_network'] === 'zot') { if(! zot_refresh($orig_record[0],\App::get_channel())) diff --git a/Zotlabs/Module/README.md b/Zotlabs/Module/README.md new file mode 100644 index 000000000..3b870dd7b --- /dev/null +++ b/Zotlabs/Module/README.md @@ -0,0 +1,80 @@ +Zotlabs/Module +============== + + +This directory contains controller modules for handling web requests. The +lowercase class name indicates the head of the URL path which this module +handles. There are other methods of attaching (routing) URL paths to +controllers, but this is the primary method used in this project. + +Module controllers MUST reside in this directory and namespace to be +autoloaded (unless other specific routing methods are employed). They +typically use and extend the class definition in Zotlabs/Web/Controller +as a template. + +Template: + + Date: Tue, 14 Jun 2016 20:30:34 -0700 Subject: support cookie auth in Sabre DAV --- Zotlabs/Storage/BasicAuth.php | 53 +++++++++++++++++++++++++++++++++++++++++++ Zotlabs/Web/Controller.php | 3 ++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/Zotlabs/Storage/BasicAuth.php b/Zotlabs/Storage/BasicAuth.php index 121a9c3a1..60fc2c988 100644 --- a/Zotlabs/Storage/BasicAuth.php +++ b/Zotlabs/Storage/BasicAuth.php @@ -3,6 +3,8 @@ namespace Zotlabs\Storage; use Sabre\DAV; +use Sabre\HTTP\RequestInterface; +use Sabre\HTTP\ResponseInterface; /** * @brief Authentication backend class for DAV. @@ -145,6 +147,57 @@ class BasicAuth extends DAV\Auth\Backend\AbstractBasic { return true; } + /** + * When this method is called, the backend must check if authentication was + * successful. + * + * The returned value must be one of the following + * + * [true, "principals/username"] + * [false, "reason for failure"] + * + * If authentication was successful, it's expected that the authentication + * backend returns a so-called principal url. + * + * Examples of a principal url: + * + * principals/admin + * principals/user1 + * principals/users/joe + * principals/uid/123457 + * + * If you don't use WebDAV ACL (RFC3744) we recommend that you simply + * return a string such as: + * + * principals/users/[username] + * + * @param RequestInterface $request + * @param ResponseInterface $response + * @return array + */ + function check(RequestInterface $request, ResponseInterface $response) { + + if(local_channel()) { + return [ true, $this->principalPrefix . $this->channel_name ]; + } + + $auth = new \Sabre\HTTP\Auth\Basic( + $this->realm, + $request, + $response + ); + + $userpass = $auth->getCredentials(); + if (!$userpass) { + return [false, "No 'Authorization: Basic' header found. Either the client didn't send one, or the server is misconfigured"]; + } + if (!$this->validateUserPass($userpass[0], $userpass[1])) { + return [false, "Username or password was incorrect"]; + } + return [true, $this->principalPrefix . $userpass[0]]; + + } + protected function check_module_access($channel_id) { if($channel_id && \App::$module === 'cdav') { $x = get_pconfig($channel_id,'cdav','enabled'); diff --git a/Zotlabs/Web/Controller.php b/Zotlabs/Web/Controller.php index ac835e008..2d0f58891 100644 --- a/Zotlabs/Web/Controller.php +++ b/Zotlabs/Web/Controller.php @@ -9,4 +9,5 @@ class Controller { function post() {} function get() {} -} \ No newline at end of file +} + -- cgit v1.2.3 From 47fc0c79588d55a207dc39ae8062ec55382e2564 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 15 Jun 2016 05:28:16 -0700 Subject: add new connection to default group when auto-accepted --- include/follow.php | 2 +- include/zot.php | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/follow.php b/include/follow.php index 0c3973175..e5a74f85e 100644 --- a/include/follow.php +++ b/include/follow.php @@ -275,7 +275,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) call_hooks('follow', $arr); - /** If there is a default group for this channel, add this member to it */ + /** If there is a default group for this channel, add this connection to it */ if($default_group) { require_once('include/group.php'); diff --git a/include/zot.php b/include/zot.php index af79b5723..043139e2f 100644 --- a/include/zot.php +++ b/include/zot.php @@ -538,6 +538,16 @@ function zot_refresh($them, $channel = null, $force = false) { Zotlabs\Daemon\Master::Summon(array('Onepoll',$new_connection[0]['abook_id'])); } + + /** If there is a default group for this channel, add this connection to it */ + $default_group = $channel['channel_default_group']; + if($default_group) { + require_once('include/group.php'); + $g = group_rec_byhash($channel['channel_id'],$default_group); + if($g) + group_add_member($channel['channel_id'],'',$x['hash'],$g['id']); + } + unset($new_connection[0]['abook_id']); unset($new_connection[0]['abook_account']); unset($new_connection[0]['abook_channel']); -- cgit v1.2.3 From 476116a972c0f8b8ade495de557b8fc8d3097964 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Wed, 15 Jun 2016 16:24:45 -0700 Subject: translate already imported system apps --- Zotlabs/Lib/Apps.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index ed06943a1..20556212a 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -264,6 +264,8 @@ class Apps { if(! $papp['photo']) $papp['photo'] = z_root() . '/' . get_default_profile_photo(80); + self::translate_system_apps($papp); + $papp['papp'] = self::papp_encode($papp); if(! strstr($papp['url'],'://')) -- cgit v1.2.3