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 all 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# This repository is read-only and kept only for documentation purposes. The development of the epubreader app is done in this repository: https://github.com/e-alfred/epubreader

owncloud-apps
=============

This repo contains a few apps I made for Nextcloud and Owncloud, mostly related to reading/publishing books and other digital publications.
This repo contains a few apps made for Nextcloud and Owncloud, mostly related to reading/publishing books and other digital publications.

Install
-------
Expand Down
Binary file added dist/files_opds-1.2.3-patched-4-NC.tar.gz
Binary file not shown.
Binary file added dist/files_opds-1.2.3-patched-4-OC.tar.gz
Binary file not shown.
Binary file added dist/files_opds-1.2.3-patched-5-NC.tar.gz
Binary file not shown.
Binary file added dist/files_opds-1.2.3-patched-5-OC.tar.gz
Binary file not shown.
Binary file added dist/files_reader-1.2.3-patched-4-NC.tar.gz
Binary file not shown.
Binary file added dist/files_reader-1.2.3-patched-4-OC.tar.gz
Binary file not shown.
Binary file added dist/files_reader-1.2.3-patched-5-NC.tar.gz
Binary file not shown.
Binary file added dist/files_reader-1.2.3-patched-5-OC.tar.gz
Binary file not shown.
Binary file added dist/files_reader-1.2.3-patched-NC.tar.gz
Binary file not shown.
7 changes: 3 additions & 4 deletions files_opds/ajax/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

namespace OCA\Files_Opds;

\OCP\JSON::callCheck();
\OCP\JSON::checkLoggedIn();
\OC_JSON::callCheck();
\OC_JSON::checkLoggedIn();
$defaults = new \OC_Defaults();

$l = \OC::$server->getL10N('files_opds');
Expand Down Expand Up @@ -53,11 +53,10 @@
Config::setPreview('OC\Preview\MSOffice2007',$opdsPreviewMsOffice);
}

\OCP\JSON::success(
\OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
);

exit();

6 changes: 3 additions & 3 deletions files_opds/ajax/clear_bookshelf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

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

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

Bookshelf::clear();
\OCP\JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared"))));
\OC_JSON::success(array( "data" => array( "message" => $l->t("Bookshelf cleared"))));
23 changes: 12 additions & 11 deletions files_opds/ajax/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,40 @@

namespace OCA\Files_Opds;

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

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

$opdsEnable = isset($_POST['opdsEnable']) ? $_POST['opdsEnable'] : 'false';
$rootPath = isset($_POST['rootPath']) ? $_POST['rootPath'] : '/Library';
$fileTypes = isset($_POST['fileTypes']) ? $_POST['fileTypes'] : '';
$skipList = isset($_POST['skipList']) ? $_POST['skipList'] : 'metadata.opf,cover.jpg';
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OCP\User::getDisplayName());
$feedTitle = isset($_POST['feedTitle']) ? $_POST['feedTitle'] : $l->t("%s's Library", \OC_User::getDisplayName());
$opdsoldMime = isset($_POST['opdsoldMime']) ? $_POST['opdsoldMime'] : '';

if (!strlen($rootPath) ||
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
\OC\Files\Filesystem::isValidPath($rootPath) === false ||
\OC\Files\Filesystem::file_exists($rootPath) === false ) {
\OCP\JSON::error(
\OC_JSON::error(
array(
'data' => array('message'=> $l->t('Directory does not exist!'))
)
);
} else {
Config::set('root_path', $rootPath);
Config::set('enable', $opdsEnable);
Config::set('file_types', $fileTypes);
Config::set('skip_list', $skipList);
Config::set('feed_title', $feedTitle);
Config::set('enable', $opdsEnable);
Config::set('file_types', $fileTypes);
Config::set('skip_list', $skipList);
Config::set('feed_title', $feedTitle);
Config::set('old_mime', $opdsoldMime);
Config::set('id', Util::genUuid());

\OCP\JSON::success(
\OC_JSON::success(
array(
'data' => array('message'=> $l->t('Settings updated successfully.'))
)
);
}

exit();

6 changes: 3 additions & 3 deletions files_opds/ajax/schedule_rescan.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@

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

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

Meta::rescan();
\OCP\JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled"))));
\OC_JSON::success(array( "data" => array( "message" => $l->t("Rescan scheduled"))));
11 changes: 2 additions & 9 deletions files_opds/appinfo/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ See [README] for more information on (mis)features of this app.
]]>
</description>
<licence>AGPL</licence>
<version>0.8.8</version>
<version>0.9</version>
<author>Frank de Lange</author>
<category>tools</category>
<category>files</category>
Expand All @@ -32,16 +32,9 @@ See [README] for more information on (mis)features of this app.
</documentation>
<screenshot>https://raw.githubusercontent.com/Yetangitu/owncloud-apps/master/screenshots/files_opds-1.png</screenshot>
<dependencies>
<php min-version="5.4" />
<database>pgsql</database>
<database>sqlite</database>
<database>mysql</database>
<owncloud min-version="8.2" max-version="10.0" />
<nextcloud min-version="8.1" max-version="13.0" />
<nextcloud min-version="14" max-version="17" />
</dependencies>
<settings>
<admin>OCA\Files_Opds\Settings\Admin</admin>
</settings>
<ocsid>168132</ocsid>
</info>

