Skip to content

Commit

Permalink
direct editing for selected groups (Fixed #228)
Browse files Browse the repository at this point in the history
  • Loading branch information
LinneyS committed Jan 27, 2020
1 parent 8a85f32 commit 1765e17
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
3 changes: 1 addition & 2 deletions appinfo/application.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ function() {
$eventDispatcher->addListener(RegisterDirectEditorEvent::class,
function (RegisterDirectEditorEvent $event) use ($container) {
if (!empty($this->appConfig->GetDocumentServerUrl())
&& $this->appConfig->SettingsAreSuccessful()
&& $this->appConfig->isUserAllowedToUse()) {
&& $this->appConfig->SettingsAreSuccessful()) {
$editor = $container->query("DirectEditor");
$event->register($editor);
}
Expand Down
14 changes: 13 additions & 1 deletion lib/directeditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,10 @@ public function getName(): string {
*/
public function getMimetypes(): array {
$mimes = array();
if (!$this->config->isUserAllowedToUse()) {
return $mimes;
}

$formats = $this->config->FormatsSetting();
foreach ($formats as $format => $setting) {
if (array_key_exists("edit", $setting) && $setting["edit"]
Expand All @@ -157,6 +161,10 @@ public function getMimetypes(): array {
*/
public function getMimetypesOptional(): array {
$mimes = array();
if (!$this->config->isUserAllowedToUse()) {
return $mimes;
}

$formats = $this->config->FormatsSetting();
foreach ($formats as $format => $setting) {
if (array_key_exists("edit", $setting) && $setting["edit"]
Expand All @@ -174,6 +182,10 @@ public function getMimetypesOptional(): array {
* @return array of ACreateFromTemplate|ACreateEmpty
*/
public function getCreators(): array {
if (!$this->config->isUserAllowedToUse()) {
return array();
}

return [
new FileCreator($this->appName, $this->trans, $this->logger, "docx"),
new FileCreator($this->appName, $this->trans, $this->logger, "xlsx"),
Expand All @@ -194,7 +206,7 @@ public function isSecure(): bool {
* Return a template response for displaying the editor
*
* open can only be called once when the client requests the editor with a one-time-use token
* For handling editing and later requests, editors need to impelement their own token handling
* For handling editing and later requests, editors need to implement their own token handling
* and take care of invalidation
*
* @param IToken $token - one time token
Expand Down

0 comments on commit 1765e17

Please sign in to comment.