2022-09-14 11:32:04 +02:00
|
|
|
const mongoose = require('mongoose').set('debug', false)
|
2019-12-07 00:20:06 +01:00
|
|
|
const Schema = mongoose.Schema;
|
|
|
|
|
|
|
|
|
|
const tools = require('../tools/general');
|
|
|
|
|
|
|
|
|
|
mongoose.Promise = global.Promise;
|
|
|
|
|
mongoose.level = "F";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Resolving error Unknown modifier: $pushAll
|
|
|
|
|
mongoose.plugin(schema => {
|
|
|
|
|
schema.options.usePushEach = true
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const MyPageSchema = new Schema({
|
|
|
|
|
idapp: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
author_username: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
lang: {
|
2019-12-07 00:20:06 +01:00
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
title: {
|
2019-12-07 00:20:06 +01:00
|
|
|
type: String,
|
|
|
|
|
},
|
2022-10-27 11:22:58 +02:00
|
|
|
subtitle: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
icon: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-10-27 11:22:58 +02:00
|
|
|
iconsize: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-31 00:44:53 +01:00
|
|
|
order: {
|
|
|
|
|
type: Number,
|
|
|
|
|
default: 1000,
|
|
|
|
|
},
|
|
|
|
|
path: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
keywords: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
description: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
heightimg: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
2020-01-20 01:48:25 +01:00
|
|
|
onlyif_logged: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
2021-03-30 02:23:38 +02:00
|
|
|
only_residenti: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
color: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
imgback: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
img1: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
content: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2021-04-30 01:31:12 +02:00
|
|
|
video1: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
ratio1: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
img2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
video2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
ratio2: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
img3: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content3: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
video3: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
ratio3: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
|
|
|
|
content4: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
active: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
inmenu: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
submenu: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
l_par: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
|
|
|
|
l_child: {
|
|
|
|
|
type: Number,
|
|
|
|
|
},
|
2021-06-04 10:07:57 +02:00
|
|
|
internalpage: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
infooter: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
2022-10-27 11:22:58 +02:00
|
|
|
extraclass: {
|
|
|
|
|
type: String,
|
|
|
|
|
},
|
2022-11-20 10:20:56 +01:00
|
|
|
loadFirst: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
showFooter: {
|
|
|
|
|
type: Boolean,
|
2024-09-26 02:14:33 +02:00
|
|
|
},
|
|
|
|
|
mainMenu: {
|
|
|
|
|
type: Boolean,
|
|
|
|
|
},
|
|
|
|
|
sottoMenu: [{
|
|
|
|
|
type: String
|
|
|
|
|
}],
|
2024-10-31 23:22:46 +01:00
|
|
|
date_created: {
|
|
|
|
|
type: Date,
|
|
|
|
|
default: Date.now
|
|
|
|
|
},
|
|
|
|
|
date_updated: {
|
|
|
|
|
type: Date,
|
|
|
|
|
},
|
2019-12-07 00:20:06 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
MyPageSchema.statics.getFieldsForSearch = function () {
|
2020-03-21 10:28:26 +01:00
|
|
|
return [{ field: 'title', type: tools.FieldType.string },
|
2023-02-20 02:19:53 +01:00
|
|
|
{ field: 'path', type: tools.FieldType.string },
|
2022-11-20 10:20:56 +01:00
|
|
|
{ field: 'keywords', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'description', type: tools.FieldType.string },
|
|
|
|
|
{ field: 'content', type: tools.FieldType.string }]
|
2019-12-07 00:20:06 +01:00
|
|
|
};
|
|
|
|
|
|
2022-06-16 20:34:42 +02:00
|
|
|
MyPageSchema.statics.executeQueryTable = function (idapp, params, user) {
|
2019-12-07 00:20:06 +01:00
|
|
|
params.fieldsearch = this.getFieldsForSearch();
|
2022-06-16 20:34:42 +02:00
|
|
|
return tools.executeQueryTable(this, idapp, params, user);
|
2019-12-07 00:20:06 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MyPageSchema.statics.findAllIdApp = async function (idapp) {
|
|
|
|
|
const MyPage = this;
|
|
|
|
|
|
|
|
|
|
const myfind = { idapp };
|
|
|
|
|
|
|
|
|
|
return await MyPage.find(myfind, (err, arrrec) => {
|
|
|
|
|
return arrrec
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-20 10:20:56 +01:00
|
|
|
MyPageSchema.statics.findOnlyStruttRec = async function (idapp) {
|
2021-04-30 01:31:12 +02:00
|
|
|
const MyPage = this;
|
|
|
|
|
|
2022-11-20 10:20:56 +01:00
|
|
|
const arrFirst = await MyPage.find(
|
|
|
|
|
{
|
|
|
|
|
idapp,
|
|
|
|
|
loadFirst: true,
|
|
|
|
|
},
|
|
|
|
|
(err, arrrec) => {
|
|
|
|
|
return arrrec
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const arrfixed = await MyPage.find(
|
2024-09-26 02:14:33 +02:00
|
|
|
{
|
|
|
|
|
idapp,
|
2022-11-20 10:20:56 +01:00
|
|
|
$or: [
|
2024-09-26 02:14:33 +02:00
|
|
|
{ loadFirst: { $exists: false } },
|
|
|
|
|
{ loadFirst: { $exists: true, $eq: false } }],
|
2022-11-20 10:20:56 +01:00
|
|
|
}
|
|
|
|
|
, {
|
|
|
|
|
title: 1,
|
|
|
|
|
subtitle: 1,
|
|
|
|
|
icon: 1,
|
|
|
|
|
order: 1,
|
|
|
|
|
keywords: 1,
|
|
|
|
|
description: 1,
|
|
|
|
|
path: 1,
|
|
|
|
|
active: 1,
|
|
|
|
|
onlyif_logged: 1,
|
|
|
|
|
only_residenti: 1,
|
|
|
|
|
inmenu: 1,
|
|
|
|
|
submenu: 1,
|
|
|
|
|
iconsize: 1,
|
|
|
|
|
extraclass: 1,
|
|
|
|
|
loadFirst: 1,
|
2024-09-26 02:14:33 +02:00
|
|
|
mainMenu: 1,
|
|
|
|
|
sottoMenu: 1,
|
2022-11-20 10:20:56 +01:00
|
|
|
}, (err, arrrec) => {
|
|
|
|
|
return arrrec
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return [...arrFirst, ...arrfixed];
|
2021-04-30 01:31:12 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2021-06-04 10:07:57 +02:00
|
|
|
MyPageSchema.statics.findInternalPages = async function (idapp) {
|
|
|
|
|
const MyPage = this;
|
|
|
|
|
|
2022-11-20 10:20:56 +01:00
|
|
|
const myfind = {
|
|
|
|
|
idapp,
|
2021-06-04 10:07:57 +02:00
|
|
|
internalpage: { $exists: true, $eq: true }
|
|
|
|
|
};
|
|
|
|
|
|
2022-09-11 11:45:33 +02:00
|
|
|
return await MyPage.find(myfind, {
|
2021-06-04 10:07:57 +02:00
|
|
|
title: 1,
|
|
|
|
|
path: 1,
|
|
|
|
|
onlyif_logged: 1,
|
|
|
|
|
only_residenti: 1,
|
|
|
|
|
}, (err, arrrec) => {
|
|
|
|
|
return arrrec
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2019-12-07 00:20:06 +01:00
|
|
|
const MyPage = mongoose.model('MyPage', MyPageSchema);
|
|
|
|
|
|
2023-12-09 11:55:58 +01:00
|
|
|
MyPage.createIndexes((err) => {
|
|
|
|
|
if (err) throw err;
|
|
|
|
|
});
|
|
|
|
|
|
2019-12-07 00:20:06 +01:00
|
|
|
module.exports = { MyPage };
|