Files
tomolino-processmaker/install/update_to_3_2_8.php
Moron, Olivier cc17bd5fe4 * Bugfix Reminders on task cancelled before delete reminders update was not deleted
* Bugfix Uncaught ReferenceError: $ is not defined on ITIL Object creation
* Delete error message after case cancellation successfully
* change minimum version of processmaker server
* delete TODO comment
* Add possibility to cancel case with multiple tasks
* bugfix delete reminder on case's cancel  or delete
* Add behavior on a claimed task or reasign to the current user for show task in timeline
* Fixed issue with default dates settings in reminders for tasks
* Added shortcut to select "Me as sender"
* Added a test to prevent post-only user to set reminder settings
* Updated XML
* Fix issue with screen view
* Adjusted wordings
* Reviewed $new_date computation in cron
* Bugfix creating a case in processcase tab doesn't redirect to the case
* Adjusted visualization for Reminder
* Added an <hr>
* Adjusted values in dropdowns when settings are NULL
* Added a test to prevent sending of remminders to "ProcessMaker" user
* Added view of default and actual reminder settings for a PM task
* cronPMReminder reflects changes and send reminders
* Re-engineered table fields and search options
* Fixed issue with FUP that were no longuer added to timeline.
* Added automatic reminders
* bugfix on filter
* Changed copyrights
* added .gitignore
* add process category search option + input in process form
* Added process categories
* bugfixes on helpdesk process
* bugfixes html_tags and actiontime
* Changed the way the userId of the first task was computed, to be able to have a tobeclaimed task
* Added get/set APP_DATA scripts to be able to read/write the APP_DATA in json files
* Added a followup when a reminder is sent to task user (or group)

Set version 5.2.3
2025-01-14 12:17:17 +01:00

219 lines
13 KiB
PHP

<?php
/*
-------------------------------------------------------------------------
ProcessMaker plugin for GLPI
Copyright (C) 2014-2024 by Raynet SAS a company of A.Raymond Network.
https://www.araymond.com/
-------------------------------------------------------------------------
LICENSE
This file is part of ProcessMaker plugin for GLPI.
This file 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 2 of the License, or
(at your option) any later version.
This plugin 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 this plugin. If not, see <http://www.gnu.org/licenses/>.
--------------------------------------------------------------------------
*/
function update_to_3_2_8() {
global $DB;
if ($DB->tableExists("glpi_plugin_processmaker_config")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_config`
ADD COLUMN `date_mod` DATETIME NULL DEFAULT NULL AFTER `pm_theme`,
ADD COLUMN `comment` TEXT NULL AFTER `date_mod`;
RENAME TABLE `glpi_plugin_processmaker_config` TO `glpi_plugin_processmaker_configs`;";
$DB->query($query) or die("error creating glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbserver_name" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbserver_name` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_group_guid`,
ADD COLUMN `pm_dbserver_user` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_name`,
ADD COLUMN `pm_dbserver_passwd` VARCHAR(255) NULL DEFAULT NULL AFTER `pm_dbserver_user`;";
$DB->query($query) or die("error adding fields pm_dbserver_name, pm_dbserver_user, pm_dbserver_passwd to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "domain" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `domain` VARCHAR(50) NULL DEFAULT '' AFTER `pm_dbserver_passwd`;
";
$DB->query($query) or die("error adding field domain to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "maintenance" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `maintenance` TINYINT(1) NOT NULL DEFAULT '0' AFTER `domain`;
;";
$DB->query($query) or die("error adding fields maintenance to glpi_plugin_processmaker_configs" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_configs", "pm_dbname" )) {
$query = "ALTER TABLE `glpi_plugin_processmaker_configs`
ADD COLUMN `pm_dbname` VARCHAR(50) NULL DEFAULT 'wf_workflow' AFTER `pm_dbserver_name`;
;";
$DB->query($query) or die("error adding field pm_dbname to glpi_plugin_processmaker_configs" . $DB->error());
$DB->query("UPDATE glpi_plugin_processmaker_configs SET `pm_dbname` = CONCAT('wf_', `pm_workspace`) WHERE `id` = 1");
}
if ($DB->tableExists("glpi_plugin_processmaker_profiles")) {
$query = "DROP TABLE `glpi_plugin_processmaker_profiles` ;";
$DB->query($query) or die("error dropping glpi_plugin_processmaker_profiles" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_cases", "processes_id")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
ADD COLUMN `processes_id` INT UNSIGNED NULL DEFAULT NULL;
";
$DB->query($query) or die("error adding column processes_id into glpi_plugin_processmaker_cases" . $DB->error());
} else {
$flds = $DB->listFields('glpi_plugin_processmaker_cases');
if (strcasecmp( $flds['processes_id']['Type'], 'varchar(32)' ) == 0) {
// required because autoload doesn't work for unactive plugin'
include_once(PLUGIN_PROCESSMAKER_ROOT . "/inc/process.class.php");
include_once(PLUGIN_PROCESSMAKER_ROOT . "/inc/case.class.php");
$proc = new PluginProcessmakerProcess;
$case = new PluginProcessmakerCase;
foreach ($DB->request("SELECT * FROM glpi_plugin_processmaker_cases WHERE LENGTH( processes_id ) = 32") as $row) {
$proc->getFromGUID( $row['processes_id'] );
$case->update([ 'id' => $row['id'], 'processes_id' => $proc->getID() ] );
}
$query = "ALTER TABLE `glpi_plugin_processmaker_cases`
CHANGE COLUMN `processes_id` `processes_id` INT UNSIGNED NULL DEFAULT NULL AFTER `case_status`;
";
$DB->query($query) or die("error converting column processes_id into INT UNSIGNED in glpi_plugin_processmaker_cases" . $DB->error());
}
}
if (!$DB->fieldExists('glpi_plugin_processmaker_users', 'password') && !$DB->fieldExists('glpi_plugin_processmaker_users', 'id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ADD COLUMN `id` INT NOT NULL AUTO_INCREMENT FIRST,
ADD COLUMN `password` VARCHAR(32) NULL DEFAULT NULL AFTER `pm_users_id`,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error adding column 'password' to glpi_plugin_processmaker_users" . $DB->error());
// also need to change text of tasks for tasks linked to cases
$query = "UPDATE glpi_tickettasks SET content=REPLACE(content,'##_PluginProcessmakerCases\$processmakercases','##_PluginProcessmakerCase\$processmakercases')
WHERE glpi_tickettasks.id IN (SELECT items_id FROM glpi_plugin_processmaker_tasks WHERE itemtype='TicketTask') AND content LIKE '%_PluginProcessmakerCases\$processmakercases%'";
$DB->query($query) or die("error updating TicketTask" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_users', 'glpi_users_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
ALTER `glpi_users_id` DROP DEFAULT,
DROP PRIMARY KEY,
DROP COLUMN `id`,
DROP INDEX `glpi_users_id`;
";
$DB->query($query) or die("error droping 'defaults' from 'glpi_users_id' to glpi_plugin_processmaker_users" . $DB->error());
$query = "ALTER TABLE `glpi_plugin_processmaker_users`
CHANGE COLUMN `glpi_users_id` `id` INT UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
ADD PRIMARY KEY (`id`);
";
$DB->query($query) or die("error renaming 'glpi_users_id' into 'id' to glpi_plugin_processmaker_users" . $DB->error());
}
if ($DB->fieldExists( 'glpi_plugin_processmaker_processes', 'is_helpdeskvisible')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
CHANGE COLUMN `is_helpdeskvisible` `is_helpdeskvisible_notusedanymore` TINYINT(1) NOT NULL DEFAULT '0' COMMENT 'Not used any more since version 2.2' AFTER `name`;";
$DB->query($query);
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'itilcategories_id')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `itilcategories_id` INT UNSIGNED NOT NULL DEFAULT '0',
ADD COLUMN `type` INT UNSIGNED NOT NULL DEFAULT '1' COMMENT 'Only used for Tickets';";
$DB->query($query) or die("error adding columns 'itilcategories_id' and 'type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists( 'glpi_plugin_processmaker_processes', 'project_type')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_processes`
ADD COLUMN `project_type` VARCHAR(50) NOT NULL DEFAULT 'classic';";
$DB->query($query) or die("error adding columns 'project_type' to glpi_plugin_processmaker_processes" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_taskcategories', 'is_active')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_taskcategories`
ADD COLUMN `is_active` TINYINT(1) NOT NULL DEFAULT '1' AFTER `start`;";
$DB->query($query) or die("error adding field is_active to glpi_plugin_processmaker_taskcategories table" . $DB->error());
}
if ($DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'postdatas')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `postdatas` `postdata` MEDIUMTEXT NULL DEFAULT NULL AFTER `toclaim`;";
$DB->query($query) or die("error changing 'postdatas' from glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists('glpi_plugin_processmaker_crontaskactions', 'logs_out')) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
ADD COLUMN `logs_out` MEDIUMTEXT NULL AFTER `postdata`;";
$DB->query($query) or die("error adding 'logs_out' field into glpi_plugin_processmaker_crontaskactions table" . $DB->error());
}
if (!$DB->fieldExists("glpi_plugin_processmaker_crontaskactions", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_crontaskactions`
CHANGE COLUMN `toclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `users_id`;";
$DB->query($query) or die("error renaming toclaim in glpi_plugin_processmaker_crontaskactions" . $DB->error());
}
//if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "plugin_processmaker_taskcategories_id_source")) {
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// ADD COLUMN `plugin_processmaker_taskcategories_id_source` INT UNSIGNED NULL DEFAULT NULL AFTER `sourcetask_guid`,
// ADD COLUMN `plugin_processmaker_taskcategories_id_target` INT UNSIGNED NULL DEFAULT NULL AFTER `targettask_guid`,
// ADD COLUMN `plugin_processmaker_processes_id` INT UNSIGNED NULL DEFAULT NULL AFTER `targetprocess_guid`;";
// $DB->query($query) or die("error adding col plugin_processmaker_taskcategories_id_source to glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "UPDATE glpi_plugin_processmaker_caselinks AS pm_cl
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tcsource ON pm_tcsource.pm_task_guid=pm_cl.sourcetask_guid
// LEFT JOIN glpi_plugin_processmaker_taskcategories AS pm_tctarget ON pm_tctarget.pm_task_guid=pm_cl.targettask_guid
// LEFT JOIN glpi_plugin_processmaker_processes AS pm_pr ON pm_pr.process_guid=pm_cl.targetprocess_guid
// SET pm_cl.plugin_processmaker_taskcategories_id_source = pm_tcsource.id,
// pm_cl.plugin_processmaker_taskcategories_id_target = pm_tctarget.id,
// pm_cl.plugin_processmaker_processes_id = pm_pr.id;";
// $DB->query($query) or die("error migrating data into col plugin_processmaker_taskcategories_id_source in glpi_plugin_processmaker_caselinks" . $DB->error());
// $query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
// DROP COLUMN `sourcetask_guid`,
// DROP COLUMN `targettask_guid`,
// DROP COLUMN `targetprocess_guid`;";
// $DB->query($query) or die("error dropping col plugin_processmaker_taskcategories_id_source from glpi_plugin_processmaker_caselinks" . $DB->error());
//}
if (!$DB->fieldExists("glpi_plugin_processmaker_caselinks", "is_targettoclaim")) {
$query = "ALTER TABLE `glpi_plugin_processmaker_caselinks`
CHANGE COLUMN `targettoclaim` `is_targettoclaim` TINYINT(1) NOT NULL DEFAULT '0' AFTER `sourcecondition`;";
$DB->query($query) or die("error renaming targettoclaim in glpi_plugin_processmaker_caselinks" . $DB->error());
}
//if( !$DB->tableExists('glpi_plugin_processmaker_selfservicedrafts')){
// $query = "CREATE TABLE `glpi_plugin_processmaker_selfservicedrafts` (
// `id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
// `users_id` INT UNSIGNED NOT NULL,
// `plugin_processmaker_processes_id` INT UNSIGNED NOT NULL,
// `url` TEXT NOT NULL,
// PRIMARY KEY (`id`),
// INDEX `users_id` (`users_id`)
// )
// ENGINE=InnoDB
// ;" ;
// $DB->query($query) or die("error creating glpi_plugin_processmaker_selfservicedrafts" . $DB->error());
//}
return '3.2.8';
}