diff options
-rw-r--r-- | Zotlabs/Module/Magic.php | 13 | ||||
-rw-r--r-- | Zotlabs/Module/Owa.php | 4 | ||||
-rw-r--r-- | Zotlabs/Module/Page.php | 24 | ||||
-rw-r--r-- | Zotlabs/Module/Starred.php | 2 | ||||
-rw-r--r-- | Zotlabs/Render/Comanche.php | 3 | ||||
-rw-r--r-- | doc/Widgets.md | 34 | ||||
-rw-r--r-- | include/connections.php | 2 | ||||
-rwxr-xr-x | util/add_widget_repo | 11 | ||||
-rw-r--r-- | view/pdl/mod_sources.pdl | 6 |
9 files changed, 72 insertions, 27 deletions
diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php index 879085f96..9ad9c951c 100644 --- a/Zotlabs/Module/Magic.php +++ b/Zotlabs/Module/Magic.php @@ -146,10 +146,17 @@ class Magic extends \Zotlabs\Web\Controller { if($x['success']) { $j = json_decode($x['body'],true); - if($j['success'] && $j['token']) { - $x = strpbrk($dest,'?&'); - $args = (($x) ? '&owt=' . $j['token'] : '?f=&owt=' . $j['token']) . (($delegate) ? '&delegate=1' : ''); + if($j['success']) { + $token = ''; + if($j['encrypted_token']) { + openssl_private_decrypt(base64url_decode($j['encrypted_token']),$token,$channel['channel_prvkey']); + } + else { + $token = $j['token']; + } + $x = strpbrk($dest,'?&'); + $args = (($x) ? '&owt=' . $token : '?f=&owt=' . $token) . (($delegate) ? '&delegate=1' : ''); goaway($dest . $args); } } diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php index 4b0d855c5..d58fd7a41 100644 --- a/Zotlabs/Module/Owa.php +++ b/Zotlabs/Module/Owa.php @@ -41,7 +41,9 @@ class Owa extends \Zotlabs\Web\Controller { $ret['success'] = true; $token = random_string(32); \Zotlabs\Zot\Verify::create('owt',0,$token,$r[0]['hubloc_addr']); - $ret['token'] = $token; + $result = ''; + openssl_public_encrypt($token,$result,$hubloc['xchan_pubkey']); + $ret['encrypted_token'] = base64url_encode($result); } } } diff --git a/Zotlabs/Module/Page.php b/Zotlabs/Module/Page.php index c142afe77..5fdd32825 100644 --- a/Zotlabs/Module/Page.php +++ b/Zotlabs/Module/Page.php @@ -89,22 +89,30 @@ class Page extends \Zotlabs\Web\Controller { if(! $ignore_language) { $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", + and iconfig.k = 'WEBPAGE' and item_type = %d + $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($lang_page_id), - intval(ITEM_TYPE_WEBPAGE), - intval(ITEM_TYPE_PDL) + intval(ITEM_TYPE_WEBPAGE) + ); + } + if(! $r) { + $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 + $sql_options $revision limit 1", + intval($u[0]['channel_id']), + dbesc($page_id), + intval(ITEM_TYPE_WEBPAGE) ); } if(! $r) { + // no webpage by that name, but we do allow you to load/preview a layout using this module. Try that. $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", + and iconfig.k = 'PDL' AND item_type = %d $sql_options $revision limit 1", intval($u[0]['channel_id']), dbesc($page_id), - intval(ITEM_TYPE_WEBPAGE), intval(ITEM_TYPE_PDL) ); } @@ -129,7 +137,7 @@ class Page extends \Zotlabs\Web\Controller { } return; } - + if($r[0]['title']) \App::$page['title'] = escape_tags($r[0]['title']); diff --git a/Zotlabs/Module/Starred.php b/Zotlabs/Module/Starred.php index 4f1d99ec6..8349ae25c 100644 --- a/Zotlabs/Module/Starred.php +++ b/Zotlabs/Module/Starred.php @@ -16,7 +16,7 @@ class Starred extends \Zotlabs\Web\Controller { if(! $message_id) killme(); - $r = q("SELECT item_flags FROM item WHERE uid = %d AND id = %d LIMIT 1", + $r = q("SELECT item_starred FROM item WHERE uid = %d AND id = %d LIMIT 1", intval(local_channel()), intval($message_id) ); diff --git a/Zotlabs/Render/Comanche.php b/Zotlabs/Render/Comanche.php index 8831bd117..78ca870a7 100644 --- a/Zotlabs/Render/Comanche.php +++ b/Zotlabs/Render/Comanche.php @@ -469,8 +469,11 @@ class Comanche { if(file_exists('Zotlabs/SiteWidget/' . $clsname . '.php')) require_once('Zotlabs/SiteWidget/' . $clsname . '.php'); + elseif(file_exists('widget/' . $clsname . '/' . $clsname . '.php')) + require_once('widget/' . $clsname . '/' . $clsname . '.php'); elseif(file_exists('Zotlabs/Widget/' . $clsname . '.php')) require_once('Zotlabs/Widget/' . $clsname . '.php'); + if(class_exists($nsname)) { $x = new $nsname; $f = 'widget'; diff --git a/doc/Widgets.md b/doc/Widgets.md index 4ad899a0f..7761b1833 100644 --- a/doc/Widgets.md +++ b/doc/Widgets.md @@ -129,14 +129,44 @@ Some/many of these widgets have restrictions which may restrict the type of page Creating New Widgets ==================== -If you want a widget named 'slugfish', create widget/slugfish.php containing +### Class Widgets + +To create a class-based widget named 'slugfish' create a file with the following contents: + +```` +<?php + +namespace Zotlabs\Widget; + + +class Slugfish { + + function widget($args) { + + ... widget code goes here. + ... The function returns a string which is the HTML content of the widget. + ... $args is a named array which is passed any [var] variables from the layout editor + ... For instance [widget=slugfish][var=count]3[/var][/widget] will populate $args with + ... [ 'count' => 3 ] + + } + +```` + +The resultant file may be placed in widget/Slugfish/Slugfish.php , or Zotlabs/SiteWidgets/Slugfish.php . It also may be linked from a git repository using util/add_widget_repo. + + + +Traditional function based widget: + +If you want a widget named 'slugfish', create widget/widget_slugfish.php containing <?php function widget_slugfish($args) { - .. widget code goes here + .. widget code goes here. See above information for class-based widgets for details. } diff --git a/include/connections.php b/include/connections.php index 60bce018e..e9d7daa2d 100644 --- a/include/connections.php +++ b/include/connections.php @@ -369,7 +369,7 @@ function contact_remove($channel_id, $abook_id) { return false; - $r = q("select * from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d", + $r = q("select id from item where (owner_xchan = '%s' or author_xchan = '%s') and uid = %d", dbesc($abook['abook_xchan']), dbesc($abook['abook_xchan']), intval($channel_id) diff --git a/util/add_widget_repo b/util/add_widget_repo index cb3112626..4cfd6a170 100755 --- a/util/add_widget_repo +++ b/util/add_widget_repo @@ -5,17 +5,6 @@ if [ $# -lt 2 ]; then exit 1 fi -#if [[ $1 != *"//github.com/redmatrix"* && $3 != 'insecure' ]]; then -# echo ""; -# echo "This is NOT an official project repository."; -# echo "In order to protect you from unverified and"; -# echo "possibly malicious content, this repository"; -# echo "will not be linked to your site unless you"; -# echo "append the word 'insecure' to the command."; -# echo ""; -# exit 1 -#fi - mkdir -p extend/widget/$2 mkdir widget > /dev/null 2>&1 git clone $1 extend/widget/$2 diff --git a/view/pdl/mod_sources.pdl b/view/pdl/mod_sources.pdl new file mode 100644 index 000000000..53a3ac9e5 --- /dev/null +++ b/view/pdl/mod_sources.pdl @@ -0,0 +1,6 @@ +[region=aside] +[widget=settings_menu][/widget] +[/region] +[region=right_aside] +[widget=notifications][/widget] +[/region] |