Skip to content

Commit

Permalink
Added to cronPMTaskActions to create a session with the processmaker …
Browse files Browse the repository at this point in the history
…task writer when in cron,

Fixes tomolimo#8
  • Loading branch information
tomolimo committed Jan 29, 2018
1 parent 1234c76 commit 6232296
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions inc/processmaker.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -933,8 +933,16 @@ static function cronInfo($name) {
static function cronPMTaskActions($task) {
global $DB, $PM_DB;

$usr = false; // by default
if (!isset($PM_DB)) {
$PM_DB = new PluginProcessmakerDB;

// also create a GLPI session with the processmaker task writer
$usr = new User;
$config = PluginProcessmakerConfig::getInstance();
$usr->getFromDB($config->fields['users_id']);
$save_session = $_SESSION;
$usr->loadMinimalSession(0, true);
}

$actionCode = 0; // by default
Expand Down Expand Up @@ -1013,6 +1021,13 @@ static function cronPMTaskActions($task) {
}
}

if ($usr) {
// restore previous session
Session::destroy();
Session::start();
$_SESSION = $save_session;
}

if ($error) {
return -1;
} else {
Expand Down Expand Up @@ -2259,13 +2274,14 @@ function HandleHeaderLine( $curl, $header_line ) {
$ch = curl_init();

//to be able to trace network traffic with a local proxy
// curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
//curl_setopt($ch, CURLOPT_PROXY, "localhost:8888");
curl_setopt($ch, CURLOPT_HEADER, 1);
//curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 1 ) ;
//curl_setopt($ch, CURLOPT_PROXY, "localhost:8889");

curl_setopt($ch, CURLOPT_HEADER, 1);
// curl_setopt($ch, CURLOPT_VERBOSE, 1);
// curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine");
curl_setopt($ch, CURLOPT_HEADERFUNCTION, "HandleHeaderLine");

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

Expand Down

0 comments on commit 6232296

Please sign in to comment.