From f93e6c03c96db174135977d54de2b2e0ae2a2c7d Mon Sep 17 00:00:00 2001 From: yuri Date: Fri, 15 Jan 2016 15:23:49 +0200 Subject: [PATCH] knowledge base dev --- .../ControlKnowledgeBaseArticleStatus.php | 44 ++++++++++++++++ .../Resources/i18n/en_US/ScheduledJob.json | 3 +- .../entityDefs/KnowledgeBaseArticle.json | 6 +-- .../metadata/entityDefs/ScheduledJob.json | 6 +++ .../metadata/entityDefs/ScheduledJob.json | 1 - .../knowledge-base-article/fields/status.js | 52 +++++++++++++++++++ .../src/views/user/password-change-request.js | 12 ++--- install/core/afterInstall/records.php | 6 +++ 8 files changed, 117 insertions(+), 13 deletions(-) create mode 100644 application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php create mode 100644 application/Espo/Modules/Crm/Resources/metadata/entityDefs/ScheduledJob.json create mode 100644 frontend/client/modules/crm/src/views/knowledge-base-article/fields/status.js diff --git a/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php b/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php new file mode 100644 index 0000000000..03a2fc5942 --- /dev/null +++ b/application/Espo/Modules/Crm/Jobs/ControlKnowledgeBaseArticleStatus.php @@ -0,0 +1,44 @@ +getEntityManager()->getRepository('KnowledgeBaseArticle')->where(array( + 'expirationDate<=' => date('Y-m-d'), + 'status' => 'Published' + ))->find(); + + foreach ($list as $e) { + $e->set('status', 'Archived'); + $this->getEntityManager()->saveEntity($e); + } + + return true; + } +} + diff --git a/application/Espo/Modules/Crm/Resources/i18n/en_US/ScheduledJob.json b/application/Espo/Modules/Crm/Resources/i18n/en_US/ScheduledJob.json index 4a71f96bb5..d6dc816a80 100644 --- a/application/Espo/Modules/Crm/Resources/i18n/en_US/ScheduledJob.json +++ b/application/Espo/Modules/Crm/Resources/i18n/en_US/ScheduledJob.json @@ -1,7 +1,8 @@ { "options": { "job": { - "ProcessMassEmail": "Send Mass Emails" + "ProcessMassEmail": "Send Mass Emails", + "ControlKnowledgeBaseArticleStatus": "Control Knowledge Base Article Status" } } } diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json index 37251c1d60..643d2144a4 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/KnowledgeBaseArticle.json @@ -7,7 +7,7 @@ "status": { "type": "enum", "options": ["Draft", "In Review", "Published", "Archived"], - "view": "views/fields/enum-styled", + "view": "crm:views/knowledge-base-article/fields/status", "default": "Draft" }, "language": { @@ -20,9 +20,7 @@ "options": ["Article"] }, "publishDate": { - "type": "date", - "required": true, - "default": "javascript: return this.dateTime.getToday();" + "type": "date" }, "expirationDate": { "type": "date", diff --git a/application/Espo/Modules/Crm/Resources/metadata/entityDefs/ScheduledJob.json b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/ScheduledJob.json new file mode 100644 index 0000000000..e320268120 --- /dev/null +++ b/application/Espo/Modules/Crm/Resources/metadata/entityDefs/ScheduledJob.json @@ -0,0 +1,6 @@ +{ + "jobSchedulingMap": { + "ProcessMassEmail": "15 * * * *", + "ControlKnowledgeBaseArticleStatus": "10 1 * * *" + } +} diff --git a/application/Espo/Resources/metadata/entityDefs/ScheduledJob.json b/application/Espo/Resources/metadata/entityDefs/ScheduledJob.json index 62b21d4ee8..d2987dc603 100644 --- a/application/Espo/Resources/metadata/entityDefs/ScheduledJob.json +++ b/application/Espo/Resources/metadata/entityDefs/ScheduledJob.json @@ -64,7 +64,6 @@ "CheckEmailAccounts": "*/5 * * * *", "SendEmailReminders": "/2 * * * *", "Cleanup": "1 1 * * 0", - "ProcessMassEmail": "15 * * * *", "AuthTokenControl": "*/6 * * * *" } } diff --git a/frontend/client/modules/crm/src/views/knowledge-base-article/fields/status.js b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/status.js new file mode 100644 index 0000000000..0163bfdf57 --- /dev/null +++ b/frontend/client/modules/crm/src/views/knowledge-base-article/fields/status.js @@ -0,0 +1,52 @@ +/************************************************************************ + * This file is part of EspoCRM. + * + * EspoCRM - Open Source CRM application. + * Copyright (C) 2014-2015 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko + * Website: http://www.espocrm.com + * + * EspoCRM is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * EspoCRM is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with EspoCRM. If not, see http://www.gnu.org/licenses/. + * + * The interactive user interfaces in modified source and object code versions + * of this program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU General Public License version 3. + * + * In accordance with Section 7(b) of the GNU General Public License version 3, + * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. + ************************************************************************/ + +Espo.define('crm:views/knowledge-base-article/fields/status', 'views/fields/enum', function (Dep) { + + return Dep.extend({ + + setup: function () { + Dep.prototype.setup.call(this); + var publishDateWasSet = false; + this.on('change', function () { + if (this.model.get('status') === 'Published') { + if (!this.model.get('publishDate')) { + publishDateWasSet = true; + this.model.set('publishDate', this.getDateTime().getToday()); + } + } else { + if (publishDateWasSet) { + this.model.set('publishDate', null); + } + } + }, this); + } + + }); + +}); diff --git a/frontend/client/src/views/user/password-change-request.js b/frontend/client/src/views/user/password-change-request.js index 59d3ec3cd6..11d71a9392 100644 --- a/frontend/client/src/views/user/password-change-request.js +++ b/frontend/client/src/views/user/password-change-request.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Views.User.PasswordChangeRequest', 'View', function (Dep) { +Espo.define('views./user/password-change-request', 'view', function (Dep) { return Dep.extend({ - - template: 'user.password-change-request', + + template: 'user/password-change-request', data: function () { return { @@ -52,7 +52,7 @@ Espo.define('Views.User.PasswordChangeRequest', 'View', function (Dep) { var passwordConfirm = $passwordConfirm.val(); var translatedPasswordLabel = this.translate('password', 'fields', 'User'); - + if (password == '') { var message = this.getLanguage().translate('fieldIsRequired', 'messages').replace('{field}', translatedPasswordLabel); @@ -110,10 +110,8 @@ Espo.define('Views.User.PasswordChangeRequest', 'View', function (Dep) { this.$el.find('.msg-box').removeClass('hidden').html('' + msg + ''); }.bind(this)); - - }, - + } }); }); diff --git a/install/core/afterInstall/records.php b/install/core/afterInstall/records.php index 2a2b93962a..1d42d50b2a 100644 --- a/install/core/afterInstall/records.php +++ b/install/core/afterInstall/records.php @@ -72,6 +72,12 @@ return array( 'job' => 'AuthTokenControl', 'status' => 'Active', 'scheduling' => '*/6 * * * *', + ), + array( + 'name' => 'Control Knowledge Base Article Status', + 'job' => 'ControlKnowledgeBaseArticleStatus', + 'status' => 'Active', + 'scheduling' => '10 1 * * *', ) ), ); \ No newline at end of file