Merge branch 'dev' into main
This commit is contained in:
commit
e23e0d7e8d
2 changed files with 22 additions and 55 deletions
|
@ -17,32 +17,31 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
|
|
||||||
private $values;
|
private $values;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## TwingleCampaign constructor
|
* ## TwingleCampaign constructor
|
||||||
*
|
*
|
||||||
* @param array|null $values
|
* @param array $values
|
||||||
* @param int|null $id
|
|
||||||
*
|
*
|
||||||
* @throws \CiviCRM_API3_Exception
|
* @throws \CiviCRM_API3_Exception
|
||||||
*/
|
*/
|
||||||
public function __construct(array $values = [], int $id = NULL) {
|
public function __construct(array $values = []) {
|
||||||
|
|
||||||
$this->prefix = 'twingle_campaign_';
|
$this->prefix = 'twingle_campaign_';
|
||||||
$this->id = $id ?? NULL;
|
$this->id = $values['id'] ?? NULL;
|
||||||
$this->values['campaign_type_id'] = 'twingle_campaign';
|
$this->values['campaign_type_id'] = 'twingle_campaign';
|
||||||
|
|
||||||
|
if ($this->id != NULL) {
|
||||||
|
$this->fetch($this->id);
|
||||||
|
}
|
||||||
$this->update($values);
|
$this->update($values);
|
||||||
|
|
||||||
$this->getParentProject();
|
$this->getParentProject();
|
||||||
if (!isset($this->values['cid'])) {
|
if (!isset($this->values['cid'])) {
|
||||||
$this->createCid();
|
$this->createCid();
|
||||||
}
|
}
|
||||||
$this->createUrl();
|
$this->createUrl();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Create TwingleCampaign
|
* ## Create TwingleCampaign
|
||||||
* Create this TwingleCampaign as a campaign in CiviCRM
|
* Create this TwingleCampaign as a campaign in CiviCRM
|
||||||
|
@ -69,19 +68,17 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Fetch TwingleCampaign
|
* ## Fetch TwingleCampaign
|
||||||
* Populate this instance with values from an existing TwingleCampaign.
|
* Populate this instance with values from an existing TwingleCampaign.
|
||||||
*
|
*
|
||||||
* @throws CiviCRM_API3_Exception
|
* @throws CiviCRM_API3_Exception
|
||||||
*/
|
*/
|
||||||
public function fetch() {
|
public function fetch(int $id) {
|
||||||
$this->values = civicrm_api3('TwingleCampaign', 'getsingle',
|
$this->values = civicrm_api3('TwingleCampaign', 'getsingle',
|
||||||
['id' => $this->id]);
|
['id' => $id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Get Parent Project
|
* ## Get Parent Project
|
||||||
* Determines the id of the parent TwingleProject. If there is no parent
|
* Determines the id of the parent TwingleProject. If there is no parent
|
||||||
|
@ -128,7 +125,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Set parent_project_id and retrieve parent_project_url
|
// Set parent_project_id and retrieve parent_project_url
|
||||||
if ($parent_campaign_type_id == $twingle_project_campaign_type_id) {
|
if ($parent_campaign_type_id == $twingle_project_campaign_type_id) {
|
||||||
$this->values['parent_project_id'] = $parent_id;
|
$this->values['parent_project_id'] = $parent_id;
|
||||||
|
@ -205,7 +201,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
$this->values['parent_project_url'] . '?tw_cid=' . $this->values['cid'];
|
$this->values['parent_project_url'] . '?tw_cid=' . $this->values['cid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -214,7 +209,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
$this->values['cid'] = uniqid();
|
$this->values['cid'] = uniqid();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Translate field names and custom field names
|
* ## Translate field names and custom field names
|
||||||
*
|
*
|
||||||
|
@ -283,7 +277,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Delete TwingleCampaign
|
* ## Delete TwingleCampaign
|
||||||
* Deletes this TwingleCampaign from CiviCRM
|
* Deletes this TwingleCampaign from CiviCRM
|
||||||
|
@ -303,7 +296,6 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ## Get a response
|
* ## Get a response
|
||||||
* Get a response that describes the status of this TwingleCampaign instance.
|
* Get a response that describes the status of this TwingleCampaign instance.
|
||||||
|
@ -380,5 +372,4 @@ class CRM_TwingleCampaign_BAO_TwingleCampaign {
|
||||||
return (int) $this->id;
|
return (int) $this->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,9 +7,9 @@
|
||||||
* extension.
|
* extension.
|
||||||
*/
|
*/
|
||||||
class CRM_TwingleCampaign_ExtensionUtil {
|
class CRM_TwingleCampaign_ExtensionUtil {
|
||||||
const SHORT_NAME = "twinglecampaign";
|
const SHORT_NAME = 'twinglecampaign';
|
||||||
const LONG_NAME = "de.forumzfd.twinglecampaign";
|
const LONG_NAME = 'de.forumzfd.twinglecampaign';
|
||||||
const CLASS_PREFIX = "CRM_TwingleCampaign";
|
const CLASS_PREFIX = 'CRM_TwingleCampaign';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a string using the extension's domain.
|
* Translate a string using the extension's domain.
|
||||||
|
@ -193,7 +193,8 @@ function _twinglecampaign_civix_civicrm_disable() {
|
||||||
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
|
* @param $op string, the type of operation being performed; 'check' or 'enqueue'
|
||||||
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
|
* @param $queue CRM_Queue_Queue, (for 'enqueue') the modifiable list of pending up upgrade tasks
|
||||||
*
|
*
|
||||||
* @return mixed based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
|
* @return mixed
|
||||||
|
* based on op. for 'check', returns array(boolean) (TRUE if upgrades are pending)
|
||||||
* for 'enqueue', returns void
|
* for 'enqueue', returns void
|
||||||
*
|
*
|
||||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_upgrade
|
||||||
|
@ -220,41 +221,18 @@ function _twinglecampaign_civix_upgrader() {
|
||||||
* Search directory tree for files which match a glob pattern.
|
* Search directory tree for files which match a glob pattern.
|
||||||
*
|
*
|
||||||
* Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
|
* Note: Dot-directories (like "..", ".git", or ".svn") will be ignored.
|
||||||
* Note: In Civi 4.3+, delegate to CRM_Utils_File::findFiles()
|
* Note: Delegate to CRM_Utils_File::findFiles(), this function kept only
|
||||||
|
* for backward compatibility of extension code that uses it.
|
||||||
*
|
*
|
||||||
* @param string $dir base dir
|
* @param string $dir base dir
|
||||||
* @param string $pattern , glob pattern, eg "*.txt"
|
* @param string $pattern , glob pattern, eg "*.txt"
|
||||||
*
|
*
|
||||||
* @return array(string)
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _twinglecampaign_civix_find_files($dir, $pattern) {
|
function _twinglecampaign_civix_find_files($dir, $pattern) {
|
||||||
if (is_callable(['CRM_Utils_File', 'findFiles'])) {
|
|
||||||
return CRM_Utils_File::findFiles($dir, $pattern);
|
return CRM_Utils_File::findFiles($dir, $pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
$todos = [$dir];
|
|
||||||
$result = [];
|
|
||||||
while (!empty($todos)) {
|
|
||||||
$subdir = array_shift($todos);
|
|
||||||
foreach (_twinglecampaign_civix_glob("$subdir/$pattern") as $match) {
|
|
||||||
if (!is_dir($match)) {
|
|
||||||
$result[] = $match;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($dh = opendir($subdir)) {
|
|
||||||
while (FALSE !== ($entry = readdir($dh))) {
|
|
||||||
$path = $subdir . DIRECTORY_SEPARATOR . $entry;
|
|
||||||
if ($entry{0} == '.') {
|
|
||||||
}
|
|
||||||
elseif (is_dir($path)) {
|
|
||||||
$todos[] = $path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($dh);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* (Delegated) Implements hook_civicrm_managed().
|
* (Delegated) Implements hook_civicrm_managed().
|
||||||
*
|
*
|
||||||
|
@ -362,7 +340,7 @@ function _twinglecampaign_civix_civicrm_themes(&$themes) {
|
||||||
* @link http://php.net/glob
|
* @link http://php.net/glob
|
||||||
* @param string $pattern
|
* @param string $pattern
|
||||||
*
|
*
|
||||||
* @return array, possibly empty
|
* @return array
|
||||||
*/
|
*/
|
||||||
function _twinglecampaign_civix_glob($pattern) {
|
function _twinglecampaign_civix_glob($pattern) {
|
||||||
$result = glob($pattern);
|
$result = glob($pattern);
|
||||||
|
@ -470,8 +448,6 @@ function _twinglecampaign_civix_civicrm_alterSettingsFolders(&$metaDataFolders =
|
||||||
*
|
*
|
||||||
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
|
* @link https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_entityTypes
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function _twinglecampaign_civix_civicrm_entityTypes(&$entityTypes) {
|
function _twinglecampaign_civix_civicrm_entityTypes(&$entityTypes) {
|
||||||
$entityTypes = array_merge($entityTypes, array (
|
$entityTypes = array_merge($entityTypes, []);
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue