aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Oauth.php (renamed from Zotlabs/Module/Settings/Oauth.php)60
-rw-r--r--Zotlabs/Module/Oauth2.php (renamed from Zotlabs/Module/Settings/Oauth2.php)61
-rw-r--r--app/oauth.apd6
-rw-r--r--app/oauth2.apd6
-rwxr-xr-xview/tpl/oauth.tpl (renamed from view/tpl/settings_oauth.tpl)8
-rwxr-xr-xview/tpl/oauth2.tpl (renamed from view/tpl/settings_oauth2.tpl)8
-rwxr-xr-xview/tpl/oauth2_edit.tpl (renamed from view/tpl/settings_oauth2_edit.tpl)0
-rwxr-xr-xview/tpl/oauth_edit.tpl (renamed from view/tpl/settings_oauth_edit.tpl)0
8 files changed, 96 insertions, 53 deletions
diff --git a/Zotlabs/Module/Settings/Oauth.php b/Zotlabs/Module/Oauth.php
index d6576c6de..196209308 100644
--- a/Zotlabs/Module/Settings/Oauth.php
+++ b/Zotlabs/Module/Oauth.php
@@ -1,27 +1,33 @@
<?php
-namespace Zotlabs\Module\Settings;
+namespace Zotlabs\Module;
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Web\Controller;
-class Oauth {
+class Oauth extends Controller {
function post() {
+
+ if(! Apps::system_app_installed(local_channel(), 'OAuth'))
+ return;
if(x($_POST,'remove')){
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
+ check_form_security_token_redirectOnErr('/oauth', 'oauth');
$key = $_POST['remove'];
q("DELETE FROM tokens WHERE id='%s' AND uid=%d",
dbesc($key),
local_channel());
- goaway(z_root()."/settings/oauth/");
+ goaway(z_root()."/oauth");
return;
}
- if((argc() > 2) && (argv(2) === 'edit' || argv(2) === 'add') && x($_POST,'submit')) {
+ if((argc() > 1) && (argv(1) === 'edit' || argv(1) === 'add') && x($_POST,'submit')) {
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth');
+ check_form_security_token_redirectOnErr('oauth', 'oauth');
$name = ((x($_POST,'name')) ? escape_tags($_POST['name']) : '');
$key = ((x($_POST,'key')) ? escape_tags($_POST['key']) : '');
@@ -73,17 +79,27 @@ class Oauth {
);
}
}
- goaway(z_root()."/settings/oauth/");
+ goaway(z_root()."/oauth");
return;
}
}
function get() {
+
+ if(! Apps::system_app_installed(local_channel(), 'OAuth Apps Manager')) {
+ //Do not display any associated widgets at this point
+ App::$pdl = '';
+
+ $o = '<b>OAuth App (Not Installed):</b><br>';
+ $o .= t('An OAuth apps manager');
+ return $o;
+ }
+
- if((argc() > 2) && (argv(2) === 'add')) {
- $tpl = get_markup_template("settings_oauth_edit.tpl");
+ if((argc() > 1) && (argv(1) === 'add')) {
+ $tpl = get_markup_template("oauth_edit.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth"),
+ '$form_security_token' => get_form_security_token("oauth"),
'$title' => t('Add application'),
'$submit' => t('Submit'),
'$cancel' => t('Cancel'),
@@ -96,9 +112,9 @@ class Oauth {
return $o;
}
- if((argc() > 3) && (argv(2) === 'edit')) {
+ if((argc() > 2) && (argv(1) === 'edit')) {
$r = q("SELECT * FROM clients WHERE client_id='%s' AND uid=%d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
local_channel());
if (!count($r)){
@@ -107,9 +123,9 @@ class Oauth {
}
$app = $r[0];
- $tpl = get_markup_template("settings_oauth_edit.tpl");
+ $tpl = get_markup_template("oauth_edit.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth"),
+ '$form_security_token' => get_form_security_token("oauth"),
'$title' => t('Add application'),
'$submit' => t('Update'),
'$cancel' => t('Cancel'),
@@ -122,13 +138,13 @@ class Oauth {
return $o;
}
- if((argc() > 3) && (argv(2) === 'delete')) {
- check_form_security_token_redirectOnErr('/settings/oauth', 'settings_oauth', 't');
+ if((argc() > 2) && (argv(1) === 'delete')) {
+ check_form_security_token_redirectOnErr('/oauth', 'oauth', 't');
$r = q("DELETE FROM clients WHERE client_id='%s' AND uid=%d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
local_channel());
- goaway(z_root()."/settings/oauth/");
+ goaway(z_root()."/oauth");
return;
}
@@ -141,11 +157,11 @@ class Oauth {
local_channel());
- $tpl = get_markup_template("settings_oauth.tpl");
+ $tpl = get_markup_template("oauth.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth"),
+ '$form_security_token' => get_form_security_token("oauth"),
'$baseurl' => z_root(),
- '$title' => t('Connected Apps'),
+ '$title' => t('Connected OAuth Apps'),
'$add' => t('Add application'),
'$edit' => t('Edit'),
'$delete' => t('Delete'),
@@ -158,4 +174,4 @@ class Oauth {
}
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Settings/Oauth2.php b/Zotlabs/Module/Oauth2.php
index 70fd3a5c3..2302d1b10 100644
--- a/Zotlabs/Module/Settings/Oauth2.php
+++ b/Zotlabs/Module/Oauth2.php
@@ -1,15 +1,21 @@
<?php
-namespace Zotlabs\Module\Settings;
+namespace Zotlabs\Module;
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Web\Controller;
-class Oauth2 {
+class Oauth2 extends Controller {
function post() {
+
+ if(! Apps::system_app_installed(local_channel(), 'OAuth2 Apps Manager'))
+ return;
if(x($_POST,'remove')){
- check_form_security_token_redirectOnErr('/settings/oauth2', 'settings_oauth2');
+ check_form_security_token_redirectOnErr('oauth2', 'oauth2');
$name = ((x($_POST,'name')) ? escape_tags(trim($_POST['name'])) : '');
logger("REMOVE! ".$name." uid: ".local_channel());
$key = $_POST['remove'];
@@ -25,13 +31,13 @@ class Oauth2 {
dbesc($name),
intval(local_channel())
);
- goaway(z_root()."/settings/oauth2/");
+ goaway(z_root()."/oauth2");
return;
}
- if((argc() > 2) && (argv(2) === 'edit' || argv(2) === 'add') && x($_POST,'submit')) {
+ if((argc() > 1) && (argv(1) === 'edit' || argv(1) === 'add') && x($_POST,'submit')) {
- check_form_security_token_redirectOnErr('/settings/oauth2', 'settings_oauth2');
+ check_form_security_token_redirectOnErr('oauth2', 'oauth2');
$name = ((x($_POST,'name')) ? escape_tags(trim($_POST['name'])) : '');
$secret = ((x($_POST,'secret')) ? escape_tags(trim($_POST['secret'])) : '');
@@ -80,17 +86,26 @@ class Oauth2 {
);
}
}
- goaway(z_root()."/settings/oauth2/");
+ goaway(z_root()."/oauth2");
return;
}
}
function get() {
+
+ if(! Apps::system_app_installed(local_channel(), 'OAuth2 Apps Manager')) {
+ //Do not display any associated widgets at this point
+ App::$pdl = '';
+
+ $o = '<b>OAuth2 App (Not Installed):</b><br>';
+ $o .= t('An OAuth2 apps manager');
+ return $o;
+ }
- if((argc() > 2) && (argv(2) === 'add')) {
- $tpl = get_markup_template("settings_oauth2_edit.tpl");
+ if((argc() > 1) && (argv(1) === 'add')) {
+ $tpl = get_markup_template("oauth2_edit.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth2"),
+ '$form_security_token' => get_form_security_token("oauth2"),
'$title' => t('Add OAuth2 application'),
'$submit' => t('Submit'),
'$cancel' => t('Cancel'),
@@ -103,9 +118,9 @@ class Oauth2 {
return $o;
}
- if((argc() > 3) && (argv(2) === 'edit')) {
+ if((argc() > 2) && (argv(1) === 'edit')) {
$r = q("SELECT * FROM oauth_clients WHERE client_id='%s' AND user_id= %d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
intval(local_channel())
);
@@ -116,9 +131,9 @@ class Oauth2 {
$app = $r[0];
- $tpl = get_markup_template("settings_oauth2_edit.tpl");
+ $tpl = get_markup_template("oauth2_edit.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth2"),
+ '$form_security_token' => get_form_security_token("oauth2"),
'$title' => t('Add application'),
'$submit' => t('Update'),
'$cancel' => t('Cancel'),
@@ -131,26 +146,26 @@ class Oauth2 {
return $o;
}
- if((argc() > 3) && (argv(2) === 'delete')) {
- check_form_security_token_redirectOnErr('/settings/oauth2', 'settings_oauth2', 't');
+ if((argc() > 2) && (argv(1) === 'delete')) {
+ check_form_security_token_redirectOnErr('oauth2', 'oauth2', 't');
$r = q("DELETE FROM oauth_clients WHERE client_id = '%s' AND user_id = %d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
intval(local_channel())
);
$r = q("DELETE FROM oauth_access_tokens WHERE client_id = '%s' AND user_id = %d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
intval(local_channel())
);
$r = q("DELETE FROM oauth_authorization_codes WHERE client_id = '%s' AND user_id = %d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
intval(local_channel())
);
$r = q("DELETE FROM oauth_refresh_tokens WHERE client_id = '%s' AND user_id = %d",
- dbesc(argv(3)),
+ dbesc(argv(2)),
intval(local_channel())
);
- goaway(z_root()."/settings/oauth2/");
+ goaway(z_root()."/oauth2");
return;
}
@@ -164,9 +179,9 @@ class Oauth2 {
intval(local_channel())
);
- $tpl = get_markup_template("settings_oauth2.tpl");
+ $tpl = get_markup_template("oauth2.tpl");
$o .= replace_macros($tpl, array(
- '$form_security_token' => get_form_security_token("settings_oauth2"),
+ '$form_security_token' => get_form_security_token("oauth2"),
'$baseurl' => z_root(),
'$title' => t('Connected OAuth2 Apps'),
'$add' => t('Add application'),
diff --git a/app/oauth.apd b/app/oauth.apd
new file mode 100644
index 000000000..4771773ed
--- /dev/null
+++ b/app/oauth.apd
@@ -0,0 +1,6 @@
+version: 1
+url: $baseurl/oauth
+requires: local_channel
+name: OAuth Apps Manager
+photo: icon:chevron-circle-up
+categories: Access Control
diff --git a/app/oauth2.apd b/app/oauth2.apd
new file mode 100644
index 000000000..21fa44c97
--- /dev/null
+++ b/app/oauth2.apd
@@ -0,0 +1,6 @@
+version: 1
+url: $baseurl/oauth2
+requires: local_channel
+name: OAuth2 Apps Manager
+photo: icon:chevron-circle-up
+categories: Access Control
diff --git a/view/tpl/settings_oauth.tpl b/view/tpl/oauth.tpl
index 811cfcec5..881e22e99 100755
--- a/view/tpl/settings_oauth.tpl
+++ b/view/tpl/oauth.tpl
@@ -4,13 +4,13 @@
</div>
<div class="section-content-tools-wrapper">
-<form action="settings/oauth" method="post" autocomplete="off">
+<form action="oauth" method="post" autocomplete="off">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<div id="profile-edit-links">
<ul>
<li>
- <a id="profile-edit-view-link" href="{{$baseurl}}/settings/oauth/add">{{$add}}</a>
+ <a id="profile-edit-view-link" href="{{$baseurl}}/oauth/add">{{$add}}</a>
</li>
</ul>
</div>
@@ -25,8 +25,8 @@
{{/if}}
{{/if}}
{{if $app.my}}
- <a href="{{$baseurl}}/settings/oauth/edit/{{$app.client_id}}" title="{{$edit}}"><i class="fa fa-pencil btn btn-outline-secondary"></i></a>
- <a href="{{$baseurl}}/settings/oauth/delete/{{$app.client_id}}?t={{$form_security_token}}" title="{{$delete}}"><i class="fa fa-trash-o btn btn-outline-secondary"></i></a>
+ <a href="{{$baseurl}}/oauth/edit/{{$app.client_id}}" title="{{$edit}}"><i class="fa fa-pencil btn btn-outline-secondary"></i></a>
+ <a href="{{$baseurl}}/oauth/delete/{{$app.client_id}}?t={{$form_security_token}}" title="{{$delete}}"><i class="fa fa-trash-o btn btn-outline-secondary"></i></a>
{{/if}}
</div>
{{/foreach}}
diff --git a/view/tpl/settings_oauth2.tpl b/view/tpl/oauth2.tpl
index f3bf59a12..a5b48ffce 100755
--- a/view/tpl/settings_oauth2.tpl
+++ b/view/tpl/oauth2.tpl
@@ -8,13 +8,13 @@
<div id="profile-edit-links">
<ul>
<li>
- <a id="profile-edit-view-link" href="{{$baseurl}}/settings/oauth2/add">{{$add}}</a>
+ <a id="profile-edit-view-link" href="{{$baseurl}}/oauth2/add">{{$add}}</a>
</li>
</ul>
</div>
{{foreach $apps as $app}}
-<form action="settings/oauth2" method="post" autocomplete="off">
+<form action="oauth2" method="post" autocomplete="off">
<input type='hidden' name='form_security_token' value='{{$form_security_token}}'>
<input type='hidden' name='name' value='{{$app.client_id}}'>
<div class='oauthapp'>
@@ -25,8 +25,8 @@
{{/if}}
{{/if}}
{{if $app.my}}
- <a href="{{$baseurl}}/settings/oauth2/edit/{{$app.client_id}}" title="{{$edit}}"><i class="fa fa-pencil btn btn-outline-secondary"></i></a>
- <a href="{{$baseurl}}/settings/oauth2/delete/{{$app.client_id}}?t={{$form_security_token}}" title="{{$delete}}"><i class="fa fa-trash-o btn btn-outline-secondary"></i></a>
+ <a href="{{$baseurl}}/oauth2/edit/{{$app.client_id}}" title="{{$edit}}"><i class="fa fa-pencil btn btn-outline-secondary"></i></a>
+ <a href="{{$baseurl}}/oauth2/delete/{{$app.client_id}}?t={{$form_security_token}}" title="{{$delete}}"><i class="fa fa-trash-o btn btn-outline-secondary"></i></a>
{{/if}}
</div>
</form>
diff --git a/view/tpl/settings_oauth2_edit.tpl b/view/tpl/oauth2_edit.tpl
index 399c64977..399c64977 100755
--- a/view/tpl/settings_oauth2_edit.tpl
+++ b/view/tpl/oauth2_edit.tpl
diff --git a/view/tpl/settings_oauth_edit.tpl b/view/tpl/oauth_edit.tpl
index e44b44723..e44b44723 100755
--- a/view/tpl/settings_oauth_edit.tpl
+++ b/view/tpl/oauth_edit.tpl