Skip to content
Snippets Groups Projects
Commit d08883c8 authored by Erik Hommel's avatar Erik Hommel
Browse files

fix class_name property in BAO Condition and add countRuleConditions

parent 12f24ec8
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) {
......
...@@ -129,4 +129,17 @@ class CRM_Civirules_BAO_RuleCondition extends CRM_Civirules_DAO_RuleCondition { ...@@ -129,4 +129,17 @@ class CRM_Civirules_BAO_RuleCondition extends CRM_Civirules_DAO_RuleCondition {
} }
} }
/**
* Function to count the number of conditions for a rule
*
* @param int $ruleId
* @return int
* @access public
* @static
*/
public static function countConditionsForRule($ruleId) {
$ruleCondition = new CRM_Civirules_BAO_RuleCondition();
$ruleCondition->rule_id = $ruleId;
return $ruleCondition->count();
}
} }
\ No newline at end of file
...@@ -31,6 +31,7 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form { ...@@ -31,6 +31,7 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form {
*/ */
function preProcess() { function preProcess() {
$this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer'); $this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer');
$this->assign('countRuleConditions', CRM_Civirules_BAO_RuleCondition::countConditionsForRule($this->ruleId));
if ($this->_action == CRM_Core_Action::DELETE) { if ($this->_action == CRM_Core_Action::DELETE) {
$ruleConditionId = CRM_Utils_Request::retrieve('id', 'Integer'); $ruleConditionId = CRM_Utils_Request::retrieve('id', 'Integer');
CRM_Civirules_BAO_RuleCondition::deleteWithId($ruleConditionId); CRM_Civirules_BAO_RuleCondition::deleteWithId($ruleConditionId);
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<thead> <thead>
<tr> <tr>
<th>{ts}Link operator{/ts}</th> <th>{ts}Link operator{/ts}</th>
<th>{ts}Conidtion{/ts}</th> <th>{ts}Condition{/ts}</th>
<th>{ts}Description{/ts}</th> <th>{ts}Description{/ts}</th>
<th>&nbsp;</th> <th>&nbsp;</th>
</tr> </tr>
...@@ -17,9 +17,15 @@ ...@@ -17,9 +17,15 @@
{assign var="row_class" value="odd-row"} {assign var="row_class" value="odd-row"}
{foreach from=$ruleConditions key=ruleConditionIid item=ruleCondition} {foreach from=$ruleConditions key=ruleConditionIid item=ruleCondition}
<tr class={$row_class}> <tr class={$row_class}>
<td>{$ruleCondition.condition_link}</td> {if $countRuleConditions > 0}
<td>{$ruleCondition.condition_link}</td>
{/if}
<td>{$ruleCondition.name}</td> <td>{$ruleCondition.name}</td>
<td>{if !empty($ruleCondition.formattedConditionParams)}{$ruleCondition.formattedConditionParams}{/if}</td> <td>
{if !empty($ruleCondition.formattedConditionParams)}
{$ruleCondition.formattedConditionParams}
{/if}
</td>
<td> <td>
<span> <span>
{foreach from=$ruleCondition.actions item=action_link} {foreach from=$ruleCondition.actions item=action_link}
......
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