Adicion de contadores de bandeja (y tiempo de acces token)
This commit is contained in:
@@ -1237,6 +1237,12 @@ class Cases
|
||||
$appAssignSelfServiceValue = new AppAssignSelfServiceValue();
|
||||
|
||||
$appAssignSelfServiceValue->remove($sAppUid, $iDelIndex);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$aFields = $oAppDel->toArray(BasePeer::TYPE_FIELDNAME);
|
||||
$aFields['APP_STATUS'] = 'TO_DO';
|
||||
$inbox = new ListInbox();
|
||||
$inbox->update($aFields, true);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
}
|
||||
@@ -1981,7 +1987,7 @@ class Cases
|
||||
* @return Fields
|
||||
*/
|
||||
|
||||
public function startCase($sTasUid, $sUsrUid, $isSubprocess = false)
|
||||
public function startCase($sTasUid, $sUsrUid, $isSubprocess = false, $dataPreviusApplication = array())
|
||||
{
|
||||
if ($sTasUid != '') {
|
||||
try {
|
||||
@@ -2045,11 +2051,12 @@ class Cases
|
||||
$Fields['USR_UID'] = $sUsrUid;
|
||||
$Fields['DEL_INDEX'] = $iDelIndex;
|
||||
$Fields['APP_STATUS'] = 'TO_DO';
|
||||
$Fields['DEL_DELEGATE_DATE'] = $Fields['APP_INIT_DATE'];
|
||||
if(!$isSubprocess){
|
||||
$Fields['APP_STATUS'] = 'DRAFT';
|
||||
}
|
||||
$inbox = new ListInbox();
|
||||
$inbox->newRow($Fields, $sUsrUid);
|
||||
$inbox->newRow($Fields, $sUsrUid, $isSubprocess, $dataPreviusApplication);
|
||||
/*----------------------------------********---------------------------------*/
|
||||
} catch (exception $e) {
|
||||
throw ($e);
|
||||
|
||||
@@ -748,14 +748,13 @@ class Derivation
|
||||
//SETS THE APP_PROC_CODE
|
||||
//if (isset($nextDel['TAS_DEF_PROC_CODE']))
|
||||
//$appFields['APP_PROC_CODE'] = $nextDel['TAS_DEF_PROC_CODE'];
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
if (!empty($iNewDelIndex) && empty($aSP)) {
|
||||
$oAppDel = AppDelegationPeer::retrieveByPK( $appFields['APP_UID'], $iNewDelIndex );
|
||||
$aFields = $oAppDel->toArray( BasePeer::TYPE_FIELDNAME );
|
||||
$aFields['APP_STATUS'] = $currentDelegation['APP_STATUS'];
|
||||
$inbox = new ListInbox();
|
||||
$inbox->newRow($aFields, $nextDel['USR_UID']);
|
||||
$inbox->newRow($aFields, $appFields['CURRENT_USER_UID'], false, array(), ($nextDel['TAS_ASSIGN_TYPE'] == 'SELF_SERVICE' ? true : false));
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
unset( $aSP );
|
||||
@@ -863,7 +862,7 @@ class Derivation
|
||||
if (isset( $aSP )) {
|
||||
//Create the new case in the sub-process
|
||||
// set the initial date to null the time its created
|
||||
$aNewCase = $this->case->startCase( $aSP['TAS_UID'], $aSP['USR_UID'], true );
|
||||
$aNewCase = $this->case->startCase( $aSP['TAS_UID'], $aSP['USR_UID'], true, $appFields);
|
||||
//Copy case variables to sub-process case
|
||||
$aFields = unserialize( $aSP['SP_VARIABLES_OUT'] );
|
||||
$aNewFields = array ();
|
||||
|
||||
@@ -94,6 +94,14 @@ class ListCompleted extends BaseListCompleted
|
||||
$criteriaSet->add(ListParticipatedLastPeer::APP_STATUS, 'COMPLETED');
|
||||
BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
|
||||
|
||||
$users = new Users();
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'completed');
|
||||
if ($data['DEL_PREVIOUS'] != 0) {
|
||||
$users->refreshTotal($data['USR_UID'], 'remove', 'inbox');
|
||||
} else {
|
||||
$users->refreshTotal($data['USR_UID'], 'remove', 'draft');
|
||||
}
|
||||
|
||||
$con = Propel::getConnection( ListCompletedPeer::DATABASE_NAME );
|
||||
try {
|
||||
$this->fromArray( $data, BasePeer::TYPE_FIELDNAME );
|
||||
|
||||
@@ -23,7 +23,7 @@ class ListInbox extends BaseListInbox
|
||||
* @return type
|
||||
*
|
||||
*/
|
||||
public function create($data)
|
||||
public function create($data, $isSelfService = false)
|
||||
{
|
||||
$con = Propel::getConnection( ListInboxPeer::DATABASE_NAME );
|
||||
try {
|
||||
@@ -48,12 +48,14 @@ class ListInbox extends BaseListInbox
|
||||
$listMyInbox->refresh($data);
|
||||
|
||||
// remove and create participated last
|
||||
if (!$isSelfService) {
|
||||
$listParticipatedLast = new ListParticipatedLast();
|
||||
$listParticipatedLast->remove($data['APP_UID'], $data['USR_UID']);
|
||||
$listParticipatedLast = new ListParticipatedLast();
|
||||
$listParticipatedLast->create($data);
|
||||
$listParticipatedLast = new ListParticipatedLast();
|
||||
$listParticipatedLast->refresh($data);
|
||||
}
|
||||
|
||||
return $result;
|
||||
} catch(Exception $e) {
|
||||
@@ -69,8 +71,12 @@ class ListInbox extends BaseListInbox
|
||||
* @return type
|
||||
* @throws type
|
||||
*/
|
||||
public function update($data)
|
||||
public function update($data, $addCountInbox = false)
|
||||
{
|
||||
if ($addCountInbox) {
|
||||
$users = new Users();
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'inbox');
|
||||
}
|
||||
$con = Propel::getConnection( ListInboxPeer::DATABASE_NAME );
|
||||
try {
|
||||
$con->begin();
|
||||
@@ -141,7 +147,7 @@ class ListInbox extends BaseListInbox
|
||||
}
|
||||
}
|
||||
|
||||
public function newRow ($data, $delPreviusUsrUid)
|
||||
public function newRow ($data, $delPreviusUsrUid, $isInitSubprocess = false, $dataPreviusApplication = array(), $isSelfService = false)
|
||||
{
|
||||
$data['DEL_PREVIOUS_USR_UID'] = $delPreviusUsrUid;
|
||||
if (isset($data['DEL_TASK_DUE_DATE'])) {
|
||||
@@ -211,7 +217,51 @@ class ListInbox extends BaseListInbox
|
||||
$data['DEL_PREVIOUS_USR_LASTNAME'] = $aRow['USR_LASTNAME'];
|
||||
}
|
||||
|
||||
self::create($data);
|
||||
$users = new Users();
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(SubApplicationPeer::DEL_INDEX_PARENT);
|
||||
$criteria->add( SubApplicationPeer::APP_PARENT, $data['APP_UID'], Criteria::EQUAL );
|
||||
$dataset = SubApplicationPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(ResultSet::FETCHMODE_ASSOC);
|
||||
if ($dataset->next()) {
|
||||
$aSub = $dataset->getRow();
|
||||
if ($aSub['DEL_INDEX_PARENT'] == $data['DEL_PREVIOUS'] && !$isSelfService) {
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'inbox');
|
||||
self::create($data, $isSelfService);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$isInitSubprocess) {
|
||||
if ($data['APP_STATUS'] == 'DRAFT') {
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'draft');
|
||||
} else {
|
||||
if ($data['DEL_INDEX'] == 2) {
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(SubApplicationPeer::APP_UID);
|
||||
$criteria->add( SubApplicationPeer::APP_UID, $data['APP_UID'], Criteria::EQUAL );
|
||||
$dataset = SubApplicationPeer::doSelectRS($criteria);
|
||||
if ($dataset->next()) {
|
||||
$users->refreshTotal($delPreviusUsrUid, 'remove', 'inbox');
|
||||
} else {
|
||||
$users->refreshTotal($delPreviusUsrUid, 'remove', 'draft');
|
||||
}
|
||||
} else {
|
||||
$users->refreshTotal($delPreviusUsrUid, 'remove', 'inbox');
|
||||
}
|
||||
if (!$isSelfService) {
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'inbox');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'inbox');
|
||||
if ($dataPreviusApplication['APP_STATUS'] == 'DRAFT') {
|
||||
$users->refreshTotal($dataPreviusApplication['CURRENT_USER_UID'], 'remove', 'draft');
|
||||
} else {
|
||||
$users->refreshTotal($dataPreviusApplication['CURRENT_USER_UID'], 'remove', 'inbox');
|
||||
}
|
||||
}
|
||||
self::create($data, $isSelfService);
|
||||
}
|
||||
|
||||
public function loadFilters (&$criteria, $filters)
|
||||
|
||||
@@ -48,6 +48,19 @@ class ListParticipatedLast extends BaseListParticipatedLast
|
||||
$aRow = $dataset->getRow();
|
||||
$data['APP_STATUS'] = $aRow['APP_STATUS'];
|
||||
|
||||
//Update - WHERE
|
||||
$criteriaWhere = new Criteria("workflow");
|
||||
$criteriaWhere->add(ListParticipatedLastPeer::APP_UID, $data["APP_UID"], Criteria::EQUAL);
|
||||
//Update - SET
|
||||
$criteriaSet = new Criteria("workflow");
|
||||
$criteriaSet->add(ListParticipatedLastPeer::DEL_CURRENT_USR_USERNAME, $data['DEL_CURRENT_USR_USERNAME']);
|
||||
$criteriaSet->add(ListParticipatedLastPeer::DEL_CURRENT_USR_FIRSTNAME, $data['DEL_CURRENT_USR_FIRSTNAME']);
|
||||
$criteriaSet->add(ListParticipatedLastPeer::DEL_CURRENT_USR_LASTNAME, $data['DEL_CURRENT_USR_LASTNAME']);
|
||||
BasePeer::doUpdate($criteriaWhere, $criteriaSet, Propel::getConnection("workflow"));
|
||||
|
||||
$users = new Users();
|
||||
$users->refreshTotal($data['USR_UID'], 'add', 'participated');
|
||||
|
||||
$con = Propel::getConnection( ListParticipatedLastPeer::DATABASE_NAME );
|
||||
try {
|
||||
$this->fromArray( $data, BasePeer::TYPE_FIELDNAME );
|
||||
@@ -132,6 +145,11 @@ class ListParticipatedLast extends BaseListParticipatedLast
|
||||
*/
|
||||
public function remove ($app_uid, $usr_uid)
|
||||
{
|
||||
$existField = ListParticipatedLastPeer::retrieveByPK($app_uid, $usr_uid);
|
||||
if (! is_null( $existField )) {
|
||||
$users = new Users();
|
||||
$users->refreshTotal($usr_uid, 'removed', 'participated');
|
||||
}
|
||||
$con = Propel::getConnection( ListParticipatedLastPeer::DATABASE_NAME );
|
||||
try {
|
||||
$this->setAppUid($app_uid);
|
||||
|
||||
@@ -80,9 +80,49 @@ if ($oServerConf->isRtl( SYS_LANG )) {
|
||||
$regionTreePanel = 'west';
|
||||
$regionDebug = 'east';
|
||||
}
|
||||
|
||||
$urlProxy = 'casesMenuLoader?action=getAllCounters&r=';
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$urlProxy = '/api/1.0/' . SYS_SYS . '/system/counters-lists?r=';
|
||||
$clientId = 'x-pm-local-client';
|
||||
$client = getClientCredentials($clientId);
|
||||
$authCode = getAuthorizationCode($client);
|
||||
$debug = false; //System::isDebugMode();
|
||||
|
||||
$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 \OAuth2\Request(array(), $request, array(), array(), array(), $server, null, $headers);
|
||||
$oauthServer = new \ProcessMaker\Services\OAuth2\Server();
|
||||
$response = $oauthServer->postToken($request, true);
|
||||
|
||||
$clientToken = $response->getParameters();
|
||||
$clientToken["client_id"] = $client['CLIENT_ID'];
|
||||
$clientToken["client_secret"] = $client['CLIENT_SECRET'];
|
||||
/*----------------------------------********---------------------------------*/
|
||||
|
||||
|
||||
$oHeadPublisher->assign( 'regionTreePanel', $regionTreePanel );
|
||||
$oHeadPublisher->assign( 'regionDebug', $regionDebug );
|
||||
$oHeadPublisher->assign( "defaultOption", $defaultOption ); //User menu permissions
|
||||
$oHeadPublisher->assign( 'urlProxy', $urlProxy ); //sending the urlProxy to make
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$oHeadPublisher->assign( 'credentials', $clientToken );
|
||||
/*----------------------------------********---------------------------------*/
|
||||
$oHeadPublisher->assign( "_nodeId", isset( $confDefaultOption ) ? $confDefaultOption : "PM_USERS" ); //User menu permissions
|
||||
$oHeadPublisher->assign( "FORMATS", $conf->getFormats() );
|
||||
|
||||
@@ -90,3 +130,41 @@ $_SESSION["current_ux"] = "NORMAL";
|
||||
|
||||
G::RenderPage( "publish", "extJs" );
|
||||
|
||||
|
||||
/*----------------------------------********---------------------------------*/
|
||||
function getClientCredentials($clientId)
|
||||
{
|
||||
$oauthQuery = new ProcessMaker\Services\OAuth2\PmPdo(getDsn());
|
||||
return $oauthQuery->getClientDetails($clientId);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
function getAuthorizationCode($client)
|
||||
{
|
||||
\ProcessMaker\Services\OAuth2\Server::setDatabaseSource(getDsn());
|
||||
\ProcessMaker\Services\OAuth2\Server::setPmClientId($client['CLIENT_ID']);
|
||||
|
||||
$oauthServer = new \ProcessMaker\Services\OAuth2\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;
|
||||
}
|
||||
/*----------------------------------********---------------------------------*/
|
||||
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
namespace ProcessMaker\BusinessModel;
|
||||
use \G;
|
||||
use \Criteria;
|
||||
use \UsersPeer;
|
||||
|
||||
/**
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
@@ -180,4 +182,45 @@ class Lists {
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get counters for lists
|
||||
*
|
||||
* @access public
|
||||
* @param array $userId, User Uid
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*/
|
||||
public function getCounters($userId)
|
||||
{
|
||||
$criteria = new Criteria();
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_INBOX);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_DRAFT);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_CANCELLED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PARTICIPATED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_PAUSED);
|
||||
$criteria->addSelectColumn(UsersPeer::USR_TOTAL_COMPLETED);
|
||||
$criteria->add( UsersPeer::USR_UID, $userId, Criteria::EQUAL );
|
||||
$dataset = UsersPeer::doSelectRS($criteria);
|
||||
$dataset->setFetchmode(\ResultSet::FETCHMODE_ASSOC);
|
||||
$dataset->next();
|
||||
$aRow = $dataset->getRow();
|
||||
|
||||
$oAppCache = new \AppCacheView();
|
||||
$totalUnassigned = $oAppCache->getListCounters('selfservice', $userId, false);
|
||||
|
||||
$response = array(
|
||||
array('count' => $aRow['USR_TOTAL_INBOX'], 'item' => 'CASES_INBOX'),
|
||||
array('count' => $aRow['USR_TOTAL_DRAFT'], 'item' => 'CASES_DRAFT'),
|
||||
array('count' => $aRow['USR_TOTAL_CANCELLED'], 'item' => 'CASES_CANCELLED'),
|
||||
array('count' => $aRow['USR_TOTAL_PARTICIPATED'], 'item' => 'CASES_SENT'),
|
||||
array('count' => $aRow['USR_TOTAL_PAUSED'], 'item' => 'CASES_PAUSED'),
|
||||
array('count' => $aRow['USR_TOTAL_COMPLETED'], 'item' => 'CASES_COMPLETED'),
|
||||
array('count' => $totalUnassigned, 'item' => 'CASES_SELFSERVICE')
|
||||
);
|
||||
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
@@ -29,5 +29,27 @@ class System extends Api
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get count for all lists
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @author Brayan Pereyra (Cochalo) <brayan@colosa.com>
|
||||
* @copyright Colosa - Bolivia
|
||||
*
|
||||
* @url GET /counters-lists
|
||||
*/
|
||||
public function doGetCountersLists()
|
||||
{
|
||||
try {
|
||||
$userId = $this->getUserId();
|
||||
$lists = new \ProcessMaker\BusinessModel\Lists();
|
||||
$response = $lists->getCounters($userId);
|
||||
return $response;
|
||||
} catch (\Exception $e) {
|
||||
throw (new RestException(Api::STAT_APP_EXCEPTION, $e->getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ class Server implements iAuthenticate
|
||||
}
|
||||
|
||||
// Pass a storage object or array of storage objects to the OAuth2 server class
|
||||
$this->server = new \OAuth2\Server($this->storage, array('allow_implicit' => true));
|
||||
$this->server = new \OAuth2\Server($this->storage, array('allow_implicit' => true, 'access_lifetime' => 86400));
|
||||
|
||||
$this->server->setConfig('enforce_state', false);
|
||||
|
||||
|
||||
@@ -573,7 +573,14 @@ function updateCasesTree() {
|
||||
ReloadTreeMenuItemDetail({item:currentSelectedTreeMenuItem});
|
||||
}
|
||||
Ext.Ajax.request({
|
||||
url: 'casesMenuLoader?action=getAllCounters&r='+Math.random(),
|
||||
url: urlProxy + Math.random(),
|
||||
/*----------------------------------********---------------------------------*/
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': 'Bearer ' + credentials.access_token
|
||||
},
|
||||
method: 'GET',
|
||||
/*----------------------------------********---------------------------------*/
|
||||
success: function(response){
|
||||
result = Ext.util.JSON.decode(response.responseText);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user