I recommend creating a plugin which adds an option to the Cases sidebar and uses REST to populate your custom cases list.
See:
http://wiki.processmaker.com/3.0/Plugin ... es_Sidebar
You can use this code in your plugin to get the access token for REST calls:
Code: Select allif (!isset($_SESSION['USER_LOGGED'])) {
header("Location: ../login/login");
}
$userId = $_SESSION['USER_LOGGED'];
$sql = "SELECT * FROM OAUTH_REFRESH_TOKENS WHERE USER_ID='$userId' ORDER BY EXPIRES DESC";
$result = executeQuery($sql);
if (empty($result)) {
header("Location: ../login/login");
}
$refreshToken = $result[1]['REFRESH_TOKEN'];
//Universal Client ID and Client Secret from workflow/engine/methods/oauth2/grant.php
$clientId = 'x-pm-local-client';
$clientSecret = '179ad45c6ce2cb97cf1029e212046e81';
$pmServer = (G::is_https() ? 'https://' : 'http://').$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'];
$aVars = array(
'grant_type' => 'refresh_token',
'client_id' => $clientId,
'client_secret' => $clientSecret,
'refresh_token' => $refreshToken
);
$ch = curl_init($pmServer.'/'.SYS_SYS.'/oauth2/token');
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $aVars);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$oToken = json_decode(curl_exec($ch));
$httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($httpStatus != 200) {
print "Error in HTTP status code: $httpStatus\n";
}
elseif (isset($oToken->error)) {
print "Error logging into $pmServer:\n" .
"Error: {$oToken->error}\n" .
"Description: {$oToken->description}\n";
}
else {
$accessToken = $oToken->access_token;
$refreshToken = $oToken->refresh_token;
//Now the access token can be used for REST calls or saved as a cookie.
//Save access token as a cookie that expires in 86400 seconds:
//setcookie("access_token", $oToken->access_token, time() + 86400);
}