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

added condition_params in DAO & BAO and removes for Action and Condition

parent 1cc515fb
Branches
Tags
No related merge requests found
......@@ -47,6 +47,10 @@ class CRM_Civirules_DAO_RuleCondition extends CRM_Core_DAO {
'name' => 'condition_id',
'type' => CRM_Utils_Type::T_INT
),
'condition_params' => array(
'name' => 'condition_params',
'type' => CRM_Utils_Type::T_BLOB
),
'is_active' => array(
'name' => 'is_active',
'type' => CRM_Utils_Type::T_INT,
......@@ -69,6 +73,7 @@ class CRM_Civirules_DAO_RuleCondition extends CRM_Core_DAO {
'rule_id' => 'rule_id',
'condition_link' => 'condition_link',
'condition_id' => 'condition_id',
'condition_params' => 'condition_params',
'is_active' => 'is_active'
);
}
......
......@@ -160,7 +160,7 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
* @access protected
*/
protected function createFormElements() {
$this->add('hidden', 'id', ts('RuleId'));
$this->add('hidden', 'id', ts('RuleId'), array('id' => 'ruleId'));
$this->add('text', 'rule_label', ts('Name'), array('size' => CRM_Utils_Type::HUGE), TRUE);
$this->add('checkbox', 'rule_is_active', ts('Enabled'));
$this->add('text', 'rule_created_date', ts('Created Date'));
......@@ -282,9 +282,9 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
*/
protected function setRuleConditionActions($ruleConditionId) {
$conditionActions = array();
$deleteUrl = CRM_Utils_System::url('civicrm/civirule/form/rulecondition', 'reset=1&action=delete&id='.
$ruleConditionId);
$conditionActions[] = '<a class="action-item" title="Delete" href="'.$deleteUrl.'">Remove</a>';
$removeUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_condition', 'reset=1&action=delete&rid='
.$this->ruleId.'&id='.$ruleConditionId);
$conditionActions[] = '<a class="action-item" title="Remove" href="'.$removeUrl.'">Remove</a>';
return $conditionActions;
}
......@@ -297,9 +297,9 @@ class CRM_Civirules_Form_Rule extends CRM_Core_Form {
*/
protected function setRuleActionActions($ruleActionId) {
$actionActions = array();
$deleteUrl = CRM_Utils_System::url('civicrm/civirule/form/ruleaction', 'reset=1&action=delete&id='.
$ruleActionId);
$actionActions[] = '<a class="action-item" title="Delete" href="'.$deleteUrl.'">Remove</a>';
$removeUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=delete&rid='
.$this->ruleId.'&id='.$ruleActionId);
$actionActions[] = '<a class="action-item" title="Remove" href="'.$removeUrl.'">Remove</a>';
return $actionActions;
}
......
......@@ -31,6 +31,12 @@ class CRM_Civirules_Form_RuleAction extends CRM_Core_Form {
*/
function preProcess() {
$this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer');
if ($this->_action == CRM_Core_Action::DELETE) {
$ruleActionId = CRM_Utils_Request::retrieve('id', 'Integer');
CRM_Civirules_BAO_RuleAction::deleteWithId($ruleActionId);
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->ruleId, TRUE);
CRM_Utils_System::redirect($redirectUrl);
}
}
/**
......
......@@ -31,6 +31,12 @@ class CRM_Civirules_Form_RuleCondition extends CRM_Core_Form {
*/
function preProcess() {
$this->ruleId = CRM_Utils_Request::retrieve('rid', 'Integer');
if ($this->_action == CRM_Core_Action::DELETE) {
$ruleConditionId = CRM_Utils_Request::retrieve('id', 'Integer');
CRM_Civirules_BAO_RuleCondition::deleteWithId($ruleConditionId);
$redirectUrl = CRM_Utils_System::url('civicrm/civirule/form/rule', 'action=update&id='.$this->ruleId, TRUE);
CRM_Utils_System::redirect($redirectUrl);
}
}
/**
......
......@@ -3,6 +3,7 @@ CREATE TABLE IF NOT EXISTS civirule_rule_condition (
rule_id INT UNSIGNED NULL,
condition_link VARCHAR(3) NULL,
condition_id INT UNSIGNED NULL,
condition_params BLOB,
is_active TINYINT NULL DEFAULT 1,
PRIMARY KEY (id),
UNIQUE INDEX id_UNIQUE (id ASC),
......
......@@ -13,9 +13,11 @@
</tr>
</thead>
<tbody>
{assign var="row_class" value="odd-row"}
{assign var="rowClass" value="odd_row"}
{assign var="rowNumber" value=1}
{foreach from=$ruleActions key=action_id item=ruleAction}
<tr id="row1" class={$row_class}>
<tr id="row_{$rowNumber}" class={$rowClass}>
<td hidden="1" id="ruleActionId">{$ruleAction.id}</td>
<td>{$ruleAction.label}</td>
{if !empty($ruleAction.action_params)}
<td>{$ruleAction.action_params}</td>
......@@ -24,17 +26,18 @@
{/if}
<td>
<span>
{foreach from=$ruleAction.actions item=action_link}
{$action_link}
{foreach from=$ruleAction.actions item=actionLink}
{$actionLink}
{/foreach}
</span>
</td>
</tr>
{if $row_class eq "odd-row"}
{assign var="row_class" value="even-row"}
{if $row_class eq "odd_row"}
{assign var="rowClass" value="even-row"}
{else}
{assign var="row_class" value="odd-row"}
{/if}
{assign var="rowNumber" value=$rowNumber+1}
{/foreach}
</tbody>
</table>
......@@ -45,3 +48,4 @@
<span><div class="icon add-icon"></div>Add Action</span></a>
</div>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment