add comments and style code
This commit is contained in:
parent
85afeedd23
commit
c7eca6f641
2 changed files with 27 additions and 7 deletions
|
@ -103,7 +103,14 @@ class TwingleApiCall {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param $values
|
||||
*
|
||||
* Synchronizes projects between Twingle and CiviCRM (both directions)
|
||||
* based on the timestamp.
|
||||
*
|
||||
* @param array $values
|
||||
*
|
||||
* If true: don't do any changes
|
||||
* @param bool $is_test
|
||||
*
|
||||
* @return array|null
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
|
@ -182,7 +189,7 @@ class TwingleApiCall {
|
|||
private function curlPost($url, $data) {
|
||||
$curl = curl_init($url);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
curl_setopt($curl, CURLOPT_POST, true);
|
||||
curl_setopt($curl, CURLOPT_POST, TRUE);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||
"x-access-code: $this->apiKey",
|
||||
'Content-Type: application/json',
|
||||
|
|
|
@ -52,7 +52,8 @@ class TwingleProject {
|
|||
if ($translate) {
|
||||
$this->values = $this->translateValues(TRUE);
|
||||
$this->id = $values['id'];
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Format data types for import into CiviCRM
|
||||
$this->formatForImport($this->values);
|
||||
}
|
||||
|
@ -91,6 +92,10 @@ class TwingleProject {
|
|||
/**
|
||||
* Create the project as a campaign in CiviCRM if it does not exist
|
||||
*
|
||||
* If true: don't do any changes
|
||||
*
|
||||
* @param bool $is_test
|
||||
*
|
||||
* @return array
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
|
@ -99,7 +104,7 @@ class TwingleProject {
|
|||
// Translate $value keys to custom field names
|
||||
$translatedValues = $this->translateValues();
|
||||
|
||||
// Create project if it does not exist yet and give back the result
|
||||
// Create campaign if it does not already exist and give back the result
|
||||
if (!$this->exists()) {
|
||||
if (!$is_test) {
|
||||
$result = civicrm_api3('Campaign', 'create', $translatedValues);
|
||||
|
@ -309,6 +314,10 @@ class TwingleProject {
|
|||
$values['last_update'] = $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
// Change name to title
|
||||
$values['title'] = $values['name'];
|
||||
unset($values['name']);
|
||||
|
||||
// Change event type empty string into 'default'
|
||||
if ($values['type'] == '') {
|
||||
$values['type'] = 'default';
|
||||
|
@ -328,6 +337,10 @@ class TwingleProject {
|
|||
$values['last_update'] = $date->getTimestamp();
|
||||
}
|
||||
|
||||
// Change title to name
|
||||
$values['name'] = $values['title'];
|
||||
unset($values['title']);
|
||||
|
||||
// Change event type 'default' into empty string
|
||||
if ($values['type'] == 'default') {
|
||||
$values['type'] = '';
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue