Remove deprected API usage. Step 1
This commit is contained in:
parent
d93ee482af
commit
8897dda9ab
@ -36,8 +36,8 @@ $navigationEntry = function () use ($c) {
|
||||
return [
|
||||
'id' => 'documents_index',
|
||||
'order' => 2,
|
||||
'href' => \OCP\Util::linkTo('documents/', 'index.php'),
|
||||
'icon' => \OCP\Util::imagePath('documents', 'documents.svg'),
|
||||
'href' => $c->query('ServerContainer')->getURLGenerator()->linkToRoute('documents.document.index'),
|
||||
'icon' => $c->query('ServerContainer')->getURLGenerator()->imagePath('documents', 'documents.svg'),
|
||||
'name' => $c->query('L10N')->t('Documents')
|
||||
];
|
||||
};
|
||||
|
@ -73,8 +73,8 @@ class Application extends App {
|
||||
$container->registerService('L10N', function($c) {
|
||||
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
|
||||
});
|
||||
$container->registerService('UserId', function() {
|
||||
return \OCP\User::getUser();
|
||||
$container->registerService('UserId', function($c) {
|
||||
return $c->query('ServerContainer')->getUserSession()->getUser()->getUID();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -12,37 +12,28 @@
|
||||
namespace OCA\Documents;
|
||||
|
||||
$application = new \OCA\Documents\AppInfo\Application();
|
||||
$application->registerRoutes($this, array(
|
||||
'routes' => array(
|
||||
$application->registerRoutes($this, [
|
||||
'routes' => [
|
||||
//users
|
||||
array('name' => 'user#rename', 'url' => 'ajax/user/rename', 'verb' => 'POST'),
|
||||
array('name' => 'user#disconnectUser', 'url' => 'ajax/user/disconnect', 'verb' => 'POST'),
|
||||
array('name' => 'user#disconnectGuest', 'url' => 'ajax/user/disconnectGuest', 'verb' => 'POST'),
|
||||
['name' => 'user#rename', 'url' => 'ajax/user/rename', 'verb' => 'POST'],
|
||||
['name' => 'user#disconnectUser', 'url' => 'ajax/user/disconnect', 'verb' => 'POST'],
|
||||
['name' => 'user#disconnectGuest', 'url' => 'ajax/user/disconnectGuest', 'verb' => 'POST'],
|
||||
//session
|
||||
array('name' => 'session#joinAsUser', 'url' => 'ajax/session/joinasuser/{fileId}', 'verb' => 'POST'),
|
||||
array('name' => 'session#joinAsGuest', 'url' => 'ajax/session/joinasguest/{token}', 'verb' => 'POST'),
|
||||
array('name' => 'session#save', 'url' => 'ajax/session/save', 'verb' => 'POST'),
|
||||
array('name' => 'session#poll', 'url' => 'ajax/otpoll.php', 'verb' => 'POST'),
|
||||
['name' => 'session#joinAsUser', 'url' => 'ajax/session/joinasuser/{fileId}', 'verb' => 'POST'],
|
||||
['name' => 'session#joinAsGuest', 'url' => 'ajax/session/joinasguest/{token}', 'verb' => 'POST'],
|
||||
['name' => 'session#save', 'url' => 'ajax/session/save', 'verb' => 'POST'],
|
||||
['name' => 'session#poll', 'url' => 'ajax/otpoll.php', 'verb' => 'POST'],
|
||||
//documents
|
||||
array('name' => 'document#create', 'url' => 'ajax/documents/create', 'verb' => 'POST'),
|
||||
array('name' => 'document#serve', 'url' => 'ajax/genesis/{esId}', 'verb' => 'GET'),
|
||||
array('name' => 'document#rename', 'url' => 'ajax/documents/rename/{fileId}', 'verb' => 'POST'),
|
||||
array('name' => 'document#listAll', 'url' => 'ajax/documents/list', 'verb' => 'GET'),
|
||||
array('name' => 'document#download', 'url' => 'ajax/download.php', 'verb' => 'GET'),
|
||||
['name' => 'document#index', 'url' => 'index', 'verb' => 'GET'],
|
||||
['name' => 'document#create', 'url' => 'ajax/documents/create', 'verb' => 'POST'],
|
||||
['name' => 'document#serve', 'url' => 'ajax/genesis/{esId}', 'verb' => 'GET'],
|
||||
['name' => 'document#rename', 'url' => 'ajax/documents/rename/{fileId}', 'verb' => 'POST'],
|
||||
['name' => 'document#listAll', 'url' => 'ajax/documents/list', 'verb' => 'GET'],
|
||||
['name' => 'document#download', 'url' => 'ajax/download.php', 'verb' => 'GET'],
|
||||
//settings
|
||||
array('name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'),
|
||||
array('name' => 'settings#setUnstable', 'url' => 'ajax/config/unstable', 'verb' => 'POST'),
|
||||
array('name' => 'settings#setConverter', 'url' => 'ajax/admin.php', 'verb' => 'POST'),
|
||||
array('name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'),
|
||||
)
|
||||
));
|
||||
|
||||
/**
|
||||
* Document routes
|
||||
*/
|
||||
|
||||
/** @var $this \OC\Route\Router */
|
||||
|
||||
$this->create('documents_index', '')
|
||||
->get()
|
||||
->actionInclude('documents/index.php');
|
||||
['name' => 'settings#savePersonal', 'url' => 'ajax/personal.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#setUnstable', 'url' => 'ajax/config/unstable', 'verb' => 'POST'],
|
||||
['name' => 'settings#setConverter', 'url' => 'ajax/admin.php', 'verb' => 'POST'],
|
||||
['name' => 'settings#getSupportedMimes', 'url' => 'ajax/mimes.php', 'verb' => 'GET'],
|
||||
]
|
||||
]);
|
||||
|
@ -9,16 +9,18 @@
|
||||
* later.
|
||||
*/
|
||||
|
||||
$installedVersion = \OCP\Config::getAppValue('documents', 'installed_version');
|
||||
$config = \OC::$server->getConfig();
|
||||
$dbConnection = \OC::$server->getDatabaseConnection();
|
||||
$installedVersion = $config->getAppValue('documents', 'installed_version');
|
||||
|
||||
$cleanup = \OC_DB::prepare('DELETE FROM `*PREFIX*documents_member` WHERE `last_activity`=0 or `last_activity` is NULL');
|
||||
$cleanup = $dbConnection->prepare('DELETE FROM `*PREFIX*documents_member` WHERE `last_activity`=0 or `last_activity` is NULL');
|
||||
$cleanup->execute();
|
||||
|
||||
if (version_compare($installedVersion, '0.7', '<=')) {
|
||||
\OCP\Config::setAppValue('documents', 'unstable', 'false');
|
||||
$config->setAppValue('documents', 'unstable', 'false');
|
||||
$session = new \OCA\Documents\Db\Session();
|
||||
|
||||
$query = \OC_DB::prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?');
|
||||
$query = $dbConnection->prepare('UPDATE `*PREFIX*documents_session` SET `genesis_url`=? WHERE `es_id`=?');
|
||||
|
||||
foreach ($session->getCollection() as $sessionData){
|
||||
$sessionData['genesis_url'] = \OCA\Documents\Genesis::DOCUMENTS_DIRNAME . $sessionData['genesis_url'];
|
||||
@ -30,12 +32,12 @@ if (version_compare($installedVersion, '0.7', '<=')) {
|
||||
}
|
||||
}
|
||||
if (version_compare($installedVersion, '0.8', '<')) {
|
||||
$query = \OC_DB::prepare('UPDATE `*PREFIX*documents_member` SET `is_guest`=1 WHERE `uid` LIKE \'%(guest)\' ');
|
||||
$query = $dbConnection->prepare('UPDATE `*PREFIX*documents_member` SET `is_guest`=1 WHERE `uid` LIKE \'%(guest)\' ');
|
||||
$query->execute(array());
|
||||
}
|
||||
|
||||
if (version_compare($installedVersion, '0.9', '<')) {
|
||||
$query = \OC_DB::prepare('UPDATE `*PREFIX*documents_op` SET `optype`=? WHERE `seq`=?');
|
||||
$query = $dbConnection->prepare('UPDATE `*PREFIX*documents_op` SET `optype`=? WHERE `seq`=?');
|
||||
$ops = new \OCA\Documents\Db\Op();
|
||||
foreach ($ops->getCollection() as $opData){
|
||||
$opSpec = json_decode($opData['opspec'], true);
|
||||
|
@ -16,6 +16,7 @@ use \OCP\IRequest;
|
||||
use \OCP\IConfig;
|
||||
use \OCP\IL10N;
|
||||
use \OCP\AppFramework\Http\JSONResponse;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
|
||||
use \OCA\Documents\Db;
|
||||
use \OCA\Documents\Helper;
|
||||
@ -41,6 +42,23 @@ class DocumentController extends Controller{
|
||||
$this->settings = $settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function index(){
|
||||
\OC::$server->getNavigationManager()->setActiveEntry( 'documents_index' );
|
||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
||||
return new TemplateResponse('documents', 'documents', [
|
||||
'enable_previews' => $this->settings->getSystemValue('enable_previews', true),
|
||||
'useUnstable' => $this->settings->getAppValue('documents', 'unstable', 'false'),
|
||||
'savePath' => $this->settings->getUserValue($this->uid, 'documents', 'save_path', '/'),
|
||||
'uploadMaxFilesize' => $maxUploadFilesize,
|
||||
'uploadMaxHumanFilesize' => \OCP\Util::humanFileSize($maxUploadFilesize),
|
||||
'allowShareWithLink' => $this->settings->getAppValue('core', 'shareapi_allow_links', 'yes'),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
*/
|
||||
|
55
index.php
55
index.php
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* ownCloud - Documents App
|
||||
*
|
||||
* @author Frank Karlitschek
|
||||
* @copyright 2013-2014 Frank Karlitschek karlitschek@kde.org
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library 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 along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace OCA\Documents;
|
||||
|
||||
\OCP\User::checkLoggedIn();
|
||||
\OCP\JSON::checkAppEnabled('documents');
|
||||
\OCP\App::setActiveNavigationEntry( 'documents_index' );
|
||||
|
||||
\OCP\Util::addStyle( 'documents', 'style' );
|
||||
\OCP\Util::addStyle( 'documents', '3rdparty/webodf/dojo-app' );
|
||||
|
||||
\OCP\Util::addScript('documents', 'documents');
|
||||
|
||||
\OCP\Util::addScript('files', 'file-upload');
|
||||
\OCP\Util::addScript('files', 'jquery.iframe-transport');
|
||||
\OCP\Util::addScript('files', 'jquery.fileupload');
|
||||
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'documents', 'user');
|
||||
|
||||
$previewsEnabled = \OC::$server->getConfig()->getSystemValue('enable_previews', true);
|
||||
$unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false');
|
||||
$maxUploadFilesize = \OCP\Util::maxUploadFilesize("/");
|
||||
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
|
||||
|
||||
$tmpl->assign('enable_previews', $previewsEnabled);
|
||||
$tmpl->assign('useUnstable', $unstable);
|
||||
$tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
|
||||
$tmpl->assign('uploadMaxHumanFilesize', \OCP\Util::humanFileSize($maxUploadFilesize));
|
||||
$tmpl->assign('savePath', $savePath);
|
||||
$tmpl->assign("allowShareWithLink", \OC::$server->getAppConfig()->getValue('core', 'shareapi_allow_links', 'yes'));
|
||||
|
||||
$tmpl->printPage();
|
@ -161,9 +161,10 @@ class Helper {
|
||||
}
|
||||
|
||||
public static function findOpenOffice(){
|
||||
$config = \OC::$server->getConfig();
|
||||
$cmd = '';
|
||||
if (is_string(\OC_Config::getValue('preview_libreoffice_path', null))){
|
||||
$cmd = \OC_Config::getValue('preview_libreoffice_path', null);
|
||||
if (is_string($config->getSystemValue('preview_libreoffice_path', null))){
|
||||
$cmd = $config->getSystemValue('preview_libreoffice_path', null);
|
||||
}
|
||||
|
||||
$whichLibreOffice = shell_exec('which libreoffice');
|
||||
|
@ -1,3 +1,11 @@
|
||||
<?php
|
||||
style( 'documents', 'style' );
|
||||
style( 'documents', '3rdparty/webodf/dojo-app' );
|
||||
script('documents', 'documents');
|
||||
script('files', 'file-upload');
|
||||
script('files', 'jquery.iframe-transport');
|
||||
script('files', 'jquery.fileupload');
|
||||
?>
|
||||
<div id="documents-content">
|
||||
<ul class="documentslist">
|
||||
<li class="add-document">
|
||||
|
Loading…
x
Reference in New Issue
Block a user