aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-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
2 files changed, 76 insertions, 45 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'),