/[drupal]/contributions/modules/sale/sale.module
ViewVC logotype

Diff of /contributions/modules/sale/sale.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.5, Wed Jul 18 18:04:49 2007 UTC revision 1.1.2.6, Mon Jul 30 17:13:36 2007 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: sale.module,v 1.1.2.4 2007/05/18 15:39:22 darrenoh Exp $  // $Id: sale.module,v 1.1.2.5 2007/07/18 18:04:49 darrenoh Exp $
3    
4  /**  /**
5   * Implementation of hook_help().   * Implementation of hook_help().
# Line 99  function sale_nodeapi(&$node, $op, $a3 = Line 99  function sale_nodeapi(&$node, $op, $a3 =
99            else {            else {
100              $timezone = variable_get('date_default_timezone', 0);              $timezone = variable_get('date_default_timezone', 0);
101            }            }
102            $sale_closing_date = gmmktime(0, 0, 0, $node->sale_closing_date['month'], $node->sale_closing_date['day'], $node->sale_closing_date['year']) - $timezone;            if (!empty($sale->sale_closing_date)) {
103                $sale_closing_date = gmmktime(0, 0, 0, $node->sale_closing_date['month'], $node->sale_closing_date['day'], $node->sale_closing_date['year']) - $timezone;
104              }
105            if (db_result(db_query("SELECT COUNT(*) FROM {sale_items} WHERE vid = %d", $node->vid)) == 0) {            if (db_result(db_query("SELECT COUNT(*) FROM {sale_items} WHERE vid = %d", $node->vid)) == 0) {
106              db_query("INSERT INTO {sale_items} (nid, vid, sale_closes, sale_closing_date) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->sale_closes, $sale_closing_date);              db_query("INSERT INTO {sale_items} (nid, vid, sale_closes, sale_closing_date) VALUES (%d, %d, %d, %d)", $node->nid, $node->vid, $node->sale_closes, $sale_closing_date);
107            }            }
# Line 128  function sale_link_alter(&$node, &$links Line 130  function sale_link_alter(&$node, &$links
130        );        );
131      }      }
132      elseif (empty($links['add_to_cart']['html'])) {      elseif (empty($links['add_to_cart']['html'])) {
133        $links['add_to_cart']['title'] = t('Sales of this item close !date', array(        $links['add_to_cart']['title'] = t('Sales close !date', array(
134          '!date' => format_date($node->sale->sale_closing_date, 'custom', 'F j, Y'),          '!date' => format_date($node->sale->sale_closing_date, 'custom', 'F j, Y'),
135        ));        ));
136      }      }
# Line 147  function sale_cron() { Line 149  function sale_cron() {
149    }    }
150  }  }
151    
152    /**
153     * Implementation of hook_views_tables().
154     */
155    function sale_views_tables() {
156      $tables['sale_items'] = array(
157        'name' => 'sale_items',
158        'join' => array(
159          'left' => array(
160            'table' => 'node',
161            'field' => 'nid'
162          ),
163          'right' => array(
164            'field' => 'nid'
165          ),
166        ),
167        'sorts' => array(
168          'sale_closes' => array(
169            'name' => t('Sale: Closes'),
170            'help' => t('Sort by whether sale closing has been enabled for the item.. Choose descending to put items with sale closing dates at the top.'),
171          ),
172          'sale_closing_date' => array(
173            'name' => t('Sale: Closing date'),
174            'handler' => 'views_handler_sort_date',
175            'option' => views_handler_sort_date_options(),
176          ),
177        ),
178        'filters' => array(
179          'sale_closes' => array(
180            'name' => t('Sale: Closes'),
181            'operator' => array('=' => t('Equals')),
182            'list' => 'views_handler_operator_yesno',
183            'list-type' => 'select',
184            'help' => t('Filter by whether sale closing has been enabled for the item.'),
185          ),
186          'sale_closing_date' => array(
187            'name' => t('Sale: Closing date'),
188            'operator' => 'views_handler_operator_gtlt',
189            'value' => views_handler_filter_date_value_form(),
190            'handler' => 'views_handler_filter_timestamp',
191            'option' => 'string',
192            'cacheable' => 'no',
193            'help' => t('Filter by item\'s sale closing date (or no closing date). The "Value" can either be a date in the format: CCYY-MM-DD HH:MM:SS or the word "now" to use the current time. You may enter a positive or negative number in the "Option" field that will represent the amount of seconds that will be added or substracted to the time; this is most useful when combined with "now".'),
194          ),
195        ),
196      );
197      return $tables;
198    }
199    

Legend:
Removed from v.1.1.2.5  
changed lines
  Added in v.1.1.2.6

  ViewVC Help
Powered by ViewVC 1.1.2