PMCORE-2412
This commit is contained in:
@@ -17,7 +17,8 @@ try {
|
||||
'ldapcron' => ['title' => 'LDAP Advanced CRON'],
|
||||
'messageeventcron' => ['title' => 'Message-Event CRON'],
|
||||
'timereventcron' => ['title' => 'Timer-Event CRON'],
|
||||
'sendnotificationscron' => ['title' => 'Send-Notifications CRON']
|
||||
'sendnotificationscron' => ['title' => 'Send-Notifications CRON'],
|
||||
'webentriescron' => ['title' => 'Wen Entries CRON']
|
||||
];
|
||||
|
||||
//Define constants
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
* @see workflow/engine/bin/timereventcron.php
|
||||
* @see workflow/engine/bin/ldapcron.php
|
||||
* @see workflow/engine/bin/sendnotificationscron.php
|
||||
* @see workflow/engine/bin/webentriescron.php
|
||||
* @see workflow/engine/methods/setup/cron.php
|
||||
*
|
||||
* @link https://wiki.processmaker.com/3.2/Executing_cron.php
|
||||
@@ -22,6 +23,7 @@ require_once __DIR__ . '/../../../gulliver/system/class.g.php';
|
||||
require_once __DIR__ . '/../../../bootstrap/autoload.php';
|
||||
require_once __DIR__ . '/../../../bootstrap/app.php';
|
||||
|
||||
use ProcessMaker\BusinessModel\WebEntry;
|
||||
use ProcessMaker\Core\JobsManager;
|
||||
use ProcessMaker\Core\System;
|
||||
use ProcessMaker\Plugins\PluginRegistry;
|
||||
@@ -302,6 +304,11 @@ try {
|
||||
case 'sendnotificationscron':
|
||||
sendNotifications();
|
||||
break;
|
||||
case 'webentriescron':
|
||||
setExecutionMessage('Deleting web entry cases created one week ago or more');
|
||||
WebEntry::deleteOldWebEntries();
|
||||
setExecutionResultMessage('FINISHED');
|
||||
break;
|
||||
/*----------------------------------********---------------------------------*/
|
||||
case 'actionsByEmailEmailResponse':
|
||||
(new ResponseReader)->actionsByEmailEmailResponse();
|
||||
|
||||
3
workflow/engine/bin/webentriescron.php
Normal file
3
workflow/engine/bin/webentriescron.php
Normal file
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
|
||||
require_once 'cron.php';
|
||||
@@ -1175,19 +1175,46 @@ class WebEntry
|
||||
public static function convertFromV1ToV2()
|
||||
{
|
||||
// Build query
|
||||
$sql = "UPDATE
|
||||
`WEB_ENTRY`
|
||||
LEFT JOIN
|
||||
`BPMN_PROCESS`
|
||||
ON
|
||||
(`WEB_ENTRY`.`PRO_UID` = `BPMN_PROCESS`.`PRJ_UID`)
|
||||
SET
|
||||
`WEB_ENTRY`.`DYN_UID` = '', `WEB_ENTRY`.`WE_TYPE` = 'MULTIPLE'
|
||||
WHERE
|
||||
`WE_TYPE` = 'SINGLE' AND `WE_AUTHENTICATION` = 'ANONYMOUS' AND
|
||||
`WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL";
|
||||
$query = "UPDATE
|
||||
`WEB_ENTRY`
|
||||
LEFT JOIN
|
||||
`BPMN_PROCESS`
|
||||
ON
|
||||
(`WEB_ENTRY`.`PRO_UID` = `BPMN_PROCESS`.`PRJ_UID`)
|
||||
SET
|
||||
`WEB_ENTRY`.`DYN_UID` = '', `WEB_ENTRY`.`WE_TYPE` = 'MULTIPLE'
|
||||
WHERE
|
||||
`WE_TYPE` = 'SINGLE' AND `WE_AUTHENTICATION` = 'ANONYMOUS' AND
|
||||
`WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL";
|
||||
|
||||
// Execute query
|
||||
DB::connection('workflow')->statement($sql);
|
||||
DB::connection('workflow')->statement($query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete web entries created one week ago or more
|
||||
*/
|
||||
public static function deleteOldWebEntries()
|
||||
{
|
||||
// Define some values for PM tables classes
|
||||
if (!defined('PATH_WORKSPACE')) {
|
||||
define('PATH_WORKSPACE', PATH_DB . config('system.workspace') . PATH_SEP);
|
||||
}
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . PATH_WORKSPACE);
|
||||
|
||||
// Calculate date, one week ago from today
|
||||
$date = now()->subWeek()->format('Y-m-d H:i:s');
|
||||
|
||||
// Build query
|
||||
$query = "SELECT `APP_UID` FROM `APPLICATION` WHERE `APP_NUMBER` < 0 AND `APP_CREATE_DATE` < '{$date}'";
|
||||
|
||||
// Execute query
|
||||
$cases = DB::connection('workflow')->select($query);
|
||||
|
||||
// Delete cases, one by one with all related records
|
||||
$casesInstance = new Cases();
|
||||
foreach ($cases as $case) {
|
||||
$casesInstance->removeCase($case->APP_UID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user