update project values & options from Twingle
This commit is contained in:
parent
5ed2f30133
commit
4c6827b451
2 changed files with 22 additions and 4 deletions
|
@ -191,13 +191,16 @@ class TwingleProject {
|
||||||
* @param array $values
|
* @param array $values
|
||||||
* Array with values to update
|
* Array with values to update
|
||||||
*
|
*
|
||||||
|
* @param array $options
|
||||||
|
* Array with options to update
|
||||||
|
*
|
||||||
* @param string $origin
|
* @param string $origin
|
||||||
* Origin of the array. It can be one of two constants:
|
* Origin of the array. It can be one of two constants:
|
||||||
* TwingleProject::TWINGLE|CIVICRM
|
* TwingleProject::TWINGLE|CIVICRM
|
||||||
*
|
*
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
*/
|
*/
|
||||||
public function update(array $values, array $options, string $origin) {
|
public function update(array $values, array $options, string $origin = NULL) {
|
||||||
|
|
||||||
if ($origin == self::TWINGLE) {
|
if ($origin == self::TWINGLE) {
|
||||||
// Format values and translate keys
|
// Format values and translate keys
|
||||||
|
@ -314,14 +317,27 @@ class TwingleProject {
|
||||||
// project's attributes must be updated from the campaign
|
// project's attributes must be updated from the campaign
|
||||||
if ($result['count'] == 1) {
|
if ($result['count'] == 1) {
|
||||||
|
|
||||||
|
// Set campaign id attribute
|
||||||
|
$this->id = $result['values'][0]['id'];
|
||||||
|
|
||||||
|
// Translate custom field names back
|
||||||
|
self::translateCustomFields($result['values'][0], self::OUT);
|
||||||
|
|
||||||
|
// Translate keys from CiviCRM format to Twingle format
|
||||||
|
self::translateKeys($result['values'][0], self::OUT);
|
||||||
|
|
||||||
// Split result array into project values and options
|
// Split result array into project values and options
|
||||||
$values_and_options = self::splitValues($result['values'][0]);
|
$values_and_options = self::splitValues($result['values'][0]);
|
||||||
|
|
||||||
|
// Translate keys from Twingle format to CiviCRM format
|
||||||
|
self::translateKeys($values_and_options['values'], self::IN);
|
||||||
|
self::translateKeys($values_and_options['options'], self::IN);
|
||||||
|
|
||||||
// Set attributes to the values of the existing TwingleProject campaign
|
// Set attributes to the values of the existing TwingleProject campaign
|
||||||
|
// to reflect the state of the actual campaign in the database
|
||||||
$this->update(
|
$this->update(
|
||||||
$values_and_options['values'],
|
$values_and_options['values'],
|
||||||
$values_and_options['options'],
|
$values_and_options['options']
|
||||||
self::CIVICRM
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
{
|
{
|
||||||
"project": [
|
"project": [
|
||||||
"id",
|
"id",
|
||||||
|
"identifier",
|
||||||
"allow_more",
|
"allow_more",
|
||||||
"name",
|
"name",
|
||||||
"organisation_id",
|
"organisation_id",
|
||||||
"project_target",
|
"project_target",
|
||||||
"transaction_type",
|
"transaction_type",
|
||||||
"type"
|
"type",
|
||||||
|
"last_update"
|
||||||
],
|
],
|
||||||
"event": [
|
"event": [
|
||||||
],
|
],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue