2010-12-02 23:34:41 +00:00
|
|
|
<?php
|
2017-08-17 15:23:57 -04:00
|
|
|
|
2019-02-13 15:53:21 -04:00
|
|
|
/**
|
|
|
|
|
* @see workflow/engine/bin/cron.php
|
|
|
|
|
* @see workflow/engine/bin/messageeventcron.php
|
|
|
|
|
* @see workflow/engine/bin/timereventcron.php
|
|
|
|
|
* @see workflow/engine/bin/ldapcron.php
|
|
|
|
|
* @see workflow/engine/bin/sendnotificationscron.php
|
|
|
|
|
* @see workflow/engine/methods/setup/cron.php
|
|
|
|
|
*
|
|
|
|
|
* @link https://wiki.processmaker.com/3.2/Executing_cron.php
|
|
|
|
|
*/
|
|
|
|
|
|
2017-08-17 15:23:57 -04:00
|
|
|
use Illuminate\Foundation\Http\Kernel;
|
|
|
|
|
|
|
|
|
|
require_once __DIR__ . '/../../../gulliver/system/class.g.php';
|
|
|
|
|
require_once __DIR__ . '/../../../bootstrap/autoload.php';
|
|
|
|
|
require_once __DIR__ . '/../../../bootstrap/app.php';
|
2017-08-04 10:26:44 -04:00
|
|
|
|
2017-08-14 16:13:46 -04:00
|
|
|
use ProcessMaker\Core\System;
|
2017-08-04 10:26:44 -04:00
|
|
|
use ProcessMaker\Plugins\PluginRegistry;
|
|
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$fn = '
|
|
|
|
|
if (class_exists("Propel")) {
|
|
|
|
|
Propel::close();
|
|
|
|
|
}
|
|
|
|
|
';
|
|
|
|
|
register_shutdown_function(create_function('', $fn));
|
2015-03-31 09:34:40 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
ini_set('memory_limit', '512M');
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
try {
|
|
|
|
|
//Verify data
|
2019-02-22 13:02:21 -04:00
|
|
|
if (count($argv) < 7) {
|
2015-11-25 11:54:52 -04:00
|
|
|
throw new Exception('Error: Invalid number of arguments');
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
for ($i = 1; $i <= 3; $i++) {
|
|
|
|
|
$argv[$i] = base64_decode($argv[$i]);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if (!is_dir($argv[$i])) {
|
|
|
|
|
throw new Exception('Error: The path "' . $argv[$i] . '" is invalid');
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
//Set variables
|
|
|
|
|
$osIsLinux = strtoupper(substr(PHP_OS, 0, 3)) != 'WIN';
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$pathHome = $argv[1];
|
|
|
|
|
$pathTrunk = $argv[2];
|
2015-11-25 11:54:52 -04:00
|
|
|
$pathOutTrunk = $argv[3];
|
2017-12-04 13:25:35 +00:00
|
|
|
$cronName = $argv[4];
|
|
|
|
|
$workspace = $argv[5];
|
2019-02-22 13:02:21 -04:00
|
|
|
$now = $argv[6]; //date
|
2015-11-25 11:54:52 -04:00
|
|
|
//Defines constants
|
2017-12-04 13:25:35 +00:00
|
|
|
define('PATH_SEP', ($osIsLinux) ? '/' : '\\');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
define('PATH_HOME', $pathHome);
|
|
|
|
|
define('PATH_TRUNK', $pathTrunk);
|
2015-11-25 11:54:52 -04:00
|
|
|
define('PATH_OUTTRUNK', $pathOutTrunk);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
define('PATH_CLASSES', PATH_HOME . 'engine' . PATH_SEP . 'classes' . PATH_SEP);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
define('SYS_LANG', 'en');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
require_once(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
|
|
|
|
require_once(PATH_TRUNK . 'framework' . PATH_SEP . 'src' . PATH_SEP . 'Maveriks' . PATH_SEP . 'Util' . PATH_SEP . 'ClassLoader.php');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-02-26 17:02:34 -04:00
|
|
|
//Class Loader - /ProcessMaker/BusinessModel
|
|
|
|
|
$classLoader = \Maveriks\Util\ClassLoader::getInstance();
|
2015-11-25 11:54:52 -04:00
|
|
|
$classLoader->add(PATH_TRUNK . 'framework' . PATH_SEP . 'src' . PATH_SEP, 'Maveriks');
|
|
|
|
|
$classLoader->add(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'src' . PATH_SEP, 'ProcessMaker');
|
|
|
|
|
$classLoader->add(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'src' . PATH_SEP);
|
2015-02-26 17:02:34 -04:00
|
|
|
|
|
|
|
|
//Add vendors to autoloader
|
2018-08-20 14:40:30 -04:00
|
|
|
$classLoader->addClass('Bootstrap', PATH_TRUNK . 'gulliver' . PATH_SEP . 'system' . PATH_SEP . 'class.bootstrap.php');
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$classLoader->addModelClassPath(PATH_TRUNK . 'workflow' . PATH_SEP . 'engine' . PATH_SEP . 'classes' . PATH_SEP . 'model' . PATH_SEP);
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2017-08-14 16:13:46 -04:00
|
|
|
$arraySystemConfiguration = System::getSystemConfiguration('', '', $workspace);
|
2014-09-11 11:45:17 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$e_all = (defined('E_DEPRECATED')) ? E_ALL & ~E_DEPRECATED : E_ALL;
|
|
|
|
|
$e_all = (defined('E_STRICT')) ? $e_all & ~E_STRICT : $e_all;
|
|
|
|
|
$e_all = ($arraySystemConfiguration['debug']) ? $e_all : $e_all & ~E_NOTICE;
|
2014-09-11 11:45:17 -04:00
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
//In community version the default value is 0
|
|
|
|
|
$_SESSION['__SYSTEM_UTC_TIME_ZONE__'] = (int)($arraySystemConfiguration['system_utc_time_zone']) == 1;
|
|
|
|
|
|
2017-08-17 15:23:57 -04:00
|
|
|
app()->useStoragePath(realpath(PATH_DATA));
|
|
|
|
|
app()->make(Kernel::class)->bootstrap();
|
2017-08-31 15:26:44 -04:00
|
|
|
restore_error_handler();
|
2015-11-25 11:54:52 -04:00
|
|
|
//Do not change any of these settings directly, use env.ini instead
|
2017-12-04 13:25:35 +00:00
|
|
|
ini_set('display_errors', $arraySystemConfiguration['debug']);
|
2015-11-25 11:54:52 -04:00
|
|
|
ini_set('error_reporting', $e_all);
|
2017-12-04 13:25:35 +00:00
|
|
|
ini_set('short_open_tag', 'On');
|
2015-11-25 11:54:52 -04:00
|
|
|
ini_set('default_charset', 'UTF-8');
|
|
|
|
|
ini_set('soap.wsdl_cache_enabled', $arraySystemConfiguration['wsdl_cache']);
|
2019-02-22 13:02:21 -04:00
|
|
|
ini_set('date.timezone', $_SESSION['__SYSTEM_UTC_TIME_ZONE__'] ? 'UTC' : $arraySystemConfiguration['time_zone']);
|
2015-11-25 11:54:52 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
define('DEBUG_SQL_LOG', $arraySystemConfiguration['debug_sql']);
|
2015-11-25 11:54:52 -04:00
|
|
|
define('DEBUG_TIME_LOG', $arraySystemConfiguration['debug_time']);
|
|
|
|
|
define('DEBUG_CALENDAR_LOG', $arraySystemConfiguration['debug_calendar']);
|
2017-12-04 13:25:35 +00:00
|
|
|
define('MEMCACHED_ENABLED', $arraySystemConfiguration['memcached']);
|
|
|
|
|
define('MEMCACHED_SERVER', $arraySystemConfiguration['memcached_server']);
|
2019-02-22 13:02:21 -04:00
|
|
|
define('TIME_ZONE', ini_get('date.timezone'));
|
|
|
|
|
|
|
|
|
|
date_default_timezone_set(TIME_ZONE);
|
|
|
|
|
|
|
|
|
|
config(['app.timezone' => TIME_ZONE]);
|
2015-11-25 11:54:52 -04:00
|
|
|
|
|
|
|
|
spl_autoload_register(['Bootstrap', 'autoloadClass']);
|
|
|
|
|
|
|
|
|
|
//Set variables
|
2015-04-28 15:48:30 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2017-12-04 13:25:35 +00:00
|
|
|
$dateInit = null;
|
2015-04-28 15:48:30 -04:00
|
|
|
$dateFinish = null;
|
2015-03-26 18:14:51 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$argvx = '';
|
|
|
|
|
|
|
|
|
|
for ($i = 8; $i <= count($argv) - 1; $i++) {
|
2015-03-26 18:14:51 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-11-25 11:54:52 -04:00
|
|
|
if (strpos($argv[$i], '+init-date') !== false) {
|
|
|
|
|
$dateInit = substr($argv[$i], 10);
|
2017-12-04 13:25:35 +00:00
|
|
|
} elseif (strpos($argv[$i], '+finish-date') !== false) {
|
2015-03-26 18:14:51 -04:00
|
|
|
$dateFinish = substr($argv[$i], 12);
|
|
|
|
|
} else {
|
2017-12-04 13:25:35 +00:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
$argvx = $argvx . (($argvx != '') ? ' ' : '') . $argv[$i];
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2015-03-26 18:14:51 -04:00
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2016-11-25 10:33:26 -05:00
|
|
|
global $sObject;
|
|
|
|
|
$sObject = $workspace;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
//Workflow
|
|
|
|
|
saveLog('main', 'action', 'checking folder ' . PATH_DB . $workspace);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if (is_dir(PATH_DB . $workspace) && file_exists(PATH_DB . $workspace . PATH_SEP . 'db.php')) {
|
|
|
|
|
define('SYS_SYS', $workspace);
|
2017-10-10 12:33:25 -04:00
|
|
|
config(["system.workspace" => $workspace]);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
include_once(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths_installed.php');
|
|
|
|
|
include_once(PATH_HOME . 'engine' . PATH_SEP . 'config' . PATH_SEP . 'paths.php');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
//PM Paths DATA
|
2017-12-04 13:25:35 +00:00
|
|
|
define('PATH_DATA_SITE', PATH_DATA . 'sites/' . config("system.workspace") . '/');
|
|
|
|
|
define('PATH_DOCUMENT', PATH_DATA_SITE . 'files/');
|
|
|
|
|
define('PATH_DATA_MAILTEMPLATES', PATH_DATA_SITE . 'mailTemplates/');
|
|
|
|
|
define('PATH_DATA_PUBLIC', PATH_DATA_SITE . 'public/');
|
|
|
|
|
define('PATH_DATA_REPORTS', PATH_DATA_SITE . 'reports/');
|
|
|
|
|
define('PATH_DYNAFORM', PATH_DATA_SITE . 'xmlForms/');
|
2015-11-25 11:54:52 -04:00
|
|
|
define('PATH_IMAGES_ENVIRONMENT_FILES', PATH_DATA_SITE . 'usersFiles' . PATH_SEP);
|
|
|
|
|
define('PATH_IMAGES_ENVIRONMENT_USERS', PATH_DATA_SITE . 'usersPhotographies' . PATH_SEP);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if (is_file(PATH_DATA_SITE . PATH_SEP . '.server_info')) {
|
|
|
|
|
$SERVER_INFO = file_get_contents(PATH_DATA_SITE . PATH_SEP . '.server_info');
|
|
|
|
|
$SERVER_INFO = unserialize($SERVER_INFO);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
define('SERVER_NAME', $SERVER_INFO['SERVER_NAME']);
|
|
|
|
|
define('SERVER_PORT', $SERVER_INFO['SERVER_PORT']);
|
2016-08-13 13:52:07 -04:00
|
|
|
define('REQUEST_SCHEME', $SERVER_INFO['REQUEST_SCHEME']);
|
2015-11-25 11:54:52 -04:00
|
|
|
} else {
|
|
|
|
|
eprintln('WARNING! No server info found!', 'red');
|
|
|
|
|
}
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
//DB
|
|
|
|
|
$phpCode = '';
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$fileDb = fopen(PATH_DB . $workspace . PATH_SEP . 'db.php', 'r');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($fileDb) {
|
|
|
|
|
while (!feof($fileDb)) {
|
|
|
|
|
$buffer = fgets($fileDb, 4096); //Read a line
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2018-08-20 14:40:30 -04:00
|
|
|
$phpCode .= preg_replace('/define\s*\(\s*[\x22\x27](.*)[\x22\x27]\s*,\s*(\x22.*\x22|\x27.*\x27)\s*\)\s*;/i', '$$1 = $2;', $buffer);
|
2015-02-26 17:02:34 -04:00
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
fclose($fileDb);
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$phpCode = str_replace(['<?php', '<?', '?>'], ['', '', ''], $phpCode);
|
|
|
|
|
|
|
|
|
|
eval($phpCode);
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$dsn = $DB_ADAPTER . '://' . $DB_USER . ':' . $DB_PASS . '@' . $DB_HOST . '/' . $DB_NAME;
|
2015-11-25 11:54:52 -04:00
|
|
|
$dsnRbac = $DB_ADAPTER . '://' . $DB_RBAC_USER . ':' . $DB_RBAC_PASS . '@' . $DB_RBAC_HOST . '/' . $DB_RBAC_NAME;
|
2017-12-04 13:25:35 +00:00
|
|
|
$dsnRp = $DB_ADAPTER . '://' . $DB_REPORT_USER . ':' . $DB_REPORT_PASS . '@' . $DB_REPORT_HOST . '/' . $DB_REPORT_NAME;
|
2015-11-25 11:54:52 -04:00
|
|
|
|
|
|
|
|
switch ($DB_ADAPTER) {
|
|
|
|
|
case 'mysql':
|
|
|
|
|
$dsn .= '?encoding=utf8';
|
|
|
|
|
$dsnRbac .= '?encoding=utf8';
|
|
|
|
|
break;
|
|
|
|
|
case 'mssql':
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$pro = [];
|
|
|
|
|
$pro['datasources']['workflow']['connection'] = $dsn;
|
|
|
|
|
$pro['datasources']['workflow']['adapter'] = $DB_ADAPTER;
|
|
|
|
|
$pro['datasources']['rbac']['connection'] = $dsnRbac;
|
|
|
|
|
$pro['datasources']['rbac']['adapter'] = $DB_ADAPTER;
|
|
|
|
|
$pro['datasources']['rp']['connection'] = $dsnRp;
|
|
|
|
|
$pro['datasources']['rp']['adapter'] = $DB_ADAPTER;
|
|
|
|
|
|
|
|
|
|
$oFile = fopen(PATH_CORE . 'config' . PATH_SEP . '_databases_.php', 'w');
|
|
|
|
|
fwrite($oFile, '<?php global $pro; return $pro; ?>');
|
|
|
|
|
fclose($oFile);
|
|
|
|
|
|
|
|
|
|
Propel::init(PATH_CORE . 'config' . PATH_SEP . '_databases_.php');
|
|
|
|
|
|
|
|
|
|
//Enable RBAC
|
2017-12-04 13:25:35 +00:00
|
|
|
$rbac = RBAC::getSingleton(PATH_DATA, session_id());
|
2015-11-25 11:54:52 -04:00
|
|
|
$rbac->sSystem = 'PROCESSMAKER';
|
|
|
|
|
|
|
|
|
|
if (!defined('DB_ADAPTER')) {
|
|
|
|
|
define('DB_ADAPTER', $DB_ADAPTER);
|
|
|
|
|
}
|
2019-02-13 15:53:21 -04:00
|
|
|
if (!defined('DB_HOST')) {
|
|
|
|
|
define('DB_HOST', $DB_HOST);
|
|
|
|
|
}
|
|
|
|
|
if (!defined('DB_NAME')) {
|
|
|
|
|
define('DB_NAME', $DB_NAME);
|
|
|
|
|
}
|
|
|
|
|
if (!defined('DB_USER')) {
|
|
|
|
|
define('DB_USER', $DB_USER);
|
|
|
|
|
}
|
|
|
|
|
if (!defined('DB_PASS')) {
|
|
|
|
|
define('DB_PASS', $DB_PASS);
|
|
|
|
|
}
|
|
|
|
|
if (!defined('SYS_SKIN')) {
|
|
|
|
|
$conf = new Configurations();
|
|
|
|
|
define('SYS_SKIN', $conf->getConfiguration('SKIN_CRON', ''));
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
$dateSystem = date('Y-m-d H:i:s');
|
|
|
|
|
if (empty($now)) {
|
|
|
|
|
$now = $dateSystem;
|
2018-08-20 14:40:30 -04:00
|
|
|
}
|
|
|
|
|
|
2016-03-30 13:04:55 -04:00
|
|
|
//Processing
|
2015-11-25 11:54:52 -04:00
|
|
|
eprintln('Processing workspace: ' . $workspace, 'green');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2018-01-24 10:22:17 -04:00
|
|
|
// We load plugins' pmFunctions
|
|
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
|
|
|
|
$oPluginRegistry->init();
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
try {
|
|
|
|
|
switch ($cronName) {
|
|
|
|
|
case 'cron':
|
|
|
|
|
processWorkspace();
|
|
|
|
|
break;
|
|
|
|
|
case 'ldapcron':
|
|
|
|
|
require_once(PATH_HOME . 'engine' . PATH_SEP . 'methods' . PATH_SEP . 'services' . PATH_SEP . 'ldapadvanced.php');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$ldapadvancedClassCron = new ldapadvancedClassCron();
|
2013-01-10 15:17:01 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$ldapadvancedClassCron->executeCron(in_array('+debug', $argv));
|
|
|
|
|
break;
|
|
|
|
|
case 'messageeventcron':
|
|
|
|
|
$messageApplication = new \ProcessMaker\BusinessModel\MessageApplication();
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
$messageApplication->catchMessageEvent(true);
|
|
|
|
|
break;
|
|
|
|
|
case 'timereventcron':
|
|
|
|
|
$timerEvent = new \ProcessMaker\BusinessModel\TimerEvent();
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
$timerEvent->startContinueCaseByTimerEvent($now, true);
|
2015-11-25 11:54:52 -04:00
|
|
|
break;
|
2016-06-02 11:27:55 -04:00
|
|
|
case 'sendnotificationscron':
|
|
|
|
|
sendNotifications();
|
|
|
|
|
break;
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
2015-11-25 11:54:52 -04:00
|
|
|
} catch (Exception $e) {
|
2016-08-04 14:56:58 -04:00
|
|
|
$token = strtotime("now");
|
|
|
|
|
PMException::registerErrorLog($e, $token);
|
2017-12-04 13:25:35 +00:00
|
|
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) . "\n");
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
eprintln('Problem in workspace: ' . $workspace . ' it was omitted.', 'red');
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
2015-11-25 11:54:52 -04:00
|
|
|
|
|
|
|
|
eprintln();
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if (file_exists(PATH_CORE . 'config' . PATH_SEP . '_databases_.php')) {
|
|
|
|
|
unlink(PATH_CORE . 'config' . PATH_SEP . '_databases_.php');
|
2015-06-17 10:25:36 -04:00
|
|
|
}
|
2015-11-25 11:54:52 -04:00
|
|
|
} catch (Exception $e) {
|
2016-08-04 14:56:58 -04:00
|
|
|
$token = strtotime("now");
|
|
|
|
|
PMException::registerErrorLog($e, $token);
|
2017-12-04 13:25:35 +00:00
|
|
|
G::outRes(G::LoadTranslation("ID_EXCEPTION_LOG_INTERFAZ", array($token)) . "\n");
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
//Functions
|
2012-07-03 18:20:20 -04:00
|
|
|
function processWorkspace()
|
|
|
|
|
{
|
|
|
|
|
try {
|
2012-09-24 11:51:45 -04:00
|
|
|
global $sObject;
|
|
|
|
|
global $sLastExecution;
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
resendEmails();
|
|
|
|
|
unpauseApplications();
|
|
|
|
|
calculateDuration();
|
2015-04-28 15:48:30 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
calculateAppDuration();
|
2015-03-26 18:14:51 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-07-03 18:20:20 -04:00
|
|
|
executeEvents($sLastExecution);
|
|
|
|
|
executeScheduledCases();
|
|
|
|
|
executeUpdateAppTitle();
|
2012-10-22 13:55:35 -04:00
|
|
|
executeCaseSelfService();
|
2012-09-21 10:45:13 -04:00
|
|
|
executePlugins();
|
2015-04-28 15:48:30 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
fillReportByUser();
|
|
|
|
|
fillReportByProcess();
|
2015-12-19 20:23:57 -04:00
|
|
|
synchronizeDrive();
|
2015-12-19 14:38:45 -04:00
|
|
|
synchronizeGmailLabels();
|
2015-03-26 18:14:51 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-07-03 18:20:20 -04:00
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
saveLog("main", "error", "Error processing workspace : " . $oError->getMessage() . "\n");
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function resendEmails()
|
|
|
|
|
{
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2019-02-22 13:02:21 -04:00
|
|
|
global $now;
|
2012-08-20 12:33:18 -04:00
|
|
|
global $dateSystem;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "emails") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Resending emails");
|
|
|
|
|
|
|
|
|
|
try {
|
2019-02-22 13:02:21 -04:00
|
|
|
$dateResend = $now;
|
2012-08-20 12:33:18 -04:00
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
if ($now == $dateSystem) {
|
2012-08-20 12:33:18 -04:00
|
|
|
$arrayDateSystem = getdate(strtotime($dateSystem));
|
|
|
|
|
|
|
|
|
|
$mktDateSystem = mktime(
|
|
|
|
|
$arrayDateSystem["hours"],
|
|
|
|
|
$arrayDateSystem["minutes"],
|
|
|
|
|
$arrayDateSystem["seconds"],
|
|
|
|
|
$arrayDateSystem["mon"],
|
|
|
|
|
$arrayDateSystem["mday"],
|
|
|
|
|
$arrayDateSystem["year"]
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$dateResend = date("Y-m-d H:i:s", $mktDateSystem - (7 * 24 * 60 * 60));
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2017-08-14 10:56:14 -04:00
|
|
|
$oSpool = new SpoolRun();
|
2012-09-03 11:32:52 -04:00
|
|
|
$oSpool->resendEmails($dateResend, 1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2012-08-20 12:33:18 -04:00
|
|
|
saveLog("resendEmails", "action", "Resending Emails", "c");
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
$aSpoolWarnings = $oSpool->getWarnings();
|
|
|
|
|
|
2012-08-20 12:33:18 -04:00
|
|
|
if ($aSpoolWarnings !== false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
foreach ($aSpoolWarnings as $sWarning) {
|
2017-12-04 13:25:35 +00:00
|
|
|
print("MAIL SPOOL WARNING: " . $sWarning . "\n");
|
2012-08-20 12:33:18 -04:00
|
|
|
saveLog("resendEmails", "warning", "MAIL SPOOL WARNING: " . $sWarning);
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-20 12:33:18 -04:00
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
2015-02-05 10:24:19 -04:00
|
|
|
$c = new Criteria("workflow");
|
2015-02-04 13:19:27 -04:00
|
|
|
$c->clearSelectColumns();
|
|
|
|
|
$c->addSelectColumn(ConfigurationPeer::CFG_UID);
|
|
|
|
|
$c->add(ConfigurationPeer::CFG_UID, "Emails");
|
|
|
|
|
$result = ConfigurationPeer::doSelectRS($c);
|
|
|
|
|
$result->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($result->next()) {
|
2015-02-05 10:24:19 -04:00
|
|
|
setExecutionResultMessage("WARNING", "warning");
|
|
|
|
|
$message = "Emails won't be sent, but the cron will continue its execution";
|
|
|
|
|
eprintln(" '-" . $message, "yellow");
|
|
|
|
|
} else {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
}
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2012-08-20 12:33:18 -04:00
|
|
|
saveLog("resendEmails", "error", "Error Resending Emails: " . $e->getMessage());
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function unpauseApplications()
|
|
|
|
|
{
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2019-02-22 13:02:21 -04:00
|
|
|
global $now;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "unpause") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Unpausing applications");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$oCases = new Cases();
|
2019-02-22 13:02:21 -04:00
|
|
|
$oCases->ThrowUnpauseDaemon($now, 1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
setExecutionResultMessage('DONE');
|
|
|
|
|
saveLog('unpauseApplications', 'action', 'Unpausing Applications');
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
2017-12-04 13:25:35 +00:00
|
|
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
2012-07-03 18:20:20 -04:00
|
|
|
saveLog('unpauseApplications', 'error', 'Error Unpausing Applications: ' . $oError->getMessage());
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function executePlugins()
|
|
|
|
|
{
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "plugins") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
$pathCronPlugins = PATH_CORE . 'bin' . PATH_SEP . 'plugins' . PATH_SEP;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
// Executing cron files in bin/plugins directory
|
2012-07-03 18:20:20 -04:00
|
|
|
if (!is_dir($pathCronPlugins)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($handle = opendir($pathCronPlugins)) {
|
2017-10-10 12:33:25 -04:00
|
|
|
setExecutionMessage('Executing cron files in bin/plugins directory in Workspace: ' . config("system.workspace"));
|
2012-07-03 18:20:20 -04:00
|
|
|
while (false !== ($file = readdir($handle))) {
|
2017-12-04 13:25:35 +00:00
|
|
|
if (strpos($file, '.php', 1) && is_file($pathCronPlugins . $file)) {
|
|
|
|
|
$filename = str_replace('.php', '', $file);
|
2012-07-03 18:20:20 -04:00
|
|
|
$className = $filename . 'ClassCron';
|
|
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
// Execute custom cron function
|
|
|
|
|
executeCustomCronFunction($pathCronPlugins . $file, $className);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
// Executing registered cron files
|
|
|
|
|
// -> Get registered cron files
|
2017-08-04 10:26:44 -04:00
|
|
|
$oPluginRegistry = PluginRegistry::loadSingleton();
|
2013-11-27 17:05:51 -04:00
|
|
|
$cronFiles = $oPluginRegistry->getCronFiles();
|
|
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
// -> Execute functions
|
2013-11-27 17:05:51 -04:00
|
|
|
if (!empty($cronFiles)) {
|
2018-03-15 16:35:53 -04:00
|
|
|
setExecutionMessage('Executing registered cron files for Workspace: ' . config('system.workspace'));
|
|
|
|
|
/**
|
|
|
|
|
* @var \ProcessMaker\Plugins\Interfaces\CronFile $cronFile
|
|
|
|
|
*/
|
2018-08-20 14:40:30 -04:00
|
|
|
foreach ($cronFiles as $cronFile) {
|
2018-03-15 16:35:53 -04:00
|
|
|
$path = PATH_PLUGINS . $cronFile->getNamespace() . PATH_SEP . 'bin' . PATH_SEP . $cronFile->getCronFile() . '.php';
|
|
|
|
|
if (file_exists($path)) {
|
|
|
|
|
executeCustomCronFunction($path, $cronFile->getCronFile());
|
|
|
|
|
} else {
|
|
|
|
|
setExecutionMessage('File ' . $cronFile->getCronFile() . '.php ' . 'does not exist.');
|
|
|
|
|
}
|
2013-11-27 17:05:51 -04:00
|
|
|
}
|
|
|
|
|
}
|
2013-11-25 13:01:30 -04:00
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
|
2013-11-25 13:01:30 -04:00
|
|
|
function executeCustomCronFunction($pathFile, $className)
|
|
|
|
|
{
|
|
|
|
|
include_once $pathFile;
|
|
|
|
|
|
|
|
|
|
$oPlugin = new $className();
|
|
|
|
|
|
|
|
|
|
if (method_exists($oPlugin, 'executeCron')) {
|
|
|
|
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
|
|
|
|
$arrayCron["processcTimeProcess"] = 60; //Minutes
|
2017-12-04 13:25:35 +00:00
|
|
|
$arrayCron["processcTimeStart"] = time();
|
2013-11-25 13:01:30 -04:00
|
|
|
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
|
|
|
|
|
|
|
|
|
//Try to execute Plugin Cron. If there is an error then continue with the next file
|
2013-11-27 17:05:51 -04:00
|
|
|
setExecutionMessage("\n--- Executing cron file: $pathFile");
|
2013-11-25 13:01:30 -04:00
|
|
|
try {
|
|
|
|
|
$oPlugin->executeCron();
|
|
|
|
|
setExecutionResultMessage('DONE');
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage('FAILED', 'error');
|
2017-12-04 13:25:35 +00:00
|
|
|
eprintln(" '-" . $e->getMessage(), 'red');
|
2013-11-27 17:05:51 -04:00
|
|
|
saveLog('executePlugins', 'error', 'Error executing cron file: ' . $pathFile . ' - ' . $e->getMessage());
|
2011-05-26 15:39:08 -04:00
|
|
|
}
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function calculateDuration()
|
|
|
|
|
{
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2012-07-03 18:20:20 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "calculate") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Calculating Duration");
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$oAppDelegation = new AppDelegation();
|
2012-09-03 11:32:52 -04:00
|
|
|
$oAppDelegation->calculateDuration(1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
setExecutionResultMessage('DONE');
|
|
|
|
|
saveLog('calculateDuration', 'action', 'Calculating Duration');
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
2017-12-04 13:25:35 +00:00
|
|
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
2012-07-03 18:20:20 -04:00
|
|
|
saveLog('calculateDuration', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
2012-06-25 12:37:06 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2018-08-20 14:40:30 -04:00
|
|
|
|
2015-04-28 15:48:30 -04:00
|
|
|
function calculateAppDuration()
|
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
global $argvx;
|
2015-04-28 15:48:30 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($argvx != "" && strpos($argvx, "calculateapp") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
setExecutionMessage("Calculating Duration by Application");
|
2015-04-28 15:48:30 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
try {
|
|
|
|
|
$oApplication = new Application();
|
|
|
|
|
$oApplication->calculateAppDuration(1);
|
2015-04-28 15:48:30 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
setExecutionResultMessage('DONE');
|
|
|
|
|
saveLog('calculateDurationByApp', 'action', 'Calculating Duration by Application');
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
|
|
|
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
|
|
|
|
saveLog('calculateDurationByApp', 'error', 'Error Calculating Duration: ' . $oError->getMessage());
|
|
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
}
|
2015-03-26 18:14:51 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
|
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
function executeEvents($sLastExecution, $now = null)
|
2012-07-03 18:20:20 -04:00
|
|
|
{
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2019-02-22 13:02:21 -04:00
|
|
|
global $now;
|
2012-06-25 12:37:06 -04:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
$log = array();
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "events") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Executing events");
|
2010-12-02 23:34:41 +00:00
|
|
|
setExecutionResultMessage('PROCESSING');
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
$oAppEvent = new AppEvent();
|
2019-02-22 13:02:21 -04:00
|
|
|
saveLog('executeEvents', 'action', "Executing Events $sLastExecution, $now ");
|
|
|
|
|
$n = $oAppEvent->executeEvents($now, false, $log, 1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
foreach ($log as $value) {
|
2012-09-03 11:32:52 -04:00
|
|
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
|
|
|
|
$arrayCron["processcTimeStart"] = time();
|
|
|
|
|
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
|
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
saveLog('executeEvents', 'action', "Execute Events : $value, $now ");
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("|- End Execution events");
|
|
|
|
|
setExecutionResultMessage("Processed $n");
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
2017-12-04 13:25:35 +00:00
|
|
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
2012-07-03 18:20:20 -04:00
|
|
|
saveLog('calculateAlertsDueDate', 'Error', 'Error Executing Events: ' . $oError->getMessage());
|
2012-06-21 18:29:13 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2019-02-22 13:02:21 -04:00
|
|
|
function executeScheduledCases($now = null)
|
2012-07-03 18:20:20 -04:00
|
|
|
{
|
|
|
|
|
try {
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2019-02-22 13:02:21 -04:00
|
|
|
global $now;
|
2012-07-03 18:20:20 -04:00
|
|
|
$log = array();
|
|
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "scheduler") === false) {
|
2012-07-03 18:20:20 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Executing the scheduled starting cases");
|
|
|
|
|
setExecutionResultMessage('PROCESSING');
|
|
|
|
|
|
|
|
|
|
$oCaseScheduler = new CaseScheduler();
|
2019-02-22 13:02:21 -04:00
|
|
|
$oCaseScheduler->caseSchedulerCron($now, $log, 1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
foreach ($log as $value) {
|
2012-09-03 11:32:52 -04:00
|
|
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
|
|
|
|
$arrayCron["processcTimeStart"] = time();
|
|
|
|
|
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
saveLog('executeScheduledCases', 'action', "OK Case# $value");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionResultMessage('DONE');
|
|
|
|
|
} catch (Exception $oError) {
|
|
|
|
|
setExecutionResultMessage('WITH ERRORS', 'error');
|
2017-12-04 13:25:35 +00:00
|
|
|
eprintln(" '-" . $oError->getMessage(), 'red');
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function executeUpdateAppTitle()
|
|
|
|
|
{
|
2012-09-24 11:51:45 -04:00
|
|
|
try {
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2012-08-20 12:33:18 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "update-case-labels") === false) {
|
2012-09-24 11:51:45 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
2012-08-20 12:33:18 -04:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
$criteriaConf = new Criteria("workflow");
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
$criteriaConf->addSelectColumn(ConfigurationPeer::OBJ_UID);
|
|
|
|
|
$criteriaConf->addSelectColumn(ConfigurationPeer::CFG_VALUE);
|
|
|
|
|
$criteriaConf->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
$rsCriteriaConf = ConfigurationPeer::doSelectRS($criteriaConf);
|
|
|
|
|
$rsCriteriaConf->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Update case labels");
|
|
|
|
|
saveLog("updateCaseLabels", "action", "Update case labels", "c");
|
|
|
|
|
|
|
|
|
|
while ($rsCriteriaConf->next()) {
|
|
|
|
|
$row = $rsCriteriaConf->getRow();
|
|
|
|
|
|
|
|
|
|
$taskUid = $row["OBJ_UID"];
|
2017-12-04 13:25:35 +00:00
|
|
|
$lang = $row["CFG_VALUE"];
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
//Update case labels
|
|
|
|
|
$appcv = new AppCacheView();
|
2012-09-03 11:32:52 -04:00
|
|
|
$appcv->appTitleByTaskCaseLabelUpdate($taskUid, $lang, 1);
|
2012-07-03 18:20:20 -04:00
|
|
|
|
|
|
|
|
//Delete record
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
$criteria->add(ConfigurationPeer::CFG_UID, "TAS_APP_TITLE_UPDATE");
|
|
|
|
|
$criteria->add(ConfigurationPeer::OBJ_UID, $taskUid);
|
|
|
|
|
$criteria->add(ConfigurationPeer::CFG_VALUE, $lang);
|
|
|
|
|
|
|
|
|
|
$numRowDeleted = ConfigurationPeer::doDelete($criteria);
|
|
|
|
|
|
|
|
|
|
saveLog("updateCaseLabels", "action", "OK Task $taskUid");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("updateCaseLabels", "error", "Error updating case labels: " . $e->getMessage());
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-22 13:55:35 -04:00
|
|
|
function executeCaseSelfService()
|
|
|
|
|
{
|
|
|
|
|
try {
|
2015-11-25 11:54:52 -04:00
|
|
|
global $argvx;
|
2012-10-22 13:55:35 -04:00
|
|
|
|
2015-11-25 11:54:52 -04:00
|
|
|
if ($argvx != "" && strpos($argvx, "unassigned-case") === false) {
|
2012-10-22 13:55:35 -04:00
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$criteria = new Criteria("workflow");
|
|
|
|
|
|
|
|
|
|
//SELECT
|
|
|
|
|
$criteria->addSelectColumn(AppCacheViewPeer::APP_UID);
|
|
|
|
|
$criteria->addSelectColumn(AppCacheViewPeer::DEL_INDEX);
|
|
|
|
|
$criteria->addSelectColumn(AppCacheViewPeer::DEL_DELEGATE_DATE);
|
|
|
|
|
$criteria->addSelectColumn(AppCacheViewPeer::APP_NUMBER);
|
|
|
|
|
$criteria->addSelectColumn(AppCacheViewPeer::PRO_UID);
|
|
|
|
|
$criteria->addSelectColumn(TaskPeer::TAS_UID);
|
|
|
|
|
$criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME);
|
|
|
|
|
$criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TIME_UNIT);
|
|
|
|
|
$criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_TRIGGER_UID);
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-09-08 13:28:14 -04:00
|
|
|
$criteria->addSelectColumn(TaskPeer::TAS_SELFSERVICE_EXECUTION);
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-10-22 13:55:35 -04:00
|
|
|
|
|
|
|
|
//FROM
|
|
|
|
|
$condition = array();
|
|
|
|
|
$condition[] = array(AppCacheViewPeer::TAS_UID, TaskPeer::TAS_UID);
|
|
|
|
|
$condition[] = array(TaskPeer::TAS_SELFSERVICE_TIMEOUT, 1);
|
|
|
|
|
$criteria->addJoinMC($condition, Criteria::LEFT_JOIN);
|
|
|
|
|
|
|
|
|
|
//WHERE
|
|
|
|
|
$criteria->add(AppCacheViewPeer::USR_UID, "");
|
|
|
|
|
$criteria->add(AppCacheViewPeer::DEL_THREAD_STATUS, "OPEN");
|
|
|
|
|
|
|
|
|
|
//QUERY
|
|
|
|
|
$rsCriteria = AppCacheViewPeer::doSelectRS($criteria);
|
|
|
|
|
$rsCriteria->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Unassigned case");
|
|
|
|
|
saveLog("unassignedCase", "action", "Unassigned case", "c");
|
|
|
|
|
|
2017-08-04 10:13:09 -04:00
|
|
|
$calendar = new Calendar();
|
2012-10-22 13:55:35 -04:00
|
|
|
|
|
|
|
|
while ($rsCriteria->next()) {
|
|
|
|
|
$row = $rsCriteria->getRow();
|
2017-12-04 13:25:35 +00:00
|
|
|
$flag = false;
|
2012-10-22 13:55:35 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$appcacheAppUid = $row["APP_UID"];
|
2012-10-22 13:55:35 -04:00
|
|
|
$appcacheDelIndex = $row["DEL_INDEX"];
|
|
|
|
|
$appcacheDelDelegateDate = $row["DEL_DELEGATE_DATE"];
|
|
|
|
|
$appcacheAppNumber = $row["APP_NUMBER"];
|
2017-12-04 13:25:35 +00:00
|
|
|
$appcacheProUid = $row["PRO_UID"];
|
2012-10-22 13:55:35 -04:00
|
|
|
$taskUid = $row["TAS_UID"];
|
|
|
|
|
$taskSelfServiceTime = intval($row["TAS_SELFSERVICE_TIME"]);
|
|
|
|
|
$taskSelfServiceTimeUnit = $row["TAS_SELFSERVICE_TIME_UNIT"];
|
|
|
|
|
$taskSelfServiceTriggerUid = $row["TAS_SELFSERVICE_TRIGGER_UID"];
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-09-11 11:30:48 -04:00
|
|
|
$taskSelfServiceJustOneExecution = $row["TAS_SELFSERVICE_EXECUTION"];
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($taskSelfServiceJustOneExecution == 'ONCE') {
|
|
|
|
|
$criteriaSelfService = new Criteria("workflow");
|
2014-09-08 13:28:14 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$criteriaSelfService->add(AppTimeoutActionExecutedPeer::APP_UID, $appcacheAppUid);
|
|
|
|
|
$criteriaSelfService->add(AppTimeoutActionExecutedPeer::DEL_INDEX, $appcacheDelIndex);
|
2014-09-08 13:28:14 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
$querySelfService = AppTimeoutActionExecutedPeer::doSelectRS($criteriaSelfService);
|
2014-09-08 13:28:14 -04:00
|
|
|
$querySelfService->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
2014-09-11 11:30:48 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($querySelfService->next()) {
|
|
|
|
|
$row = $querySelfService->getRow();
|
|
|
|
|
$flag = true; //already executed
|
|
|
|
|
}
|
2014-09-08 13:28:14 -04:00
|
|
|
}
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-10-22 13:55:35 -04:00
|
|
|
|
2014-01-21 13:02:08 -04:00
|
|
|
if ($calendar->pmCalendarUid == '') {
|
2017-12-04 13:25:35 +00:00
|
|
|
$calendar->getCalendar(null, $appcacheProUid, $taskUid);
|
|
|
|
|
$calendar->getCalendarData();
|
2013-11-26 17:36:40 -04:00
|
|
|
}
|
2014-01-21 13:02:08 -04:00
|
|
|
|
2013-11-26 17:36:40 -04:00
|
|
|
$dueDate = $calendar->calculateDate(
|
2012-10-22 13:55:35 -04:00
|
|
|
$appcacheDelDelegateDate,
|
|
|
|
|
$taskSelfServiceTime,
|
2015-06-08 12:59:45 -04:00
|
|
|
$taskSelfServiceTimeUnit //HOURS|DAYS|MINUTES
|
2018-08-20 14:40:30 -04:00
|
|
|
//1
|
2012-10-22 13:55:35 -04:00
|
|
|
);
|
|
|
|
|
|
2014-09-08 13:28:14 -04:00
|
|
|
if (time() > $dueDate["DUE_DATE_SECONDS"] && $flag == false) {
|
2012-10-22 13:55:35 -04:00
|
|
|
$sessProcess = null;
|
|
|
|
|
$sessProcessSw = 0;
|
|
|
|
|
|
|
|
|
|
//Load data
|
|
|
|
|
$case = new Cases();
|
|
|
|
|
$appFields = $case->loadCase($appcacheAppUid);
|
|
|
|
|
|
|
|
|
|
$appFields["APP_DATA"]["APPLICATION"] = $appcacheAppUid;
|
|
|
|
|
|
|
|
|
|
if (isset($_SESSION["PROCESS"])) {
|
|
|
|
|
$sessProcess = $_SESSION["PROCESS"];
|
|
|
|
|
$sessProcessSw = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$_SESSION["PROCESS"] = $appFields["PRO_UID"];
|
|
|
|
|
|
|
|
|
|
//Execute trigger
|
|
|
|
|
$criteriaTgr = new Criteria();
|
|
|
|
|
$criteriaTgr->add(TriggersPeer::TRI_UID, $taskSelfServiceTriggerUid);
|
|
|
|
|
|
|
|
|
|
$rsCriteriaTgr = TriggersPeer::doSelectRS($criteriaTgr);
|
|
|
|
|
$rsCriteriaTgr->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
|
|
|
|
|
|
|
|
|
if ($rsCriteriaTgr->next()) {
|
|
|
|
|
$row = $rsCriteriaTgr->getRow();
|
|
|
|
|
|
|
|
|
|
if (is_array($row) && $row["TRI_TYPE"] == "SCRIPT") {
|
|
|
|
|
$arrayCron = unserialize(trim(@file_get_contents(PATH_DATA . "cron")));
|
|
|
|
|
$arrayCron["processcTimeProcess"] = 60; //Minutes
|
2017-12-04 13:25:35 +00:00
|
|
|
$arrayCron["processcTimeStart"] = time();
|
2012-10-22 13:55:35 -04:00
|
|
|
@file_put_contents(PATH_DATA . "cron", serialize($arrayCron));
|
|
|
|
|
|
|
|
|
|
//Trigger
|
|
|
|
|
global $oPMScript;
|
|
|
|
|
|
|
|
|
|
$oPMScript = new PMScript();
|
2017-05-11 09:03:45 -04:00
|
|
|
$oPMScript->setDataTrigger($row);
|
2012-10-22 13:55:35 -04:00
|
|
|
$oPMScript->setFields($appFields["APP_DATA"]);
|
|
|
|
|
$oPMScript->setScript($row["TRI_WEBBOT"]);
|
2018-10-30 13:41:00 -04:00
|
|
|
$oPMScript->setExecutedOn(PMScript::SELF_SERVICE_TIMEOUT);
|
2012-10-22 13:55:35 -04:00
|
|
|
$oPMScript->execute();
|
|
|
|
|
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2014-09-11 11:30:48 -04:00
|
|
|
//saving the case`s data if the 'Execution' is set in ONCE.
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($taskSelfServiceJustOneExecution == "ONCE") {
|
|
|
|
|
$oAppTimeoutActionExecuted = new AppTimeoutActionExecuted();
|
|
|
|
|
$dataSelf = array();
|
|
|
|
|
$dataSelf["APP_UID"] = $appcacheAppUid;
|
|
|
|
|
$dataSelf["DEL_INDEX"] = $appcacheDelIndex;
|
|
|
|
|
$dataSelf["EXECUTION_DATE"] = time();
|
|
|
|
|
$oAppTimeoutActionExecuted->create($dataSelf);
|
2014-09-08 13:28:14 -04:00
|
|
|
}
|
2014-12-04 10:23:06 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2012-10-22 13:55:35 -04:00
|
|
|
$appFields["APP_DATA"] = array_merge($appFields["APP_DATA"], $oPMScript->aFields);
|
|
|
|
|
|
2013-07-03 09:48:46 -04:00
|
|
|
unset($appFields['APP_STATUS']);
|
|
|
|
|
unset($appFields['APP_PROC_STATUS']);
|
|
|
|
|
unset($appFields['APP_PROC_CODE']);
|
|
|
|
|
unset($appFields['APP_PIN']);
|
2012-10-22 13:55:35 -04:00
|
|
|
$case->updateCase($appFields["APP_UID"], $appFields);
|
|
|
|
|
|
2017-10-13 17:48:08 -04:00
|
|
|
saveLog("unassignedCase", "action", "OK Executed trigger to the case $appcacheAppNumber");
|
2012-10-22 13:55:35 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unset($_SESSION["PROCESS"]);
|
|
|
|
|
|
|
|
|
|
if ($sessProcessSw == 1) {
|
|
|
|
|
$_SESSION["PROCESS"] = $sessProcess;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("unassignedCase", "error", "Error in unassigned case: " . $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function saveLog($sSource, $sType, $sDescription)
|
|
|
|
|
{
|
|
|
|
|
try {
|
2012-09-24 11:51:45 -04:00
|
|
|
global $sObject;
|
2012-07-03 18:20:20 -04:00
|
|
|
global $isDebug;
|
|
|
|
|
|
|
|
|
|
if ($isDebug) {
|
2012-09-24 11:51:45 -04:00
|
|
|
print date("H:i:s") . " ($sSource) $sType $sDescription <br />\n";
|
2012-07-03 18:20:20 -04:00
|
|
|
}
|
|
|
|
|
|
2012-09-24 11:51:45 -04:00
|
|
|
G::verifyPath(PATH_DATA . "log" . PATH_SEP, true);
|
2014-10-03 11:09:45 -04:00
|
|
|
G::log("| $sObject | " . $sSource . " | $sType | " . $sDescription, PATH_DATA);
|
2012-09-24 11:51:45 -04:00
|
|
|
} catch (Exception $e) {
|
2012-07-03 18:20:20 -04:00
|
|
|
//CONTINUE
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
}
|
|
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
function setExecutionMessage($m)
|
|
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
$len = strlen($m);
|
2012-07-03 18:20:20 -04:00
|
|
|
$linesize = 60;
|
2017-12-04 13:25:35 +00:00
|
|
|
$rOffset = $linesize - $len;
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
eprint("* $m");
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
for ($i = 0; $i < $rOffset; $i++) {
|
|
|
|
|
eprint('.');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
function setExecutionResultMessage($m, $t = '')
|
2012-07-03 18:20:20 -04:00
|
|
|
{
|
|
|
|
|
$c = 'green';
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
if ($t == 'error') {
|
|
|
|
|
$c = 'red';
|
|
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
if ($t == 'info') {
|
|
|
|
|
$c = 'yellow';
|
|
|
|
|
}
|
2015-02-26 17:02:34 -04:00
|
|
|
|
2015-02-04 13:19:27 -04:00
|
|
|
if ($t == 'warning') {
|
2015-02-04 14:24:17 -04:00
|
|
|
$c = 'yellow';
|
2015-02-04 13:19:27 -04:00
|
|
|
}
|
2010-12-02 23:34:41 +00:00
|
|
|
|
2012-07-03 18:20:20 -04:00
|
|
|
eprintln("[$m]", $c);
|
|
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
/*----------------------------------********---------------------------------*/
|
2018-08-20 14:40:30 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
function fillReportByUser()
|
2015-04-28 15:48:30 -04:00
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
try {
|
|
|
|
|
global $argvx;
|
|
|
|
|
global $dateInit;
|
|
|
|
|
global $dateFinish;
|
|
|
|
|
|
|
|
|
|
if (strpos($argvx, "report_by_user") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if ($dateInit == null) {
|
|
|
|
|
eprintln("You must enter the starting date.", "red");
|
|
|
|
|
eprintln('Example: +init-date"YYYY-MM-DD HH:MM:SS" +finish-date"YYYY-MM-DD HH:MM:SS"', "red");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dateFinish = ($dateFinish != null) ? $dateFinish : date("Y-m-d H:i:s");
|
|
|
|
|
|
|
|
|
|
$appcv = new AppCacheView();
|
|
|
|
|
$appcv->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
|
|
|
|
|
setExecutionMessage("Calculating data to fill the 'User Reporting'...");
|
|
|
|
|
$appcv->fillReportByUser($dateInit, $dateFinish);
|
|
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("fillReportByUser", "error", "Error in fill report by user: " . $e->getMessage());
|
|
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
}
|
|
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
function fillReportByProcess()
|
2015-04-28 15:48:30 -04:00
|
|
|
{
|
2017-12-04 13:25:35 +00:00
|
|
|
try {
|
|
|
|
|
global $argvx;
|
|
|
|
|
global $dateInit;
|
|
|
|
|
global $dateFinish;
|
|
|
|
|
|
|
|
|
|
if (strpos($argvx, "report_by_process") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($dateInit == null) {
|
|
|
|
|
eprintln("You must enter the starting date.", "red");
|
|
|
|
|
eprintln('Example: +init-date"YYYY-MM-DD HH:MM:SS" +finish-date"YYYY-MM-DD HH:MM:SS"', "red");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$dateFinish = ($dateFinish != null) ? $dateFinish : date("Y-m-d H:i:s");
|
|
|
|
|
$appcv = new AppCacheView();
|
|
|
|
|
$appcv->setPathToAppCacheFiles(PATH_METHODS . 'setup' . PATH_SEP . 'setupSchemas' . PATH_SEP);
|
|
|
|
|
|
|
|
|
|
setExecutionMessage("Calculating data to fill the 'Process Reporting'...");
|
|
|
|
|
$appcv->fillReportByProcess($dateInit, $dateFinish);
|
|
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("fillReportByProcess", "error", "Error in fill report by process: " . $e->getMessage());
|
|
|
|
|
}
|
2015-04-28 15:48:30 -04:00
|
|
|
}
|
2015-12-19 20:23:57 -04:00
|
|
|
|
2017-12-04 13:25:35 +00:00
|
|
|
function synchronizeDrive()
|
2015-12-19 20:23:57 -04:00
|
|
|
{
|
2016-01-08 14:23:06 -04:00
|
|
|
try {
|
2015-12-19 20:23:57 -04:00
|
|
|
global $argvx;
|
|
|
|
|
|
|
|
|
|
if (strpos($argvx, "synchronize-documents-drive") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
2016-01-08 14:23:06 -04:00
|
|
|
if ($licensedFeatures->verifyfeature('AhKNjBEVXZlWUFpWE8wVTREQ0FObmo0aTdhVzhvalFic1M=')) {
|
|
|
|
|
$drive = new AppDocumentDrive();
|
|
|
|
|
if ($drive->getStatusDrive()) {
|
|
|
|
|
setExecutionMessage("Synchronize documents to Drive");
|
|
|
|
|
$drive->synchronizeDrive(true);
|
|
|
|
|
} else {
|
|
|
|
|
setExecutionMessage("It has not enabled Feature Drive");
|
|
|
|
|
}
|
2015-12-20 11:28:29 -04:00
|
|
|
} else {
|
2016-01-08 14:23:06 -04:00
|
|
|
setExecutionMessage("The Drive license is not enabled");
|
2015-12-20 11:28:29 -04:00
|
|
|
}
|
2015-12-19 20:23:57 -04:00
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("synchronizeDocumentsDrive", "error", "Error in synchronize documents to drive: " . $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-19 14:38:45 -04:00
|
|
|
function synchronizeGmailLabels()
|
|
|
|
|
{
|
2016-01-08 14:23:06 -04:00
|
|
|
try {
|
2015-12-19 14:38:45 -04:00
|
|
|
global $argvx;
|
|
|
|
|
|
|
|
|
|
if (strpos($argvx, "synchronize-gmail-labels") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2017-12-04 13:25:35 +00:00
|
|
|
$licensedFeatures = PMLicensedFeatures::getSingleton();
|
2016-01-08 14:23:06 -04:00
|
|
|
if ($licensedFeatures->verifyfeature('7qhYmF1eDJWcEdwcUZpT0k4S0xTRStvdz09')) {
|
2017-08-11 13:43:39 -04:00
|
|
|
$pmGoogle = new PmGoogleApi();
|
2016-01-08 14:23:06 -04:00
|
|
|
if ($pmGoogle->getServiceGmailStatus()) {
|
|
|
|
|
setExecutionMessage("Synchronize labels in Gmail");
|
|
|
|
|
$labGmail = new labelsGmail();
|
|
|
|
|
$labGmail->processPendingRelabelingInQueue();
|
|
|
|
|
} else {
|
|
|
|
|
setExecutionMessage("It has not enabled Feature Gmail");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
setExecutionMessage("The Gmail license is not enabled");
|
2016-01-05 14:52:10 -04:00
|
|
|
}
|
2015-12-19 14:38:45 -04:00
|
|
|
setExecutionResultMessage("DONE");
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("synchronizeGmailLabels", "error", "Error when synchronizing Gmail labels: " . $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/*----------------------------------********---------------------------------*/
|
2016-06-02 11:27:55 -04:00
|
|
|
|
|
|
|
|
function sendNotifications()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
global $argvx;
|
|
|
|
|
if ($argvx != "" && strpos($argvx, "send-notifications") === false) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
setExecutionMessage("Resending Notifications");
|
|
|
|
|
setExecutionResultMessage("PROCESSING");
|
|
|
|
|
$notQueue = new \NotificationQueue();
|
2016-08-03 14:13:10 -04:00
|
|
|
$notQueue->checkIfCasesOpenForResendingNotification();
|
2016-06-02 11:27:55 -04:00
|
|
|
$notificationsAndroid = $notQueue->loadStatusDeviceType('pending', 'android');
|
|
|
|
|
if ($notificationsAndroid) {
|
|
|
|
|
setExecutionMessage("|-- Send Android's Notifications");
|
|
|
|
|
$n = 0;
|
|
|
|
|
foreach ($notificationsAndroid as $key => $item) {
|
|
|
|
|
$oNotification = new \ProcessMaker\BusinessModel\Light\PushMessageAndroid();
|
|
|
|
|
$oNotification->setSettingNotification();
|
|
|
|
|
$oNotification->setDevices(unserialize($item['DEV_UID']));
|
|
|
|
|
$response['android'] = $oNotification->send($item['NOT_MSG'], unserialize($item['NOT_DATA']));
|
|
|
|
|
$notQueue = new \NotificationQueue();
|
|
|
|
|
$notQueue->changeStatusSent($item['NOT_UID']);
|
|
|
|
|
$n += $oNotification->getNumberDevices();
|
|
|
|
|
}
|
|
|
|
|
setExecutionResultMessage("Processed $n");
|
|
|
|
|
}
|
|
|
|
|
$notificationsApple = $notQueue->loadStatusDeviceType('pending', 'apple');
|
2017-12-04 13:25:35 +00:00
|
|
|
if ($notificationsApple) {
|
2016-06-02 11:27:55 -04:00
|
|
|
setExecutionMessage("|-- Send Apple Notifications");
|
|
|
|
|
$n = 0;
|
|
|
|
|
foreach ($notificationsApple as $key => $item) {
|
|
|
|
|
$oNotification = new \ProcessMaker\BusinessModel\Light\PushMessageIOS();
|
|
|
|
|
$oNotification->setSettingNotification();
|
|
|
|
|
$oNotification->setDevices(unserialize($item['DEV_UID']));
|
|
|
|
|
$response['apple'] = $oNotification->send($item['NOT_MSG'], unserialize($item['NOT_DATA']));
|
|
|
|
|
$notQueue = new \NotificationQueue();
|
|
|
|
|
$notQueue->changeStatusSent($item['NOT_UID']);
|
|
|
|
|
$n += $oNotification->getNumberDevices();
|
|
|
|
|
}
|
|
|
|
|
setExecutionResultMessage("Processed $n");
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception $e) {
|
|
|
|
|
setExecutionResultMessage("WITH ERRORS", "error");
|
|
|
|
|
eprintln(" '-" . $e->getMessage(), "red");
|
|
|
|
|
saveLog("ExecuteSendNotifications", "error", "Error when sending notifications " . $e->getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|