Merge remote-tracking branch 'upstream/develop' into bugfix/HOR-3290
This commit is contained in:
@@ -22,6 +22,7 @@ class Home extends Controller
|
|||||||
|
|
||||||
private $clientBrowser;
|
private $clientBrowser;
|
||||||
private $lastSkin;
|
private $lastSkin;
|
||||||
|
private $usrId;
|
||||||
|
|
||||||
public function __construct ()
|
public function __construct ()
|
||||||
{
|
{
|
||||||
@@ -39,6 +40,10 @@ class Home extends Controller
|
|||||||
$this->userName = isset( $_SESSION['USR_USERNAME'] ) ? $_SESSION['USR_USERNAME'] : '';
|
$this->userName = isset( $_SESSION['USR_USERNAME'] ) ? $_SESSION['USR_USERNAME'] : '';
|
||||||
$this->userFullName = isset( $_SESSION['USR_FULLNAME'] ) ? $_SESSION['USR_FULLNAME'] : '';
|
$this->userFullName = isset( $_SESSION['USR_FULLNAME'] ) ? $_SESSION['USR_FULLNAME'] : '';
|
||||||
$this->userRolName = isset( $_SESSION['USR_ROLENAME'] ) ? $_SESSION['USR_ROLENAME'] : '';
|
$this->userRolName = isset( $_SESSION['USR_ROLENAME'] ) ? $_SESSION['USR_ROLENAME'] : '';
|
||||||
|
|
||||||
|
$users = new Users();
|
||||||
|
$users = $users->load($this->userID);
|
||||||
|
$this->usrId = $users["USR_ID"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +266,6 @@ class Home extends Controller
|
|||||||
|
|
||||||
// settings vars and rendering
|
// settings vars and rendering
|
||||||
$this->setVar( 'cases', $cases['data'] );
|
$this->setVar( 'cases', $cases['data'] );
|
||||||
$this->setVar( 'cases_count', $cases['totalCount'] );
|
|
||||||
$this->setVar( 'title', $title );
|
$this->setVar( 'title', $title );
|
||||||
$this->setVar( 'noPerms', G::LoadTranslation( 'ID_CASES_NOTES_NO_PERMISSIONS' ));
|
$this->setVar( 'noPerms', G::LoadTranslation( 'ID_CASES_NOTES_NO_PERMISSIONS' ));
|
||||||
$this->setVar( 'appListStart', $this->appListLimit );
|
$this->setVar( 'appListStart', $this->appListLimit );
|
||||||
@@ -279,6 +283,7 @@ class Home extends Controller
|
|||||||
// settings html template
|
// settings html template
|
||||||
$this->setView( $this->userUxBaseTemplate . PATH_SEP . 'appListSearch' );
|
$this->setView( $this->userUxBaseTemplate . PATH_SEP . 'appListSearch' );
|
||||||
|
|
||||||
|
// get data
|
||||||
$process = (isset($httpData->process)) ? $httpData->process : null;
|
$process = (isset($httpData->process)) ? $httpData->process : null;
|
||||||
$status = (isset($httpData->status)) ? $httpData->status : null;
|
$status = (isset($httpData->status)) ? $httpData->status : null;
|
||||||
$search = (isset($httpData->search)) ? $httpData->search : null;
|
$search = (isset($httpData->search)) ? $httpData->search : null;
|
||||||
@@ -286,18 +291,16 @@ class Home extends Controller
|
|||||||
$user = (isset($httpData->user)) ? $httpData->user : null;
|
$user = (isset($httpData->user)) ? $httpData->user : null;
|
||||||
$dateFrom = (isset($httpData->dateFrom)) ? $httpData->dateFrom : null;
|
$dateFrom = (isset($httpData->dateFrom)) ? $httpData->dateFrom : null;
|
||||||
$dateTo = (isset($httpData->dateTo)) ? $httpData->dateTo : null;
|
$dateTo = (isset($httpData->dateTo)) ? $httpData->dateTo : null;
|
||||||
|
$processTitle = "";
|
||||||
if (!empty($process)) {
|
if (!empty($process)) {
|
||||||
$processTitle = Process::loadById($process)->getProTitle();
|
$processTitle = Process::loadById($process)->getProTitle();
|
||||||
} else {
|
|
||||||
$processTitle = '';
|
|
||||||
}
|
}
|
||||||
if (!empty($user)) {
|
$userName = "";
|
||||||
|
if (!empty($user) && $user !== "ALL" && $user !== "CURRENT_USER") {
|
||||||
$userObject = Users::loadById($user);
|
$userObject = Users::loadById($user);
|
||||||
$userName = $userObject->getUsrLastname()." ".$userObject->getUsrFirstname();
|
$userName = $userObject->getUsrLastname() . " " . $userObject->getUsrFirstname();
|
||||||
} else {
|
|
||||||
$userName = '';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cases = $this->getAppsData( $httpData->t, null, null, $user, null, $search, $process, $status, $dateFrom, $dateTo, null, null, 'APP_CACHE_VIEW.APP_NUMBER', $category);
|
$cases = $this->getAppsData( $httpData->t, null, null, $user, null, $search, $process, $status, $dateFrom, $dateTo, null, null, 'APP_CACHE_VIEW.APP_NUMBER', $category);
|
||||||
$arraySearch = array($process, $status, $search, $category, $user, $dateFrom, $dateTo );
|
$arraySearch = array($process, $status, $search, $category, $user, $dateFrom, $dateTo );
|
||||||
|
|
||||||
@@ -318,7 +321,6 @@ class Home extends Controller
|
|||||||
$this->setVar( 'arraySearch', $arraySearch );
|
$this->setVar( 'arraySearch', $arraySearch );
|
||||||
|
|
||||||
$this->setVar( 'cases', $cases['data'] );
|
$this->setVar( 'cases', $cases['data'] );
|
||||||
$this->setVar( 'cases_count', $cases['totalCount'] );
|
|
||||||
$this->setVar( 'title', $title );
|
$this->setVar( 'title', $title );
|
||||||
$this->setVar( 'noPerms', G::LoadTranslation( 'ID_CASES_NOTES_NO_PERMISSIONS' ));
|
$this->setVar( 'noPerms', G::LoadTranslation( 'ID_CASES_NOTES_NO_PERMISSIONS' ));
|
||||||
$this->setVar( 'appListStart', $this->appListLimit );
|
$this->setVar( 'appListStart', $this->appListLimit );
|
||||||
@@ -369,13 +371,13 @@ class Home extends Controller
|
|||||||
$notesLimit = 4;
|
$notesLimit = 4;
|
||||||
switch ($user) {
|
switch ($user) {
|
||||||
case 'CURRENT_USER':
|
case 'CURRENT_USER':
|
||||||
$user = $this->userID;
|
$user = $this->usrId;
|
||||||
break;
|
break;
|
||||||
case 'ALL':
|
case 'ALL':
|
||||||
$user = null;
|
$user = null;
|
||||||
break;
|
break;
|
||||||
case null:
|
case null:
|
||||||
$user = $this->userID;
|
$user = $this->usrId;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//$user = $this->userID;
|
//$user = $this->userID;
|
||||||
@@ -444,21 +446,15 @@ class Home extends Controller
|
|||||||
if (true) {
|
if (true) {
|
||||||
//In enterprise version this block of code should always be executed
|
//In enterprise version this block of code should always be executed
|
||||||
//In community version this block of code is deleted and is executed the other
|
//In community version this block of code is deleted and is executed the other
|
||||||
$list = new \ProcessMaker\BusinessModel\Lists();
|
$swType = $type === "todo" || $type === "draft";
|
||||||
$listName = 'inbox';
|
if ($swType || $type === "unassigned") {
|
||||||
switch ($type) {
|
//The change is made because the method 'getList()' does not
|
||||||
case 'draft':
|
//support 'USR_UID', this method uses the numeric field 'USR_ID'.
|
||||||
case 'todo':
|
$userObject = Users::loadById($dataList['userId']);
|
||||||
$listName = 'inbox';
|
$dataList['userId'] = $userObject->getUsrUid();
|
||||||
$cases = $list->getList($listName, $dataList);
|
$listType = $swType ? "inbox" : $type;
|
||||||
break;
|
$list = new \ProcessMaker\BusinessModel\Lists();
|
||||||
case 'unassigned':
|
$cases = $list->getList($listType, $dataList);
|
||||||
$case = new \ProcessMaker\BusinessModel\Cases();
|
|
||||||
$cases = $case->getList($dataList);
|
|
||||||
foreach ($cases['data'] as &$value) {
|
|
||||||
$value = array_change_key_case($value, CASE_UPPER);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/*----------------------------------********---------------------------------*/
|
/*----------------------------------********---------------------------------*/
|
||||||
@@ -559,31 +555,32 @@ class Home extends Controller
|
|||||||
$this->render();
|
$this->render();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUserArray ($action, $userUid, $search = null)
|
function getUserArray($action, $userUid, $search = null)
|
||||||
{
|
{
|
||||||
global $oAppCache;
|
global $oAppCache;
|
||||||
$status = array ();
|
$status = array();
|
||||||
$users[] = array ("CURRENT_USER",G::LoadTranslation( "ID_CURRENT_USER" ));
|
$users[] = array("CURRENT_USER", G::LoadTranslation("ID_CURRENT_USER"));
|
||||||
$users[] = array ("ALL",G::LoadTranslation( "ID_ALL_USERS" ));
|
$users[] = array("ALL", G::LoadTranslation("ID_ALL_USERS"));
|
||||||
|
|
||||||
//now get users, just for the Search action
|
//now get users, just for the Search action
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
case 'search_simple':
|
case 'search_simple':
|
||||||
case 'search':
|
case 'search':
|
||||||
$cUsers = new Criteria( 'workflow' );
|
$cUsers = new Criteria('workflow');
|
||||||
$cUsers->clearSelectColumns();
|
$cUsers->clearSelectColumns();
|
||||||
$cUsers->addSelectColumn( UsersPeer::USR_UID );
|
$cUsers->addSelectColumn(UsersPeer::USR_UID);
|
||||||
$cUsers->addSelectColumn( UsersPeer::USR_FIRSTNAME );
|
$cUsers->addSelectColumn(UsersPeer::USR_FIRSTNAME);
|
||||||
$cUsers->addSelectColumn( UsersPeer::USR_LASTNAME );
|
$cUsers->addSelectColumn(UsersPeer::USR_LASTNAME);
|
||||||
|
$cUsers->addSelectColumn(UsersPeer::USR_ID);
|
||||||
if (!empty($search)) {
|
if (!empty($search)) {
|
||||||
$cUsers->addOr(UsersPeer::USR_FIRSTNAME, "%$search%", Criteria::LIKE);
|
$cUsers->addOr(UsersPeer::USR_FIRSTNAME, "%$search%", Criteria::LIKE);
|
||||||
$cUsers->addOr(UsersPeer::USR_LASTNAME, "%$search%", Criteria::LIKE);
|
$cUsers->addOr(UsersPeer::USR_LASTNAME, "%$search%", Criteria::LIKE);
|
||||||
}
|
}
|
||||||
$oDataset = UsersPeer::doSelectRS( $cUsers );
|
$oDataset = UsersPeer::doSelectRS($cUsers);
|
||||||
$oDataset->setFetchmode( ResultSet::FETCHMODE_ASSOC );
|
$oDataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
while ($aRow = $oDataset->getRow()) {
|
while ($aRow = $oDataset->getRow()) {
|
||||||
$users[] = array ($aRow['USR_UID'], htmlentities($aRow['USR_LASTNAME'] . ' ' . $aRow['USR_FIRSTNAME'], ENT_QUOTES, "UTF-8"));
|
$users[] = array($aRow['USR_ID'], htmlentities($aRow['USR_LASTNAME'] . ' ' . $aRow['USR_FIRSTNAME'], ENT_QUOTES, "UTF-8"));
|
||||||
$oDataset->next();
|
$oDataset->next();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -227,9 +227,7 @@ class Cases
|
|||||||
{
|
{
|
||||||
Validator::isArray($dataList, '$dataList');
|
Validator::isArray($dataList, '$dataList');
|
||||||
if (!isset($dataList["userId"])) {
|
if (!isset($dataList["userId"])) {
|
||||||
throw (new \Exception(\G::LoadTranslation("ID_USER_NOT_EXIST", array('userId',''))));
|
$dataList["userId"] = null;
|
||||||
} else {
|
|
||||||
Validator::usrUid($dataList["userId"], "userId");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$solrEnabled = false;
|
$solrEnabled = false;
|
||||||
|
|||||||
@@ -1,12 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace ProcessMaker\Util;
|
namespace ProcessMaker\Util;
|
||||||
|
|
||||||
|
use \ProcessMaker\Services\OAuth2\PmPdo;
|
||||||
|
use \ProcessMaker\Services\OAuth2\Server;
|
||||||
|
use \OAuth2\Request;
|
||||||
|
|
||||||
class System
|
class System
|
||||||
{
|
{
|
||||||
|
const CLIENT_ID = 'x-pm-local-client';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Time Zone
|
* Get Time Zone
|
||||||
*
|
*
|
||||||
* @return string Return Time Zone
|
* @return string Return Time Zone
|
||||||
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public static function getTimeZone()
|
public static function getTimeZone()
|
||||||
{
|
{
|
||||||
@@ -22,7 +30,7 @@ class System
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush the cache files for the specified workspace.
|
* Flush the cache files for the specified workspace.
|
||||||
*
|
*
|
||||||
* @param object $workspace
|
* @param object $workspace
|
||||||
*/
|
*/
|
||||||
public static function flushCache($workspace)
|
public static function flushCache($workspace)
|
||||||
@@ -68,4 +76,88 @@ class System
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get Token with USER_LOGGED saved in $_SESSION
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function tokenUserLogged()
|
||||||
|
{
|
||||||
|
$client = self::getClientCredentials();
|
||||||
|
|
||||||
|
$authCode = self::getAuthorizationCodeUserLogged($client);
|
||||||
|
|
||||||
|
$loader = \Maveriks\Util\ClassLoader::getInstance();
|
||||||
|
$loader->add(PATH_TRUNK . 'vendor/bshaffer/oauth2-server-php/src/', "OAuth2");
|
||||||
|
|
||||||
|
$request = array(
|
||||||
|
'grant_type' => 'authorization_code',
|
||||||
|
'code' => $authCode
|
||||||
|
);
|
||||||
|
$server = array(
|
||||||
|
'REQUEST_METHOD' => 'POST'
|
||||||
|
);
|
||||||
|
$headers = array(
|
||||||
|
"PHP_AUTH_USER" => $client['CLIENT_ID'],
|
||||||
|
"PHP_AUTH_PW" => $client['CLIENT_SECRET'],
|
||||||
|
"Content-Type" => "multipart/form-data;",
|
||||||
|
"Authorization" => "Basic " . base64_encode($client['CLIENT_ID'] . ":" . $client['CLIENT_SECRET'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$request = new Request(array(), $request, array(), array(), array(), $server, null, $headers);
|
||||||
|
$oauthServer = new Server();
|
||||||
|
$response = $oauthServer->postToken($request, true);
|
||||||
|
$clientToken = $response->getParameters();
|
||||||
|
$clientToken["client_id"] = $client['CLIENT_ID'];
|
||||||
|
$clientToken["client_secret"] = $client['CLIENT_SECRET'];
|
||||||
|
return $clientToken;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get client credentials
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getClientCredentials()
|
||||||
|
{
|
||||||
|
$oauthQuery = new PmPdo(self::getDsn());
|
||||||
|
return $oauthQuery->getClientDetails(self::CLIENT_ID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get DNS of workspace
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function getDsn()
|
||||||
|
{
|
||||||
|
list($host, $port) = strpos(DB_HOST, ':') !== false ? explode(':', DB_HOST) : array(DB_HOST, '');
|
||||||
|
$port = empty($port) ? '' : ";port=$port";
|
||||||
|
$dsn = DB_ADAPTER . ':host=' . $host . ';dbname=' . DB_NAME . $port;
|
||||||
|
|
||||||
|
return array('dsn' => $dsn, 'username' => DB_USER, 'password' => DB_PASS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get authorization code for user logged in session
|
||||||
|
* @param $client
|
||||||
|
* @return bool|string
|
||||||
|
*/
|
||||||
|
protected function getAuthorizationCodeUserLogged($client)
|
||||||
|
{
|
||||||
|
Server::setDatabaseSource(self::getDsn());
|
||||||
|
Server::setPmClientId($client['CLIENT_ID']);
|
||||||
|
|
||||||
|
$oauthServer = new Server();
|
||||||
|
|
||||||
|
$userId = $_SESSION['USER_LOGGED'];
|
||||||
|
$authorize = true;
|
||||||
|
$_GET = array_merge($_GET, array(
|
||||||
|
'response_type' => 'code',
|
||||||
|
'client_id' => $client['CLIENT_ID'],
|
||||||
|
'scope' => implode(' ', $oauthServer->getScope())
|
||||||
|
));
|
||||||
|
|
||||||
|
$response = $oauthServer->postAuthorize($authorize, $userId, true);
|
||||||
|
$code = substr($response->getHttpHeader('Location'), strpos($response->getHttpHeader('Location'), 'code=') + 5, 40);
|
||||||
|
return $code;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,7 @@
|
|||||||
<body onload="resize()" onresize="resize()" >
|
<body onload="resize()" onresize="resize()" >
|
||||||
<center>
|
<center>
|
||||||
<div class="content-header" style="text-align:left">
|
<div class="content-header" style="text-align:left">
|
||||||
<h1 style="padding: 10px">{$title} ({$cases_count})</h1>
|
<h1 style="padding: 10px">{$title}</h1>
|
||||||
<ul id="commentlist">
|
<ul id="commentlist">
|
||||||
{include file='home/applications.html'}
|
{include file='home/applications.html'}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -356,7 +356,7 @@
|
|||||||
|
|
||||||
<center>
|
<center>
|
||||||
<div class="content-header" style="text-align:left">
|
<div class="content-header" style="text-align:left">
|
||||||
<h1 style="padding: 10px">{$title} ({$cases_count})</h1>
|
<h1 style="padding: 10px">{$title}</h1>
|
||||||
<ul id="commentlist">
|
<ul id="commentlist">
|
||||||
{include file='home/applications.html'}
|
{include file='home/applications.html'}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
Reference in New Issue
Block a user