Skip to content
Snippets Groups Projects
Commit 89596af3 authored by jaapjansma's avatar jaapjansma
Browse files

update add primary email changed condition

parent 53abeaf8
No related branches found
No related tags found
No related merge requests found
...@@ -150,7 +150,7 @@ class CRM_Civirules_BAO_Condition extends CRM_Civirules_DAO_Condition { ...@@ -150,7 +150,7 @@ class CRM_Civirules_BAO_Condition extends CRM_Civirules_DAO_Condition {
return false; return false;
} }
$className = $condition->className; $className = $condition->class_name;
if (!class_exists($className)) { if (!class_exists($className)) {
if ($abort) { if ($abort) {
......
...@@ -164,9 +164,10 @@ class CRM_Civirules_BAO_Rule extends CRM_Civirules_DAO_Rule { ...@@ -164,9 +164,10 @@ class CRM_Civirules_BAO_Rule extends CRM_Civirules_DAO_Rule {
$sql = "SELECT r.id AS rule_id, e.id AS event_id $sql = "SELECT r.id AS rule_id, e.id AS event_id
FROM `civirule_rule` r FROM `civirule_rule` r
INNER JOIN `civirule_event` e ON r.event_id = e.id AND e.is_active = 1 INNER JOIN `civirule_event` e ON r.event_id = e.id AND e.is_active = 1
WHERE r.`is_active` = 1 AND e.class_name IS NULL AND e.entity = %1 AND e.action = %2"; WHERE r.`is_active` = 1 AND (e.class_name IS NULL OR e.class_name = '') AND e.entity = %1 AND e.action = %2";
$params[1] = array($entity, 'String'); $params[1] = array($entity, 'String');
$params[2] = array($action, 'String'); $params[2] = array($action, 'String');
$dao = CRM_Core_DAO::executeQuery($sql, $params); $dao = CRM_Core_DAO::executeQuery($sql, $params);
while ($dao->fetch()) { while ($dao->fetch()) {
$rule_data = array( $rule_data = array(
......
<?php
class CRM_CivirulesConditions_PrimaryEmailChanged extends CRM_CivirulesConditions_Generic_FieldChanged {
/**
* Returns name of entity
*
* @return string
*/
protected function getEntity() {
return 'Email';
}
/**
* Returns name of the field
* @return string
*/
protected function getField() {
return 'email';
}
public function isConditionValid(CRM_Civirules_EventData_EventData $eventData) {
$isValid = parent::isConditionValid($eventData);
if ($isValid) {
$data = $eventData->getEntityData($this->getEntity());
if (!empty($data['is_primary'])) {
$isValid = true;
} else {
$isValid = false;
}
}
return $isValid;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment