diff --git a/web/documentserver-example/php/common.php b/web/documentserver-example/php/common.php index 3e823ab1..f01ade8d 100644 --- a/web/documentserver-example/php/common.php +++ b/web/documentserver-example/php/common.php @@ -313,33 +313,14 @@ function getVirtualPath($forDocumentServer) { } // get a file with meta information -function createMeta($fileName, $uid = "0", $userAddress = NULL) { +function createMeta($fileName, $user, $userAddress = NULL) { $histDir = getHistoryDir(getStoragePath($fileName, $userAddress)); // get the history directory - if (empty($uid)) $uid = "0"; - - // get the user name for each uid - $name = ""; - switch ($uid) { - case 0: - $name = "John Smith"; - break; - case 1: - $name = "Mark Pottato"; - break; - case 2: - $name = "Hamish Mitchell"; - break; - case 3: - $name = null; - break; - } - // turn the file information into the json format $json = [ "created" => date("Y-m-d H:i:s"), - "uid" => $uid, - "name" => $name, + "uid" => $user->id, + "name" => $user->name, ]; // write the encoded file information to the createdInfo.json file diff --git a/web/documentserver-example/php/doceditor.php b/web/documentserver-example/php/doceditor.php index 43dbe865..8f869654 100644 --- a/web/documentserver-example/php/doceditor.php +++ b/web/documentserver-example/php/doceditor.php @@ -21,9 +21,12 @@ require_once( dirname(__FILE__) . '/common.php' ); require_once( dirname(__FILE__) . '/functions.php' ); require_once( dirname(__FILE__) . '/jwtmanager.php' ); + require_once( dirname(__FILE__) . '/users.php' ); $filename; + $user = getUser($_GET["user"]); + // get the file url and upload it $externalUrl = $_GET["fileUrl"]; if (!empty($externalUrl)) @@ -40,7 +43,7 @@ if (!empty($createExt)) { // and get demo file name by the extension - $filename = tryGetDefaultByType($createExt); + $filename = tryGetDefaultByType($createExt, $user); // create the demo file url $new_url = "doceditor.php?fileID=" . $filename . "&user=" . $_GET["user"]; @@ -53,28 +56,6 @@ $docKey = getDocEditorKey($filename); $filetype = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); - $uid = empty($_GET["user"]) ? "0" : $_GET["user"]; // get file uid by its user - $uname = ""; - // get user names and groups by the uids - switch ($uid) { - case 0: - $uname = "John Smith"; - break; - case 1: - $uname = "Mark Pottato"; - $ugroup = "group-2"; - $reviewGroups = ["group-2", ""]; - break; - case 2: - $uname = "Hamish Mitchell"; - $ugroup = "group-3"; - $reviewGroups = ["group-2"]; - break; - case 3: - $uname = null; - break; - } - $editorsMode = empty($_GET["action"]) ? "edit" : $_GET["action"]; // get the editors mode $canEdit = in_array(strtolower('.' . pathinfo($filename, PATHINFO_EXTENSION)), $GLOBALS['DOC_SERV_EDITED']); // check if the file can be edited $submitForm = $canEdit && ($editorsMode == "edit" || $editorsMode == "fillForms"); // check if the Submit form button is displayed or not @@ -93,19 +74,19 @@ "info" => [ "owner" => "Me", "uploaded" => date('d.m.y'), - "favorite" => isset($_GET["user"]) ? $_GET["user"] == 1 : null + "favorite" => $user->id == "uid-0" || $user->id == "uid-1" ? null : $user->id == "uid-2" ], "permissions" => [ // the permission for the document to be edited and downloaded or not "comment" => $editorsMode != "view" && $editorsMode != "fillForms" && $editorsMode != "embedded" && $editorsMode != "blockcontent", - "copy" => $uid == 2 ? false : true, - "download" => $uid == 2 ? false : true, + "copy" => $user->id == "uid-3" ? false : true, + "download" => $user->id == "uid-3" ? false : true, "edit" => $canEdit && ($editorsMode == "edit" || $editorsMode == "view" || $editorsMode == "filter" || $editorsMode == "blockcontent"), - "print" => $uid == 2 ? false : true, + "print" => $user->id == "uid-3" ? false : true, "fillForms" => $editorsMode != "view" && $editorsMode != "comment" && $editorsMode != "embedded" && $editorsMode != "blockcontent", "modifyFilter" => $editorsMode != "filter", "modifyContentControl" => $editorsMode != "blockcontent", "review" => $canEdit && ($editorsMode == "edit" || $editorsMode == "review"), - "reviewGroups" => $reviewGroups + "reviewGroups" => $user->reviewGroups ] ], "editorConfig" => [ @@ -113,11 +94,11 @@ "mode" => $mode, "lang" => empty($_COOKIE["ulang"]) ? "en" : $_COOKIE["ulang"], "callbackUrl" => getCallbackUrl($filename), // absolute URL to the document storage service - "createUrl" => getCreateUrl($filename, $uid, $type), + "createUrl" => getCreateUrl($filename, $user->id, $type), "user" => [ // the user currently viewing or editing the document - "id" => $uid, - "name" => $uname, - "group" => $ugroup + "id" => $user->id, + "name" => $user->name, + "group" => $user->group ], "embedded" => [ // the parameters for the embedded document type "saveUrl" => $fileuriUser, // the absolute URL that will allow the document to be saved onto the user personal computer @@ -131,7 +112,7 @@ "forcesave" => false, // adds the request for the forced file saving to the callback handler when saving the document "submitForm" => $submitForm, // if the Submit form button is displayed or not "goback" => [ // settings for the Open file location menu button and upper right corner button - "url" => serverPath(), // the absolute URL to the website address which will be opened when clicking the Open file location menu button + "url" => serverPath(), // the absolute URL to the website address which will be opened when clicking the Open file location menu button ] ] ] @@ -164,7 +145,7 @@ } // get demo file name by the extension - function tryGetDefaultByType($createExt) { + function tryGetDefaultByType($createExt, $user) { $demoName = ($_GET["sample"] ? "sample." : "new.") . $createExt; $demoPath = "assets" . DIRECTORY_SEPARATOR . ($_GET["sample"] ? "sample" : "new") . DIRECTORY_SEPARATOR; $demoFilename = GetCorrectName($demoName); @@ -176,7 +157,7 @@ } // create demo file meta information - createMeta($demoFilename, $_GET["user"]); + createMeta($demoFilename, $user); return $demoFilename; } diff --git a/web/documentserver-example/php/index.php b/web/documentserver-example/php/index.php index e86061f7..5d0e109c 100644 --- a/web/documentserver-example/php/index.php +++ b/web/documentserver-example/php/index.php @@ -20,6 +20,7 @@ require_once( dirname(__FILE__) . '/config.php' ); require_once( dirname(__FILE__) . '/common.php' ); require_once( dirname(__FILE__) . '/functions.php' ); + require_once( dirname(__FILE__) . '/users.php' ); $user = $_GET["user"]; ?> @@ -74,7 +75,7 @@
@@ -84,10 +85,10 @@ Username