diff --git a/Zotlabs/Module/Settings/Oauth.php b/Zotlabs/Module/Oauth.php
similarity index 74%
rename from Zotlabs/Module/Settings/Oauth.php
rename to Zotlabs/Module/Oauth.php
index d6576c6de..196209308 100644
--- a/Zotlabs/Module/Settings/Oauth.php
+++ b/Zotlabs/Module/Oauth.php
@@ -1,27 +1,33 @@
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 = 'OAuth App (Not Installed):
';
+ $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
similarity index 79%
rename from Zotlabs/Module/Settings/Oauth2.php
rename to Zotlabs/Module/Oauth2.php
index 70fd3a5c3..2302d1b10 100644
--- a/Zotlabs/Module/Settings/Oauth2.php
+++ b/Zotlabs/Module/Oauth2.php
@@ -1,15 +1,21 @@
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 = 'OAuth2 App (Not Installed):
';
+ $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
similarity index 63%
rename from view/tpl/settings_oauth.tpl
rename to view/tpl/oauth.tpl
index 811cfcec5..881e22e99 100755
--- a/view/tpl/settings_oauth.tpl
+++ b/view/tpl/oauth.tpl
@@ -4,13 +4,13 @@