3 changes: 3 additions & 0 deletions files_opds/js/personal.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ $(document).ready(function(){
var opdsSettings = {
save : function() {
var opdsEnable = document.getElementById('opds-enable').checked ? 'true' : 'false';
var opdsoldMime = document.getElementById('opds-oldmime').checked ? 'true' : 'false';
var data = {
opdsEnable : opdsEnable,
opdsoldMime : opdsoldMime,
rootPath : $('#opds-root-path').val(),
fileTypes : $('#opds-file-types').val(),
skipList : $('#opds-skip-list').val(),
Expand All @@ -61,5 +63,6 @@ $(document).ready(function(){
}
});
$('#opds-enable').on("change", opdsSettings.save);
$('#opds-oldmime').on("change", opdsSettings.save);
});

18 changes: 9 additions & 9 deletions files_opds/lib/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Config
* @return string retrieved value or default
*/
public static function get($key, $default) {
return \OCP\Config::getUserValue(\OCP\User::getUser(), 'files_opds', $key, $default);
return \OC::$server->getConfig()->getUserValue(\OC::$server->getUserSession()->getUser()->getUID(), 'files_opds', $key, $default);
}

/**
Expand All @@ -36,7 +36,7 @@ public static function get($key, $default) {
* @return bool success
*/
public static function set($key, $value) {
return \OCP\Config::setUserValue(\OCP\User::getUser(), 'files_opds', $key, $value);
return \OC::$server->getConfig()->setUserValue(\OC::$server->getUserSession()->getUser()->getUID(), 'files_opds', $key, $value);
}

/**
Expand All @@ -47,7 +47,7 @@ public static function set($key, $value) {
* @return string retrieved value or default
*/
public static function getApp($key, $default) {
return \OCP\Config::getAppValue('files_opds', $key, $default);
return \OC::$server->getConfig()->getAppValue('files_opds', $key, $default);
}

/**
Expand All @@ -58,17 +58,17 @@ public static function getApp($key, $default) {
* @return bool success
*/
public static function setApp($key, $value) {
return \OCP\Config::setAppValue('files_opds', $key, $value);
return \OC::$server->getConfig()->setAppValue('files_opds', $key, $value);
}

/**
* @brief get preview status
*
*
* @param string format
* @return bool (true = enabled, false = disabled)
*/
public static function getPreview($format) {
$enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null);
$enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if (!($enablePreviewProviders === null)) {
return in_array($format, $enablePreviewProviders);
}
Expand All @@ -83,7 +83,7 @@ public static function getPreview($format) {
* @return bool
*/
public static function setPreview($format, $enable = 'false') {
$enablePreviewProviders = \OCP\Config::getSystemValue('enabledPreviewProviders', null);
$enablePreviewProviders = \OC::$server->getConfig()->getSystemValue('enabledPreviewProviders', null);
if ($enable == 'true') {
if ($enablePreviewProviders === null) {
// set up default providers
Expand All @@ -103,7 +103,7 @@ public static function setPreview($format, $enable = 'false') {
}
}

if (!(\OCP\Config::setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
if (!(\OC::$server->getConfig()->setSystemValue('enabledPreviewProviders', $enablePreviewProviders))) {
logWarn("Failed to enable " . $format . " preview provider (config.php readonly?)");
return true;
}
Expand Down
6 changes: 3 additions & 3 deletions files_opds/lib/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Feed
* @return string feed id
*/
public static function getFeedId() {
return Config::get('id', '');
return Config::get('id', '');
}

/**
Expand Down Expand Up @@ -66,8 +66,8 @@ public static function serveFeed($dir, $id, $type) {
$tmpl->assign('id', $id);
$tmpl->assign('type', $type);
$tmpl->assign('dir', $dir);
$tmpl->assign('user', \OCP\User::getDisplayName());
$tmpl->assign('feed_title', Config::get('feed_title',\OCP\User::getDisplayName() . "'s Library"));
$tmpl->assign('user', \OC_User::getDisplayName());
$tmpl->assign('feed_title', Config::get('feed_title',\OC_User::getDisplayName() . "'s Library"));
$tmpl->assign('feed_subtitle', Config::getApp('feed_subtitle', $defaults->getName() . " OPDS catalog"));
$tmpl->assign('feed_updated', time());
$tmpl->printPage();
Expand Down
10 changes: 5 additions & 5 deletions files_opds/lib/meta.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static function isValid($meta) {
protected static function load($id) {
$sql = 'SELECT * FROM `*PREFIX*opds_metadata` WHERE id = ?';
$args = array($id);
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);
$result = $query->execute($args);

return ($row = $result->fetchRow()) ? $row : false;
Expand All @@ -79,7 +79,7 @@ protected static function load($id) {
protected static function save($meta) {
$sql = "SELECT `id` FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($meta['id']);
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);
$result = $query->execute($args);
$data = $result->fetchRow();
if (isset($data['id'])) {
Expand Down Expand Up @@ -118,7 +118,7 @@ protected static function save($meta) {
$meta['rescan']
);
}
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);

return $query->execute($args);
}
Expand Down Expand Up @@ -150,7 +150,7 @@ public static function get($id) {
public static function remove($id) {
$sql = "DELETE FROM *PREFIX*opds_metadata WHERE `id`=?";
$args = array($id);
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);

return $query->execute($args);
}
Expand All @@ -162,7 +162,7 @@ public static function remove($id) {
public static function rescan() {
$sql = "UPDATE *PREFIX*opds_metadata SET `rescan`=?";
$args = array(date("Y-m-d H:i:s"));
$query = \OCP\DB::prepare($sql);
$query = \OC_DB::prepare($sql);
$result = $query->execute($args);
}

Expand Down
2 changes: 1 addition & 1 deletion files_opds/lib/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public static function changeHttpStatus($statusCode) {
*/
public static function genUuid() {
$defaults = new \OC_Defaults();
$hash = md5(\OCP\User::getDisplayName() . $defaults->getBaseUrl());
$hash = md5(\OC_User::getDisplayName() . $defaults->getBaseUrl());
$hash = substr($hash, 0, 8 ) .'-'.
substr($hash, 8, 4) .'-3'.
substr($hash, 13, 3) .'-9'.
Expand Down
5 changes: 4 additions & 1 deletion files_opds/personal.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@

$tmpl = new \OCP\Template('files_opds', 'personal');
$opdsEnable = Config::get('enable', false);
$opdsoldMime = Config::get('old_mime', false);
$tmpl->assign('opdsEnable-checked', ($opdsEnable === 'true') ? 'checked="checked"' : '');
$tmpl->assign('opdsEnable-value', ($opdsEnable === 'true') ? '1' : '0');
$tmpl->assign('rootPath', Config::get('root_path', '/Library'));
$tmpl->assign('fileTypes', Config::get('file_types', ''));
$tmpl->assign('skipList', Config::get('skip_list', 'metadata.opf,cover.jpg'));
$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OCP\User::getDisplayName())));
$tmpl->assign('feedTitle', Config::get('feed_title', $l->t("%s's Library", \OC_User::getDisplayName())));
$tmpl->assign('bookshelf-count', Bookshelf::count());
$tmpl->assign('feedUrl', Util::linkToAbsolute('','index.php') . '/apps/files_opds/');
$tmpl->assign('opdsoldMime-checked', ($opdsoldMime === 'true') ? 'checked="checked"' : '');
$tmpl->assign('opdsoldMime-value', ($opdsoldMime === 'true') ? '1' : '0');

return $tmpl->fetchPage();

11 changes: 8 additions & 3 deletions files_opds/templates/feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ function formatMetadata($humansize,$mimetype,$name) {

case 'bookshelf':
foreach ($_['bookshelf'] as $file) {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
foreach( $file as $key => $value )
$newfile["file_".$key] = $value;
print_unescaped($this->inc('part.feed.acquisition', $newfile ));
}
break;

Expand All @@ -60,10 +62,13 @@ function formatMetadata($humansize,$mimetype,$name) {
case 'directory':
default:
foreach ($_['files'] as $file) {
foreach( $file as $key => $value )
$newfile["file_".$key] = $value;

if ($file['type'] == 'dir') {
print_unescaped($this->inc('part.feed.navigation', [ 'file' => $file ]));
print_unescaped($this->inc('part.feed.navigation', $newfile ));
} else {
print_unescaped($this->inc('part.feed.acquisition', [ 'file' => $file ]));
print_unescaped($this->inc('part.feed.acquisition', $newfile ));
}
}
break;
Expand Down
Loading