Merge remote-tracking branch 'remotes/origin/develop' into feature/submit-form

# Conflicts:
#	web/documentserver-example/csharp-mvc/Helpers/Users.cs
#	web/documentserver-example/csharp/Users.cs
#	web/documentserver-example/java-spring/src/main/java/com/onlyoffice/integration/ExampleData.java
#	web/documentserver-example/java/src/main/java/helpers/Users.java
#	web/documentserver-example/php/src/helpers/ExampleUsers.php
#	web/documentserver-example/python/src/utils/users.py
#	web/documentserver-example/ruby/app/models/users.rb
This commit is contained in:
Sergey Linnik
2023-11-21 12:29:52 +03:00
55 changed files with 562 additions and 88 deletions

View File

@ -1,11 +1,18 @@
# Change Log
- php: link in referenceData
- ruby: link in referenceData
- java: link in referenceData
- java-spring: link in referenceData
- csharp-mvc: link in referenceData
- csharp: link in referenceData
- python: link in referenceData
- ruby: convert after uploading only tagged formats
- python: convert after uploading only tagged formats
- php: convert after uploading only tagged formats
- setUsers for region protection
- onRequestOpen method
- nodejs: user avatar
- user avatar
- trimming long name of uploading file
- nodejs: link in referenceData
- onRequestSelectDocument method

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -32,6 +32,7 @@ namespace OnlineEditorsExampleMVC.Helpers
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
"Has an avatar",
"Can submit forms"
};
@ -43,6 +44,7 @@ namespace OnlineEditorsExampleMVC.Helpers
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Has an avatar",
"Cant submit forms"
};
@ -89,6 +91,7 @@ namespace OnlineEditorsExampleMVC.Helpers
null,
new List<string>(),
descr_user_1,
true,
true
),
new User(
@ -107,7 +110,8 @@ namespace OnlineEditorsExampleMVC.Helpers
true,
new List<string>(),
descr_user_2,
false
false,
true
),
new User(
"uid-3",
@ -125,6 +129,7 @@ namespace OnlineEditorsExampleMVC.Helpers
false,
new List<string>() { "copy", "download", "print" },
descr_user_3,
false,
false
),
new User(
@ -138,6 +143,7 @@ namespace OnlineEditorsExampleMVC.Helpers
null,
new List<string>() { "protect" },
descr_user_0,
false,
false
)
};
@ -176,6 +182,24 @@ namespace OnlineEditorsExampleMVC.Helpers
return usersData;
}
public static List<Dictionary<string, object>> getUsersInfo(string id)
{
List<Dictionary<string, object>> usersData = new List<Dictionary<string, object>>();
if (id != "uid-0") {
foreach (User user in users)
{
usersData.Add(new Dictionary<string, object>()
{
{"id", user.id},
{"name", user.name },
{"email", user.email },
{"image", user.avatar ? DocManagerHelper.GetServerUrl(false) + "/Content/images/" + user.id + ".png" : null}
});
}
}
return usersData;
}
// get a list of users with their names and emails for protect
public static List<Dictionary<string, object>> getUsersForProtect(string id)
{
@ -209,8 +233,9 @@ namespace OnlineEditorsExampleMVC.Helpers
public List<string> descriptions;
public bool templates;
public List<string> userInfoGroups;
public bool avatar;
public User(string id, string name, string email, string group, List<string> reviewGroups, Dictionary<string, object> commentGroups, List<string> userInfoGroups, bool? favorite, List<string> deniedPermissions, List<string> descriptions, bool templates)
public User(string id, string name, string email, string group, List<string> reviewGroups, Dictionary<string, object> commentGroups, List<string> userInfoGroups, bool? favorite, List<string> deniedPermissions, List<string> descriptions, bool templates, bool avatar)
{
this.id = id;
this.name = name;
@ -223,6 +248,7 @@ namespace OnlineEditorsExampleMVC.Helpers
this.descriptions = descriptions;
this.templates = templates;
this.userInfoGroups = userInfoGroups;
this.avatar = avatar;
}
}
}

View File

