Skip to content

Commit

Permalink
switch listener to hook
Browse files Browse the repository at this point in the history
  • Loading branch information
LinneyS committed Mar 15, 2018
1 parent 96fe4eb commit 8232cdf
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
8 changes: 2 additions & 6 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
use OCA\Onlyoffice\Controller\EditorController;
use OCA\Onlyoffice\Controller\SettingsController;
use OCA\Onlyoffice\Crypt;
use OCA\Onlyoffice\Hookhandler;

class Application extends App {

Expand Down Expand Up @@ -70,12 +71,7 @@ function() {
}
});

$eventDispatcher->addListener("OCA\Files_Sharing::loadAdditionalScripts",
function() {
if (!empty($this->appConfig->GetDocumentServerUrl()) && $this->appConfig->SettingsAreSuccessful()) {
Util::addScript("onlyoffice", "public");
}
});
Util::connectHook("OCP\Share", "share_link_access", Hookhandler::class, "PublicPage");

require_once __DIR__ . "/../3rdparty/jwt/BeforeValidException.php";
require_once __DIR__ . "/../3rdparty/jwt/ExpiredException.php";
Expand Down
46 changes: 46 additions & 0 deletions lib/hookhandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* @author Jörn Friedrich Dreyer <jfd@butonic.de>
*
* @copyright Copyright (c) 2018, ownCloud GmbH
* @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 <http://www.gnu.org/licenses/>
*
*/

namespace OCA\Onlyoffice;

use OCP\Util;

use OCA\Onlyoffice\AppConfig;

/**
* Class HookHandler
*
* handles hooks
*
* @package OCA\Onlyoffice
*/
class HookHandler {

public static function PublicPage() {
$appName = "onlyoffice";

$appConfig = new AppConfig($appName);

if (!empty($appConfig->GetDocumentServerUrl()) && $appConfig->SettingsAreSuccessful()) {
Util::addScript("onlyoffice", "public");
}
}
}

0 comments on commit 8232cdf

Please sign in to comment.