/** * Checks row for data integrity. * Assumes working dates have been converted to local time for display, * so will always convert working dates to GMT * * @return unknown_type */ function check() { if (empty($this->product_id)) { $this->setError(JText::_('COM_CITRUSCART_PRODUCT_ASSOCIATION_REQUIRED')); return false; } $offset = JFactory::getConfig()->getValue('config.offset'); if (isset($this->publishing_date)) { $this->publishing_date = date('Y-m-d H:i:s', strtotime(CitruscartHelperBase::getOffsetDate($this->publishing_date, -$offset))); } $nullDate = $this->_db->getNullDate(); Citruscart::load('CitruscartHelperBase', 'helpers._base'); if (empty($this->created_date) || $this->created_date == $nullDate) { $date = JFactory::getDate(); $this->created_date = $date->toSql(); } $date = JFactory::getDate(); $this->modified_date = $date->toSql(); $act = strtotime(Date('Y-m-d', strtotime($this->publishing_date))); $db = $this->_db; if (empty($this->product_issue_id)) { $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($next === null) { return true; } $next = strtotime($next); if ($act <= $next) { $this->setError(JText::_('COM_CITRUSCART_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } else { $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_issue_id`=' . $this->product_issue_id; $db->setQuery($q); $original = $db->loadResult(); if ($act == strtotime(Date('Y-m-d', strtotime($original)))) { return true; } $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` < \'' . $original . '\' ORDER BY `publishing_date` DESC LIMIT 1'; $db->setQuery($q); $prev = $db->loadResult(); $q = 'SELECT `publishing_date` FROM `#__citruscart_productissues` WHERE `product_id`=' . $this->product_id . ' AND `publishing_date` > \'' . $original . '\' ORDER BY `publishing_date` ASC LIMIT 1'; $db->setQuery($q); $next = $db->loadResult(); if ($prev === null) { $prev = 0; } else { $prev = strtotime($prev); } if ($next) { $next = strtotime($next); } if ($prev >= $act || $next && $next <= $act) { $this->setError(JText::_('COM_CITRUSCART_PUBLISHING_DATE_IS_NOT_PRESERVING_ISSUE_ORDER') . ' - ' . $this->publishing_date); return false; } } return true; }
/** * Checks row for data integrity. * Assumes working dates have been converted to local time for display, * so will always convert working dates to GMT * * @return unknown_type */ function check() { if (empty($this->product_id)) { $this->setError(JText::_('COM_CITRUSCART_PRODUCT_ASSOCIATION_REQUIRED')); return false; } $nullDate = $this->_db->getNullDate(); Citruscart::load('CitruscartHelperBase', 'helpers._base'); $CitruscartHelperBase = new CitruscartHelperBase(); $this->product_price_startdate = $this->product_price_startdate != $nullDate ? $CitruscartHelperBase->getOffsetDate($this->product_price_startdate) : $this->product_price_startdate; $this->product_price_enddate = $this->product_price_enddate != $nullDate ? $CitruscartHelperBase->getOffsetDate($this->product_price_enddate) : $this->product_price_enddate; if (empty($this->created_date) || $this->created_date == $nullDate) { $date = JFactory::getDate(); $this->created_date = $date->toSql(); } $date = JFactory::getDate(); $this->modified_date = $date->toSql(); return true; }
public function store($updateNulls = false) { // Check the table activation status first if (!$this->active) { // Activate it with a default value $this->setType(''); } if ($this->getType() == 'datetime') { if (isset($this->eavvalue_value)) { $null_date = JFactory::getDbo()->getNullDate(); if ($this->eavvalue_value == $null_date || $this->eavvalue_value == '') { $this->eavvalue_value = $null_date; } else { $offset = JFactory::getConfig()->getValue('config.offset'); $this->eavvalue_value = date('Y-m-d H:i:s', strtotime(CitruscartHelperBase::getOffsetDate($this->eavvalue_value, -$offset))); } } } return parent::store($updateNulls); }
/** * Method to delete expired session compared products * @return void */ function deleteExpiredSessionProductsCompared() { $config = Citruscart::getInstance(); $last_run = $config->get('last_deleted_expired_sessionproductscompared'); Citruscart::load("CitruscartHelperBase", 'helpers._base'); $helper = new CitruscartHelperBase(); $date = JFactory::getDate(); $now = $date->toSql(); $three_hours_ago = $helper->getOffsetDate($now, '-3'); // when was this last run? // if it was run more than 3 hours ago, run again if ($last_run < $three_hours_ago) { // run it jimport('joomla.application.component.model'); JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_citruscart/models'); $model = JModelLegacy::getInstance('ProductCompare', 'CitruscartModel'); $model->deleteExpiredSessionProductCompared(); } return; }