/** * Function to set the actions for each rule action * * @param int $ruleActionId * @param CRM_Civirules_Action $action * @return array * @access protected */ protected function setRuleActionActions($ruleActionId, CRM_Civirules_Action $action) { $actionActions = array(); $delaySettingsUrl = CRM_Utils_System::url('civicrm/civirule/form/rule_action', 'reset=1&action=update&rid=' . $this->ruleId . '&id=' . $ruleActionId); $actionActions[] = '<a class="action-item" title="Edit delay settings" href="' . $delaySettingsUrl . '">' . ts('Edit delay') . '</a>'; $editUrl = $action->getExtraDataInputUrl($ruleActionId); if (!empty($editUrl)) { $actionActions[] = '<a class="action-item" title="Edit" href="' . $editUrl . '">' . ts('Edit') . '</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; }
/** * Returns false when action could not be delayed or return a DateTime * This DateTime object holds the date and time till when the action should be delayed * * The delay is calculated by a separate delay class. See CRM_Civirules_DelayDelay * * @param $ruleAction * @param CRM_Civirules_Action $actionObject * @return bool|\DateTime */ protected static function getActionDelay($ruleAction, CRM_Civirules_Action $actionObject) { $delayedTo = new DateTime(); $now = new DateTime(); if (!empty($ruleAction['delay'])) { $delayClass = unserialize($ruleAction['delay']); if ($delayClass instanceof CRM_Civirules_Delay_Delay) { $delayedTo = $delayClass->delayTo($delayedTo); } } $actionDelayedTo = $actionObject->delayTo($delayedTo); if ($actionDelayedTo instanceof DateTime) { if ($now < $actionDelayedTo) { return $actionDelayedTo; } return false; } elseif ($delayedTo instanceof DateTime and $now < $delayedTo) { return $delayedTo; } return false; }