library/Garp/Model/Behavior/Draftable.php
public function addWhereClause(&$model, Zend_Db_Select &$select) {
        $statusColumn = $model->getAdapter()->quoteIdentifier(self::STATUS_COLUMN);
        $publishedColumn = $model->getAdapter()->quoteIdentifier(self::PUBLISHED_COLUMN);

        if ($this->_modelAlias) {
            $modelAlias = $this->_modelAlias;
            $modelAlias = $model->getAdapter()->quoteIdentifier($modelAlias);
            $statusColumn = "$modelAlias.$statusColumn";
            $publishedColumn = "$modelAlias.$publishedColumn";
        }

        // Add online_status check
        $select->where($statusColumn . ' = ?', self::ONLINE);

        // Add published check
        if ($this->_config['draft_only']) {
            return;
        }

        $ini = Zend_Registry::get('config');
        $timezone = !empty($ini->resources->db->params->timezone) ?
            $ini->resources->db->params->timezone : null;
        $timecalc = '';
        if ($timezone == 'GMT' || $timezone == 'UTC') {
            $dstStart = strtotime('Last Sunday of March');
            $dstEnd   = strtotime('Last Sunday of October');
            $now      = time();
            $daylightSavingsTime = $now > $dstStart && $now < $dstEnd;

            $timecalc = '+ INTERVAL';
            if ($daylightSavingsTime) {
                $timecalc .= ' 2 HOUR';
            } else {
                $timecalc .= ' 1 HOUR';
            }
        }
        $select->where(
            $publishedColumn . ' IS NULL OR ' . $publishedColumn . ' <= NOW() ' . $timecalc
        );
    }
public function addWhereClause(&$model, Zend_Db_Select &$select) {
        $statusColumn = $model->getAdapter()->quoteIdentifier(self::STATUS_COLUMN);
        $publishedColumn = $model->getAdapter()->quoteIdentifier(self::PUBLISHED_COLUMN);

        if ($this->_modelAlias) {
            $modelAlias = $this->_modelAlias;
            $modelAlias = $model->getAdapter()->quoteIdentifier($modelAlias);
            $statusColumn = "$modelAlias.$statusColumn";
            $publishedColumn = "$modelAlias.$publishedColumn";
        }

        // Add online_status check
        $select->where($statusColumn . ' = ?', self::ONLINE);

        // Add published check
        if ($this->_config['draft_only']) {
            return;
        }

        $ini = Zend_Registry::get('config');
        $timezone = !empty($ini->resources->db->params->timezone) ?
            $ini->resources->db->params->timezone : null;
        $timecalc = '';
        if ($timezone == 'GMT' || $timezone == 'UTC') {
            $dstStart = strtotime('Last Sunday of March');
            $dstEnd   = strtotime('Last Sunday of October');
            $now      = time();
            $daylightSavingsTime = $now > $dstStart && $now < $dstEnd;

            $timecalc = '+ INTERVAL';
            if ($daylightSavingsTime) {
                $timecalc .= ' 2 HOUR';
            } else {
                $timecalc .= ' 1 HOUR';
            }
        }
        $select->where(
            $publishedColumn . ' IS NULL OR ' . $publishedColumn . ' <= NOW() ' . $timecalc
        );
    }
public function addWhereClause ( & $ model , Zend_Db_Select & $ select ) { $ statusColumn = $ model -> getAdapter ( ) -> quoteIdentifier ( self :: STATUS_COLUMN ) ; $ publishedColumn = $ model -> getAdapter ( ) -> quoteIdentifier ( self :: PUBLISHED_COLUMN ) ; if ( $ this -> _modelAlias ) { $ modelAlias = $ this -> _modelAlias ; $ modelAlias = $ model -> getAdapter ( ) -> quoteIdentifier ( $ modelAlias ) ; $ statusColumn = "$modelAlias.$statusColumn" ; $ publishedColumn = "$modelAlias.$publishedColumn" ; } // Add online_status check $ select -> where ( $ statusColumn . ' = ?' , self :: ONLINE ) ; // Add published check if ( $ this -> _config [ 'draft_only' ] ) { return ; } $ ini = Zend_Registry :: get ( 'config' ) ; $ timezone = ! empty ( $ ini -> resources -> db -> params -> timezone ) ? $ ini -> resources -> db -> params -> timezone : null ; $ timecalc = '' ; if ( $ timezone == 'GMT' || $ timezone == 'UTC' ) { $ dstStart = strtotime ( 'Last Sunday of March' ) ; $ dstEnd = strtotime ( 'Last Sunday of October' ) ; $ now = time ( ) ; $ daylightSavingsTime = $ now > $ dstStart && $ now < $ dstEnd ; $ timecalc = '+ INTERVAL' ; if ( $ daylightSavingsTime ) { $ timecalc .= ' 2 HOUR' ; } else { $ timecalc .= ' 1 HOUR' ; } } $ select -> where ( $ publishedColumn . ' IS NULL OR ' . $ publishedColumn . ' <= NOW() ' . $ timecalc ) ; }
Add the WHERE clause that keeps offline items from appearing in the results

@param Garp_Model_Db $model
@param Zend_Db_Select $select
@return void
Add the WHERE clause that keeps offline items from appearing in the results