aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Module/Block.php8
-rw-r--r--Zotlabs/Module/Blocks.php13
-rw-r--r--Zotlabs/Module/Connedit.php22
-rw-r--r--Zotlabs/Module/Display.php5
-rw-r--r--Zotlabs/Module/Editblock.php4
-rw-r--r--Zotlabs/Module/Editlayout.php5
-rw-r--r--Zotlabs/Module/Editwebpage.php4
-rw-r--r--Zotlabs/Module/Impel.php26
-rw-r--r--Zotlabs/Module/Item.php30
-rw-r--r--Zotlabs/Module/Layouts.php20
-rw-r--r--Zotlabs/Module/Page.php20
-rw-r--r--Zotlabs/Module/README.md80
-rw-r--r--Zotlabs/Module/Webpages.php18
-rw-r--r--Zotlabs/Module/Wiki.php4
-rw-r--r--Zotlabs/Render/Comanche.php9
-rw-r--r--Zotlabs/Storage/BasicAuth.php53
-rw-r--r--Zotlabs/Web/Controller.php3
17 files changed, 235 insertions, 89 deletions
diff --git a/Zotlabs/Module/Block.php b/Zotlabs/Module/Block.php
index 062befdb5..45e61e4ea 100644
--- a/Zotlabs/Module/Block.php
+++ b/Zotlabs/Module/Block.php
@@ -52,8 +52,8 @@ class Block extends \Zotlabs\Web\Controller {
require_once('include/security.php');
$sql_options = item_permissions_sql($u[0]['channel_id']);
- $r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and
+ $r = q("select item.* from item left join iconfig on item.id = iconfig.iid
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and iconfig.k = 'BUILDBLOCK' and
item_type = %d $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
@@ -64,8 +64,8 @@ class Block extends \Zotlabs\Web\Controller {
// Check again with no permissions clause to see if it is a permissions issue
- $x = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and service = 'BUILDBLOCK' and
+ $x = q("select item.* from item left join iconfig on item.id = iconfig.iid
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and iconfig.k = 'BUILDBLOCK' and
item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
diff --git a/Zotlabs/Module/Blocks.php b/Zotlabs/Module/Blocks.php
index 32650a090..475cfa6b3 100644
--- a/Zotlabs/Module/Blocks.php
+++ b/Zotlabs/Module/Blocks.php
@@ -27,7 +27,7 @@ class Blocks extends \Zotlabs\Web\Controller {
}
- function get() {
+ function get() {
if(! \App::$profile) {
notice( t('Requested profile is not available.') . EOL );
@@ -111,8 +111,11 @@ class Blocks extends \Zotlabs\Web\Controller {
$editor = status_editor($a,$x);
- $r = q("select iid, sid, mid, title, body, mimetype, created, edited from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'BUILDBLOCK' and item_type = %d order by item.created desc",
+
+ $r = q("select iconfig.iid, iconfig.k, iconfig.v, mid, title, body, mimetype, created, edited from iconfig
+ left join item on iconfig.iid = item.id
+ where uid = %d and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK'
+ and item_type = %d order by item.created desc",
intval($owner),
intval(ITEM_TYPE_BLOCK)
);
@@ -129,12 +132,12 @@ class Blocks extends \Zotlabs\Web\Controller {
'created' => $rr['created'],
'edited' => $rr['edited'],
'mimetype' => $rr['mimetype'],
- 'pagetitle' => $rr['sid'],
+ 'pagetitle' => $rr['v'],
'mid' => $rr['mid']
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
- 'name' => $rr['sid'],
+ 'name' => $rr['v'],
'title' => $rr['title'],
'created' => $rr['created'],
'edited' => $rr['edited'],
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/Display.php b/Zotlabs/Module/Display.php
index c1a0d84bc..d1d4edc7d 100644
--- a/Zotlabs/Module/Display.php
+++ b/Zotlabs/Module/Display.php
@@ -106,12 +106,13 @@ class Display extends \Zotlabs\Web\Controller {
$x = q("select * from channel where channel_id = %d limit 1",
intval($target_item['uid'])
);
- $y = q("select * from item_id where uid = %d and service = 'WEBPAGE' and iid = %d limit 1",
+ $y = q("select * from iconfig left join item on iconfig.iid = item.id
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item.id = %d limit 1",
intval($target_item['uid']),
intval($target_item['id'])
);
if($x && $y) {
- goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['sid']);
+ goaway(z_root() . '/page/' . $x[0]['channel_address'] . '/' . $y[0]['v']);
}
else {
notice( t('Page not found.') . EOL);
diff --git a/Zotlabs/Module/Editblock.php b/Zotlabs/Module/Editblock.php
index fb86557f2..1d6ef7a0a 100644
--- a/Zotlabs/Module/Editblock.php
+++ b/Zotlabs/Module/Editblock.php
@@ -85,11 +85,11 @@ class Editblock extends \Zotlabs\Web\Controller {
intval($owner)
);
if($itm) {
- $item_id = q("select * from item_id where service = 'BUILDBLOCK' and iid = %d limit 1",
+ $item_id = q("select * from iconfig where cat = 'system' and k = 'BUILDBLOCK' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
- $block_title = $item_id[0]['sid'];
+ $block_title = $item_id[0]['v'];
}
else {
notice( t('Item not found') . EOL);
diff --git a/Zotlabs/Module/Editlayout.php b/Zotlabs/Module/Editlayout.php
index 5028882d2..fe794b5fd 100644
--- a/Zotlabs/Module/Editlayout.php
+++ b/Zotlabs/Module/Editlayout.php
@@ -96,11 +96,12 @@ class Editlayout extends \Zotlabs\Web\Controller {
intval($owner)
);
- $item_id = q("select * from item_id where service = 'PDL' and iid = %d limit 1",
+ $item_id = q("select * from iconfig where cat = 'system' and k = 'PDL' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
- $layout_title = $item_id[0]['sid'];
+ $layout_title = $item_id[0]['v'];
+
$rp = 'layouts/' . $which;
diff --git a/Zotlabs/Module/Editwebpage.php b/Zotlabs/Module/Editwebpage.php
index 1b5c320a0..6d67c08e7 100644
--- a/Zotlabs/Module/Editwebpage.php
+++ b/Zotlabs/Module/Editwebpage.php
@@ -114,11 +114,11 @@ class Editwebpage extends \Zotlabs\Web\Controller {
$itm[0]['body'] = crypto_unencapsulate(json_decode_plus($itm[0]['body']),$key);
}
- $item_id = q("select * from item_id where service = 'WEBPAGE' and iid = %d limit 1",
+ $item_id = q("select * from iconfig where cat = 'system' and k = 'WEBPAGE' and iid = %d limit 1",
intval($itm[0]['id'])
);
if($item_id)
- $page_title = $item_id[0]['sid'];
+ $page_title = $item_id[0]['v'];
$mimetype = $itm[0]['mimetype'];
diff --git a/Zotlabs/Module/Impel.php b/Zotlabs/Module/Impel.php
index e326f7818..735c311d0 100644
--- a/Zotlabs/Module/Impel.php
+++ b/Zotlabs/Module/Impel.php
@@ -137,9 +137,7 @@ class Impel extends \Zotlabs\Web\Controller {
require_once('library/urlify/URLify.php');
$pagetitle = strtolower(\URLify::transliterate($j['pagetitle']));
}
-
-
-
+
// Verify ability to use html or php!!!
$execflag = false;
@@ -154,21 +152,14 @@ class Impel extends \Zotlabs\Web\Controller {
}
}
- $remote_id = 0;
-
- $z = q("select * from item_id where sid = '%s' and service = '%s' and uid = %d limit 1",
- dbesc($pagetitle),
- dbesc($namespace),
- intval(local_channel())
- );
-
$i = q("select id, edited, item_deleted from item where mid = '%s' and uid = %d limit 1",
dbesc($arr['mid']),
intval(local_channel())
);
+
+ \Zotlabs\Lib\IConfig::Set($arr,'system',$namespace,(($pagetitle) ? $pagetitle : substr($arr['mid'],0,16)),true);
- if($z && $i) {
- $remote_id = $z[0]['id'];
+ if($i) {
$arr['id'] = $i[0]['id'];
// don't update if it has the same timestamp as the original
if($arr['edited'] > $i[0]['edited'])
@@ -182,12 +173,12 @@ class Impel extends \Zotlabs\Web\Controller {
intval(local_channel())
);
}
- $x = item_store($arr,$execflag);
+ else
+ $x = item_store($arr,$execflag);
}
- if($x['success']) {
+ if($x && $x['success']) {
$item_id = $x['item_id'];
- update_remote_id($channel,$item_id,$arr['item_type'],$pagetitle,$namespace,$remote_id,$arr['mid']);
}
}
@@ -199,7 +190,8 @@ class Impel extends \Zotlabs\Web\Controller {
notice( sprintf( t('%s element installation failed'), $installed_type));
}
- //??? should perhaps return ret?
+ //??? should perhaps return ret?
+
json_return_and_die(true);
}
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 2601feb0a..272da7971 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -1,4 +1,5 @@
<?php
+
namespace Zotlabs\Module;
/**
@@ -229,7 +230,7 @@ class Item extends \Zotlabs\Web\Controller {
if($namespace && $remote_id) {
// It wasn't an internally generated post - see if we've got an item matching this remote service id
- $i = q("select iid from item_id where service = '%s' and sid = '%s' limit 1",
+ $i = q("select iid from iconfig where cat = 'system' and k = '%s' and v = '%s' limit 1",
dbesc($namespace),
dbesc($remote_id)
);
@@ -880,13 +881,21 @@ class Item extends \Zotlabs\Web\Controller {
}
}
+ if($webpage) {
+ Zlib\IConfig::Set($datarray,'system', webpage_to_namespace($webpage),
+ (($pagetitle) ? $pagetitle : substr($datarray['mid'],0,16)),true);
+ }
+ elseif($namespace) {
+ Zlib\IConfig::Set($datarray,'system', $namespace,
+ (($remote_id) ? $remote_id : substr($datarray['mid'],0,16)),true);
+ }
+
+
if($orig_post) {
$datarray['id'] = $post_id;
item_store_update($datarray,$execflag);
- update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
-
if(! $parent) {
$r = q("select * from item where id = %d",
intval($post_id)
@@ -894,10 +903,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- $rid = q("select * from item_id where iid = %d",
- intval($post_id)
- );
- build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid));
+ build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true))));
}
}
if(! $nopush)
@@ -978,10 +984,7 @@ class Item extends \Zotlabs\Web\Controller {
goaway(z_root() . "/" . $return_path );
// NOTREACHED
}
-
-
- update_remote_id($channel,$post_id,$webpage,$pagetitle,$namespace,$remote_id,$mid);
-
+
if(($parent) && ($parent != $post_id)) {
// Store the comment signature information in case we need to relay to Diaspora
//$ditem = $datarray;
@@ -995,10 +998,7 @@ class Item extends \Zotlabs\Web\Controller {
if($r) {
xchan_query($r);
$sync_item = fetch_post_tags($r);
- $rid = q("select * from item_id where iid = %d",
- intval($post_id)
- );
- build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true)),'item_id' => $rid));
+ build_sync_packet($uid,array('item' => array(encode_item($sync_item[0],true))));
}
}
diff --git a/Zotlabs/Module/Layouts.php b/Zotlabs/Module/Layouts.php
index 9b9fc22f3..a0b1c31cc 100644
--- a/Zotlabs/Module/Layouts.php
+++ b/Zotlabs/Module/Layouts.php
@@ -90,13 +90,14 @@ class Layouts extends \Zotlabs\Web\Controller {
return;
}
- //This feature is not exposed in redbasic ui since it is not clear why one would want to
- //download a json encoded pdl file - we dont have a possibility to import it.
- //Use the buildin share/install feature instead.
+ // This feature is not exposed in redbasic ui since it is not clear why one would want to
+ // download a json encoded pdl file - we dont have a possibility to import it.
+ // Use the buildin share/install feature instead.
+
if((argc() > 3) && (argv(2) === 'share') && (argv(3))) {
- $r = q("select sid, service, mimetype, title, body from item_id
- left join item on item.id = item_id.iid
- where item_id.uid = %d and item.mid = '%s' and service = 'PDL' order by sid asc",
+ $r = q("select iconfig.v, iconfig.k, mimetype, title, body from iconfig
+ left join item on item.id = iconfig.iid
+ where uid = %d and mid = '%s' and iconfig.cat = 'system' and iconfig.k = 'PDL' order by iconfig.v asc",
intval($owner),
dbesc(argv(3))
);
@@ -141,8 +142,9 @@ class Layouts extends \Zotlabs\Web\Controller {
$editor = status_editor($a,$x);
- $r = q("select iid, sid, mid, title, body, mimetype, created, edited, item_type from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'PDL' and item_type = %d order by item.created desc",
+ $r = q("select iconfig.iid, iconfig.v, mid, title, body, mimetype, created, edited, item_type from iconfig
+ left join item on iconfig.iid = item.id
+ where uid = %d and iconfig.cat = 'system' and iconfig.k = 'PDL' and item_type = %d order by item.created desc",
intval($owner),
intval(ITEM_TYPE_PDL)
);
@@ -164,7 +166,7 @@ class Layouts extends \Zotlabs\Web\Controller {
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
- 'title' => $rr['sid'],
+ 'title' => $rr['v'],
'descr' => $rr['title'],
'mid' => $rr['mid'],
'created' => $rr['created'],
diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php
index 14273614c..deb23da68 100644
--- a/Zotlabs/Module/Page.php
+++ b/Zotlabs/Module/Page.php
@@ -65,9 +65,10 @@ class Page extends \Zotlabs\Web\Controller {
require_once('include/security.php');
$sql_options = item_permissions_sql($u[0]['channel_id']);
- $r = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and item.item_delayed = 0 and (( service = 'WEBPAGE' and item_type = %d )
- OR ( service = 'PDL' AND item_type = %d )) $sql_options $revision limit 1",
+ $r = q("select item.* from item left join iconfig on item.id = iconfig.iid
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0
+ and (( iconfig.k = 'WEBPAGE' and item_type = %d )
+ OR ( iconfig.k = 'PDL' AND item_type = %d )) $sql_options $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
intval(ITEM_TYPE_WEBPAGE),
@@ -77,9 +78,9 @@ class Page extends \Zotlabs\Web\Controller {
// Check again with no permissions clause to see if it is a permissions issue
- $x = q("select item.* from item left join item_id on item.id = item_id.iid
- where item.uid = %d and sid = '%s' and item.item_delayed = 0 and service = 'WEBPAGE' and
- item_type = %d $revision limit 1",
+ $x = q("select item.* from item left join iconfig on item.id = iconfig.iid
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.v = '%s' and item.item_delayed = 0
+ and iconfig.k = 'WEBPAGE' and item_type = %d $revision limit 1",
intval($u[0]['channel_id']),
dbesc($page_id),
intval(ITEM_TYPE_WEBPAGE)
@@ -119,11 +120,8 @@ class Page extends \Zotlabs\Web\Controller {
\App::$data['webpage'] = $r;
}
-
-
-
-
- function get() {
+
+ function get() {
$r = \App::$data['webpage'];
if(! $r)
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:
+
+ <?php
+
+ namespace Zotlabs\Web;
+
+
+ class Controller {
+
+ function init() {}
+ function post() {}
+ function get() {}
+
+ }
+
+
+Typical Module declaration for the '/foo' URL route:
+
+
+ <?php
+ namespace Zotlabs\Module;
+
+ class Foo extends \Zotlabs\Web\Controller {
+
+ function init() {
+ // init() handler goes here
+ }
+
+ function post() {
+ // post handler goes here
+ }
+
+ function get() {
+ return 'Hello world.' . EOL;
+ }
+
+ }
+
+This model provides callbacks for public functions named init(), post(),
+and get(). init() is always called. post() is called if $_POST variables
+are present, and get() is called if none of the prior functions terminated
+the handler. The get() method typically retuns a string which represents
+the contents of the content region of the resulting page. Modules which emit
+json, xml or other machine-readable formats typically emit their contents
+inside the init() function and call 'killme()' to terminate the Module.
+
+Modules are passed the URL path as argc,argv arguments. For a path such as
+
+ https://mysite.something/foo/bar/baz
+
+The app will typically invoke the Module class 'Foo' and pass it
+
+ $x = argc(); // $x = 3
+
+ $x = argv(0); // $x = 'foo'
+ $x = argv(1); // $x = 'bar'
+ $x = argv(2); // $x = 'baz'
+
+These are handled in a similar fashion to their counterparts in the Unix shell
+or C/C++ languages. Do not confuse the argc(),argv() functions with the
+global variables $argc,$argv which are passed to command line programs. These
+are handled separately by command line and Zotlabs/Daemon class functions.
+
+
+
+ \ No newline at end of file
diff --git a/Zotlabs/Module/Webpages.php b/Zotlabs/Module/Webpages.php
index bb8d454c8..fc292be6f 100644
--- a/Zotlabs/Module/Webpages.php
+++ b/Zotlabs/Module/Webpages.php
@@ -28,7 +28,7 @@ class Webpages extends \Zotlabs\Web\Controller {
}
- function get() {
+ function get() {
if(! \App::$profile) {
notice( t('Requested profile is not available.') . EOL );
@@ -138,11 +138,19 @@ class Webpages extends \Zotlabs\Web\Controller {
$sql_extra = item_permissions_sql($owner);
- $r = q("select * from item_id left join item on item_id.iid = item.id
- where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
+
+ $r = q("select * from iconfig left join item on iconfig.iid = item.id
+ where item.uid = %d and iconfig.cat = 'system' and iconfig.k = 'WEBPAGE' and item_type = %d
+ $sql_extra order by item.created desc",
intval($owner),
intval(ITEM_TYPE_WEBPAGE)
);
+
+// $r = q("select * from item_id left join item on item_id.iid = item.id
+// where item_id.uid = %d and service = 'WEBPAGE' and item_type = %d $sql_extra order by item.created desc",
+// intval($owner),
+// intval(ITEM_TYPE_WEBPAGE)
+// );
$pages = null;
@@ -160,13 +168,13 @@ class Webpages extends \Zotlabs\Web\Controller {
'created' => $rr['created'],
'edited' => $rr['edited'],
'mimetype' => $rr['mimetype'],
- 'pagetitle' => $rr['sid'],
+ 'pagetitle' => $rr['v'],
'mid' => $rr['mid'],
'layout_mid' => $rr['layout_mid']
);
$pages[$rr['iid']][] = array(
'url' => $rr['iid'],
- 'pagetitle' => $rr['sid'],
+ 'pagetitle' => $rr['v'],
'title' => $rr['title'],
'created' => datetime_convert('UTC',date_default_timezone_get(),$rr['created']),
'edited' => datetime_convert('UTC',date_default_timezone_get(),$rr['edited']),
diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php
index 1e6446904..f1f7b87b2 100644
--- a/Zotlabs/Module/Wiki.php
+++ b/Zotlabs/Module/Wiki.php
@@ -1,6 +1,6 @@
-<?php
+<?php /** @file */
-namespace Zotlabs\Module;/** @file */
+namespace Zotlabs\Module;
class Wiki extends \Zotlabs\Web\Controller {
diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php
index 1017ec6aa..820897ee9 100644
--- a/Zotlabs/Render/Comanche.php
+++ b/Zotlabs/Render/Comanche.php
@@ -179,7 +179,8 @@ class Comanche {
$channel_id = $this->get_channel_id();
if($channel_id) {
- $r = q("select * from item inner join item_id on iid = item.id and item_id.uid = item.uid and item.uid = %d and service = 'BUILDBLOCK' and sid = '%s' limit 1",
+ $r = q("select * from item inner join iconfig on iconfig.iid = item.id and item.uid = %d
+ and iconfig.cat = 'system' and iconfig.k = 'BUILDBLOCK' and iconfig.v = '%s' limit 1",
intval($channel_id),
dbesc($name)
);
@@ -282,12 +283,12 @@ class Comanche {
/**
- * Widgets will have to get any operational arguments from the session, the
- * global app environment, or config storage until we implement argument passing
+ * Render a widget
*
* @param string $name
* @param string $text
*/
+
function widget($name, $text) {
$vars = array();
$matches = array();
@@ -314,7 +315,7 @@ class Comanche {
require_once(theme_include($theme_widget));
}
- if (function_exists($func))
+ if(function_exists($func))
return $func($vars);
}
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
+}
+