diff --git a/CRM/CivirulesConditions/AgeComparison.php b/CRM/CivirulesConditions/AgeComparison.php index 31bebc248aef5ac876497c28382c8b7d83a1a1c5..e7808b3827ecd0358ceef19320b8437cdeb1ac8c 100644 --- a/CRM/CivirulesConditions/AgeComparison.php +++ b/CRM/CivirulesConditions/AgeComparison.php @@ -1,27 +1,35 @@ <?php +/** + * Class for CiviRules AgeComparison (extending generic ValueComparison) + * + * @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org> + * @license AGPL-3.0 + */ class CRM_CivirulesConditions_AgeComparison extends CRM_CivirulesConditions_Generic_ValueComparison { /** * Returns value of the field * - * @param CRM_Civirules_EventData_EventData $eventData + * @param object CRM_Civirules_EventData_EventData $eventData * @return mixed + * @access protected */ protected function getFieldValue(CRM_Civirules_EventData_EventData $eventData) { - $birth_date = civicrm_api3('Contact', 'getvalue', array('id' => $eventData->getContactId(), 'return' => 'birth_date')); - if ($birth_date) { - $birthDate = new DateTime($birth_date); + $sourceBirthDate = civicrm_api3('Contact', 'getvalue', array('id' => $eventData->getContactId(), 'return' => 'birth_date')); + if ($sourceBirthDate) { + $birthDate = new DateTime($sourceBirthDate); return $birthDate->diff(new DateTime('now'))->y; } return false; //undefined birth date } /** - * Retruns a user friendly text explaining the condition params + * Returns a user friendly text explaining the condition params * e.g. 'Older than 65' * * @return string + * @access public */ public function userFriendlyConditionParams() { switch ($this->getOperator()) { @@ -54,6 +62,7 @@ class CRM_CivirulesConditions_AgeComparison extends CRM_CivirulesConditions_Gene * Returns an array with required entity names * * @return array + * @access public */ public function requiredEntities() { return array('contact'); diff --git a/CRM/CivirulesConditions/BirthdayChanged.php b/CRM/CivirulesConditions/BirthdayChanged.php index 99e2605936384583258c98a7ad119b02a05f8797..a67f363db3dc4346a1f242cca61633fa4d64864d 100644 --- a/CRM/CivirulesConditions/BirthdayChanged.php +++ b/CRM/CivirulesConditions/BirthdayChanged.php @@ -1,4 +1,10 @@ <?php +/** + * Class for CiviRules AgeComparison (extending generic ValueComparison) + * + * @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org> + * @license AGPL-3.0 + */ class CRM_CivirulesConditions_BirthdayChanged extends CRM_CivirulesConditions_Generic_FieldChanged { @@ -6,6 +12,7 @@ class CRM_CivirulesConditions_BirthdayChanged extends CRM_CivirulesConditions_Ge * Returns name of entity * * @return string + * @access protected */ protected function getEntity() { return 'contact'; @@ -13,14 +20,16 @@ class CRM_CivirulesConditions_BirthdayChanged extends CRM_CivirulesConditions_Ge /** * Returns name of the field + * * @return string + * @access protected */ protected function getField() { return 'birth_date'; } /** - * This function could be overridden in subclasses to + * This method could be overridden in subclasses to * transform field data to a certain type * * E.g. a date field could be transformed to a DataTime object so that @@ -28,6 +37,7 @@ class CRM_CivirulesConditions_BirthdayChanged extends CRM_CivirulesConditions_Ge * * @param $fieldData * @return mixed + * @access protected */ protected function transformFieldData($fieldData) { return new DateTime($fieldData); diff --git a/CRM/CivirulesConditions/PrimaryEmailChanged.php b/CRM/CivirulesConditions/PrimaryEmailChanged.php index 737b77d50ef4f21b3a046004c65dd85f7ef6d055..78b92478030256756244c3e70ca727f2903aceed 100644 --- a/CRM/CivirulesConditions/PrimaryEmailChanged.php +++ b/CRM/CivirulesConditions/PrimaryEmailChanged.php @@ -1,4 +1,10 @@ <?php +/** + * Class for CiviRules Primary Email Changed condition (extending generic FieldChanged) + * + * @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org> + * @license AGPL-3.0 + */ class CRM_CivirulesConditions_PrimaryEmailChanged extends CRM_CivirulesConditions_Generic_FieldChanged { @@ -6,6 +12,7 @@ class CRM_CivirulesConditions_PrimaryEmailChanged extends CRM_CivirulesCondition * Returns name of entity * * @return string + * @access protected */ protected function getEntity() { return 'Email'; @@ -13,13 +20,21 @@ class CRM_CivirulesConditions_PrimaryEmailChanged extends CRM_CivirulesCondition /** * Returns name of the field + * * @return string + * @access protected */ protected function getField() { return 'email'; } - + /** + * Method to check if the condition is valid + * + * @param object CRM_Civirules_EventData_EventData $eventData + * @return bool + * @access public + */ public function isConditionValid(CRM_Civirules_EventData_EventData $eventData) { $isValid = parent::isConditionValid($eventData); if ($isValid) { @@ -32,5 +47,4 @@ class CRM_CivirulesConditions_PrimaryEmailChanged extends CRM_CivirulesCondition } return $isValid; } - } \ No newline at end of file diff --git a/CRM/CivirulesCronEvent/Birthday.php b/CRM/CivirulesCronEvent/Birthday.php index 317c635faf8fb3a27fc0d7319891380fb1cd8c60..724f9b88835ea6413159737f68eabbc3dabb748f 100644 --- a/CRM/CivirulesCronEvent/Birthday.php +++ b/CRM/CivirulesCronEvent/Birthday.php @@ -1,15 +1,22 @@ <?php +/** + * Class for CiviRules CronEvent Birthday + * + * @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org> + * @license AGPL-3.0 + */ class CRM_CivirulesCronEvent_Birthday extends CRM_Civirules_Event_Cron { private $dao = false; /** - * This function returns a CRM_Civirules_EventData_EventData this entity is used for triggering the rule + * This method returns a CRM_Civirules_EventData_EventData this entity is used for triggering the rule * * Return false when no next entity is available * - * @return CRM_Civirules_EventData_EventData|false + * @return object|bool CRM_Civirules_EventData_EventData|false + * @access protected */ protected function getNextEntityEventData() { if (!$this->dao) { @@ -24,6 +31,11 @@ class CRM_CivirulesCronEvent_Birthday extends CRM_Civirules_Event_Cron { return false; } + /** + * Method to query event entities + * + * @access private + */ private function queryForEventEntities() { $sql = "SELECT c.* FROM `civicrm_contact` `c`