/**
  * Function executed from the Scheduler.
  * Sends an email
  *
  * @return	boolean
  */
 public function execute()
 {
     $success = TRUE;
     $taskId = $this->taskUid;
     tx_rnbase::load('tx_rnbase_util_Misc');
     try {
         $lastRun = $this->getLastRunTime($taskId);
         /* @var $srv tx_mklog_srv_WatchDog */
         $srv = tx_rnbase_util_Misc::getService('mklog', 'WatchDog');
         $filters = array();
         $options = array();
         $options['minimalSeverity'] = $this->getMinimalSeverity();
         $options['forceSummaryMail'] = $this->getForceSummaryMail();
         $options['includeDataVar'] = $this->getIncludeDataVar();
         //damit jede Nachricht nur einmal kommt, auch wenn sie mehrmals vorhanden ist
         if ($this->getGroupEntries()) {
             $options['groupby'] = Tx_Mklog_Utility_Devlog::getMessageFieldName() . ',extkey';
             // wir wollen aber wissen wie oft jede Nachricht vorhanden ist
             $options['count'] = TRUE;
         }
         $srv->triggerMails($this->getEmailReceiver(), $lastRun, $filters, $options);
         $this->updateLastRunTime($taskId);
     } catch (Exception $e) {
         tx_rnbase_util_Logger::fatal('WatchDog failed!', 'mklog', array('Exception' => $e->getMessage()));
         $success = FALSE;
     }
     return $success;
 }
 /**
  * This method is used to define new fields for adding or editing a task
  * In this case, it adds an email field
  *
  * @param	array					$taskInfo: reference to the array containing the info used in the add/edit form
  * @param	object					$task: when editing, reference to the current task object. Null when adding.
  * @param	tx_scheduler_Module		$parentObject: reference to the calling object (Scheduler's BE module)
  * @return	array					Array containg all the information pertaining to the additional fields
  *									The array is multidimensional, keyed to the task class name and each field's id
  *									For each field it provides an associative sub-array with the following:
  *										['code']		=> The HTML code for the field
  *										['label']		=> The label of the field (possibly localized)
  *										['cshKey']		=> The CSH key for the field
  *										['cshLabel']	=> The code of the CSH label
  */
 protected function _getAdditionalFields(array &$taskInfo, $task, $parentObject)
 {
     // Initialize extra field value
     if (!array_key_exists(MKLOG_FIELD_EMAIL, $taskInfo) || empty($taskInfo[MKLOG_FIELD_EMAIL])) {
         if ($parentObject->CMD == 'add') {
             // New task
             $taskInfo[MKLOG_FIELD_EMAIL] = '';
         } elseif ($parentObject->CMD == 'edit') {
             // Editing a task, set to internal value if data was not submitted already
             $taskInfo[MKLOG_FIELD_EMAIL] = $task->getEmailReceiver();
             $taskInfo[MKLOG_FIELD_FORCE] = $task->getForceSummaryMail();
             $taskInfo[MKLOG_FIELD_SEVERITY] = $task->getMinimalSeverity();
             $taskInfo[MKLOG_FIELD_DATAVAR] = $task->getIncludeDataVar();
             $taskInfo[MKLOG_FIELD_GROUP_ENTRIES] = $task->getGroupEntries();
         } else {
             // Otherwise set an empty value, as it will not be used anyway
             $taskInfo[MKLOG_FIELD_EMAIL] = '';
         }
     }
     // Write the code for the field
     $additionalFields = array();
     // Email
     $fieldID = 'field_' . MKLOG_FIELD_EMAIL;
     // Note: Name qualifier MUST be "tx_scheduler" as the tx_scheduler's BE module is used!
     $fieldCode = '<input type="text" name="tx_scheduler[' . MKLOG_FIELD_EMAIL . ']" id="' . $fieldID . '" value="' . $taskInfo[MKLOG_FIELD_EMAIL] . '" size="50" />';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => 'LLL:EXT:mklog/locallang_db.xml:scheduler_watchdog_field_' . MKLOG_FIELD_EMAIL, 'cshKey' => '_MOD_tools_txschedulerM1');
     // Minimum severity
     $fieldID = 'field_' . MKLOG_FIELD_SEVERITY;
     $fieldCode = '<select name="tx_scheduler[' . MKLOG_FIELD_SEVERITY . ']" id="' . $fieldID . '">';
     $srv = tx_rnbase_util_Misc::getService('mklog', 'WatchDog');
     $severities = $srv->getSeverities();
     foreach ($severities as $key => $label) {
         $fieldCode .= '<option value="' . $key . '" ' . ($taskInfo[MKLOG_FIELD_SEVERITY] == $key ? 'selected="selected"' : '') . ' />' . $label . "</option>\n";
     }
     $fieldCode .= '</select>';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => 'LLL:EXT:mklog/locallang_db.xml:scheduler_watchdog_field_' . MKLOG_FIELD_SEVERITY, 'cshKey' => '_MOD_tools_txschedulerM1');
     // Force summary
     $fieldID = 'field_' . MKLOG_FIELD_FORCE;
     $fieldCode = '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_FORCE . ']" id="' . $fieldID . '" value="1" ' . ($taskInfo[MKLOG_FIELD_FORCE] ? 'checked="checked"' : '') . ' /> Yes';
     $fieldCode .= '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_FORCE . ']" id="' . $fieldID . '" value="0" ' . ($taskInfo[MKLOG_FIELD_FORCE] ? '' : 'checked="checked"') . ' /> No';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => 'LLL:EXT:mklog/locallang_db.xml:scheduler_watchdog_field_' . MKLOG_FIELD_FORCE, 'cshKey' => '_MOD_tools_txschedulerM1');
     // data_var
     $fieldID = 'field_' . MKLOG_FIELD_DATAVAR;
     $fieldCode = '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_DATAVAR . ']" id="' . $fieldID . '" value="1" ' . ($taskInfo[MKLOG_FIELD_DATAVAR] ? 'checked="checked"' : '') . ' /> Yes';
     $fieldCode .= '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_DATAVAR . ']" id="' . $fieldID . '" value="0" ' . ($taskInfo[MKLOG_FIELD_DATAVAR] ? '' : 'checked="checked"') . ' /> No';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => 'LLL:EXT:mklog/locallang_db.xml:scheduler_watchdog_field_' . MKLOG_FIELD_DATAVAR, 'cshKey' => '_MOD_tools_txschedulerM1');
     // data_var
     $fieldID = 'field_' . MKLOG_FIELD_GROUP_ENTRIES;
     if (isset($taskInfo[MKLOG_FIELD_GROUP_ENTRIES])) {
         $fieldValue = $taskInfo[MKLOG_FIELD_GROUP_ENTRIES];
     } else {
         // default
         $fieldValue = 1;
     }
     $fieldCode = '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_GROUP_ENTRIES . ']" id="' . $fieldID . '" value="1" ' . ($fieldValue ? 'checked="checked"' : '') . ' /> Yes';
     $fieldCode .= '<input type="radio" name="tx_scheduler[' . MKLOG_FIELD_GROUP_ENTRIES . ']" id="' . $fieldID . '" value="0" ' . ($fieldValue ? '' : 'checked="checked"') . ' /> No';
     $additionalFields[$fieldID] = array('code' => $fieldCode, 'label' => 'LLL:EXT:mklog/locallang_db.xml:scheduler_watchdog_field_' . MKLOG_FIELD_GROUP_ENTRIES, 'cshKey' => '_MOD_tools_txschedulerM1');
     return $additionalFields;
 }
コード例 #3
0
 /**
  * @return tx_mklib_srv_StaticCountryZones
  */
 public static function getStaticCountryZonesService()
 {
     return tx_rnbase_util_Misc::getService(self::$extKey, 'staticCountryZones');
 }