PMCORE-2412
This commit is contained in:
@@ -17,7 +17,8 @@ try {
|
|||||||
'ldapcron' => ['title' => 'LDAP Advanced CRON'],
|
'ldapcron' => ['title' => 'LDAP Advanced CRON'],
|
||||||
'messageeventcron' => ['title' => 'Message-Event CRON'],
|
'messageeventcron' => ['title' => 'Message-Event CRON'],
|
||||||
'timereventcron' => ['title' => 'Timer-Event CRON'],
|
'timereventcron' => ['title' => 'Timer-Event CRON'],
|
||||||
'sendnotificationscron' => ['title' => 'Send-Notifications CRON']
|
'sendnotificationscron' => ['title' => 'Send-Notifications CRON'],
|
||||||
|
'webentriescron' => ['title' => 'Wen Entries CRON']
|
||||||
];
|
];
|
||||||
|
|
||||||
//Define constants
|
//Define constants
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
* @see workflow/engine/bin/timereventcron.php
|
* @see workflow/engine/bin/timereventcron.php
|
||||||
* @see workflow/engine/bin/ldapcron.php
|
* @see workflow/engine/bin/ldapcron.php
|
||||||
* @see workflow/engine/bin/sendnotificationscron.php
|
* @see workflow/engine/bin/sendnotificationscron.php
|
||||||
|
* @see workflow/engine/bin/webentriescron.php
|
||||||
* @see workflow/engine/methods/setup/cron.php
|
* @see workflow/engine/methods/setup/cron.php
|
||||||
*
|
*
|
||||||
* @link https://wiki.processmaker.com/3.2/Executing_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/autoload.php';
|
||||||
require_once __DIR__ . '/../../../bootstrap/app.php';
|
require_once __DIR__ . '/../../../bootstrap/app.php';
|
||||||
|
|
||||||
|
use ProcessMaker\BusinessModel\WebEntry;
|
||||||
use ProcessMaker\Core\JobsManager;
|
use ProcessMaker\Core\JobsManager;
|
||||||
use ProcessMaker\Core\System;
|
use ProcessMaker\Core\System;
|
||||||
use ProcessMaker\Plugins\PluginRegistry;
|
use ProcessMaker\Plugins\PluginRegistry;
|
||||||
@@ -302,6 +304,11 @@ try {
|
|||||||
case 'sendnotificationscron':
|
case 'sendnotificationscron':
|
||||||
sendNotifications();
|
sendNotifications();
|
||||||
break;
|
break;
|
||||||
|
case 'webentriescron':
|
||||||
|
setExecutionMessage('Deleting web entry cases created one week ago or more');
|
||||||
|
WebEntry::deleteOldWebEntries();
|
||||||
|
setExecutionResultMessage('FINISHED');
|
||||||
|
break;
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
case 'actionsByEmailEmailResponse':
|
case 'actionsByEmailEmailResponse':
|
||||||
(new ResponseReader)->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()
|
public static function convertFromV1ToV2()
|
||||||
{
|
{
|
||||||
// Build query
|
// Build query
|
||||||
$sql = "UPDATE
|
$query = "UPDATE
|
||||||
`WEB_ENTRY`
|
`WEB_ENTRY`
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
`BPMN_PROCESS`
|
`BPMN_PROCESS`
|
||||||
ON
|
ON
|
||||||
(`WEB_ENTRY`.`PRO_UID` = `BPMN_PROCESS`.`PRJ_UID`)
|
(`WEB_ENTRY`.`PRO_UID` = `BPMN_PROCESS`.`PRJ_UID`)
|
||||||
SET
|
SET
|
||||||
`WEB_ENTRY`.`DYN_UID` = '', `WEB_ENTRY`.`WE_TYPE` = 'MULTIPLE'
|
`WEB_ENTRY`.`DYN_UID` = '', `WEB_ENTRY`.`WE_TYPE` = 'MULTIPLE'
|
||||||
WHERE
|
WHERE
|
||||||
`WE_TYPE` = 'SINGLE' AND `WE_AUTHENTICATION` = 'ANONYMOUS' AND
|
`WE_TYPE` = 'SINGLE' AND `WE_AUTHENTICATION` = 'ANONYMOUS' AND
|
||||||
`WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL";
|
`WE_CALLBACK` = 'PROCESSMAKER' AND `BPMN_PROCESS`.`PRJ_UID` IS NOT NULL";
|
||||||
|
|
||||||
// Execute query
|
// 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