Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecated calls in files_reader app #108

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions files_reader/ajax/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@

namespace OCA\Files_Reader;

\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OC_JSON::callCheck();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: you replaced a deprecated public API with a private API that is subject to change at any time without warning (can even happen within minor version of the Nextcloud server because these are not supposed to be used in apps).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These files should be replaced with proper controllers, then you don't have to use any of these private APIs. See https://docs.nextcloud.com/server/14/developer_manual/app/controllers.html for more info on that.

\OC_JSON::checkLoggedIn();

$l = \OC::$server->getL10N('files_reader');

$EpubEnable = isset($_POST['EpubEnable']) ? $_POST['EpubEnable'] : 'false';
$PdfEnable = isset($_POST['PdfEnable']) ? $_POST['PdfEnable'] : 'false';
$CbxEnable = isset($_POST['CbxEnable']) ? $_POST['CbxEnable'] : 'false';

Config::set('epub_enable', $EpubEnable);
Config::set('pdf_enable', $PdfEnable);
Config::set('cbx_enable', $CbxEnable);
\OC::$server->getAppConfig()->setValue('files_reader', 'epub_enable', $EpubEnable);
\OC::$server->getAppConfig()->setValue('files_reader', 'pdf_enable', $PdfEnable);
\OC::$server->getAppConfig()->setValue('files_reader', 'cbx_enable', $CbxEnable);

\OCP\JSON::success(
\OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
Expand Down
2 changes: 1 addition & 1 deletion files_reader/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ See [README] for more exhaustive information on features and potential misfeatur
</types>
<dependencies>
<owncloud min-version="8.2" max-version="10.0" />
<nextcloud min-version="8.1" max-version="13.0"/>
<nextcloud min-version="8.1" max-version="14.0"/>
<database>pgsql</database>
<database>sqlite</database>
<database>mysql</database>
Expand Down
6 changes: 3 additions & 3 deletions files_reader/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
#$l = \OC::$server->getL10N('files_reader');

$tmpl = new \OCP\Template('files_reader', 'settings-personal');
$EpubEnable = Config::get('epub_enable', 'true');
$PdfEnable = Config::get('pdf_enable', 'true');
$CbxEnable = Config::get('cbx_enable', 'true');
$EpubEnable = \OC::$server->getConfig()->getAppValue('epub_enable', 'true');
$PdfEnable = \OC::$server->getConfig()->getAppValue('pdf_enable', 'true');
$CbxEnable = \OC::$server->getConfig()->getAppValue('cbx_enable', 'true');
$tmpl->assign('EpubEnable', $EpubEnable);
$tmpl->assign('PdfEnable', $PdfEnable);
$tmpl->assign('CbxEnable', $CbxEnable);
Expand Down