Merged in develop (pull request #6849)

Updating feature branch with last changes in develop

Approved-by: Julio Cesar Laura Avendaño <contact@julio-laura.com>
This commit is contained in:
Julio Cesar Laura Avendaño
2019-04-12 14:06:59 +00:00
11 changed files with 155 additions and 126 deletions

View File

@@ -207,7 +207,7 @@ class Bootstrap
* = local path
* @return boolean
*/
public function virtualURI($url, $convertionTable, &$realPath)
public static function virtualURI($url, $convertionTable, &$realPath)
{
foreach ($convertionTable as $urlPattern => $localPath) {
// $urlPattern = addcslashes( $urlPattern , '/');
@@ -240,7 +240,7 @@ class Bootstrap
* @param string $downloadFileName
* @return string
*/
public function streamFile($file, $download = false, $downloadFileName = '', $forceLoad = false)
public static function streamFile($file, $download = false, $downloadFileName = '', $forceLoad = false)
{
$filter = new InputFilter();
$file = $filter->xssFilterHard($file);
@@ -399,7 +399,7 @@ class Bootstrap
* nameWorkspace to specific workspace
* return true if the file exists, otherwise false.
*/
public function isPMUnderUpdating($setFlag = 2, $content="true")
public static function isPMUnderUpdating($setFlag = 2, $content="true")
{
if (!defined('PATH_DATA')) {
return false;
@@ -438,7 +438,7 @@ class Bootstrap
* array containig the template data
* @return $content string containing the parsed template content
*/
public function parseTemplate($template, $data = array())
public static function parseTemplate($template, $data = array())
{
$content = '';
@@ -556,7 +556,7 @@ class Bootstrap
* @param string $strSkin
* @return void
*/
public function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '')
public static function RenderPage($strTemplate = "default", $strSkin = SYS_SKIN, $objContent = null, $layout = '')
{
global $G_CONTENT;
global $G_TEMPLATE;
@@ -617,7 +617,7 @@ class Bootstrap
*
* @return void
*/
public function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null)
public static function SendTemporalMessage($msgID, $strType, $sType = 'LABEL', $time = null, $width = null, $customLabels = null)
{
if (isset($width)) {
$_SESSION ['G_MESSAGE_WIDTH'] = $width;
@@ -653,7 +653,7 @@ class Bootstrap
* @param string $parameter
* @return string
*/
public function header($parameter)
public static function header($parameter)
{
if (defined('ENABLE_ENCRYPT') && (ENABLE_ENCRYPT == 'yes') && (substr($parameter, 0, 9) == 'location:')) {
$url = Bootstrap::encrypt(substr($parameter, 10), URL_KEY);
@@ -673,7 +673,7 @@ class Bootstrap
* @access public
* @return void
*/
public function LoadAllPluginModelClasses()
public static function LoadAllPluginModelClasses()
{
// Get the current Include path, where the plugins directories should be
if (!defined('PATH_SEPARATOR')) {
@@ -723,7 +723,7 @@ class Bootstrap
/**
* function to calculate the time used to render a page
*/
public function logTimeByPage()
public static function logTimeByPage()
{
if (!defined(PATH_DATA)) {
return false;
@@ -748,7 +748,7 @@ class Bootstrap
* @param string $downloadFileName
* @return string
*/
public function streamJSTranslationFile($filename, $locale = 'en')
public static function streamJSTranslationFile($filename, $locale = 'en')
{
$typearray = explode('.', basename($filename));
$typeCount = count($typearray);
@@ -808,7 +808,7 @@ class Bootstrap
* @param string $file
* @return string
*/
public function streamCSSBigFile($filename)
public static function streamCSSBigFile($filename)
{
header('Content-Type: text/css');
@@ -964,7 +964,7 @@ class Bootstrap
*
* @return void
*/
public function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '')
public static function sendHeaders($filename, $contentType = '', $download = false, $downloadFileName = '')
{
if ($download) {
if ($downloadFileName == '') {
@@ -1115,7 +1115,7 @@ class Bootstrap
* strip_slashes
* @param vVar
*/
public function strip_slashes($vVar)
public static function strip_slashes($vVar)
{
if (is_array($vVar)) {
foreach ($vVar as $sKey => $vValue) {
@@ -1142,7 +1142,7 @@ class Bootstrap
* @param eter array data // erik: associative array within data input to replace for formatted string i.e "any messsage {replaced_label} that contains a replace label"
* @return string
*/
public function LoadTranslation($msgID, $lang = SYS_LANG, $data = null)
public static function LoadTranslation($msgID, $lang = SYS_LANG, $data = null)
{
global $translation;
@@ -1182,7 +1182,7 @@ class Bootstrap
* @param $pattern pattern to filter some specified files
* @return <array> array containing the recursive glob results
*/
public function rglob($pattern = '*', $flags = 0, $path = '')
public static function rglob($pattern = '*', $flags = 0, $path = '')
{
$paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
$files = glob($path . $pattern, $flags);
@@ -1197,7 +1197,7 @@ class Bootstrap
*
* @author Erik A.O. <erik@gmail.com, aortiz.erik@gmail.com>
*/
public function json_encode($Json)
public static function json_encode($Json)
{
if (function_exists('json_encode')) {
return json_encode($Json);
@@ -1229,7 +1229,7 @@ class Bootstrap
*
* @author Erik Amaru Ortiz <erik@colosa.com>
*/
public function xmlParser(&$string)
public static function xmlParser(&$string)
{
$parser = xml_parser_create();
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0);
@@ -1304,7 +1304,7 @@ class Bootstrap
* @param unknown_type $maxmtime
* @return Ambigous <number, unknown>
*/
public function getDirectorySize($path, $maxmtime = 0)
public static function getDirectorySize($path, $maxmtime = 0)
{
$totalsize = 0;
$totalcount = 0;
@@ -1365,7 +1365,7 @@ class Bootstrap
* @author Ralph A.
* @return multitype:array containing browser name and type
*/
public function get_current_browser()
public static function get_current_browser()
{
static $a_full_assoc_data, $a_mobile_data, $browser_user_agent;
static $browser_working, $moz_type, $webkit_type;
@@ -1563,7 +1563,7 @@ class Bootstrap
* @param unknown_type $pv_extra_search
* @return string
*/
public function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '')
public static function get_item_version($pv_browser_user_agent, $pv_search_string, $pv_b_break_last = '', $pv_extra_search = '')
{
$substring_length = 15;
$start_pos = 0; // set $start_pos to 0 for first iteration
@@ -1594,7 +1594,7 @@ class Bootstrap
* @param unknown_type $pv_type
* @param unknown_type $pv_value
*/
public function get_set_count($pv_type, $pv_value = '')
public static function get_set_count($pv_type, $pv_value = '')
{
static $slice_increment;
$return_value = '';
@@ -1743,7 +1743,7 @@ class Bootstrap
* @param unknown_type $pv_browser_user_agent
* @return string
*/
public function check_is_mobile($pv_browser_user_agent)
public static function check_is_mobile($pv_browser_user_agent)
{
$mobile_working_test = '';
$a_mobile_search = array(
@@ -1771,7 +1771,7 @@ class Bootstrap
*
* @param unknown_type $pv_browser_user_agent
*/
public function get_mobile_data($pv_browser_user_agent)
public static function get_mobile_data($pv_browser_user_agent)
{
$mobile_browser = '';
$mobile_browser_number = '';
@@ -1943,7 +1943,7 @@ class Bootstrap
* @param string $key
* @return string
*/
public function encrypt($string, $key)
public static function encrypt($string, $key)
{
//print $string;
// if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) {
@@ -1973,7 +1973,7 @@ class Bootstrap
* @param string $key
* @return string
*/
public function decrypt($string, $key)
public static function decrypt($string, $key)
{
// if ( defined ( 'ENABLE_ENCRYPT' ) && ENABLE_ENCRYPT == 'yes' ) {
//if (strpos($string, '|', 0) !== false) return $string;
@@ -2066,7 +2066,7 @@ class Bootstrap
* @param string $array_i
* @return array
*/
public function array_merge_2(&$array, &$array_i)
public static function array_merge_2(&$array, &$array_i)
{
foreach ($array_i as $k => $v) {
if (is_array($v)) {
@@ -2095,7 +2095,7 @@ class Bootstrap
* @return array_sum(explode(' ',microtime()))
*/
/* public static */
public function microtime_float()
public static function microtime_float()
{
return array_sum(explode(' ', microtime()));
}
@@ -2344,7 +2344,7 @@ class Bootstrap
* @author Erik Amaru Ortiz <erik@colosa.com>
* @name complete_field($string, $lenght, $type={1:number/2:string/3:float})
*/
public function complete_field($campo, $long, $tipo)
public static function complete_field($campo, $long, $tipo)
{
$campo = trim($campo);
switch ($tipo) {
@@ -2580,7 +2580,7 @@ class Bootstrap
* @param string $userPass hash of password
* @return bool true or false
*/
public function verifyHashPassword($pass, $userPass)
public static function verifyHashPassword($pass, $userPass)
{
global $RBAC;
$passwordHashConfig = Bootstrap::getPasswordHashConfig();
@@ -2610,7 +2610,7 @@ class Bootstrap
* @param $string
* @return mixed
*/
public function encryptOld($string)
public static function encryptOld($string)
{
$consthashFx = self::hashFx;
return $consthashFx($string);

View File

@@ -318,6 +318,7 @@ function processWorkspace()
executeScheduledCases();
executeUpdateAppTitle();
executeCaseSelfService();
cleanSelfServiceTables();
executePlugins();
/*----------------------------------********---------------------------------*/
fillReportByUser();
@@ -1047,3 +1048,46 @@ function sendNotifications()
saveLog("ExecuteSendNotifications", "error", "Error when sending notifications " . $e->getMessage());
}
}
/**
* Clean unused records in tables related to the Self-Service Value Based feature
*
* @see processWorkspace()
*
* @link https://wiki.processmaker.com/3.2/Executing_cron.php#Syntax_of_cron.php_Options
*/
function cleanSelfServiceTables()
{
try {
global $argvx;
// Check if the action can be executed
if ($argvx !== "" && strpos($argvx, "clean-self-service-tables") === false) {
return false;
}
// Start message
setExecutionMessage("Clean unused records for Self-Service Value Based feature");
// Get Propel connection
$cnn = Propel::getConnection(AppAssignSelfServiceValueGroupPeer::DATABASE_NAME);
// Delete related rows and missing relations, criteria don't execute delete with joins
$cnn->begin();
$stmt = $cnn->createStatement();
$stmt->executeQuery("DELETE " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
FROM " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
LEFT JOIN " . AppAssignSelfServiceValuePeer::TABLE_NAME . "
ON (" . AppAssignSelfServiceValueGroupPeer::ID . " = " . AppAssignSelfServiceValuePeer::ID . ")
WHERE " . AppAssignSelfServiceValuePeer::ID . " IS NULL");
$cnn->commit();
// Success message
setExecutionResultMessage("DONE");
} catch (Exception $e) {
$cnn->rollback();
setExecutionResultMessage("WITH ERRORS", "error");
eprintln(" '-" . $e->getMessage(), "red");
saveLog("ExecuteCleanSelfServiceTables", "error", "Error when try to clean self-service tables " . $e->getMessage());
}
}

View File

@@ -963,10 +963,9 @@ class Cases
if (isset($Fields['CURRENT_USER_UID'])) {
$Fields['USR_UID'] = $Fields['CURRENT_USER_UID'];
}
/*----------------------------------********---------------------------------*/
$completed = new ListCompleted();
$completed->create(array_merge($Fields, $newTitleOrDescription));
/*----------------------------------********---------------------------------*/
//Will be update the status in the list Participated
$listParticipatedLast = new ListParticipatedLast();
$listParticipatedLast->refreshStatus($Fields['APP_UID'], 'COMPLETED');
}
/** Update case*/
@@ -1138,9 +1137,6 @@ class Cases
$oCriteria->add(ListParticipatedHistoryPeer::APP_UID, $sAppUid);
ListParticipatedHistoryPeer::doDelete($oCriteria);
$oCriteria = new Criteria('workflow');
$oCriteria->add(ListCompletedPeer::APP_UID, $sAppUid);
ListCompletedPeer::doDelete($oCriteria);
$oCriteria = new Criteria('workflow');
$oCriteria->add(ListUnassignedPeer::APP_UID, $sAppUid);
ListUnassignedPeer::doDelete($oCriteria);
/*----------------------------------********---------------------------------*/

View File

@@ -74,6 +74,44 @@ class Groups
}
}
/**
* Get the IDs of the active groups for an user
*
* @param string $usrUid
*
* @return array
* @throws Exception
*/
public function getActiveGroupsForAnUserById($usrUid)
{
try {
$criteria = new Criteria();
$criteria->addSelectColumn(GroupUserPeer::GRP_ID);
$criteria->addJoin(GroupUserPeer::GRP_ID, GroupwfPeer::GRP_ID, Criteria::LEFT_JOIN);
//@todo: we need to add a new column GROUP_USER.USR_ID
$criteria->add(GroupUserPeer::USR_UID, $usrUid);
//@todo: we need to add a new column GROUPWF.GRP_STATUS_ID
$criteria->add(GroupwfPeer::GRP_STATUS, 'ACTIVE');
$dataset = GroupUserPeer::doSelectRS($criteria);
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
$dataset->next();
//If the user does not relate with any group we will to return a default value for avoiding problems with the IN
$groups = [-1];
$row = $dataset->getRow();
while (is_array($row)) {
$groups[] = $row['GRP_ID'];
$dataset->next();
$row = $dataset->getRow();
}
return $groups;
} catch (Exception $error) {
throw ($error);
}
}
/**
* Set a user to group
*

View File

@@ -2400,7 +2400,7 @@ class WorkspaceTools
return;
}
$arrayTable1 = ['ListInbox', 'ListMyInbox', 'ListCanceled', 'ListParticipatedLast', 'ListParticipatedHistory', 'ListPaused', 'ListCompleted'];
$arrayTable1 = ['ListInbox', 'ListMyInbox', 'ListCanceled', 'ListParticipatedLast', 'ListParticipatedHistory', 'ListPaused'];
$arrayTable2 = ['ListUnassigned', 'ListUnassignedGroup'];
$arrayTable = array_merge($arrayTable1, $arrayTable2);
@@ -2426,7 +2426,6 @@ class WorkspaceTools
}
if ($flagReinsert || !$flagListAll) {
$this->regenerateListCompleted($lang);
$this->regenerateListCanceled($lang);
$this->regenerateListMyInbox(); //This list require no translation
$this->regenerateListInbox(); //This list require no translation
@@ -2511,69 +2510,6 @@ class WorkspaceTools
CLI::logging("> Completed table LIST_CANCELED\n");
}
public function regenerateListCompleted($lang = 'en')
{
$this->initPropel(true);
$query = 'INSERT INTO ' . $this->dbName . '.LIST_COMPLETED
(APP_UID,
USR_UID,
TAS_UID,
PRO_UID,
APP_NUMBER,
APP_TITLE,
APP_PRO_TITLE,
APP_TAS_TITLE,
APP_CREATE_DATE,
APP_FINISH_DATE,
DEL_INDEX,
DEL_PREVIOUS_USR_UID,
DEL_CURRENT_USR_USERNAME,
DEL_CURRENT_USR_FIRSTNAME,
DEL_CURRENT_USR_LASTNAME)
SELECT
ACV.APP_UID,
ACV.USR_UID,
ACV.TAS_UID,
ACV.PRO_UID,
ACV.APP_NUMBER,
C_APP.CON_VALUE AS APP_TITLE,
C_PRO.CON_VALUE AS APP_PRO_TITLE,
C_TAS.CON_VALUE AS APP_TAS_TITLE,
ACV.APP_CREATE_DATE,
ACV.APP_FINISH_DATE,
ACV.DEL_INDEX,
PREV_AD.USR_UID AS DEL_PREVIOUS_USR_UID,
USR.USR_USERNAME AS DEL_CURRENT_USR_USERNAME,
USR.USR_FIRSTNAME AS DEL_CURRENT_USR_FIRSTNAME,
USR.USR_LASTNAME AS DEL_CURRENT_USR_LASTNAME
FROM
(' . $this->dbName . '.APP_CACHE_VIEW ACV
LEFT JOIN ' . $this->dbName . '.CONTENT C_APP ON ACV.APP_UID = C_APP.CON_ID
AND C_APP.CON_CATEGORY = \'APP_TITLE\'
AND C_APP.CON_LANG = \'' . $lang . '\'
LEFT JOIN ' . $this->dbName . '.CONTENT C_PRO ON ACV.PRO_UID = C_PRO.CON_ID
AND C_PRO.CON_CATEGORY = \'PRO_TITLE\'
AND C_PRO.CON_LANG = \'' . $lang . '\'
LEFT JOIN ' . $this->dbName . '.CONTENT C_TAS ON ACV.TAS_UID = C_TAS.CON_ID
AND C_TAS.CON_CATEGORY = \'TAS_TITLE\'
AND C_TAS.CON_LANG = \'' . $lang . '\')
LEFT JOIN
(' . $this->dbName . '.APP_DELEGATION AD
INNER JOIN ' . $this->dbName . '.APP_DELEGATION PREV_AD ON AD.APP_UID = PREV_AD.APP_UID
AND AD.DEL_PREVIOUS = PREV_AD.DEL_INDEX) ON ACV.APP_UID = AD.APP_UID
AND ACV.DEL_INDEX = AD.DEL_INDEX
LEFT JOIN
' . $this->dbName . '.USERS USR ON ACV.USR_UID = USR.USR_UID
WHERE
ACV.APP_STATUS = \'COMPLETED\'
AND ACV.DEL_LAST_INDEX = 1';
$con = Propel::getConnection("workflow");
$stmt = $con->createStatement();
$stmt->executeQuery($query);
CLI::logging("> Completed table LIST_COMPLETED\n");
}
public function regenerateListMyInbox()
{
$this->initPropel(true);

View File

@@ -64,6 +64,12 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
*
* @return void
* @throws Exception
*
* @see \Cases->removeCase()
* @see \Cases->setCatchUser()
* @see \Cases->updateCase()
*
* @link https://wiki.processmaker.com/3.2/Tasks#Self_Service_Value_Based_Assignment
*/
public function remove($applicationUid, $delIndex = 0)
{
@@ -76,18 +82,7 @@ class AppAssignSelfServiceValue extends BaseAppAssignSelfServiceValue
$criteria->add(AppAssignSelfServiceValuePeer::DEL_INDEX, $delIndex, Criteria::EQUAL);
}
$result = AppAssignSelfServiceValuePeer::doDelete($criteria);
// Delete related rows and missing relations, criteria don't execute delete with joins
$cnn = Propel::getConnection(AppAssignSelfServiceValueGroupPeer::DATABASE_NAME);
$cnn->begin();
$stmt = $cnn->createStatement();
$rs = $stmt->executeQuery("DELETE " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
FROM " . AppAssignSelfServiceValueGroupPeer::TABLE_NAME . "
LEFT JOIN " . AppAssignSelfServiceValuePeer::TABLE_NAME . "
ON (" . AppAssignSelfServiceValueGroupPeer::ID . " = " . AppAssignSelfServiceValuePeer::ID . ")
WHERE " . AppAssignSelfServiceValuePeer::ID . " IS NULL");
$cnn->commit();
AppAssignSelfServiceValuePeer::doDelete($criteria);
} catch (Exception $e) {
throw $e;
}

View File

@@ -13,8 +13,8 @@ require_once 'classes/model/om/BaseListCompleted.php';
* long as it does not already exist in the output directory.
*
* @package classes.model
* @deprecated Method deprecated in Release 3.3.9
*/
// @codingStandardsIgnoreStart
class ListCompleted extends BaseListCompleted implements ListInterface
{
use ListBaseTrait;

View File

@@ -1,6 +1,7 @@
<?php
require_once 'classes/model/om/BaseListParticipatedLast.php';
use ProcessMaker\BusinessModel\Cases as BmCases;
/**
@@ -536,4 +537,25 @@ class ListParticipatedLast extends BaseListParticipatedLast implements ListInter
}
BasePeer::doUpdate($criteriaWhere, $criteriaSet, $con);
}
/**
* Update the column APP_STATUS
*
* @param string $appUid
* @param string $status, can be [TO_DO, COMPLETED, etc]
*
* @return void
*
* @see Cases::updateCase()
*/
public function refreshStatus($appUid, $status = 'TO_DO')
{
//Update - WHERE
$criteriaWhere = new Criteria("workflow");
$criteriaWhere->add(ListParticipatedLastPeer::APP_UID, $appUid, Criteria::EQUAL);
//Update - SET
$criteriaSet = new Criteria("workflow");
$criteriaSet->add(ListParticipatedLastPeer::APP_STATUS, $status);
BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
}
}

View File

@@ -333,17 +333,15 @@ class ListUnassigned extends BaseListUnassigned implements ListInterface
{
try {
$arrayAppAssignSelfServiceValueData = [];
$criteria = new Criteria("workflow");
$group = new Groups();
//Get the GRP_ID related to the $userUid
$arrayId = $group->getActiveGroupsForAnUserById($userUid);
$sql = "("
. AppAssignSelfServiceValueGroupPeer::ASSIGNEE_ID . " IN ("
. " SELECT " . GroupUserPeer::GRP_ID . " "
. " FROM " . GroupUserPeer::TABLE_NAME . " "
. " LEFT JOIN " . GroupwfPeer::TABLE_NAME . " ON (" . GroupUserPeer::GRP_ID . "=" . GroupwfPeer::GRP_ID . ") "
. " WHERE " . GroupUserPeer::USR_UID . "='" . $userUid . "' AND " . GroupwfPeer::GRP_STATUS . "='ACTIVE'"
. " ) AND "
. " " . AppAssignSelfServiceValueGroupPeer::ASSIGNEE_TYPE . "=2 "
. AppAssignSelfServiceValueGroupPeer::ASSIGNEE_ID . " IN (" . implode(",", $arrayId) . ") AND "
. " " . AppAssignSelfServiceValueGroupPeer::ASSIGNEE_TYPE . " = 2 "
. ")";
$criteria->setDistinct();

View File

@@ -373,7 +373,7 @@ ViewDashboardPresenter.prototype.statusViewModel = function(indicatorId, data) {
};
var newObject3 = {
datalabel : originalObject.taskTitle,
value : 100 - (originalObject.percentageTotalOverdue + originalObject.percentageTotalAtRisk)
value : originalObject.percentageTotalOnTime
};
if (newObject1.value > 0) {

View File

@@ -3,7 +3,7 @@ CREATE TRIGGER CONTENT_UPDATE BEFORE UPDATE ON CONTENT
FOR EACH ROW
BEGIN
DECLARE str TEXT;
DECLARE str MEDIUMTEXT;
IF (NEW.CON_VALUE IS NULL) THEN
SET str = '';