format & comment code
This commit is contained in:
parent
e923ba91dc
commit
12d31e300f
2 changed files with 33 additions and 10 deletions
|
@ -8,20 +8,35 @@ use CRM_TwingleCampaign_ExtensionUtil as E;
|
|||
class CustomField {
|
||||
|
||||
private $id;
|
||||
|
||||
private $custom_group_id;
|
||||
|
||||
private $label;
|
||||
|
||||
private $name;
|
||||
|
||||
private $is_required;
|
||||
|
||||
private $is_searchable;
|
||||
|
||||
private $data_type;
|
||||
|
||||
private $html_type;
|
||||
|
||||
private $option_values;
|
||||
|
||||
private $text_length;
|
||||
|
||||
private $is_active;
|
||||
|
||||
private $is_view;
|
||||
|
||||
private $weight;
|
||||
|
||||
private $help_post;
|
||||
|
||||
private $default_value;
|
||||
|
||||
private $result;
|
||||
|
||||
/**
|
||||
|
@ -50,12 +65,11 @@ class CustomField {
|
|||
'get',
|
||||
[
|
||||
'sequential' => 1,
|
||||
'name' => $this->getName()
|
||||
'name' => $this->getName(),
|
||||
]
|
||||
);
|
||||
|
||||
if ($field['count'] == 0)
|
||||
{
|
||||
if ($field['count'] == 0) {
|
||||
$this->result = civicrm_api3(
|
||||
'CustomField',
|
||||
'create',
|
||||
|
@ -101,6 +115,8 @@ class CustomField {
|
|||
}
|
||||
|
||||
/**
|
||||
* Alter a custom field
|
||||
*
|
||||
* @param $values
|
||||
*
|
||||
* @return bool
|
||||
|
@ -122,7 +138,7 @@ class CustomField {
|
|||
/**
|
||||
* @param $name
|
||||
*
|
||||
* @return \CRM\TwingleCampaign\Models\CustomField
|
||||
* @return array|\CRM\TwingleCampaign\Models\CustomField
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public static function fetch($name = NULL) {
|
||||
|
@ -163,6 +179,11 @@ class CustomField {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a custom field
|
||||
*
|
||||
* @throws \CiviCRM_API3_Exception
|
||||
*/
|
||||
public function delete() {
|
||||
$this->result = civicrm_api3(
|
||||
'CustomField',
|
||||
|
|
|
@ -35,7 +35,9 @@ class TwingleProject {
|
|||
*/
|
||||
public function __construct(array $values) {
|
||||
|
||||
$this->timestamp = $values['last_update'];
|
||||
$this->values = $values;
|
||||
|
||||
$this->project_id = $values['project_id'];
|
||||
|
||||
// Format data types of the values for import into CiviCRM
|
||||
$this->formatForImport($values);
|
||||
|
@ -46,7 +48,7 @@ class TwingleProject {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get all related custom fields as CustomField objects in an static array.
|
||||
* Get custom field mapping.
|
||||
* This function will be fully executed only once, when the TwingleProject
|
||||
* class gets instantiated for the first time.
|
||||
*
|
||||
|
@ -142,12 +144,12 @@ class TwingleProject {
|
|||
|
||||
// Change timestamp into DateTime string
|
||||
if (!empty($values['last_update'])) {
|
||||
$date = DateTime::createFromFormat('U', $values['last_update'] );
|
||||
$date = DateTime::createFromFormat('U', $values['last_update']);
|
||||
$values['last_update'] = $date->format('Y-m-d H:i:s');
|
||||
}
|
||||
|
||||
// Change event type empty string into 'default'
|
||||
if ($values['type'] == ''){
|
||||
if ($values['type'] == '') {
|
||||
$values['type'] = 'default';
|
||||
}
|
||||
}
|
||||
|
@ -161,12 +163,12 @@ class TwingleProject {
|
|||
|
||||
// Change DateTime string into timestamp
|
||||
if (!empty($values['last_update'])) {
|
||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $values['last_update'] );
|
||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $values['last_update']);
|
||||
$values['last_update'] = $date->getTimestamp();
|
||||
}
|
||||
|
||||
// Change event type 'default' into empty string
|
||||
if ($values['type'] == 'default'){
|
||||
if ($values['type'] == 'default') {
|
||||
$values['type'] = '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue