conflicts: merge develop
This commit is contained in:
@@ -1556,16 +1556,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
@@ -1608,16 +1608,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
@@ -1661,16 +1661,16 @@ class AbstractCases implements CasesInterface
|
||||
$list = end($listArray);
|
||||
switch ($list) {
|
||||
case 'Inbox':
|
||||
$query->inbox($this->getUserId());
|
||||
$query->inboxMetrics();
|
||||
break;
|
||||
case 'Draft':
|
||||
$query->draft($this->getUserId());
|
||||
$query->draftMetrics();
|
||||
break;
|
||||
case 'Paused':
|
||||
$query->paused($this->getUserId());
|
||||
$query->pausedMetrics();
|
||||
break;
|
||||
case 'Unassigned':
|
||||
$query->selfService($this->getUserUid());
|
||||
$query->selfServiceMetrics();
|
||||
break;
|
||||
}
|
||||
$query->joinProcess();
|
||||
|
||||
@@ -258,4 +258,16 @@ class Draft extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in DRAFT
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->draftMetrics();
|
||||
return $query->count(['APPLICATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,4 +275,16 @@ class Inbox extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in TO_DO
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->inboxMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,4 +265,16 @@ class Paused extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in PAUSED
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->pausedMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -278,4 +278,16 @@ class Unassigned extends AbstractCases
|
||||
'total' => $count
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Count how many cases there are in SELF_SERVICE
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getCounterMetrics()
|
||||
{
|
||||
$query = Delegation::query()->select();
|
||||
$query->selfServiceMetrics();
|
||||
return $query->count(['APP_DELEGATION.APP_NUMBER']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -874,8 +874,8 @@ class Light
|
||||
session_start();
|
||||
session_regenerate_id();
|
||||
|
||||
setcookie("workspaceSkin", SYS_SKIN, time() + (24 * 60 * 60), "/sys" . config("system.workspace"), null, G::is_https(),
|
||||
true);
|
||||
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + (24 * 60 * 60), 'path' => '/sys' . config('system.workspace'), 'httponly' => true]);
|
||||
setcookie('workspaceSkin', SYS_SKIN, $cookieOptions);
|
||||
|
||||
if (strlen($msg) > 0) {
|
||||
$_SESSION['G_MESSAGE'] = $msg;
|
||||
|
||||
@@ -86,6 +86,21 @@ class System
|
||||
'disable_task_manager_routing_async' => '0',
|
||||
'on_one_server_enable' => 0,
|
||||
'at_risk_delegation_max_time' => '0.2',
|
||||
'samesite_cookie_setting' => ''
|
||||
];
|
||||
|
||||
public static $cookieDefaultOptions = [
|
||||
'expires' => 0,
|
||||
'path' => '/',
|
||||
'domain' => '',
|
||||
'secure' => false,
|
||||
'httponly' => false,
|
||||
'samesite' => ''
|
||||
];
|
||||
|
||||
public static $cookieSameSiteValues = [
|
||||
'Lax',
|
||||
'Strict'
|
||||
];
|
||||
|
||||
/**
|
||||
@@ -1252,6 +1267,13 @@ class System
|
||||
$config['at_risk_delegation_max_time'] = self::$defaultConfig['at_risk_delegation_max_time'];
|
||||
}
|
||||
|
||||
$value = ucfirst(strtolower($config['samesite_cookie_setting']));
|
||||
if (in_array($value, self::$cookieSameSiteValues)) {
|
||||
$config['samesite_cookie_setting'] = $value;
|
||||
} else {
|
||||
$config['samesite_cookie_setting'] = '';
|
||||
}
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
@@ -1778,4 +1800,29 @@ class System
|
||||
$parseDsn["pass"] = urldecode($parseDsn["pass"]);
|
||||
return $parseDsn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the options for a cookie, according to the system configuration and values optionally sent to this method
|
||||
*
|
||||
* @param array $options
|
||||
* @return array
|
||||
*/
|
||||
public static function buildCookieOptions(array $options = [])
|
||||
{
|
||||
// Get system values
|
||||
$cookieOptions = self::$cookieDefaultOptions;
|
||||
$systemConfiguration = self::getSystemConfiguration();
|
||||
|
||||
// Always set "secure" option according to the server protocol
|
||||
$cookieOptions['secure'] = G::is_https();
|
||||
|
||||
// Set the "samesite" option according to the system configuration
|
||||
$cookieOptions['samesite'] = $systemConfiguration['samesite_cookie_setting'];
|
||||
|
||||
// Overrides the cookie options with the values sent to the method
|
||||
$cookieOptions = array_merge($cookieOptions, $options);
|
||||
|
||||
// Return the cookie options
|
||||
return $cookieOptions;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1069,6 +1069,64 @@ class Delegation extends Model
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope the Inbox cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeInboxMetrics($query)
|
||||
{
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_TODO);
|
||||
$query->threadOpen();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a draft cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeDraftMetrics($query)
|
||||
{
|
||||
$query->joinApplication();
|
||||
$query->status(Application::STATUS_DRAFT);
|
||||
$query->threadOpen();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope paused cases list no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopePausedMetrics($query)
|
||||
{
|
||||
$query->joinAppDelay('PAUSE');
|
||||
$query->joinApplication();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Scope a self service cases no matter the user
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query
|
||||
*
|
||||
* @return \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
public function scopeSelfServiceMetrics($query)
|
||||
{
|
||||
$query->taskAssignType('SELF_SERVICE');
|
||||
$query->threadOpen()->withoutUserId();
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific cases unassigned that the user can view
|
||||
*
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
namespace ProcessMaker\Services\Api;
|
||||
|
||||
use Exception;
|
||||
use Luracast\Restler\RestException;
|
||||
use ProcessMaker\BusinessModel\Cases\Draft;
|
||||
use ProcessMaker\BusinessModel\Cases\Inbox;
|
||||
use ProcessMaker\BusinessModel\Cases\Paused;
|
||||
use ProcessMaker\BusinessModel\Cases\Unassigned;
|
||||
use ProcessMaker\Model\User;
|
||||
use ProcessMaker\Services\Api;
|
||||
use RBAC;
|
||||
|
||||
@@ -46,8 +46,6 @@ class Metrics extends Api
|
||||
*/
|
||||
public function getProcessTotalCases($caseList, $category = null, $topTen = false, $processes = [])
|
||||
{
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
try {
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
@@ -61,10 +59,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCountersByProcesses($category, $topTen, $processes);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
@@ -91,8 +87,6 @@ class Metrics extends Api
|
||||
*/
|
||||
public function getTotalCasesByRange($caseList, $processId = null, $dateFrom = null, $dateTo = null, $groupBy = 'day')
|
||||
{
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
try {
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
@@ -106,10 +100,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCountersByRange($processId, $dateFrom, $dateTo, $groupBy);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
@@ -125,31 +117,21 @@ class Metrics extends Api
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||
*/
|
||||
public function getCountersList()
|
||||
{
|
||||
try {
|
||||
$usrUid = $this->getUserId();
|
||||
$properties['user'] = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
|
||||
$listInbox = new Inbox();
|
||||
$listInbox->setProperties($properties);
|
||||
|
||||
$listDraft = new Draft();
|
||||
$listDraft->setUserUid($usrUid);
|
||||
$listDraft->setProperties($properties);
|
||||
|
||||
$listPaused = new Paused();
|
||||
$listPaused->setProperties($properties);
|
||||
|
||||
$listUnassigned = new Unassigned();
|
||||
$listUnassigned->setUserUid($usrUid);
|
||||
$listUnassigned->setProperties($properties);
|
||||
|
||||
$casesInbox = $listInbox->getCounter();
|
||||
$casesDraft = $listDraft->getCounter();
|
||||
$casesPaused = $listPaused->getCounter();
|
||||
$casesUnassigned = $listUnassigned->getCounter();
|
||||
$casesInbox = $listInbox->getCounterMetrics();
|
||||
$casesDraft = $listDraft->getCounterMetrics();
|
||||
$casesPaused = $listPaused->getCounterMetrics();
|
||||
$casesUnassigned = $listUnassigned->getCounterMetrics();
|
||||
|
||||
$result = [
|
||||
['List Name' => 'Inbox', 'Total' => $casesInbox, 'Color' => 'green'],
|
||||
@@ -179,12 +161,12 @@ class Metrics extends Api
|
||||
* @return array
|
||||
*
|
||||
* @throws RestException
|
||||
*
|
||||
* @class AccessControl {@permission TASK_METRICS_VIEW}
|
||||
*/
|
||||
public function getCasesRiskByProcess($caseList = 'inbox', $process, $dateFrom = null, $dateTo = null, $riskStatus = 'ON_TIME', $topCases = null)
|
||||
{
|
||||
try {
|
||||
$usrUid = $this->getUserId();
|
||||
$usrId = !empty($usrUid) ? User::getId($usrUid) : 0;
|
||||
switch ($caseList) {
|
||||
case 'inbox':
|
||||
$list = new Inbox();
|
||||
@@ -197,10 +179,8 @@ class Metrics extends Api
|
||||
break;
|
||||
case 'unassigned':
|
||||
$list = new Unassigned();
|
||||
$list->setUserUid($usrUid);
|
||||
break;
|
||||
}
|
||||
$list->setUserId($usrId);
|
||||
$result = $list->getCasesRisk($process, $dateFrom, $dateTo, $riskStatus, $topCases);
|
||||
return $result;
|
||||
} catch (Exception $e) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace ProcessMaker\Services\OAuth2;
|
||||
|
||||
use Bootstrap;
|
||||
use Luracast\Restler\iAuthenticate;
|
||||
use Luracast\Restler\RestException;
|
||||
use OAuth2\Request;
|
||||
@@ -367,7 +368,8 @@ class Server implements iAuthenticate
|
||||
$lifetime = 1440;
|
||||
}
|
||||
|
||||
setcookie($session->getSessionName(), $_COOKIE[$session->getSessionName()], time() + $lifetime, "/", null, false, true);
|
||||
$cookieOptions = Bootstrap::buildCookieOptions(['expires' => time() + $lifetime, 'secure' => false, 'httponly' => true]);
|
||||
setcookie($session->getSessionName(), $_COOKIE[$session->getSessionName()], $cookieOptions);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user