Ingo_Rule_System_Vacation::vacationReason PHP Method

vacationReason() public static method

Returns the vacation reason with all placeholder replaced.
public static vacationReason ( string $reason, integer $start, integer $end ) : string
$reason string The vacation reason including placeholders.
$start integer The vacation start timestamp.
$end integer The vacation end timestamp.
return string The vacation reason suitable for usage in the filter scripts.
    public static function vacationReason($reason, $start, $end)
    {
        global $injector, $prefs;
        $format = $prefs->getValue('date_format');
        $identity = $injector->getInstance('Horde_Core_Factory_Identity')->create(Ingo::getUser());
        $replace = array('%NAME%' => $identity->getName(), '%EMAIL%' => $identity->getDefaultFromAddress(), '%SIGNATURE%' => $identity->getValue('signature'), '%STARTDATE%' => $start ? strftime($format, $start) : '', '%ENDDATE%' => $end ? strftime($format, $end) : '');
        return str_replace(array_keys($replace), array_values($replace), $reason);
    }

Usage Example

Example #1
0
 /**
  * Generates the maildrop script to handle vacation messages.
  *
  * @param Ingo_Rule $rule  Rule object.
  */
 protected function _generateVacation(Ingo_Rule $rule)
 {
     if (!count($rule)) {
         return;
     }
     $this->_addItem(Ingo::RULE_VACATION, new Ingo_Script_Maildrop_Comment(_("Vacation"), $disable, true));
     $recipe = new Ingo_Script_Maildrop_Recipe(array('action' => 'Ingo_Rule_System_Vacation', 'action-value' => array('addresses' => $rule->addresses, 'subject' => $rule->subject, 'days' => $rule->days, 'ignorelist' => $rule->ignore_list, 'excludes' => $rule->exclude, 'start' => $rule->start, 'end' => $rule->end), 'disable' => $disable), $this->_params);
     $this->_addItem(Ingo::RULE_VACATION, $recipe);
     $this->_addItem(Ingo::RULE_VACATION, new Ingo_Script_String(Ingo_Rule_System_Vacation::vacationReason($rule->reason, $rule->start, $rule->end)), 'vacation.msg');
 }
All Usage Examples Of Ingo_Rule_System_Vacation::vacationReason