@ -190,7 +190,8 @@ namespace OnlineEditorsExampleMVC.Models
{
{ "id", !user.id.Equals("uid-0") ? user.id : null },
{ "name", user.name },
{ "group", user.group }
{ "group", user.group },
{ "image", user.avatar ? DocManagerHelper.GetServerUrl(false) + "/Content/images/" + user.id + ".png" : null}
}
},
{
@ -373,6 +374,14 @@ namespace OnlineEditorsExampleMVC.Models
usersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(Users.getUsersForMentions(user.id)) : null;
}
public void GetUsersInfo(HttpRequest request, out string usersInfo)
{
var jss = new JavaScriptSerializer();
var id = request.Cookies.GetOrDefault("uid", null);
var user = Users.getUser(id);
usersInfo = jss.Serialize(Users.getUsersInfo(user.id));
}
//get a users for protect
public void GetUsersProtect(HttpRequest request, out string usersForProtect)
{

View File

@ -278,6 +278,8 @@
<% string usersForMentions; %>
<% Model.GetUsersMentions(Request, out usersForMentions); %>
<% string usersInfo; %>
<% Model.GetUsersInfo(Request, out usersInfo); %>
<% string usersForProtect; %>
<% Model.GetUsersProtect(Request, out usersForProtect); %>
@ -300,6 +302,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = <%= usersInfo %>;
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = <%= usersForProtect %>;
break;

View File

@ -812,6 +812,27 @@ namespace OnlineEditorsExampleMVC
}
}
if (fileName == "" && body.ContainsKey("link"))
{
string link = body["link"].ToString();
if (!link.Contains(DocManagerHelper.GetServerUrl(false)))
{
context.Response.Write(jss.Serialize(new Dictionary<string, string>() {
{ "url", link },
{ "directUrl", link }
}));
return;
}
Uri linkUri = new Uri(link);
fileName = HttpUtility.ParseQueryString(linkUri.Query).Get("fileName");
if (string.IsNullOrEmpty(fileName) || !File.Exists(DocManagerHelper.StoragePath(fileName, null)))
{
context.Response.Write("{ \"error\": \"File is not exist\"}");
return;
}
}
if (fileName == "")
{
try

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -303,6 +303,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = <%= UsersInfo %>;
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = <%= UsersForProtect %>;
break;

View File

@ -64,6 +64,7 @@ namespace OnlineEditorsExample
protected string DocumentData { get; private set; }
protected string DataSpreadsheet { get; private set; }
protected string UsersForMentions { get; private set; }
protected string UsersInfo { get; private set; }
protected string UsersForProtect { get; private set; }
protected string DocumentType { get { return _Default.DocumentType(FileName); } }
@ -257,7 +258,8 @@ namespace OnlineEditorsExample
{
{ "id", !user.id.Equals("uid-0") ? user.id : null },
{ "name", user.name },
{ "group", user.group }
{ "group", user.group },
{ "image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null }
}
},
{
@ -319,6 +321,9 @@ namespace OnlineEditorsExample
List<Dictionary<string, object>> usersData = Users.getUsersForMentions(user.id);
UsersForMentions = !user.id.Equals("uid-0") ? jss.Serialize(usersData) : null;
List<Dictionary<string, object>> usersInfo = Users.getUsersInfo(user.id);
UsersInfo = jss.Serialize(usersData);
// get users for protect
List<Dictionary<string, object>> usersProtectData = Users.getUsersForProtect(user.id);
UsersForProtect = !user.id.Equals("uid-0") ? jss.Serialize(usersProtectData) : null;

View File

@ -31,6 +31,7 @@ namespace OnlineEditorsExample
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
"Has an avatar",
"Can submit forms"
};
@ -42,6 +43,7 @@ namespace OnlineEditorsExample
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Has an avatar",
"Cant submit forms"
};
@ -88,6 +90,7 @@ namespace OnlineEditorsExample
null,
new List<string>(),
descr_user_1,
true,
true
),
new User(
@ -106,7 +109,8 @@ namespace OnlineEditorsExample
true,
new List<string>(),
descr_user_2,
false
false,
true
),
new User(
"uid-3",
@ -124,6 +128,7 @@ namespace OnlineEditorsExample
false,
new List<string>() { "copy", "download", "print" },
descr_user_3,
false,
false
),
new User(
@ -137,6 +142,7 @@ namespace OnlineEditorsExample
null,
new List<string>() { "protect" },
descr_user_0,
false,
false
)
};
@ -176,6 +182,24 @@ namespace OnlineEditorsExample
return usersData;
}
public static List<Dictionary<string, object>> getUsersInfo(string id)
{
List<Dictionary<string, object>> usersData = new List<Dictionary<string, object>>();
if(id != "uid-0"){
foreach (User user in users)
{
usersData.Add(new Dictionary<string, object>()
{
{"id", user.id},
{"name", user.name },
{"email", user.email },
{"image", user.avatar ? _Default.GetServerUrl(false) + "/App_Themes/images/"+ user.id + ".png" : null }
});
}
}
return usersData;
}
// get a list of users with their names and emails for protect
public static List<Dictionary<string, object>> getUsersForProtect(string id)
{
@ -210,8 +234,9 @@ namespace OnlineEditorsExample
public List<string> descriptions;
public bool templates;
public List<string> userInfoGroups;
public bool avatar;
public User(string id, string name, string email, string group, List<string> reviewGroups, Dictionary<string, object> commentGroups, List<string> userInfoGroups, bool? favorite, List<string> deniedPermissions, List<string> descriptions, bool templates)
public User(string id, string name, string email, string group, List<string> reviewGroups, Dictionary<string, object> commentGroups, List<string> userInfoGroups, bool? favorite, List<string> deniedPermissions, List<string> descriptions, bool templates, bool avatar)
{
this.id = id;
this.name = name;
@ -224,6 +249,7 @@ namespace OnlineEditorsExample
this.descriptions = descriptions;
this.templates = templates;
this.userInfoGroups = userInfoGroups;
this.avatar = avatar;
}
}
}

View File

@ -29,6 +29,7 @@ using System.Net;
using System.Collections;
using System.Net.Sockets;
using ASC.Api.DocumentConverter;
using Newtonsoft.Json;
namespace OnlineEditorsExample
{
@ -622,6 +623,27 @@ namespace OnlineEditorsExample
}
}
if (fileName == "" && body.ContainsKey("link"))
{
string link = body["link"].ToString();
if (!link.Contains(_Default.GetServerUrl(false)))
{
context.Response.Write(jss.Serialize(new Dictionary<string, string>() {
{ "url", link },
{ "directUrl", link }
}));
return;
}
Uri linkUri = new Uri(link);
fileName = HttpUtility.ParseQueryString(linkUri.Query).Get("fileID");
if (string.IsNullOrEmpty(fileName) || !File.Exists(_Default.StoragePath(fileName, null)))
{
context.Response.Write("{ \"error\": \"File is not exist\"}");
return;
}
}
if (fileName == "")
{
try

View File

@ -60,6 +60,7 @@ public class ExampleData {
"Can create a file from a template with data from the editor",
"Can see the information about all users",
"Can view chat",
"Has an avatar",
"Can submit forms"
);
@ -74,6 +75,7 @@ public class ExampleData {
"Can create a file from an editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Can view chat",
"Has an avatar",
"Cant submit forms"
);
@ -97,23 +99,23 @@ public class ExampleData {
userService.createUser("John Smith", "smith@example.com", descriptionUserFirst,
"", List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), null, true, true);
List.of(FilterState.NULL.toString()), null, true, true, true);
// create user 2 with the specified parameters
userService.createUser("Mark Pottato", "pottato@example.com", descriptionUserSecond,
"group-2", List.of("", "group-2"), List.of(FilterState.NULL.toString()),
List.of("group-2", ""), List.of("group-2"), List.of("group-2", ""), true, true,
true);
true, true);
// create user 3 with the specified parameters
userService.createUser("Hamish Mitchell", null, descriptionUserThird,
"group-3", List.of("group-2"), List.of("group-2", "group-3"), List.of("group-2"),
new ArrayList<>(), List.of("group-2"), false, true, true);
new ArrayList<>(), List.of("group-2"), false, true, true, false);
// create user 0 with the specified parameters
userService.createUser("Anonymous", null, descriptionUserZero, "",
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
List.of(FilterState.NULL.toString()), List.of(FilterState.NULL.toString()),
new ArrayList<>(), null, false, false);
new ArrayList<>(), null, false, false, false);
}
}

View File

@ -25,6 +25,7 @@ import com.onlyoffice.integration.documentserver.models.enums.Action;
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
import com.onlyoffice.integration.entities.User;
import com.onlyoffice.integration.dto.Mentions;
import com.onlyoffice.integration.dto.UserInfo;
import com.onlyoffice.integration.dto.Protect;
import com.onlyoffice.integration.documentserver.models.enums.Type;
import com.onlyoffice.integration.documentserver.models.filemodel.FileModel;
@ -118,6 +119,8 @@ public class EditorController {
}
User user = optionalUser.get();
user.setImage(user.getAvatar() ? storagePathBuilder.getServerUrl(true) + "/css/img/uid-"
+ user.getId() + ".png" : null);
// get file model with the default file parameters
FileModel fileModel = fileConfigurer.getFileModel(
@ -152,8 +155,11 @@ public class EditorController {
// get user data for mentions and add it to the model
model.addAttribute("usersForMentions", getUserMentions(uid));
model.addAttribute("usersInfo", getUsersInfo(uid));
// get user data for protect and add it to the model
model.addAttribute("usersForProtect", getUserProtect(uid));
return "editor.html";
}
@ -173,6 +179,19 @@ public class EditorController {
return usersForMentions;
}
private List<UserInfo> getUsersInfo(final String uid) { // get user data for mentions
List<UserInfo> usersInfo = new ArrayList<>();
if (uid != null && !uid.equals("4")) {
List<User> list = userService.findAll();
for (User u : list) {
String image = u.getAvatar() ? storagePathBuilder.getServerUrl(true) + "/css/img/uid-"
+ u.getId() + ".png" : null;
usersInfo.add(new UserInfo(u.getId(), u.getName(), u.getEmail(), image));
}
}
return usersInfo;
}
private List<Protect> getUserProtect(final String uid) { // get user data for protect
List<Protect> usersForProtect = new ArrayList<>();
if (uid != null && !uid.equals("4")) {
@ -189,6 +208,7 @@ public class EditorController {
return usersForProtect;
}
@SneakyThrows
private String getInsertImage(final Boolean directUrl) { // get an image that will be inserted into the document
Map<String, Object> dataInsertImage = new HashMap<>();

View File

@ -48,6 +48,7 @@ import org.json.simple.parser.JSONParser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.core.io.UrlResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
@ -62,6 +63,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
@ -70,6 +73,7 @@ import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@ -147,6 +151,28 @@ public class FileController {
.body(resource);
}
private ResponseEntity<Resource> downloadSample(final String fileName) {
String serverPath = System.getProperty("user.dir");
String contentType = "application/octet-stream";
String[] fileLocation = new String[] {serverPath, "src", "main", "resources", "assets", "document-templates",
"sample", fileName};
Path filePath = Paths.get(String.join(File.separator, fileLocation));
Resource resource;
try {
resource = new UrlResource(filePath.toUri());
if (resource.exists()) {
return ResponseEntity.ok()
.contentType(MediaType.parseMediaType(contentType))
.header(HttpHeaders.CONTENT_DISPOSITION,
"attachment; filename=\"" + resource.getFilename() + "\"")
.body(resource);
}
} catch (MalformedURLException e) {
e.printStackTrace();
}
return null;
}
// download data from the specified history file
private ResponseEntity<Resource> downloadFileHistory(final String fileName,
final String version,
@ -372,14 +398,12 @@ public class FileController {
@GetMapping("/assets")
public ResponseEntity<Resource> assets(@RequestParam("name")
final String name) { // get sample files from the assests
String fileName = Path.of("assets", "document-templates", "sample", fileUtility.getFileName(name)).toString();
return downloadFile(fileName);
return downloadSample(name);
}
@GetMapping("/csv")
public ResponseEntity<Resource> csv() { // download a csv file
String fileName = Path.of("assets", "document-templates", "sample", "csv.csv").toString();
return downloadFile(fileName);
return downloadSample("csv.csv");
}
@GetMapping("/files")
@ -485,6 +509,22 @@ public class FileController {
}
}
String link = body.getLink();
if (fileName.equals("") && link != null) {
if (!link.contains(storagePathBuilder.getServerUrl(true))) {
HashMap<String, String> data = new HashMap<>();
data.put("url", link);
data.put("directUrl", link);
return gson.toJson(data);
}
UriComponents uriComponents = UriComponentsBuilder.fromUriString(body.getLink()).build();
fileName = uriComponents.getQueryParams().getFirst("fileName");
boolean fileExists = new File(storagePathBuilder.getFileLocation(fileName)).exists();
if (!fileExists) {
return "{ \"error\": \"File is not exist\"}";
}
}
if (fileName.equals("")) {
try {

View File

@ -19,6 +19,8 @@
package com.onlyoffice.integration.documentserver.models.filemodel;
import com.onlyoffice.integration.documentserver.models.AbstractModel;
import com.onlyoffice.integration.documentserver.storage.FileStoragePathBuilder;
import lombok.Getter;
import lombok.Setter;
import org.springframework.context.annotation.Scope;
@ -29,14 +31,17 @@ import org.springframework.stereotype.Component;
@Getter
@Setter
public class User extends AbstractModel {
private FileStoragePathBuilder storagePathBuilder;
private String id;
private String name;
private String group;
private String image;
// the user configuration parameters
public void configure(final int idParam, final String nameParam, final String groupParam) {
this.id = "uid-" + idParam; // the user id
this.name = nameParam; // the user name
this.group = groupParam; // the group the user belongs to
this.image = storagePathBuilder.getServerUrl(true) + "/css/img/uid-" + this.id + ".png";
}
}

View File

@ -33,4 +33,5 @@ public class Reference {
private Boolean directUrl;
private ReferenceData referenceData;
private String path;
private String link;
}

View File

@ -0,0 +1,33 @@
/**
*
* (c) Copyright Ascensio System SIA 2023
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.onlyoffice.integration.dto;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
public class UserInfo {
private Integer id;
private String name;
private String email;
private String image;
}

View File

@ -45,4 +45,6 @@ public class User extends AbstractEntity {
@ElementCollection
@CollectionTable(name = "user_descriptions")
private List<String> descriptions;
private Boolean avatar;
private String image;
}

View File

@ -58,13 +58,15 @@ public class UserServices {
final List<String> removeGroups,
final List<String> userInfoGroups, final Boolean favoriteDoc,
final Boolean chat,
final Boolean protect) {
final Boolean protect,
final Boolean avatar) {
User newUser = new User();
newUser.setName(name); // set the user name
newUser.setEmail(email); // set the user email
newUser.setGroup(groupServices.createGroup(group)); // set the user group
newUser.setDescriptions(description); // set the user description
newUser.setFavorite(favoriteDoc); // specify if the user has the favorite documents or not
newUser.setAvatar(avatar);
List<Group> groupsReview = groupServices
.createGroups(reviewGroups); // define the groups whose changes the user can accept/reject

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -283,6 +283,7 @@
};
var usersForMentions = [[${usersForMentions}]];
var usersInfo = [[${usersInfo}]];
var usersForProtect = [[${usersForProtect}]];
if (config.editorConfig.user.id != 4) {
@ -292,6 +293,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = usersInfo;
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = usersForProtect;
break;

View File

@ -108,6 +108,8 @@ public class EditorServlet extends HttpServlet {
List<Map<String, Object>> usersForMentions = Users.getUsersForMentions(user.getId());
List<Map<String, Object>> usersForProtect = Users.getUsersForProtect(user.getId());
List<Map<String, Object>> usersInfo = Users.getUsersInfo(user.getId());
// check if the document token is enabled
if (DocumentManager.tokenEnabled()) {
file.buildToken(); // generate document token
@ -132,6 +134,7 @@ public class EditorServlet extends HttpServlet {
request.setAttribute("dataSpreadsheet", gson.toJson(dataSpreadsheet));
request.setAttribute("usersForMentions", !user.getId()
.equals("uid-0") ? gson.toJson(usersForMentions) : null);
request.setAttribute("usersInfo", gson.toJson(usersInfo));
request.setAttribute("usersForProtect", !user.getId()
.equals("uid-0") ? gson.toJson(usersForProtect) : null);
request.getRequestDispatcher("editor.jsp").forward(request, response);

View File

@ -694,6 +694,33 @@ public class IndexServlet extends HttpServlet {
}
}
Object link = body.get("link");
if (fileName.equals("") && link != null) {
if (!((String) link).contains(DocumentManager.getServerUrl(false))) {
HashMap<String, Object> data = new HashMap<>();
data.put("url", link);
data.put("directUrl", link);
writer.write(gson.toJson(data));
return;
}
URL url = new URL((String) link);
String query = url.getQuery();
String[] parameters = query.split("&");
for (String parameter : parameters) {
String[] keyValue = parameter.split("=");
if (keyValue.length == 2 && "fileName".equals(keyValue[0])) {
fileName = keyValue[1];
break;
}
}
boolean fileExists = new File(DocumentManager.storagePath(fileName, null)).exists();
if (!fileExists) {
writer.write("{ \"error\": \"File is not exist\"}");
return;
}
}
if (fileName.equals("")) {
try {
String path = (String) body.get("path");

View File

@ -111,6 +111,8 @@ public class FileModel {
editorConfig.getUser().setId(!user.getId().equals("uid-0") ? user.getId() : null);
editorConfig.getUser().setName(user.getName());
editorConfig.getUser().setGroup(user.getGroup());
editorConfig.getUser().setImage(user.getAvatar() ? DocumentManager.getServerUrl(false)
+ "/css/img/" + user.getId() + ".png" : null);
// write the absolute URL to the file location
editorConfig.getCustomization().getGoback()
@ -521,6 +523,7 @@ public class FileModel {
private String id;
private String name;
private String group;
private String image;
public String getId() {
return id;
@ -545,6 +548,10 @@ public class FileModel {
public void setGroup(final String groupParam) {
this.group = groupParam;
}
public void setImage(final String imageParam) {
this.image = imageParam;
}
}
// customization parameters

View File

@ -32,12 +32,13 @@ public class User {
private final List<String> descriptions;
private final Boolean templates;
private final List<String> userInfoGroups;
private final Boolean avatar;
public User(final String idParam, final String nameParam, final String emailParam, final String groupParam,
final List<String> reviewGroupsParam, final CommentGroups commentGroupsParam,
final List<String> userInfoGroupsParam, final Boolean favoriteParam,
final List<String> deniedPermissionsParam, final List<String> descriptionsParam,
final Boolean templatesParam) {
final Boolean templatesParam, final Boolean avatarParam) {
this.id = idParam;
this.name = nameParam;
this.email = emailParam;
@ -49,6 +50,7 @@ public class User {
this.descriptions = descriptionsParam;
this.templates = templatesParam;
this.userInfoGroups = userInfoGroupsParam;
this.avatar = avatarParam;
}
public String getId() {
@ -94,4 +96,8 @@ public class User {
public List<String> getUserInfoGroups() {
return userInfoGroups;
}
public Boolean getAvatar() {
return avatar;
}
}

View File

@ -37,6 +37,7 @@ public final class Users {
add("The file favorite state is undefined");
add("Can create files from templates using data from the editor");
add("Can see the information about all users");
add("Has an avatar");
add("Can submit forms");
}};
@ -48,6 +49,7 @@ public final class Users {
add("This file is marked as favorite");
add("Can create new files from the editor");
add("Can see the information about users from Group2 and users who dont belong to any group");
add("Has an avatar");
add("Cant submit forms");
}};
@ -83,19 +85,19 @@ public final class Users {
private static List<User> users = new ArrayList<User>() {{
add(new User("uid-1", "John Smith", "smith@example.com",
"", null, new CommentGroups(), null,
null, new ArrayList<String>(), descriptionUserFirst, true));
null, new ArrayList<String>(), descriptionUserFirst, true, true));
add(new User("uid-2", "Mark Pottato", "pottato@example.com",
"group-2", Arrays.asList("group-2", ""), new CommentGroups(null,
Arrays.asList("group-2", ""), Arrays.asList("group-2")), Arrays.asList("group-2", ""),
true, new ArrayList<String>(), descriptionUserSecond, false));
true, new ArrayList<String>(), descriptionUserSecond, false, true));
add(new User("uid-3", "Hamish Mitchell", null,
"group-3", Arrays.asList("group-2"), new CommentGroups(Arrays.asList("group-3", "group-2"),
Arrays.asList("group-2"), null), Arrays.asList("group-2"),
false, Arrays.asList("copy", "download", "print"),
descriptionUserThird, false));
descriptionUserThird, false, false));
add(new User("uid-0", null, null,
"", null, null, null,
null, Arrays.asList("protect"), descriptionUserZero, false));
null, Arrays.asList("protect"), descriptionUserZero, false, false));
}};
private Users() { }
@ -129,6 +131,22 @@ public final class Users {
return usersData;
}
public static List<Map<String, Object>> getUsersInfo(final String id) {
List<Map<String, Object>> usersData = new ArrayList<>();
if (id != "uid-0") {
for (User user : users) {
Map<String, Object> data = new HashMap<>();
data.put("id", user.getId());
data.put("name", user.getName());
data.put("email", user.getEmail());
data.put("image", user.getAvatar() ? DocumentManager.getServerUrl(false)
+ "/css/img/" + user.getId() + ".png" : null);
usersData.add(data);
}
}
return usersData;
}
// get a list of users with their names and emails for protect
public static List<Map<String, Object>> getUsersForProtect(final String id) {
List<Map<String, Object>> usersData = new ArrayList<>();

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -283,6 +283,7 @@
<%
String usersForMentions = (String) request.getAttribute("usersForMentions");
String usersInfo = (String) request.getAttribute("usersInfo");
String usersForProtect = (String) request.getAttribute("usersForProtect");
%>
@ -293,6 +294,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = <%=usersInfo%>;
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = <%=usersForProtect%>;
break;

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -74,24 +74,12 @@ function routers()
$view->render();
return;
}
if (str_starts_with($path, '/assets')) {
$response = assets();
$response['status'] = 'success';
echo json_encode($response);
return;
}
if (str_starts_with($path, '/convert')) {
$response = convert();
$response['status'] = 'success';
echo json_encode($response);
return;
}
if (str_starts_with($path, '/csv')) {
$response = csv();
$response['status'] = 'success';
echo json_encode($response);
return;
}
if (str_starts_with($path, '/delete')) {
$response = delete();
$response['status'] = isset($response['error']) ? 'error' : 'success';

View File

@ -333,34 +333,6 @@ function files()
}
}
/**
* Download assets
*
* @return void
*/
function assets()
{
$fileName = basename($_GET["name"]);
$filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates"
. DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
downloadFile($filePath);
}
/**
* Download a csv file
*
* @return void
*/
function csv()
{
$fileName = "csv.csv";
$filePath = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . "assets" . DIRECTORY_SEPARATOR . "document-templates"
. DIRECTORY_SEPARATOR . "sample" . DIRECTORY_SEPARATOR . $fileName;
downloadFile($filePath);
}
/**
* Download a file from history
*
@ -553,6 +525,20 @@ function reference()
}
}
$link = $post["link"];
if (!isset($filename) && isset($link)) {
if (strpos($link, serverPath()) === false) {
return ["url" => $link, "directUrl"=> $link];
}
$urlObj = parse_url($link);
parse_str($urlObj["query"], $urlParams);
$fileName = $urlParams["fileID"];
if (!file_exists(getStoragePath($fileName))) {
return ["error" => "File does not exist"];
}
}
if (!isset($filename) && isset($post["path"])) {
$path = basename($post["path"]);
if (file_exists(getStoragePath($path))) {

View File

@ -353,12 +353,13 @@ function getStoredFiles()
$cdir = scandir($directory); // get all the files and folders from the directory
$result = [];
$index = 0;
foreach ($cdir as $key => $fileName) { // run through all the file and folder names
if (!in_array($fileName, [".", ".."])) {
if (!is_dir($directory . DIRECTORY_SEPARATOR . $fileName)) { // if an element isn't a directory
$ext = mb_strtolower(pathinfo($fileName, PATHINFO_EXTENSION));
$dat = filemtime($directory . DIRECTORY_SEPARATOR . $fileName); // get the time of element modification
$result[$dat] = (object) [ // and write the file to the result
$result[$dat + $index++] = (object) [ // and write the file to the result
"name" => $fileName,
"documentType" => getDocumentType($fileName),
"canEdit" => in_array($ext, $formatManager->editableExtensions()),

View File

@ -38,6 +38,7 @@ final class ExampleUsers
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
"Has an avatar",
"Can submit forms"
];
$this->user2Description = [
@ -48,6 +49,7 @@ final class ExampleUsers
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Has an avatar",
"Cant submit forms"
];
$this->user3Description = [
@ -88,6 +90,7 @@ final class ExampleUsers
null,
[],
$this->user1Description,
true,
true
),
new Users(
@ -105,7 +108,8 @@ final class ExampleUsers
true,
[],
$this->user2Description,
false
false,
true
),
new Users(
"uid-3",
@ -122,6 +126,7 @@ final class ExampleUsers
false,
["copy", "download", "print"],
$this->user3Description,
false,
false
),
new Users(
@ -135,6 +140,7 @@ final class ExampleUsers
null,
["protect"],
$this->user0Description,
false,
false
),
];

View File

@ -32,6 +32,8 @@ final class Users
public ?bool $templates;
public ?array $userInfoGroups;
public ?bool $avatar;
/**
* Constructor
*
@ -46,6 +48,7 @@ final class Users
* @param array|null $deniedPermissions
* @param array|null $descriptions
* @param bool|null $templates
* @param bool|null $avatar
*
* @return void
*/
@ -60,7 +63,8 @@ final class Users
?bool $favorite,
?array $deniedPermissions,
?array $descriptions,
?bool $templates
?bool $templates,
?bool $avatar
) {
$this->id = $id;
$this->name = $name;
@ -73,5 +77,6 @@ final class Users
$this->descriptions = $descriptions;
$this->templates = $templates;
$this->userInfoGroups = $userInfoGroups;
$this->avatar = $avatar;
}
}

View File

@ -161,6 +161,7 @@ final class DocEditorView extends View
"id" => $user->id != "uid-0" ? $user->id : null,
"name" => $user->name,
"group" => $user->group,
"image" => $user->avatar ? serverPath(true) . "/assets/images/" . $user->id . ".png" : null
],
"embedded" => [ // the parameters for the embedded document type
// the absolute URL that will allow the document to be saved onto the user personal computer
@ -211,18 +212,28 @@ final class DocEditorView extends View
// recipients data for mail merging
$dataSpreadsheet = $isEnableDirectUrl ? [
"fileType" => "csv",
"url" => serverPath(true) . "/csv",
"directUrl" => serverPath(false) . "/csv",
"url" => serverPath(true) . "/assets/document-templates/sample/csv.csv",
"directUrl" => serverPath(false) . "/assets/document-templates/sample/csv.csv",
] : [
"fileType" => "csv",
"url" => serverPath(true) . "/csv",
"url" => serverPath(true) . "/assets/document-templates/sample/csv.csv",
];
// users data for mentions
$usersForMentions = $user->id != "uid-0" ? $userList->getUsersForMentions($user->id) : null;
// users data for protect
$usersForProtect = $user->id != "uid-0" ? $userList->getUsersForProtect($user->id) : null;
$usersInfo = [];
if ($user->id != 'uid-0') {
foreach ($userList->getAllUsers() as $userInfo) {
$u = $userInfo;
$u->image = $userInfo->avatar ? serverPath(true) . "/assets/images/" . $userInfo->id . ".png" : null;
array_push($usersInfo, $u);
}
}
// check if the secret key to generate token exists
if ($jwtManager->isJwtEnabled()) {
$config["token"] = $jwtManager->jwtEncode($config); // encode config into the token
@ -256,6 +267,18 @@ final class DocEditorView extends View
var c = event.data.c;
}
switch (c) {
case \"info\":
users = [];
var allUsers = {usersInfo};
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case \"protect\":
var users = {usersForProtect};
break;
@ -292,6 +315,7 @@ final class DocEditorView extends View
"config" => json_encode($config),
"history" => $historyLayout,
"usersForMentions" => json_encode($usersForMentions),
"usersInfo" => json_encode($usersInfo),
"usersForProtect" => json_encode($usersForProtect),
];
}

View File

@ -68,6 +68,7 @@ def routers():
path('convert', actions.convert),
path('create', actions.createNew),
path('csv', actions.csv),
path('assets', actions.assets),
path('download', actions.download),
path('downloadhistory', actions.downloadhistory),
path('edit', actions.edit),

View File

@ -21,7 +21,7 @@ from typing import Optional
class User:
def __init__(self, uid, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite,
deniedPermissions, descriptions, templates):
deniedPermissions, descriptions, templates, avatar):
self.id = uid
self.name = name
self.email = email
@ -33,6 +33,7 @@ class User:
self.descriptions = descriptions
self.templates = templates
self.userInfoGroups = userInfoGroups
self.avatar = avatar
descr_user_1 = [
@ -43,6 +44,7 @@ descr_user_1 = [
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
"Has an avatar",
"Can submit forms"
]
@ -54,6 +56,7 @@ descr_user_2 = [
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Has an avatar",
"Cant submit forms"
]
@ -89,7 +92,7 @@ descr_user_0 = [
USERS = [
User('uid-1', 'John Smith', 'smith@example.com',
'', None, {}, None,
None, [], descr_user_1, True),
None, [], descr_user_1, True, True),
User('uid-2', 'Mark Pottato', 'pottato@example.com',
'group-2', ['group-2', ''], {
'view': "",
@ -97,17 +100,17 @@ USERS = [
'remove': ["group-2"]
},
['group-2', ''],
True, [], descr_user_2, False),
True, [], descr_user_2, False, True),
User('uid-3', 'Hamish Mitchell', None,
'group-3', ['group-2'], {
'view': ["group-3", "group-2"],
'edit': ["group-2"],
'remove': []
}, ['group-2'],
False, ["copy", "download", "print"], descr_user_3, False),
False, ["copy", "download", "print"], descr_user_3, False, False),
User('uid-0', None, None,
'', None, {}, [],
None, ["protect"], descr_user_0, False)
None, ["protect"], descr_user_0, False, False)
]
DEFAULT_USER = USERS[0]

View File

@ -29,6 +29,7 @@ from src.common import http
from src.configuration import ConfigurationManager
from src.response import ErrorResponse
from src.utils import docManager, fileUtils, serviceConverter, users, jwtManager, historyManager, trackManager
from urllib.parse import urlparse, parse_qs
config_manager = ConfigurationManager()
@ -232,6 +233,16 @@ def edit(request):
}
]
usersInfo = []
if user.id != 'uid-0':
for userInfo in users.getAllUsers():
u = userInfo
u.image = docManager.getServerUrl(True, request) + f'/static/images/{u.id}.jpg' if user.avatar else None
usersInfo.append({"id": u.id, "name": u.name, "email": u.email, "image": u.image, "group": u.group,
"reviewGroups": u.reviewGroups, "commentGroups": u.commentGroups, "favorite": u.favorite,
"deniedPermissions": u.deniedPermissions, "descriptions": u.descriptions,
"templates": u.templates, "userInfoGroups": u.userInfoGroups, "avatar": u.avatar})
if meta: # if the document meta data exists,
infObj = { # write author and creation time parameters to the information object
'owner': meta['uname'],
@ -294,7 +305,9 @@ def edit(request):
'user': { # the user currently viewing or editing the document
'id': user.id if user.id != 'uid-0' else None,
'name': user.name,
'group': user.group
'group': user.group,
'image': docManager.getServerUrl(True, request) + f'/static/images/{user.id}.jpg' if user.avatar
else None
},
'embedded': { # the parameters for the embedded document type
# the absolute URL that will allow the document to be saved onto the user personal computer
@ -376,7 +389,8 @@ def edit(request):
'dataDocument': dataDocument, # document which will be compared with the current document
'dataSpreadsheet': json.dumps(dataSpreadsheet), # recipient data for mail merging
'usersForMentions': json.dumps(usersForMentions) if user.id != 'uid-0' else None,
'usersForProtect': json.dumps(usersForProtect) if user.id != 'uid-0' else None
'usersInfo': json.dumps(usersInfo),
'usersForProtect': json.dumps(usersForProtect) if user.id != 'uid-0' else None,
}
return render(request, 'editor.html', context) # execute the "editor.html" template with context data
@ -444,6 +458,14 @@ def csv():
return response
# download a sample file
def assets(request):
filename = fileUtils.getFileName(request.GET['filename'])
filePath = os.path.join('assets', 'document-templates', 'sample', filename)
response = docManager.download(filePath)
return response
# download a file
def download(request):
try:
@ -527,19 +549,35 @@ def reference(request):
if userAddress == request.META['REMOTE_ADDR']:
fileName = fileKey['fileName']
link = body['link']
if not fileName and link:
if docManager.getServerUrl(False, request) not in link:
data = {
'url': link,
'directUrl': link
}
return HttpResponse(json.dumps(data), content_type='application/json')
url_obj = urlparse(link)
query = parse_qs(url_obj.query)
if 'filename' in query:
fileName = query['filename'][0]
if not os.path.exists(docManager.getStoragePath(fileName, request)):
response.setdefault('error', 'File does not exist')
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
if fileName is None:
try:
path = fileUtils.getFileName(body['path'])
if os.path.exists(docManager.getStoragePath(path, request)):
fileName = path
else:
response.setdefault('error', 'File not found')
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
except KeyError:
response.setdefault('error', 'Path not found')
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
if fileName is None:
response.setdefault('error', 'File not found')
return HttpResponse(json.dumps(response), content_type='application/json', status=404)
data = {
'fileType': fileUtils.getFileExt(fileName).replace('.', ''),
'key': docManager.generateFileKey(fileName, request),

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@ -275,6 +275,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = {{ usersInfo | safe }};
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = {{ usersForProtect | safe }};
break;

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -278,6 +278,18 @@ class HomeController < ApplicationController
send_file csvPath, :x_sendfile => true
end
# downloading an assets file
def assets
file_name = File.basename(params[:fileName])
asset_path = Rails.root.join('assets', 'document-templates', 'sample', file_name)
response.headers['Content-Length'] = File.size(asset_path).to_s
response.headers['Content-Type'] = MimeMagic.by_path(asset_path).type
response.headers['Content-Disposition'] = "attachment;filename*=UTF-8\'\'" + ERB::Util.url_encode(file_name)
send_file asset_path, :x_sendfile => true
end
# downloading a file
def download
begin
@ -395,6 +407,26 @@ class HomeController < ApplicationController
end
end
link = body["link"]
if fileName.empty? and body.key?("link")
if !link.include?(DocumentHelper.get_server_url(false))
data = {
url: link,
directUrl: link
}
render plain: data.to_json
return
end
url_obj = URI(link)
query_params = CGI.parse(url_obj.query)
fileName = query_params['fileName'].first
if !File.exist?(DocumentHelper.storage_path(fileName, nil))
render plain: '{ "error": "File is not exist"}'
return
end
end
if fileName.empty? and body.key?("path")
path = File.basename(body["path"])
if File.exist?(DocumentHelper.storage_path(path, nil))

View File

@ -158,7 +158,8 @@ class FileModel
:user => { # the user currently viewing or editing the document
:id => !@user.id.eql?("uid-0") ? @user.id : nil,
:name => @user.name,
:group => @user.group
:group => @user.group,
:image => @user.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{@user.id}.png" : nil
},
:embedded => { # the parameters for the embedded document type
:saveUrl => download_url(false), # the absolute URL that will allow the document to be saved onto the user personal computer
@ -350,6 +351,31 @@ class FileModel
return !@user.id.eql?("uid-0") ? Users.get_users_for_mentions(@user.id) : nil
end
def get_users_info
users_info = []
if !@user.id.eql?("uid-0")
Users.get_all_users().each do |user_info|
u = {
id: user_info.id,
name: user_info.name,
email: user_info.email,
group: user_info.group,
reviewGroups: user_info.reviewGroups,
commentGroups: user_info.commentGroups,
userInfoGroups: user_info.userInfoGroups,
favorite: user_info.favorite,
deniedPermissions: user_info.deniedPermissions,
descriptions: user_info.descriptions,
templates: user_info.templates,
avatar: user_info.avatar
}
u["image"] = user_info.avatar ? "#{DocumentHelper.get_server_url(true)}/assets/#{user_info.id}.png" : nil
users_info.push(u)
end
return users_info
end
end
# get users data for protect
def get_users_protect
return !@user.id.eql?("uid-0") ? Users.get_users_for_protect(@user.id) : nil

View File

@ -15,9 +15,11 @@
#
class User
attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite, :deniedPermissions, :descriptions, :templates
attr_accessor :id, :name, :email, :group, :reviewGroups, :commentGroups, :userInfoGroups, :favorite,
:deniedPermissions, :descriptions, :templates, :avatar
def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite, deniedPermissions, descriptions, templates)
def initialize (id, name, email, group, reviewGroups, commentGroups, userInfoGroups, favorite,
deniedPermissions, descriptions, templates, avatar)
@id = id
@name = name
@email = email
@ -29,6 +31,7 @@ class User
@descriptions = descriptions
@templates = templates
@userInfoGroups = userInfoGroups
@avatar = avatar
end
end
@ -41,7 +44,8 @@ class Users
"The file favorite state is undefined",
"Can create files from templates using data from the editor",
"Can see the information about all users",
"Can submit forms"
"Has an avatar",
"Can submit forms",
];
@@descr_user_2 = [
@ -51,7 +55,8 @@ class Users
"This file is marked as favorite",
"Can create new files from the editor",
"Can see the information about users from Group2 and users who dont belong to any group",
"Can't submit forms"
"Has an avatar",
"Can't submit forms",
];
@@descr_user_3 = [
@ -64,7 +69,7 @@ class Users
"Cant print the file",
"Can create new files from the editor",
"Can see the information about Group2 users",
"Can't submit forms"
"Can't submit forms",
];
@@descr_user_0 = [
@ -86,7 +91,7 @@ class Users
@@users = [
User.new("uid-1", "John Smith", "smith@example.com",
"", nil, {}, nil,
nil, [], @@descr_user_1, true),
nil, [], @@descr_user_1, true, true),
User.new("uid-2", "Mark Pottato", "pottato@example.com",
"group-2", ["group-2", ""], {
:view => "",
@ -94,7 +99,7 @@ class Users
:remove => ["group-2"]
},
["group-2", ""],
true, [], @@descr_user_2, false),
true, [], @@descr_user_2, false, true),
User.new("uid-3", "Hamish Mitchell", nil,
"group-3", ["group-2"], {
:view => ["group-3", "group-2"],
@ -102,10 +107,10 @@ class Users
:remove => []
},
["group-2"],
false, ["copy", "download", "print"], @@descr_user_3, false),
false, ["copy", "download", "print"], @@descr_user_3, false, false),
User.new("uid-0", nil, nil,
"", nil, {}, [],
nil, ["protect"], @@descr_user_0, false)
nil, ["protect"], @@descr_user_0, false, false)
]
class << self

View File

@ -260,6 +260,18 @@
var c = event.data.c;
}
switch (c) {
case "info":
users = [];
var allUsers = <%= raw @file.get_users_info.to_json %>;
for (var i = 0; i < event.data.id.length; i++) {
for (var j = 0; j < allUsers.length; j++) {
if (allUsers[j].id == event.data.id[i]) {
users.push(allUsers[j]);
break;
}
}
}
break;
case "protect":
var users = <%= raw @file.get_users_protect.to_json %>;
break;

View File

@ -28,6 +28,7 @@ class Application < Rails::Application
root to: 'home#index'
match '/convert', to: 'home#convert', via: 'post'
match '/csv', to: 'home#csv', via: 'get'
match '/asset', to: 'home#assets', via: 'get'
match '/download', to: 'home#download', via: 'get'
match '/downloadhistory', to: 'home#downloadhistory', via: 'get'
match '/editor', to: 'home#editor', via: 'get'