Remove deprecated API usage. Step 2
This commit is contained in:
parent
8897dda9ab
commit
58725da687
@ -2,10 +2,9 @@
|
||||
|
||||
namespace OCA\Documents;
|
||||
|
||||
\OCP\Util::addScript('documents', 'admin');
|
||||
use \OCA\Documents\AppInfo\Application;
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'admin');
|
||||
$tmpl->assign('converter', Config::getConverter());
|
||||
$tmpl->assign('converter_url', Config::getConverterUrl());
|
||||
$app = new Application();
|
||||
$response = $app->getContainer()->query('\OCA\Documents\Controller\SettingsController')->adminIndex();
|
||||
return $response->render();
|
||||
|
||||
return $tmpl->fetchPage();
|
||||
|
@ -55,7 +55,6 @@ class Application extends App {
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('CoreConfig'),
|
||||
$c->query('Logger'),
|
||||
$c->query('L10N'),
|
||||
$c->query('UserId')
|
||||
);
|
||||
|
@ -123,8 +123,8 @@ class SessionController extends Controller{
|
||||
$member = new Db\Member();
|
||||
$member->load($memberId);
|
||||
|
||||
if (!$member->getIsGuest()){
|
||||
\OCP\JSON::checkLoggedIn();
|
||||
if (!$member->getIsGuest() && !\OCP\User::checkLoggedIn()){
|
||||
exit();
|
||||
}
|
||||
|
||||
try {
|
||||
@ -236,7 +236,7 @@ class SessionController extends Controller{
|
||||
if ($this->uid){
|
||||
$view = new View('/' . $this->uid . '/files');
|
||||
|
||||
$dir = \OCP\Config::getUserValue($this->uid, 'documents', 'save_path', '');
|
||||
$dir = \OC::$server->getConfig()->getUserValue($this->uid, 'documents', 'save_path', '');
|
||||
$path = Helper::getNewFileName($view, $dir . 'New Document.odt');
|
||||
} else {
|
||||
throw $e;
|
||||
|
@ -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\Converter;
|
||||
use OCA\Documents\Config;
|
||||
@ -23,16 +24,14 @@ use OCA\Documents\Filter;
|
||||
|
||||
class SettingsController extends Controller{
|
||||
|
||||
private $uid;
|
||||
private $userId;
|
||||
private $settings;
|
||||
private $logger;
|
||||
private $l10n;
|
||||
|
||||
public function __construct($appName, IRequest $request, IConfig $settings, $logger, IL10N $l10n, $uid){
|
||||
public function __construct($appName, IRequest $request, IConfig $settings, IL10N $l10n, $userId){
|
||||
parent::__construct($appName, $request);
|
||||
$this->uid = $uid;
|
||||
$this->userId = $userId;
|
||||
$this->settings = $settings;
|
||||
$this->logger = $logger;
|
||||
$this->l10n = $l10n;
|
||||
}
|
||||
|
||||
@ -46,6 +45,45 @@ class SettingsController extends Controller{
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function personalIndex(){
|
||||
return new TemplateResponse(
|
||||
'documents',
|
||||
'personal',
|
||||
[ 'save_path' => $this->settings->getUserValue($this->userId, 'documents', 'save_path', '/') ],
|
||||
'blank'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function settingsIndex(){
|
||||
return new TemplateResponse(
|
||||
'documents',
|
||||
'settings',
|
||||
[ 'unstable' => $this->settings->getAppValue('documents', 'unstable', 'false') ],
|
||||
'blank'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoCSRFRequired
|
||||
*/
|
||||
public function adminIndex(){
|
||||
return new TemplateResponse(
|
||||
'documents',
|
||||
'admin',
|
||||
[
|
||||
'converter' => Config::getConverter(),
|
||||
'converter_url' => Config::getConverterUrl(),
|
||||
],
|
||||
'blank'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
@ -60,7 +98,7 @@ class SettingsController extends Controller{
|
||||
}
|
||||
|
||||
if ($status){
|
||||
$this->settings->setUserValue($this->uid, $this->appName, 'save_path', $savePath);
|
||||
$this->settings->setUserValue($this->userId, $this->appName, 'save_path', $savePath);
|
||||
$response = array(
|
||||
'status' => 'success',
|
||||
'data' => array('message'=> $this->l10n->t('Directory saved successfully.'))
|
||||
@ -100,7 +138,10 @@ class SettingsController extends Controller{
|
||||
$currentConverter = $this->settings->getAppValue($this->appName, 'converter', 'off');
|
||||
if ($currentConverter == 'external'){
|
||||
if (!Converter::checkConnection()){
|
||||
$this->logger->warning('Bad response from Format Filter Server', array('app' => $this->appName));
|
||||
\OC::$server->getLogger()->warning(
|
||||
'Bad response from Format Filter Server',
|
||||
['app' => $this->appName]
|
||||
);
|
||||
$response = array(
|
||||
'status' => 'error',
|
||||
'data'=>
|
||||
|
@ -66,11 +66,11 @@ class Config {
|
||||
}
|
||||
|
||||
protected static function getAppValue($key, $default){
|
||||
return \OCP\Config::getAppValue(self::APP_NAME, $key, $default);
|
||||
return \OC::$server->getConfig()->getAppValue(self::APP_NAME, $key, $default);
|
||||
}
|
||||
|
||||
protected static function setAppValue($key, $value){
|
||||
return \OCP\Config::setAppValue(self::APP_NAME, $key, $value);
|
||||
return \OC::$server->getConfig()->setAppValue(self::APP_NAME, $key, $value);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,8 +43,8 @@ class Converter {
|
||||
* @return string
|
||||
*/
|
||||
protected static function convertLocal($input, $targetFilter, $targetExtension){
|
||||
$infile = \OCP\Files::tmpFile();
|
||||
$outdir = \OCP\Files::tmpFolder();
|
||||
$infile = \OC::$server->getTempManager()->getTemporaryFile();
|
||||
$outdir = \OC::$server->getTempManager()->getTemporaryFolder();
|
||||
$cmd = Helper::findOpenOffice();
|
||||
$params = ' --headless --convert-to ' . $targetFilter . ' --outdir '
|
||||
. escapeshellarg($outdir)
|
||||
|
@ -12,6 +12,8 @@
|
||||
|
||||
namespace OCA\Documents\Db;
|
||||
|
||||
use OCP\Security\ISecureRandom;
|
||||
|
||||
use OCA\Documents\Filter;
|
||||
|
||||
/**
|
||||
@ -204,7 +206,9 @@ class Session extends \OCA\Documents\Db {
|
||||
protected function getUniqueSessionId(){
|
||||
$testSession = new Session();
|
||||
do{
|
||||
$id = \OC_Util::generateRandomBytes(30);
|
||||
$id = \OC::$server->getSecureRandom()
|
||||
->getMediumStrengthGenerator()
|
||||
->generate(30, ISecureRandom::CHAR_LOWER . ISecureRandom::CHAR_DIGITS);
|
||||
} while ($testSession->load($id)->hasData());
|
||||
|
||||
return $id;
|
||||
|
10
personal.php
10
personal.php
@ -12,10 +12,8 @@
|
||||
|
||||
namespace OCA\Documents;
|
||||
|
||||
\OCP\Util::addScript('documents', 'personal');
|
||||
use \OCA\Documents\AppInfo\Application;
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'personal');
|
||||
$savePath = \OCP\Config::getUserValue(\OCP\User::getUser(), 'documents', 'save_path', '/');
|
||||
$tmpl->assign('savePath', $savePath);
|
||||
|
||||
return $tmpl->fetchPage();
|
||||
$app = new Application();
|
||||
$response = $app->getContainer()->query('\OCA\Documents\Controller\SettingsController')->personalIndex();
|
||||
return $response->render();
|
||||
|
@ -15,8 +15,6 @@ namespace OCA\Documents;
|
||||
|
||||
\OCP\JSON::checkAppEnabled('documents');
|
||||
|
||||
\OCP\Util::addStyle( 'documents', 'style' );
|
||||
|
||||
if (\OC_Appconfig::getValue('core', 'shareapi_allow_links', 'yes') !== 'yes') {
|
||||
header('HTTP/1.0 404 Not Found');
|
||||
$tmpl = new OCP\Template('', '404', 'guest');
|
||||
|
10
settings.php
10
settings.php
@ -12,10 +12,8 @@
|
||||
|
||||
namespace OCA\Documents;
|
||||
|
||||
\OCP\Util::addScript('documents', 'settings');
|
||||
use \OCA\Documents\AppInfo\Application;
|
||||
|
||||
$tmpl = new \OCP\Template('documents', 'settings');
|
||||
$unstable = \OCP\Config::getAppValue('documents', 'unstable', 'false');
|
||||
$tmpl->assign('unstable', $unstable);
|
||||
|
||||
return $tmpl->fetchPage();
|
||||
$app = new Application();
|
||||
$response = $app->getContainer()->query('\OCA\Documents\Controller\SettingsController')->settingsIndex();
|
||||
return $response->render();
|
||||
|
@ -1,3 +1,6 @@
|
||||
<?php
|
||||
script('documents', 'admin');
|
||||
?>
|
||||
<div class="section" id="documents">
|
||||
<h2><?php p($l->t('Documents')) ?></h2>
|
||||
<p><?php p($l->t('MS Word support (requires openOffice/libreOffice)')) ?></p>
|
||||
|
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
script('documents', 'personal');
|
||||
?>
|
||||
<div class="section" id="documents-personal">
|
||||
<h2><?php p($l->t('Documents')); ?></h2>
|
||||
<div>
|
||||
<label for="documents-default-path"><?php p($l->t('Save new documents to')) ?></label>
|
||||
<input type="text" id="documents-default-path" value="<?php p($_['savePath']) ?>" /><span class="msg"></span>
|
||||
<input type="text" id="documents-default-path" value="<?php p($_['save_path']) ?>" /><span class="msg"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,3 +1,6 @@
|
||||
<?php
|
||||
style( 'documents', 'style' );
|
||||
?>
|
||||
<div id="notification-container">
|
||||
<div id="notification" style="display: none;"></div>
|
||||
</div>
|
||||
|
@ -1,3 +1,6 @@
|
||||
<?php
|
||||
script('documents', 'settings');
|
||||
?>
|
||||
<div id="documents" class="section">
|
||||
<h2><?php p($l->t('Documents')) ?></h2>
|
||||
<input id="webodf-unstable" type ="checkbox"
|
||||
|
Loading…
x
Reference in New Issue
Block a user