public function setEventId($eventId) { parent::setEventId($eventId); $event = new CRM_Civirules_BAO_Event(); $event->id = $this->eventId; if (!$event->find(true)) { throw new Exception('Civirules: could not find event with ID: ' . $this->eventId); } $this->objectName = $event->object_name; $this->op = $event->op; }
/** * @param $fields */ static function validateConditionEntities($fields) { $conditionClass = CRM_Civirules_BAO_Condition::getConditionObjectById($fields['rule_condition_select'], false); if (!$conditionClass) { $errors['rule_condition_select'] = ts('Not a valid condition, condition class is missing'); return $errors; } $requiredEntities = $conditionClass->requiredEntities(); $rule = new CRM_Civirules_BAO_Rule(); $rule->id = $fields['rule_id']; $rule->find(true); $event = new CRM_Civirules_BAO_Event(); $event->id = $rule->event_id; $event->find(true); $eventObject = CRM_Civirules_BAO_Event::getPostEventObjectByClassName($event->class_name, true); $eventObject->setEventId($event->id); $availableEntities = array(); foreach ($eventObject->getProvidedEntities() as $entityDef) { $availableEntities[] = strtolower($entityDef->entity); } foreach ($requiredEntities as $entity) { if (!in_array(strtolower($entity), $availableEntities)) { $errors['rule_condition_select'] = ts('This condition is not available with event %1', array(1 => $event->label)); return $errors; } } return true; }
/** * Function to retrieve the label of an event with eventId * * @param int $eventId * @return string $event->label * @access public * @static */ public static function getEventLabelWithId($eventId) { if (empty($eventId)) { return ''; } $event = new CRM_Civirules_BAO_Event(); $event->id = $eventId; $event->find(true); return $event->label; }