|
@@ -1,6 +1,8 @@
|
|
|
-import { templateChecker, pagePathUtils } from '@growi/core';
|
|
|
|
|
|
|
+import { templateChecker, pagePathUtils, pathUtils } from '@growi/core';
|
|
|
|
|
+
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
|
|
+
|
|
|
// disable no-return-await for model functions
|
|
// disable no-return-await for model functions
|
|
|
/* eslint-disable no-return-await */
|
|
/* eslint-disable no-return-await */
|
|
|
|
|
|
|
@@ -12,7 +14,6 @@ const urljoin = require('url-join');
|
|
|
const mongoose = require('mongoose');
|
|
const mongoose = require('mongoose');
|
|
|
const differenceInYears = require('date-fns/differenceInYears');
|
|
const differenceInYears = require('date-fns/differenceInYears');
|
|
|
|
|
|
|
|
-const { pathUtils } = require('@growi/core');
|
|
|
|
|
const escapeStringRegexp = require('escape-string-regexp');
|
|
const escapeStringRegexp = require('escape-string-regexp');
|
|
|
|
|
|
|
|
const { isTopPage, isTrashPage } = pagePathUtils;
|
|
const { isTopPage, isTrashPage } = pagePathUtils;
|
|
@@ -44,7 +45,7 @@ const pageSchema = {
|
|
|
* @param {string} pagePath
|
|
* @param {string} pagePath
|
|
|
* @return {string[]} ancestors paths
|
|
* @return {string[]} ancestors paths
|
|
|
*/
|
|
*/
|
|
|
-const extractToAncestorsPaths = (pagePath) => {
|
|
|
|
|
|
|
+export const extractToAncestorsPaths = (pagePath) => {
|
|
|
const ancestorsPaths = [];
|
|
const ancestorsPaths = [];
|
|
|
|
|
|
|
|
let parentPath;
|
|
let parentPath;
|
|
@@ -62,7 +63,7 @@ const extractToAncestorsPaths = (pagePath) => {
|
|
|
* @param {string} userPublicFields string to set to select
|
|
* @param {string} userPublicFields string to set to select
|
|
|
*/
|
|
*/
|
|
|
/* eslint-disable object-curly-newline, object-property-newline */
|
|
/* eslint-disable object-curly-newline, object-property-newline */
|
|
|
-const populateDataToShowRevision = (page, userPublicFields) => {
|
|
|
|
|
|
|
+export const populateDataToShowRevision = (page, userPublicFields) => {
|
|
|
return page
|
|
return page
|
|
|
.populate([
|
|
.populate([
|
|
|
{ path: 'lastUpdateUser', model: 'User', select: userPublicFields },
|
|
{ path: 'lastUpdateUser', model: 'User', select: userPublicFields },
|
|
@@ -77,307 +78,6 @@ const populateDataToShowRevision = (page, userPublicFields) => {
|
|
|
/* eslint-enable object-curly-newline, object-property-newline */
|
|
/* eslint-enable object-curly-newline, object-property-newline */
|
|
|
|
|
|
|
|
|
|
|
|
|
-export class PageQueryBuilder {
|
|
|
|
|
-
|
|
|
|
|
- constructor(query, includeEmpty = false) {
|
|
|
|
|
- this.query = query;
|
|
|
|
|
- if (!includeEmpty) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: [
|
|
|
|
|
- { isEmpty: false },
|
|
|
|
|
- { isEmpty: null }, // for v4 compatibility
|
|
|
|
|
- ],
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToExcludeTrashed() {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: [
|
|
|
|
|
- { status: null },
|
|
|
|
|
- { status: STATUS_PUBLISHED },
|
|
|
|
|
- ],
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * generate the query to find the pages '{path}/*' and '{path}' self.
|
|
|
|
|
- * If top page, return without doing anything.
|
|
|
|
|
- */
|
|
|
|
|
- addConditionToListWithDescendants(path, option) {
|
|
|
|
|
- // No request is set for the top page
|
|
|
|
|
- if (isTopPage(path)) {
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const pathNormalized = pathUtils.normalizePath(path);
|
|
|
|
|
- const pathWithTrailingSlash = pathUtils.addTrailingSlash(path);
|
|
|
|
|
-
|
|
|
|
|
- const startsPattern = escapeStringRegexp(pathWithTrailingSlash);
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: [
|
|
|
|
|
- { path: pathNormalized },
|
|
|
|
|
- { path: new RegExp(`^${startsPattern}`) },
|
|
|
|
|
- ],
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * generate the query to find the pages '{path}/*' (exclude '{path}' self).
|
|
|
|
|
- * If top page, return without doing anything.
|
|
|
|
|
- */
|
|
|
|
|
- addConditionToListOnlyDescendants(path, option) {
|
|
|
|
|
- // No request is set for the top page
|
|
|
|
|
- if (isTopPage(path)) {
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const pathWithTrailingSlash = pathUtils.addTrailingSlash(path);
|
|
|
|
|
-
|
|
|
|
|
- const startsPattern = escapeStringRegexp(pathWithTrailingSlash);
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({ path: new RegExp(`^${startsPattern}`) });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToListOnlyAncestors(path) {
|
|
|
|
|
- const pathNormalized = pathUtils.normalizePath(path);
|
|
|
|
|
- const ancestorsPaths = extractToAncestorsPaths(pathNormalized);
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- path: {
|
|
|
|
|
- $in: ancestorsPaths,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /**
|
|
|
|
|
- * generate the query to find pages that start with `path`
|
|
|
|
|
- *
|
|
|
|
|
- * In normal case, returns '{path}/*' and '{path}' self.
|
|
|
|
|
- * If top page, return without doing anything.
|
|
|
|
|
- *
|
|
|
|
|
- * *option*
|
|
|
|
|
- * Left for backward compatibility
|
|
|
|
|
- */
|
|
|
|
|
- addConditionToListByStartWith(path, option) {
|
|
|
|
|
- // No request is set for the top page
|
|
|
|
|
- if (isTopPage(path)) {
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const startsPattern = escapeStringRegexp(path);
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({ path: new RegExp(`^${startsPattern}`) });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- async addConditionForParentNormalization(user) {
|
|
|
|
|
- // determine UserGroup condition
|
|
|
|
|
- let userGroups = null;
|
|
|
|
|
- if (user != null) {
|
|
|
|
|
- const UserGroupRelation = mongoose.model('UserGroupRelation');
|
|
|
|
|
- userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- const grantConditions = [
|
|
|
|
|
- { grant: null },
|
|
|
|
|
- { grant: GRANT_PUBLIC },
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- if (user != null) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_OWNER, grantedUsers: user._id },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (userGroups != null && userGroups.length > 0) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_USER_GROUP, grantedGroup: { $in: userGroups } },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: grantConditions,
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- async addConditionAsMigratablePages(user) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: [
|
|
|
|
|
- { grant: { $ne: GRANT_RESTRICTED } },
|
|
|
|
|
- { grant: { $ne: GRANT_SPECIFIED } },
|
|
|
|
|
- ],
|
|
|
|
|
- });
|
|
|
|
|
- this.addConditionAsNotMigrated();
|
|
|
|
|
- this.addConditionAsNonRootPage();
|
|
|
|
|
- this.addConditionToExcludeTrashed();
|
|
|
|
|
- await this.addConditionForParentNormalization(user);
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToFilteringByViewer(user, userGroups, showAnyoneKnowsLink = false, showPagesRestrictedByOwner = false, showPagesRestrictedByGroup = false) {
|
|
|
|
|
- const grantConditions = [
|
|
|
|
|
- { grant: null },
|
|
|
|
|
- { grant: GRANT_PUBLIC },
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
- if (showAnyoneKnowsLink) {
|
|
|
|
|
- grantConditions.push({ grant: GRANT_RESTRICTED });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (showPagesRestrictedByOwner) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_SPECIFIED },
|
|
|
|
|
- { grant: GRANT_OWNER },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- else if (user != null) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_SPECIFIED, grantedUsers: user._id },
|
|
|
|
|
- { grant: GRANT_OWNER, grantedUsers: user._id },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (showPagesRestrictedByGroup) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_USER_GROUP },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
- else if (userGroups != null && userGroups.length > 0) {
|
|
|
|
|
- grantConditions.push(
|
|
|
|
|
- { grant: GRANT_USER_GROUP, grantedGroup: { $in: userGroups } },
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- $or: grantConditions,
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToPagenate(offset, limit, sortOpt) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .sort(sortOpt).skip(offset).limit(limit); // eslint-disable-line newline-per-chained-call
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionAsNonRootPage() {
|
|
|
|
|
- this.query = this.query.and({ path: { $ne: '/' } });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionAsNotMigrated() {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({ parent: null });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionAsMigrated() {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and(
|
|
|
|
|
- {
|
|
|
|
|
- $or: [
|
|
|
|
|
- { parent: { $ne: null } },
|
|
|
|
|
- { path: '/' },
|
|
|
|
|
- ],
|
|
|
|
|
- },
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /*
|
|
|
|
|
- * Add this condition when get any ancestor pages including the target's parent
|
|
|
|
|
- */
|
|
|
|
|
- addConditionToSortPagesByDescPath() {
|
|
|
|
|
- this.query = this.query.sort('-path');
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToSortPagesByAscPath() {
|
|
|
|
|
- this.query = this.query.sort('path');
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToMinimizeDataForRendering() {
|
|
|
|
|
- this.query = this.query.select('_id path isEmpty grant revision descendantCount');
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToListByPathsArray(paths) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- path: {
|
|
|
|
|
- $in: paths,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToListByPageIdsArray(pageIds) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .and({
|
|
|
|
|
- _id: {
|
|
|
|
|
- $in: pageIds,
|
|
|
|
|
- },
|
|
|
|
|
- });
|
|
|
|
|
-
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- populateDataToList(userPublicFields) {
|
|
|
|
|
- this.query = this.query
|
|
|
|
|
- .populate({
|
|
|
|
|
- path: 'lastUpdateUser',
|
|
|
|
|
- select: userPublicFields,
|
|
|
|
|
- });
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- populateDataToShowRevision(userPublicFields) {
|
|
|
|
|
- this.query = populateDataToShowRevision(this.query, userPublicFields);
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- addConditionToFilteringByParentId(parentId) {
|
|
|
|
|
- this.query = this.query.and({ parent: parentId });
|
|
|
|
|
- return this;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
export const getPageSchema = (crowi) => {
|
|
export const getPageSchema = (crowi) => {
|
|
|
let pageEvent;
|
|
let pageEvent;
|
|
|
|
|
|
|
@@ -638,7 +338,7 @@ export const getPageSchema = (crowi) => {
|
|
|
userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
userGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const queryBuilder = new PageQueryBuilder(baseQuery);
|
|
|
|
|
|
|
+ const queryBuilder = new this.PageQueryBuilder(baseQuery);
|
|
|
queryBuilder.addConditionToFilteringByViewer(user, userGroups, true);
|
|
queryBuilder.addConditionToFilteringByViewer(user, userGroups, true);
|
|
|
|
|
|
|
|
const count = await queryBuilder.query.exec();
|
|
const count = await queryBuilder.query.exec();
|
|
@@ -660,7 +360,7 @@ export const getPageSchema = (crowi) => {
|
|
|
relatedUserGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
relatedUserGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const queryBuilder = new PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
|
|
|
|
+ const queryBuilder = new this.PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
queryBuilder.addConditionToFilteringByViewer(user, relatedUserGroups, true);
|
|
queryBuilder.addConditionToFilteringByViewer(user, relatedUserGroups, true);
|
|
|
|
|
|
|
|
return queryBuilder.query.exec();
|
|
return queryBuilder.query.exec();
|
|
@@ -668,7 +368,7 @@ export const getPageSchema = (crowi) => {
|
|
|
|
|
|
|
|
pageSchema.statics.findByIdAndViewerToEdit = async function(id, user, includeEmpty = false) {
|
|
pageSchema.statics.findByIdAndViewerToEdit = async function(id, user, includeEmpty = false) {
|
|
|
const baseQuery = this.findOne({ _id: id });
|
|
const baseQuery = this.findOne({ _id: id });
|
|
|
- const queryBuilder = new PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
|
|
|
|
+ const queryBuilder = new this.PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
|
|
|
|
|
// add grant conditions
|
|
// add grant conditions
|
|
|
await addConditionToFilteringByViewerToEdit(queryBuilder, user);
|
|
await addConditionToFilteringByViewerToEdit(queryBuilder, user);
|
|
@@ -682,7 +382,7 @@ export const getPageSchema = (crowi) => {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const builder = new PageQueryBuilder(this.findOne({ path }), includeEmpty);
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.findOne({ path }), includeEmpty);
|
|
|
|
|
|
|
|
return builder.query.exec();
|
|
return builder.query.exec();
|
|
|
};
|
|
};
|
|
@@ -713,7 +413,7 @@ export const getPageSchema = (crowi) => {
|
|
|
relatedUserGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
relatedUserGroups = await UserGroupRelation.findAllUserGroupIdsRelatedToUser(user);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const queryBuilder = new PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
|
|
|
|
+ const queryBuilder = new this.PageQueryBuilder(baseQuery, includeEmpty);
|
|
|
queryBuilder.addConditionToFilteringByViewer(user, relatedUserGroups);
|
|
queryBuilder.addConditionToFilteringByViewer(user, relatedUserGroups);
|
|
|
|
|
|
|
|
return queryBuilder.query.exec();
|
|
return queryBuilder.query.exec();
|
|
@@ -723,7 +423,7 @@ export const getPageSchema = (crowi) => {
|
|
|
* find pages that is match with `path` and its descendants
|
|
* find pages that is match with `path` and its descendants
|
|
|
*/
|
|
*/
|
|
|
pageSchema.statics.findListWithDescendants = async function(path, user, option = {}, includeEmpty = false) {
|
|
pageSchema.statics.findListWithDescendants = async function(path, user, option = {}, includeEmpty = false) {
|
|
|
- const builder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find(), includeEmpty);
|
|
|
builder.addConditionToListWithDescendants(path, option);
|
|
builder.addConditionToListWithDescendants(path, option);
|
|
|
|
|
|
|
|
return findListFromBuilderAndViewer(builder, user, false, option);
|
|
return findListFromBuilderAndViewer(builder, user, false, option);
|
|
@@ -737,7 +437,7 @@ export const getPageSchema = (crowi) => {
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- const builder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find(), includeEmpty);
|
|
|
builder.addConditionToListWithDescendants(page.path, option);
|
|
builder.addConditionToListWithDescendants(page.path, option);
|
|
|
|
|
|
|
|
// add grant conditions
|
|
// add grant conditions
|
|
@@ -758,7 +458,7 @@ export const getPageSchema = (crowi) => {
|
|
|
* find pages that start with `path`
|
|
* find pages that start with `path`
|
|
|
*/
|
|
*/
|
|
|
pageSchema.statics.findListByStartWith = async function(path, user, option, includeEmpty = false) {
|
|
pageSchema.statics.findListByStartWith = async function(path, user, option, includeEmpty = false) {
|
|
|
- const builder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find(), includeEmpty);
|
|
|
builder.addConditionToListByStartWith(path, option);
|
|
builder.addConditionToListByStartWith(path, option);
|
|
|
|
|
|
|
|
return findListFromBuilderAndViewer(builder, user, false, option);
|
|
return findListFromBuilderAndViewer(builder, user, false, option);
|
|
@@ -773,7 +473,7 @@ export const getPageSchema = (crowi) => {
|
|
|
*/
|
|
*/
|
|
|
pageSchema.statics.findListByCreator = async function(targetUser, currentUser, option) {
|
|
pageSchema.statics.findListByCreator = async function(targetUser, currentUser, option) {
|
|
|
const opt = Object.assign({ sort: 'createdAt', desc: -1 }, option);
|
|
const opt = Object.assign({ sort: 'createdAt', desc: -1 }, option);
|
|
|
- const builder = new PageQueryBuilder(this.find({ creator: targetUser._id }));
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find({ creator: targetUser._id }));
|
|
|
|
|
|
|
|
let showAnyoneKnowsLink = null;
|
|
let showAnyoneKnowsLink = null;
|
|
|
if (targetUser != null && currentUser != null) {
|
|
if (targetUser != null && currentUser != null) {
|
|
@@ -787,7 +487,7 @@ export const getPageSchema = (crowi) => {
|
|
|
const User = crowi.model('User');
|
|
const User = crowi.model('User');
|
|
|
|
|
|
|
|
const opt = Object.assign({}, option);
|
|
const opt = Object.assign({}, option);
|
|
|
- const builder = new PageQueryBuilder(this.find({ _id: { $in: ids } }), shouldIncludeEmpty);
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find({ _id: { $in: ids } }), shouldIncludeEmpty);
|
|
|
|
|
|
|
|
builder.addConditionToPagenate(opt.offset, opt.limit);
|
|
builder.addConditionToPagenate(opt.offset, opt.limit);
|
|
|
|
|
|
|
@@ -1089,7 +789,7 @@ export const getPageSchema = (crowi) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pageSchema.statics.applyScopesToDescendantsAsyncronously = async function(parentPage, user) {
|
|
pageSchema.statics.applyScopesToDescendantsAsyncronously = async function(parentPage, user) {
|
|
|
- const builder = new PageQueryBuilder(this.find());
|
|
|
|
|
|
|
+ const builder = new this.PageQueryBuilder(this.find());
|
|
|
builder.addConditionToListWithDescendants(parentPage.path);
|
|
builder.addConditionToListWithDescendants(parentPage.path);
|
|
|
|
|
|
|
|
// add grant conditions
|
|
// add grant conditions
|
|
@@ -1117,7 +817,7 @@ export const getPageSchema = (crowi) => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
pageSchema.statics.findListByPathsArray = async function(paths, includeEmpty = false) {
|
|
pageSchema.statics.findListByPathsArray = async function(paths, includeEmpty = false) {
|
|
|
- const queryBuilder = new PageQueryBuilder(this.find(), includeEmpty);
|
|
|
|
|
|
|
+ const queryBuilder = new this.PageQueryBuilder(this.find(), includeEmpty);
|
|
|
queryBuilder.addConditionToListByPathsArray(paths);
|
|
queryBuilder.addConditionToListByPathsArray(paths);
|
|
|
|
|
|
|
|
return await queryBuilder.query.exec();
|
|
return await queryBuilder.query.exec();
|
|
@@ -1215,7 +915,5 @@ export const getPageSchema = (crowi) => {
|
|
|
pageSchema.statics.GRANT_USER_GROUP = GRANT_USER_GROUP;
|
|
pageSchema.statics.GRANT_USER_GROUP = GRANT_USER_GROUP;
|
|
|
pageSchema.statics.PAGE_GRANT_ERROR = PAGE_GRANT_ERROR;
|
|
pageSchema.statics.PAGE_GRANT_ERROR = PAGE_GRANT_ERROR;
|
|
|
|
|
|
|
|
- pageSchema.statics.PageQueryBuilder = PageQueryBuilder;
|
|
|
|
|
-
|
|
|
|
|
return pageSchema;
|
|
return pageSchema;
|
|
|
};
|
|
};
|