Commit ce9e4308 authored by everykittysdaydream's avatar everykittysdaydream

import uses settings now too

parent 94dcb47e
......@@ -76,7 +76,7 @@ function civicrm_api3_importer_Import($params) {
$returnValues["count"] = $count;
$returnValues["session"] = $_SESSION["extractors"];
$returnValues["session"] = Civi::settings()->get("extractors");
return civicrm_api3_create_success($returnValues, $params, 'Importer', 'import');
}
......@@ -41,13 +41,19 @@ function _civicrm_api3_importer_Schedule_spec(&$spec) {
function civicrm_api3_importer_Schedule($params) {
$returnValues = array();
// Get out if nobody started.
if (!isset($_SESSION["extractors"]) or empty($_SESSION["extractors"])) {
$extractors = Civi::settings()->get("extractors");
if ($extractors == NULL) {
$returnValues["status"] = "no variable set";
return civicrm_api3_create_success($returnValues, $params, 'Importer', 'schedule');
} else if (empty($extractors)) {
$returnValues["status"] = "no variable set";
return civicrm_api3_create_success($returnValues, $params, 'Importer', 'schedule');
}
// Run this 20 times, quit if you hit NULL.
$to_unserialize = array_pop($_SESSION["extractors"]);
$to_unserialize = array_pop($extractors);
Civi::settings()->set("extractors", $to_unserialize);
$malformed = FALSE;
if (is_string($to_unserialize)) {
$rootdata = unserialize($to_unserialize);
......@@ -125,7 +131,10 @@ function civicrm_api3_importer_Schedule($params) {
CRM_Core_Session::setStatus('adding contacts to pipeline', 'Queue task', 'success');
$returned_data = new ResourceStruct($root, $rootdata->rule, $rootdata->filter, $rootdata->group, $zone, $apikey, $rootdata->endpoint);
$_SESSION["extractors"][] = serialize($returned_data);
$extractors = Civi::settings()->get("extractors");
$extractors[] = serialize($returned_data);
Civi::settings()->set("extractors", $extractors);
$returnValues["status"] = "partially completed";
$returnValues["counter"] = $counter;
......
......@@ -213,7 +213,9 @@ function civicrm_api3_o_s_d_i_job_Add($params) {
}
$second_key = $params["signupendpoint"] . $hash;
unset($_SESSION["exporters_offset"][$second_key]);
$exporters_offset = Civi::settings()->get("exporters_offset");
unset($exporters_offset[$second_key]);
Civi::settings()->set("exporters_offset", $exporters_offset);
}
// and then continue the edit job as it were
......
......@@ -38,12 +38,15 @@ abstract class AbstractContactImporter {
}
// Shunt the root into the queue.
if (!isset($_SESSION["extractors"])) {
$_SESSION["extractors"] = array();
$extractors = Civi::settings()->get("extractors");
if ($extractors == NULL) {
$extractors = array();
}
$final_data = new ResourceStruct($resource_root, $rule, $filter, $group, $zone, $this->apikey, $this->endpoint);
$_SESSION["extractors"][] = serialize($final_data);
$extractors[] = serialize($final_data);
Civi::settings()->set("extractors", $extractors);
return $counter;
}
......
......@@ -66,11 +66,13 @@ class ActionNetworkContactImporter extends AbstractContactImporter {
$final_data = new ResourceStruct($data, $rule, $filter, $group, $zone, $this->apikey, "");
// Shunt the root into the queue.
if (!isset($_SESSION["extractors"])) {
$_SESSION["extractors"] = array();
$extractors = Civi::settings()->get("extractors");
if ($extractors == NULL) {
$extractors = array();
}
$_SESSION["extractors"][] = serialize($final_data);
$extractors[] = serialize($final_data);
Civi::settings()->set("extractors", $extractors);
$serialized_item = serialize($final_data);
return $serialized_item;
......
......@@ -68,11 +68,13 @@ class CiviCRMContactImporter extends AbstractContactImporter {
$final_data = new ResourceStruct($data, $rule, $filter, $group, $zone, $this->apikey, $this->endpoint);
// Shunt the root into the queue.
if (!isset($_SESSION["extractors"])) {
$_SESSION["extractors"] = array();
$extractors = Civi::settings()->get("extractors");
if ($extractors == NULL) {
$extractors = array();
}
$_SESSION["extractors"][] = serialize($final_data);
$extractors[] = serialize($final_data);
Civi::settings()->set("extractors", $extractors);
$serialized_item = serialize($final_data);
return $serialized_item;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment