Skip to content
Snippets Groups Projects
Commit 54242e43 authored by jaapjansma's avatar jaapjansma
Browse files

refactored findRulesByObjectNameAndOp to use cron=0 rathher than empty class name

parent df7f3bc8
No related branches found
No related tags found
No related merge requests found
......@@ -167,7 +167,7 @@ class CRM_Civirules_BAO_Rule extends CRM_Civirules_DAO_Rule {
$sql = "SELECT r.id AS rule_id, e.id AS event_id
FROM `civirule_rule` r
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 OR e.class_name = '') AND e.object_name = %1 AND e.op = %2";
WHERE r.`is_active` = 1 AND e.cron = 0 AND e.object_name = %1 AND e.op = %2";
$params[1] = array($objectName, 'String');
$params[2] = array($op, 'String');
......
<?php
class CRM_Civirules_Event_Cron {
}
\ No newline at end of file
......@@ -18,6 +18,7 @@ class CRM_Civirules_Upgrader extends CRM_Civirules_Upgrader_Base {
$this->executeSqlFile('sql/createCiviruleRule.sql');
$this->executeSqlFile('sql/createCiviruleRuleAction.sql');
$this->executeSqlFile('sql/createCiviruleRuleCondition.sql');
$this->executeSqlFile('sql/createCiviruleRuleLog.sql');
$this->addCondition('CRM_CivirulesConditions_PrimaryEmailChanged', 'primary_email_changed', ts('Primary e-mail addres is changed'));
$this->addCondition('CRM_CivirulesConditions_AgeComparison', 'age_comparison', ts('Age comparison'));
......
<?php
// This file declares a managed database record of type "Job".
// The record will be automatically inserted, updated, or deleted from the
// database as appropriate. For more details, see "hook_civicrm_managed" at:
// http://wiki.civicrm.org/confluence/display/CRMDOC42/Hook+Reference
return array (
0 =>
array (
'name' => 'Cron:Civirules.Cron',
'entity' => 'Job',
'params' =>
array (
'version' => 3,
'name' => 'Civirules cron',
'description' => 'Trigger civirules cron events',
'run_frequency' => 'Always',
'api_entity' => 'Civirules',
'api_action' => 'Cron',
'parameters' => '',
),
),
);
\ No newline at end of file
<?php
/**
* Civirules.Cron API specification (optional)
* This is used for documentation and validation.
*
* @param array $spec description of fields supported by this API call
* @return void
* @see http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
*/
function _civicrm_api3_civirules_cron_spec(&$spec) {
//there are no parameters for the civirules cron
}
/**
* Civirules.Cron API
*
* @param array $params
* @return array API result descriptor
* @see civicrm_api3_create_success
* @see civicrm_api3_create_error
* @throws API_Exception
*/
function civicrm_api3_civirules_cron($params) {
$returnValues = array();
return civicrm_api3_create_success($returnValues, $params, 'Civirules', 'cron');
}
CREATE TABLE IF NOT EXISTS civirule_rule_log (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
rule_id INT UNSIGNED NULL,
contact_id INT UNSIGNED NULL,
log_date DATETIME NOT NULL,
PRIMARY KEY (id),
INDEX rule_idx (rule_id ASC),
INDEX contact_idx (contact_id ASC),
INDEX rule_contact_idx (rule_id ASC, contact_id ASC))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_general_ci
DROP TABLE IF EXISTS `civirule_rule_action`;
DROP TABLE IF EXISTS `civirule_rule_condition`;
DROP TABLE IF EXISTS `civirule_rule_log`;
DROP TABLE IF EXISTS `civirule_rule`;
DROP TABLE IF EXISTS `civirule_action`;
DROP TABLE IF EXISTS `civirule_condition`;
DROP TABLE IF EXISTS `civirule_event`;
\ 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