public static function checkStatus() { // ALTER TABLE `#__virtuemart_order_histories` ADD INDEX ( `virtuemart_order_id` ) if (method_exists('JApplication', 'getHash')) { $hashn = JApplication::getHash('opctracking'); } else { $hashn = JUtility::getHash('opctracking'); } $hash = JRequest::getVar($hashn, false, 'COOKIE'); if (empty($hash)) { return false; } OPCtrackingHelper::$html = ''; $tracking_s = OPCtrackingHelper::getLines(0, 0, $hash); require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'tracking.php'; require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'config.php'; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php'; jimport('joomla.filesystem.file'); jimport('joomla.utilities.date'); if (empty($tracking_s)) { return; } foreach ($tracking_s as $tracking) { self::$actions = array(); $order_id = (int) $tracking['virtuemart_order_id']; if (empty($order_id)) { continue; } // $config = new JModelConfig(); $config->loadVmConfig(); //$files = $config->getPhpTrackingThemes(); $statuses = $config->getOrderStatuses(); $trackingModel = new JModelTracking(); self::$config = $config = $trackingModel->getStatusConfig($statuses); $min_a = array(); foreach (self::$config as $status => $t) { foreach ($t as $mkey => $val) { if (stripos($mkey, 'since')) { if (is_numeric($val)) { $min_a[$val] = $val; } } } } $time = time() - 24 * 60 * 60 * 30; if (!empty($min_a)) { $min = min($min_a); //only take orders less than one month // only run tracking since it was enabled and ignore one month old data if (is_numeric($min)) { if ($min > $time) { $time = $min; } } } $date = new JDate($time); if (method_exists($date, 'toSql')) { $dd = $date->toSql(); } else { $dd = date("Y-m-d H:i:s", $time); } $q = 'select * from #__virtuemart_order_histories where virtuemart_order_id = ' . $order_id . ' and created_on > \'' . $dd . '\' order by virtuemart_order_history_id desc'; $db = JFactory::getDBO(); $db->setQuery($q); $res = $db->loadAssocList(); if (empty($res)) { continue; } // this should not happen $ind = 0; foreach ($res as $state) { if (empty($config[$state['order_status_code']])) { continue; } else { $lc = $config[$state['order_status_code']]; } if (!empty($lc->only_when)) { $newa = array_slice($res, $ind + 1); foreach ($newa as $ns) { if ($ns['order_status_code'] == $lc->only_when) { //OK, do an action if (!empty($config[$state['order_status_code']]->code)) { self::prepareAction($state['order_status_code'], 'code', $config[$state['order_status_code']]->code); } foreach ($lc as $key => $file) { // inbuilt limitations if ($file == 'only_when') { continue; } if ($file == 'code') { continue; } if (stripos($file, 'since') === 0) { continue; } $file = JFile::makeSafe($file); if (empty($lc->{$key . '_enabled'})) { continue; } if (empty($lc->{$file})) { continue; } self::prepareAction($state['order_status_code'], $file); } } } } else { if (!empty($config[$state['order_status_code']]->code)) { self::prepareAction($state['order_status_code'], 'code', $config[$state['order_status_code']]->code); } // only when is not set: $cx = 0; foreach ($lc as $key => $file) { $cx++; // inbuilt limitations if (stripos($file, 'since') === 0) { continue; } if ($file == 'only_when') { continue; } if ($file == 'code') { continue; } if (empty($lc->{$key . '_enabled'})) { continue; } //echo $cx.' '.$key.' '.$file."<br />\n"; self::prepareAction($state['order_status_code'], $file); } } $ind++; } self::checkActions($tracking); self::doActions($tracking); } if (!empty(OPCtrackingHelper::$html)) { return true; } return false; }