Пример #1
0
$weekday = date('w');
foreach ($reminders as $reminder) {
    // if this is the weekend and this reminder isn't supposed to run on weekends skip
    if ($reminder['rem_skip_weekend'] == 1 && in_array($weekday, array(0, 6))) {
        if (Reminder::isDebug()) {
            echo "Skipping Reminder '" . $reminder['rem_title'] . "' due to weekend exclusion\n";
        }
        continue;
    }
    // for each action, get the conditions and see if it triggered any issues
    $found = 0;
    foreach ($reminder['actions'] as $action) {
        if (Reminder::isDebug()) {
            echo "Processing Reminder Action '" . $action['rma_title'] . "'\n";
        }
        $conditions = Reminder_Condition::getList($action['rma_id']);
        if (count($conditions) == 0) {
            if (Reminder::isDebug()) {
                echo "  - Skipping Reminder because there were no reminder conditions found\n";
            }
            continue;
        }
        $issues = Reminder::getTriggeredIssues($reminder, $conditions);
        // avoid repeating reminder actions, so get the list of issues
        // that were last triggered with this reminder action ID
        $repeat_issues = Reminder_Action::getRepeatActions($issues, $action['rma_id']);
        if (count($repeat_issues) > 0) {
            // add the repeated issues to the list of already triggered
            // issues, so they get ignored for the next reminder actions
            foreach ($repeat_issues as $issue) {
                if (Reminder::isDebug()) {
Пример #2
0
$reminders = Reminder::getList();
for ($i = 0; $i < count($reminders); $i++) {
    // if this is the weekend and this reminder isn't supposed to run on weekends skip
    if ($reminders[$i]['rem_skip_weekend'] == 1 && in_array(date("w"), array(0, 6))) {
        if (Reminder::isDebug()) {
            echo "Skipping Reminder '" . $reminders[$i]['rem_title'] . "' due to weekend exclusion\n";
        }
        continue;
    }
    // for each action, get the conditions and see if it triggered any issues
    $found = 0;
    for ($y = 0; $y < count($reminders[$i]['actions']); $y++) {
        if (Reminder::isDebug()) {
            echo "Processing Reminder Action '" . $reminders[$i]['actions'][$y]['rma_title'] . "'\n";
        }
        $conditions = Reminder_Condition::getList($reminders[$i]['actions'][$y]['rma_id']);
        if (count($conditions) == 0) {
            if (Reminder::isDebug()) {
                echo "  - Skipping Reminder because there were no reminder conditions found\n";
            }
            continue;
        }
        $issues = Reminder::getTriggeredIssues($reminders[$i], $conditions);
        // avoid repeating reminder actions, so get the list of issues
        // that were last triggered with this reminder action ID
        $repeat_issues = Reminder_Action::getRepeatActions($issues, $reminders[$i]['actions'][$y]['rma_id']);
        if (count($repeat_issues) > 0) {
            // add the repeated issues to the list of already triggered
            // issues, so they get ignored for the next reminder actions
            for ($w = 0; $w < count($repeat_issues); $w++) {
                if (Reminder::isDebug()) {
 /**
  * Method used to get the list of reminder actions to be displayed in the 
  * administration section.
  *
  * @access  public
  * @param   integer $rem_id The reminder ID
  * @return  array The list of reminder actions
  */
 function getAdminList($rem_id)
 {
     $stmt = "SELECT\n                    rma_rem_id,\n                    rma_id,\n                    rma_title,\n                    rmt_title,\n                    rma_rank,\n                    rma_alert_irc,\n                    rma_alert_group_leader\n                 FROM\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action,\n                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "reminder_action_type\n                 WHERE\n                    rma_rmt_id=rmt_id AND\n                    rma_rem_id=" . Misc::escapeInteger($rem_id) . "\n                 ORDER BY\n                    rma_rank ASC";
     $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
     if (PEAR::isError($res)) {
         Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
         return array();
     } else {
         for ($i = 0; $i < count($res); $i++) {
             $conditions = Reminder_Condition::getList($res[$i]['rma_id']);
             $res[$i]['total_conditions'] = count($conditions);
             foreach ($conditions as $condition) {
                 if ($condition['rmf_sql_field'] == 'iss_sta_id') {
                     $res[$i]['status'] = Status::getStatusTitle($condition['rlc_value']);
                 }
             }
         }
         return $res;
     }
 }
Пример #4
0
 /**
  * Method used to generate an SQL query to be used in debugging the reminder
  * conditions.
  *
  * @access  public
  * @param   integer $rem_id The reminder ID
  * @param   integer $rma_id The reminder action ID
  * @return  string The SQL query
  */
 function getSQLQuery($rem_id, $rma_id)
 {
     $reminder = Reminder::getDetails($rem_id);
     $conditions = Reminder_Condition::getList($rma_id);
     $stmt = "SELECT\n                    iss_id\n                 FROM\n                    " . APP_TABLE_PREFIX . "issue";
     $stmt .= Reminder::getWhereClause($reminder, $conditions);
     // can't rely on the mysql server's timezone setting, so let's use gmt dates throughout
     $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_API::getCurrentDateGMT() . "')", $stmt);
     return $stmt;
 }
Пример #5
0
 /**
  * Method used to generate an SQL query to be used in debugging the reminder
  * conditions.
  *
  * @param   integer $rem_id The reminder ID
  * @param   integer $rma_id The reminder action ID
  * @return  string The SQL query
  */
 public static function getSQLQuery($rem_id, $rma_id)
 {
     $reminder = self::getDetails($rem_id);
     $conditions = Reminder_Condition::getList($rma_id);
     $stmt = 'SELECT
                 iss_id
              FROM
                 {{%issue}}';
     $products = self::getAssociatedProducts($reminder['rem_id']);
     if (count($products) > 0) {
         $stmt .= ',
                 issue_product_version';
     }
     $stmt .= self::getWhereClause($reminder, $conditions);
     // can't rely on the mysql server's timezone setting, so let's use gmt dates throughout
     $stmt = str_replace('UNIX_TIMESTAMP()', "UNIX_TIMESTAMP('" . Date_Helper::getCurrentDateGMT() . "')", $stmt);
     return $stmt;
 }
 /**
  * Method used to get the list of reminder actions to be displayed in the
  * administration section.
  *
  * @param   integer $rem_id The reminder ID
  * @return  array The list of reminder actions
  */
 public static function getAdminList($rem_id)
 {
     $stmt = 'SELECT
                 rma_rem_id,
                 rma_id,
                 rma_title,
                 rmt_title,
                 rma_rank,
                 rma_alert_irc,
                 rma_alert_group_leader
              FROM
                 {{%reminder_action}},
                 {{%reminder_action_type}}
              WHERE
                 rma_rmt_id=rmt_id AND
                 rma_rem_id=?
              ORDER BY
                 rma_rank ASC';
     try {
         $res = DB_Helper::getInstance()->getAll($stmt, array($rem_id));
     } catch (DbException $e) {
         return array();
     }
     foreach ($res as &$row) {
         $conditions = Reminder_Condition::getList($row['rma_id']);
         $row['total_conditions'] = count($conditions);
         foreach ($conditions as $condition) {
             if ($condition['rmf_sql_field'] == 'iss_sta_id') {
                 $row['status'] = Status::getStatusTitle($condition['rlc_value']);
             }
         }
     }
     return $res;
 }