From 3dac15a8911fea1e8473af7e7a26d7a57e68328b Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 22 Mar 2018 13:19:29 +0100 Subject: [PATCH 1/3] Move calls to \OCP\JSON to private \OC_JSON They should be properly fixed at some point. Signed-off-by: Roeland Jago Douma --- apps/files/ajax/list.php | 10 +++---- apps/files_external/ajax/applicable.php | 8 ++--- apps/files_external/ajax/oauth2.php | 6 ++-- apps/files_trashbin/ajax/delete.php | 8 ++--- apps/files_trashbin/ajax/isEmpty.php | 6 ++-- apps/files_trashbin/ajax/list.php | 4 +-- apps/files_trashbin/ajax/undelete.php | 8 ++--- apps/files_versions/ajax/getVersions.php | 10 +++---- apps/files_versions/ajax/rollbackVersion.php | 10 +++---- apps/files_versions/download.php | 4 +-- apps/user_ldap/ajax/clearMappings.php | 10 +++---- apps/user_ldap/ajax/deleteConfiguration.php | 10 +++---- apps/user_ldap/ajax/getConfiguration.php | 8 ++--- .../ajax/getNewServerConfigPrefix.php | 8 ++--- apps/user_ldap/ajax/setConfiguration.php | 8 ++--- apps/user_ldap/ajax/testConfiguration.php | 16 +++++----- apps/user_ldap/ajax/wizard.php | 30 +++++++++---------- lib/base.php | 4 +-- settings/ajax/disableapp.php | 4 +-- settings/ajax/enableapp.php | 2 +- settings/ajax/navigationdetect.php | 4 +-- settings/ajax/setquota.php | 2 +- settings/ajax/togglesubadmins.php | 2 +- settings/ajax/uninstallapp.php | 4 +-- settings/ajax/updateapp.php | 6 ++-- 25 files changed, 96 insertions(+), 96 deletions(-) diff --git a/apps/files/ajax/list.php b/apps/files/ajax/list.php index 951377abf8664..c013733dbb31e 100644 --- a/apps/files/ajax/list.php +++ b/apps/files/ajax/list.php @@ -27,7 +27,7 @@ use OCP\Files\StorageNotAvailableException; use OCP\Files\StorageInvalidException; -OCP\JSON::checkLoggedIn(); +\OC_JSON::checkLoggedIn(); \OC::$server->getSession()->close(); $l = \OC::$server->getL10N('files'); @@ -79,10 +79,10 @@ $data['files'] = \OCA\Files\Helper::formatFileInfos($files); $data['permissions'] = $permissions; - OCP\JSON::success(array('data' => $data)); + \OC_JSON::success(array('data' => $data)); } catch (\OCP\Files\StorageNotAvailableException $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); - OCP\JSON::error([ + \OC_JSON::error([ 'data' => [ 'exception' => StorageNotAvailableException::class, 'message' => $l->t('Storage is temporarily not available') @@ -90,7 +90,7 @@ ]); } catch (\OCP\Files\StorageInvalidException $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); - OCP\JSON::error(array( + \OC_JSON::error(array( 'data' => array( 'exception' => StorageInvalidException::class, 'message' => $l->t('Storage invalid') @@ -98,7 +98,7 @@ )); } catch (\Exception $e) { \OC::$server->getLogger()->logException($e, ['app' => 'files']); - OCP\JSON::error(array( + \OC_JSON::error(array( 'data' => array( 'exception' => \Exception::class, 'message' => $l->t('Unknown error') diff --git a/apps/files_external/ajax/applicable.php b/apps/files_external/ajax/applicable.php index 4ee922b63ac7c..eb0f754870d22 100644 --- a/apps/files_external/ajax/applicable.php +++ b/apps/files_external/ajax/applicable.php @@ -21,10 +21,10 @@ * along with this program. If not, see * */ -OCP\JSON::checkAppEnabled('files_external'); -OCP\JSON::callCheck(); +\OC_JSON::checkAppEnabled('files_external'); +\OC_JSON::callCheck(); -OCP\JSON::checkAdminUser(); +\OC_JSON::checkAdminUser(); $pattern = ''; $limit = null; @@ -51,4 +51,4 @@ $results = array('groups' => $groups, 'users' => $users); -\OCP\JSON::success($results); +\\OC_JSON::success($results); diff --git a/apps/files_external/ajax/oauth2.php b/apps/files_external/ajax/oauth2.php index 9a3f2e0af6a05..8a6af8f8a40c0 100644 --- a/apps/files_external/ajax/oauth2.php +++ b/apps/files_external/ajax/oauth2.php @@ -22,9 +22,9 @@ * along with this program. If not, see * */ -OCP\JSON::checkAppEnabled('files_external'); -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); +\OC_JSON::checkAppEnabled('files_external'); +\OC_JSON::checkLoggedIn(); +\OC_JSON::callCheck(); $l = \OC::$server->getL10N('files_external'); // TODO: implement redirect to which storage backend requested this diff --git a/apps/files_trashbin/ajax/delete.php b/apps/files_trashbin/ajax/delete.php index d75325c3aeb5c..149bbbd94ffa8 100644 --- a/apps/files_trashbin/ajax/delete.php +++ b/apps/files_trashbin/ajax/delete.php @@ -24,8 +24,8 @@ * along with this program. If not, see * */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); +\OC_JSON::checkLoggedIn(); +\OC_JSON::callCheck(); \OC::$server->getSession()->close(); $folder = isset($_POST['dir']) ? $_POST['dir'] : '/'; @@ -83,8 +83,8 @@ } $l = \OC::$server->getL10N('files_trashbin'); $message = $l->t("Couldn't delete %s permanently", array(rtrim($filelist, ', '))); - OCP\JSON::error(array("data" => array("message" => $message, + \OC_JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); } else { - OCP\JSON::success(array("data" => array("success" => $success))); + \OC_JSON::success(array("data" => array("success" => $success))); } diff --git a/apps/files_trashbin/ajax/isEmpty.php b/apps/files_trashbin/ajax/isEmpty.php index 1ee671334f285..73356047e747a 100644 --- a/apps/files_trashbin/ajax/isEmpty.php +++ b/apps/files_trashbin/ajax/isEmpty.php @@ -22,12 +22,12 @@ * */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); +\OC_JSON::checkLoggedIn(); +\OC_JSON::callCheck(); \OC::$server->getSession()->close(); $trashStatus = OCA\Files_Trashbin\Trashbin::isEmpty(OCP\User::getUser()); -OCP\JSON::success(array("data" => array("isEmpty" => $trashStatus))); +\OC_JSON::success(array("data" => array("isEmpty" => $trashStatus))); diff --git a/apps/files_trashbin/ajax/list.php b/apps/files_trashbin/ajax/list.php index dff647aa694c9..c31a33c20500e 100644 --- a/apps/files_trashbin/ajax/list.php +++ b/apps/files_trashbin/ajax/list.php @@ -21,7 +21,7 @@ * along with this program. If not, see * */ -OCP\JSON::checkLoggedIn(); +\OC_JSON::checkLoggedIn(); \OC::$server->getSession()->close(); // Load the files @@ -44,5 +44,5 @@ $data['directory'] = $dir; $data['files'] = \OCA\Files_Trashbin\Helper::formatFileInfos($files); -OCP\JSON::success(array('data' => $data)); +\OC_JSON::success(array('data' => $data)); diff --git a/apps/files_trashbin/ajax/undelete.php b/apps/files_trashbin/ajax/undelete.php index f7e0594cd8a8d..5fb042aa1c4be 100644 --- a/apps/files_trashbin/ajax/undelete.php +++ b/apps/files_trashbin/ajax/undelete.php @@ -26,8 +26,8 @@ * along with this program. If not, see * */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); +\OC_JSON::checkLoggedIn(); +\OC_JSON::callCheck(); \OC::$server->getSession()->close(); $dir = '/'; @@ -88,8 +88,8 @@ } $l = OC::$server->getL10N('files_trashbin'); $message = $l->t("Couldn't restore %s", array(rtrim($filelist, ', '))); - OCP\JSON::error(array("data" => array("message" => $message, + \OC_JSON::error(array("data" => array("message" => $message, "success" => $success, "error" => $error))); } else { - OCP\JSON::success(array("data" => array("success" => $success))); + \OC_JSON::success(array("data" => array("success" => $success))); } diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index c3cb47da88947..6bba0a540c6b5 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -24,9 +24,9 @@ * along with this program. If not, see * */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::callCheck(); -OCP\JSON::checkAppEnabled('files_versions'); +\OC_JSON::checkLoggedIn(); +\OC_JSON::callCheck(); +\OC_JSON::checkAppEnabled('files_versions'); $source = (string)$_GET['source']; $start = (int)$_GET['start']; @@ -47,10 +47,10 @@ unset($version['path']); } - \OCP\JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); + \\OC_JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); } else { - \OCP\JSON::success(array('data' => array('versions' => [], 'endReached' => true))); + \\OC_JSON::success(array('data' => array('versions' => [], 'endReached' => true))); } diff --git a/apps/files_versions/ajax/rollbackVersion.php b/apps/files_versions/ajax/rollbackVersion.php index 6d5933e07fd6f..c1a5c094edeee 100644 --- a/apps/files_versions/ajax/rollbackVersion.php +++ b/apps/files_versions/ajax/rollbackVersion.php @@ -26,16 +26,16 @@ * along with this program. If not, see * */ -OCP\JSON::checkLoggedIn(); -OCP\JSON::checkAppEnabled('files_versions'); -OCP\JSON::callCheck(); +\OC_JSON::checkLoggedIn(); +\OC_JSON::checkAppEnabled('files_versions'); +\OC_JSON::callCheck(); $file = (string)$_GET['file']; $revision=(int)$_GET['revision']; if(OCA\Files_Versions\Storage::rollback( $file, $revision )) { - OCP\JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); + \OC_JSON::success(array("data" => array( "revision" => $revision, "file" => $file ))); }else{ $l = \OC::$server->getL10N('files_versions'); - OCP\JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); + \OC_JSON::error(array("data" => array( "message" => $l->t("Could not revert: %s", array($file) )))); } diff --git a/apps/files_versions/download.php b/apps/files_versions/download.php index c61e04610285a..77f3e9f088716 100644 --- a/apps/files_versions/download.php +++ b/apps/files_versions/download.php @@ -25,8 +25,8 @@ * */ -OCP\JSON::checkAppEnabled('files_versions'); -OCP\JSON::checkLoggedIn(); +\OC_JSON::checkAppEnabled('files_versions'); +\OC_JSON::checkLoggedIn(); $file = $_GET['file']; $revision=(int)$_GET['revision']; diff --git a/apps/user_ldap/ajax/clearMappings.php b/apps/user_ldap/ajax/clearMappings.php index 4ec0330729605..01b6b7f0ef2c8 100644 --- a/apps/user_ldap/ajax/clearMappings.php +++ b/apps/user_ldap/ajax/clearMappings.php @@ -27,9 +27,9 @@ use OCA\User_LDAP\Mapping\GroupMapping; // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $subject = (string)$_POST['ldap_clear_mapping']; $mapping = null; @@ -43,7 +43,7 @@ $l = \OC::$server->getL10N('user_ldap'); throw new \Exception($l->t('Failed to clear the mappings.')); } - OCP\JSON::success(); + \OC_JSON::success(); } catch (\Exception $e) { - OCP\JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(array('message' => $e->getMessage())); } diff --git a/apps/user_ldap/ajax/deleteConfiguration.php b/apps/user_ldap/ajax/deleteConfiguration.php index 220f4c13c4ab3..fa2ab36770fb0 100644 --- a/apps/user_ldap/ajax/deleteConfiguration.php +++ b/apps/user_ldap/ajax/deleteConfiguration.php @@ -27,15 +27,15 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $prefix = (string)$_POST['ldap_serverconfig_chooser']; $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); if($helper->deleteServerConfiguration($prefix)) { - OCP\JSON::success(); + \OC_JSON::success(); } else { $l = \OC::$server->getL10N('user_ldap'); - OCP\JSON::error(array('message' => $l->t('Failed to delete the server configuration'))); + \OC_JSON::error(array('message' => $l->t('Failed to delete the server configuration'))); } diff --git a/apps/user_ldap/ajax/getConfiguration.php b/apps/user_ldap/ajax/getConfiguration.php index a6c3d975782ae..72404d6b30475 100644 --- a/apps/user_ldap/ajax/getConfiguration.php +++ b/apps/user_ldap/ajax/getConfiguration.php @@ -25,9 +25,9 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $prefix = (string)$_POST['ldap_serverconfig_chooser']; $ldapWrapper = new OCA\User_LDAP\LDAP(); @@ -37,4 +37,4 @@ // hide password $configuration['ldap_agent_password'] = '**PASSWORD SET**'; } -OCP\JSON::success(array('configuration' => $configuration)); +\OC_JSON::success(array('configuration' => $configuration)); diff --git a/apps/user_ldap/ajax/getNewServerConfigPrefix.php b/apps/user_ldap/ajax/getNewServerConfigPrefix.php index c0c81be14d7bc..b0e6ce31a83fe 100644 --- a/apps/user_ldap/ajax/getNewServerConfigPrefix.php +++ b/apps/user_ldap/ajax/getNewServerConfigPrefix.php @@ -24,9 +24,9 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $helper = new \OCA\User_LDAP\Helper(\OC::$server->getConfig()); $serverConnections = $helper->getServerConfigurationPrefixes(); @@ -48,4 +48,4 @@ } $newConfig->saveConfiguration(); -OCP\JSON::success($resultData); +\OC_JSON::success($resultData); diff --git a/apps/user_ldap/ajax/setConfiguration.php b/apps/user_ldap/ajax/setConfiguration.php index 51737cc995332..1ed1a36d093de 100644 --- a/apps/user_ldap/ajax/setConfiguration.php +++ b/apps/user_ldap/ajax/setConfiguration.php @@ -26,9 +26,9 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $prefix = (string)$_POST['ldap_serverconfig_chooser']; @@ -47,4 +47,4 @@ $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); $connection->setConfiguration($_POST); $connection->saveConfiguration(); -OCP\JSON::success(); +\OC_JSON::success(); diff --git a/apps/user_ldap/ajax/testConfiguration.php b/apps/user_ldap/ajax/testConfiguration.php index 1b33a02544039..b1f339e6148b3 100644 --- a/apps/user_ldap/ajax/testConfiguration.php +++ b/apps/user_ldap/ajax/testConfiguration.php @@ -28,9 +28,9 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $l = \OC::$server->getL10N('user_ldap'); @@ -69,20 +69,20 @@ $ldapWrapper->read($connection->getConnectionResource(), '', 'objectClass=*', array('dn')); } catch (\Exception $e) { if($e->getCode() === 1) { - OCP\JSON::error(array('message' => $l->t('Invalid configuration: Anonymous binding is not allowed.'))); + \OC_JSON::error(array('message' => $l->t('Invalid configuration: Anonymous binding is not allowed.'))); exit; } } - OCP\JSON::success(array('message' + \OC_JSON::success(array('message' => $l->t('Valid configuration, connection established!'))); } else { - OCP\JSON::error(array('message' + \OC_JSON::error(array('message' => $l->t('Valid configuration, but binding failed. Please check the server settings and credentials.'))); } } else { - OCP\JSON::error(array('message' + \OC_JSON::error(array('message' => $l->t('Invalid configuration. Please have a look at the logs for further details.'))); } } catch (\Exception $e) { - OCP\JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(array('message' => $e->getMessage())); } diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php index d25a70b41c8e0..f0ce8f87c3987 100644 --- a/apps/user_ldap/ajax/wizard.php +++ b/apps/user_ldap/ajax/wizard.php @@ -29,20 +29,20 @@ */ // Check user and app status -OCP\JSON::checkAdminUser(); -OCP\JSON::checkAppEnabled('user_ldap'); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::checkAppEnabled('user_ldap'); +\OC_JSON::callCheck(); $l = \OC::$server->getL10N('user_ldap'); if(!isset($_POST['action'])) { - \OCP\JSON::error(array('message' => $l->t('No action specified'))); + \\OC_JSON::error(array('message' => $l->t('No action specified'))); } $action = (string)$_POST['action']; if(!isset($_POST['ldap_serverconfig_chooser'])) { - \OCP\JSON::error(array('message' => $l->t('No configuration specified'))); + \\OC_JSON::error(array('message' => $l->t('No configuration specified'))); } $prefix = (string)$_POST['ldap_serverconfig_chooser']; @@ -94,14 +94,14 @@ try { $result = $wizard->$action(); if($result !== false) { - OCP\JSON::success($result->getResultArray()); + \OC_JSON::success($result->getResultArray()); exit; } } catch (\Exception $e) { - \OCP\JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); + \\OC_JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); exit; } - \OCP\JSON::error(); + \\OC_JSON::error(); exit; break; @@ -110,14 +110,14 @@ $loginName = $_POST['ldap_test_loginname']; $result = $wizard->$action($loginName); if($result !== false) { - OCP\JSON::success($result->getResultArray()); + \OC_JSON::success($result->getResultArray()); exit; } } catch (\Exception $e) { - \OCP\JSON::error(array('message' => $e->getMessage())); + \\OC_JSON::error(array('message' => $e->getMessage())); exit; } - \OCP\JSON::error(); + \\OC_JSON::error(); exit; break; } @@ -126,14 +126,14 @@ $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; if($key === false || is_null($val)) { - \OCP\JSON::error(array('message' => $l->t('No data specified'))); + \\OC_JSON::error(array('message' => $l->t('No data specified'))); exit; } $cfg = array($key => $val); $setParameters = array(); $configuration->setConfiguration($cfg, $setParameters); if(!in_array($key, $setParameters)) { - \OCP\JSON::error(array('message' => $l->t($key. + \\OC_JSON::error(array('message' => $l->t($key. ' Could not set configuration %s', $setParameters[0]))); exit; } @@ -141,9 +141,9 @@ //clear the cache on save $connection = new \OCA\User_LDAP\Connection($ldapWrapper, $prefix); $connection->clearCache(); - OCP\JSON::success(); + \OC_JSON::success(); break; default: - \OCP\JSON::error(array('message' => $l->t('Action does not exist'))); + \\OC_JSON::error(array('message' => $l->t('Action does not exist'))); break; } diff --git a/lib/base.php b/lib/base.php index 0c78d235c5940..8af674e7ee8b1 100644 --- a/lib/base.php +++ b/lib/base.php @@ -944,8 +944,8 @@ public static function handleRequest() { && $request->getMethod() === 'POST' && ((array)$request->getParam('appid')) !== '' ) { - \OCP\JSON::callCheck(); - \OCP\JSON::checkAdminUser(); + \OC_JSON::callCheck(); + \OC_JSON::checkAdminUser(); $appIds = (array)$request->getParam('appid'); foreach($appIds as $appId) { $appId = \OC_App::cleanAppId($appId); diff --git a/settings/ajax/disableapp.php b/settings/ajax/disableapp.php index 1d9cb984e2af1..d719c3e9f2339 100644 --- a/settings/ajax/disableapp.php +++ b/settings/ajax/disableapp.php @@ -21,8 +21,8 @@ * along with this program. If not, see * */ -OCP\JSON::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::callCheck(); $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay diff --git a/settings/ajax/enableapp.php b/settings/ajax/enableapp.php index edcccf9b0b994..efe5ee3374f90 100644 --- a/settings/ajax/enableapp.php +++ b/settings/ajax/enableapp.php @@ -25,7 +25,7 @@ * */ OC_JSON::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::callCheck(); $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay diff --git a/settings/ajax/navigationdetect.php b/settings/ajax/navigationdetect.php index 043e10da559de..35cc25f19ffa9 100644 --- a/settings/ajax/navigationdetect.php +++ b/settings/ajax/navigationdetect.php @@ -21,8 +21,8 @@ * */ OC_Util::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::callCheck(); $navigation = \OC::$server->getNavigationManager()->getAll(); -OCP\JSON::success(['nav_entries' => $navigation]); +\OC_JSON::success(['nav_entries' => $navigation]); diff --git a/settings/ajax/setquota.php b/settings/ajax/setquota.php index c3fde409c00f9..b1155ee0f971d 100644 --- a/settings/ajax/setquota.php +++ b/settings/ajax/setquota.php @@ -31,7 +31,7 @@ */ OC_JSON::checkSubAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::callCheck(); $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay diff --git a/settings/ajax/togglesubadmins.php b/settings/ajax/togglesubadmins.php index 4fee0530dd145..c115568bca7f4 100644 --- a/settings/ajax/togglesubadmins.php +++ b/settings/ajax/togglesubadmins.php @@ -24,7 +24,7 @@ * */ OC_JSON::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::callCheck(); $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay diff --git a/settings/ajax/uninstallapp.php b/settings/ajax/uninstallapp.php index 63107905b02fd..26100d3b0668f 100644 --- a/settings/ajax/uninstallapp.php +++ b/settings/ajax/uninstallapp.php @@ -22,8 +22,8 @@ * along with this program. If not, see * */ -OCP\JSON::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::callCheck(); $lastConfirm = (int) \OC::$server->getSession()->get('last-password-confirm'); if ($lastConfirm < (time() - 30 * 60 + 15)) { // allow 15 seconds delay diff --git a/settings/ajax/updateapp.php b/settings/ajax/updateapp.php index 3431c68dbd7e5..d37e1cfcaed07 100644 --- a/settings/ajax/updateapp.php +++ b/settings/ajax/updateapp.php @@ -25,11 +25,11 @@ * along with this program. If not, see * */ -OCP\JSON::checkAdminUser(); -OCP\JSON::callCheck(); +\OC_JSON::checkAdminUser(); +\OC_JSON::callCheck(); if (!array_key_exists('appid', $_POST)) { - OCP\JSON::error(array( + \OC_JSON::error(array( 'message' => 'No AppId given!' )); return; From 26073eac0c76cb3c6f6ee4a8688e0e1bada820ff Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 22 Mar 2018 13:20:03 +0100 Subject: [PATCH 2/3] Finally remove \OCP\JSON Signed-off-by: Roeland Jago Douma --- apps/files_external/ajax/applicable.php | 2 +- apps/files_versions/ajax/getVersions.php | 4 +- apps/user_ldap/ajax/wizard.php | 18 +-- lib/public/JSON.php | 166 ----------------------- 4 files changed, 12 insertions(+), 178 deletions(-) delete mode 100644 lib/public/JSON.php diff --git a/apps/files_external/ajax/applicable.php b/apps/files_external/ajax/applicable.php index eb0f754870d22..a946962a2931f 100644 --- a/apps/files_external/ajax/applicable.php +++ b/apps/files_external/ajax/applicable.php @@ -51,4 +51,4 @@ $results = array('groups' => $groups, 'users' => $users); -\\OC_JSON::success($results); +\OC_JSON::success($results); diff --git a/apps/files_versions/ajax/getVersions.php b/apps/files_versions/ajax/getVersions.php index 6bba0a540c6b5..5811242c2368c 100644 --- a/apps/files_versions/ajax/getVersions.php +++ b/apps/files_versions/ajax/getVersions.php @@ -47,10 +47,10 @@ unset($version['path']); } - \\OC_JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); + \OC_JSON::success(array('data' => array('versions' => $versions, 'endReached' => $endReached))); } else { - \\OC_JSON::success(array('data' => array('versions' => [], 'endReached' => true))); + \OC_JSON::success(array('data' => array('versions' => [], 'endReached' => true))); } diff --git a/apps/user_ldap/ajax/wizard.php b/apps/user_ldap/ajax/wizard.php index f0ce8f87c3987..df178ac0a822e 100644 --- a/apps/user_ldap/ajax/wizard.php +++ b/apps/user_ldap/ajax/wizard.php @@ -36,13 +36,13 @@ $l = \OC::$server->getL10N('user_ldap'); if(!isset($_POST['action'])) { - \\OC_JSON::error(array('message' => $l->t('No action specified'))); + \OC_JSON::error(array('message' => $l->t('No action specified'))); } $action = (string)$_POST['action']; if(!isset($_POST['ldap_serverconfig_chooser'])) { - \\OC_JSON::error(array('message' => $l->t('No configuration specified'))); + \OC_JSON::error(array('message' => $l->t('No configuration specified'))); } $prefix = (string)$_POST['ldap_serverconfig_chooser']; @@ -98,10 +98,10 @@ exit; } } catch (\Exception $e) { - \\OC_JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); + \OC_JSON::error(array('message' => $e->getMessage(), 'code' => $e->getCode())); exit; } - \\OC_JSON::error(); + \OC_JSON::error(); exit; break; @@ -114,10 +114,10 @@ exit; } } catch (\Exception $e) { - \\OC_JSON::error(array('message' => $e->getMessage())); + \OC_JSON::error(array('message' => $e->getMessage())); exit; } - \\OC_JSON::error(); + \OC_JSON::error(); exit; break; } @@ -126,14 +126,14 @@ $key = isset($_POST['cfgkey']) ? $_POST['cfgkey'] : false; $val = isset($_POST['cfgval']) ? $_POST['cfgval'] : null; if($key === false || is_null($val)) { - \\OC_JSON::error(array('message' => $l->t('No data specified'))); + \OC_JSON::error(array('message' => $l->t('No data specified'))); exit; } $cfg = array($key => $val); $setParameters = array(); $configuration->setConfiguration($cfg, $setParameters); if(!in_array($key, $setParameters)) { - \\OC_JSON::error(array('message' => $l->t($key. + \OC_JSON::error(array('message' => $l->t($key. ' Could not set configuration %s', $setParameters[0]))); exit; } @@ -144,6 +144,6 @@ \OC_JSON::success(); break; default: - \\OC_JSON::error(array('message' => $l->t('Action does not exist'))); + \OC_JSON::error(array('message' => $l->t('Action does not exist'))); break; } diff --git a/lib/public/JSON.php b/lib/public/JSON.php deleted file mode 100644 index 6138aec1f4929..0000000000000 --- a/lib/public/JSON.php +++ /dev/null @@ -1,166 +0,0 @@ - - * @author Frank Karlitschek - * @author Lukas Reschke - * @author Morris Jobke - * @author Roeland Jago Douma - * @author Thomas Müller - * @author Thomas Tanghus - * @author Vincent Petry - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -/** - * Public interface of ownCloud for apps to use. - * JSON Class - */ - -// use OCP namespace for all classes that are considered public. -// This means that they should be used by apps instead of the internal ownCloud classes -namespace OCP; - -/** - * This class provides convenient functions to generate and send JSON data. Useful for Ajax calls - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - */ -class JSON { - /** - * Check if the user is logged in, send json error msg if not. - * - * This method checks if a user is logged in. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Authentication error."}} - * - * Add this call to the start of all ajax method files that requires - * an authenticated user. - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead - * - * @suppress PhanDeprecatedFunction - */ - public static function checkLoggedIn() { - \OC_JSON::checkLoggedIn(); - } - - /** - * Check an ajax get/post call if the request token is valid. - * - * This method checks for a valid variable 'requesttoken' in $_GET, - * $_POST and $_SERVER. If a valid token is not found, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Token expired. Please reload page."}} - * - * Add this call to the start of all ajax method files that creates, - * updates or deletes anything. - * In cases where you e.g. use an ajax call to load a dialog containing - * a submittable form, you will need to add the requesttoken first as a - * parameter to the ajax call, then assign it to the template and finally - * add a hidden input field also named 'requesttoken' containing the value. - * @deprecated 8.1.0 Use annotation based CSRF checks from the AppFramework instead - * - * @suppress PhanDeprecatedFunction - */ - public static function callCheck() { - \OC_JSON::callCheck(); - } - - /** - * Send json success msg - * - * Return a json success message with optional extra data. - * @see \OCP\JSON::error() for the format to use. - * - * @param array $data The data to use - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - * @suppress PhanDeprecatedFunction - */ - public static function success( $data = array() ) { - \OC_JSON::success($data); - } - - /** - * Send json error msg - * - * Return a json error message with optional extra data for - * error message or app specific data. - * - * Example use: - * - * $id = [some value] - * OCP\JSON::error(array('data':array('message':'An error happened', 'id': $id))); - * - * Will return the json formatted string: - * - * {"status":"error","data":{"message":"An error happened", "id":[some value]}} - * - * @param array $data The data to use - * @deprecated 8.1.0 Use a AppFramework JSONResponse instead - * @suppress PhanDeprecatedFunction - */ - public static function error( $data = array() ) { - \OC_JSON::error($data); - } - - /** - * Check if the App is enabled and send JSON error message instead - * - * This method checks if a specific app is enabled. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Application is not enabled."}} - * - * Add this call to the start of all ajax method files that requires - * a specific app to be enabled. - * - * @param string $app The app to check - * @deprecated 8.1.0 Use the AppFramework instead. It will automatically check if the app is enabled. - * @suppress PhanDeprecatedFunction - */ - public static function checkAppEnabled( $app ) { - \OC_JSON::checkAppEnabled($app); - } - - /** - * Check if the user is a admin, send json error msg if not - * - * This method checks if the current user has admin rights. If not, a json error - * response will be return and the method will exit from execution - * of the script. - * The returned json will be in the format: - * - * {"status":"error","data":{"message":"Authentication error."}} - * - * Add this call to the start of all ajax method files that requires - * administrative rights. - * - * @deprecated 8.1.0 Use annotation based ACLs from the AppFramework instead - * @suppress PhanDeprecatedFunction - */ - public static function checkAdminUser() { - \OC_JSON::checkAdminUser(); - } -} From 2c9fd794b82a9aa2c762526973a9afb66cc46eda Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 23 Mar 2018 13:31:16 +0100 Subject: [PATCH 3/3] Update autoloader Signed-off-by: Roeland Jago Douma --- lib/composer/composer/autoload_classmap.php | 1 - lib/composer/composer/autoload_static.php | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/composer/composer/autoload_classmap.php b/lib/composer/composer/autoload_classmap.php index ecd7f155c0ea2..fd37ec1ca3909 100644 --- a/lib/composer/composer/autoload_classmap.php +++ b/lib/composer/composer/autoload_classmap.php @@ -222,7 +222,6 @@ 'OCP\\IUserManager' => $baseDir . '/lib/public/IUserManager.php', 'OCP\\IUserSession' => $baseDir . '/lib/public/IUserSession.php', 'OCP\\Image' => $baseDir . '/lib/public/Image.php', - 'OCP\\JSON' => $baseDir . '/lib/public/JSON.php', 'OCP\\L10N\\IFactory' => $baseDir . '/lib/public/L10N/IFactory.php', 'OCP\\LDAP\\IDeletionFlagSupport' => $baseDir . '/lib/public/LDAP/IDeletionFlagSupport.php', 'OCP\\LDAP\\ILDAPProvider' => $baseDir . '/lib/public/LDAP/ILDAPProvider.php', diff --git a/lib/composer/composer/autoload_static.php b/lib/composer/composer/autoload_static.php index 8fbff8a1e1354..a3e1aca34b20f 100644 --- a/lib/composer/composer/autoload_static.php +++ b/lib/composer/composer/autoload_static.php @@ -252,7 +252,6 @@ class ComposerStaticInit53792487c5a8370acc0b06b1a864ff4c 'OCP\\IUserManager' => __DIR__ . '/../../..' . '/lib/public/IUserManager.php', 'OCP\\IUserSession' => __DIR__ . '/../../..' . '/lib/public/IUserSession.php', 'OCP\\Image' => __DIR__ . '/../../..' . '/lib/public/Image.php', - 'OCP\\JSON' => __DIR__ . '/../../..' . '/lib/public/JSON.php', 'OCP\\L10N\\IFactory' => __DIR__ . '/../../..' . '/lib/public/L10N/IFactory.php', 'OCP\\LDAP\\IDeletionFlagSupport' => __DIR__ . '/../../..' . '/lib/public/LDAP/IDeletionFlagSupport.php', 'OCP\\LDAP\\ILDAPProvider' => __DIR__ . '/../../..' . '/lib/public/LDAP/ILDAPProvider.php',