Ignore:
Timestamp:
Jun 15, 2011, 4:19:31 PM (13 years ago)
Author:
mistic100
Message:

add filters on date_creation fields, remove 'make associations on login'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/SmartAlbums/include/functions.inc.php

    r11376 r11380  
    4242/*
    4343 * Make associations for all SmartAlbums
    44  * Called with invalidate_user_cache and/or on admin login
    45  * @param string login (not mandatory)
    46  */
    47 function smart_make_all_associations($login = false)
     44 * Called with invalidate_user_cache
     45 */
     46function smart_make_all_associations()
    4847{
    4948  global $conf;
     
    5150  if (!is_array($conf['SmartAlbums'])) $conf['SmartAlbums'] = unserialize($conf['SmartAlbums']);
    5251 
    53   if ( !$login AND !defined('SMART_NOT_UPDATE') AND $conf['SmartAlbums']['update_on_upload'] != 'false' )
    54     continue;
    55   else if ( is_string($login) AND is_admin() AND $conf['SmartAlbums']['update_on_login'] != 'false' )
    56     continue;
    57   else
    58     return;
     52  if ( defined('SMART_NOT_UPDATE') OR $conf['SmartAlbums']['update_on_upload'] == 'false' ) return;
    5953 
    6054  /* get categories with smart filters */
     
    6963  $smart_cats = array_from_query($query, 'id');
    7064  array_map('smart_make_associations', $smart_cats);
    71  
    72   if (is_string($login))
    73   {
    74     define('SMART_NOT_UPDATE', 1);
    75     invalidate_user_cache();
    76   }
    7765}
    7866
     
    178166    else if ($filter['type'] == 'date')
    179167    {
    180       if      ($filter['cond'] == 'the')    $where[] = 'date_available BETWEEN "'.$filter['value'].' 00:00:00" AND "'.$filter['value'].' 23:59:59"';
    181       else if ($filter['cond'] == 'before') $where[] = 'date_available < "'.$filter['value'].' 00:00:00"';
    182       else if ($filter['cond'] == 'after')  $where[] = 'date_available > "'.$filter['value'].' 23:59:59"';
     168      switch ($filter['cond'])
     169      {
     170        case 'the':
     171          $where[] = 'date_available BETWEEN "'.$filter['value'].' 00:00:00" AND "'.$filter['value'].' 23:59:59"';
     172          break;
     173        case 'before':
     174          $where[] = 'date_available < "'.$filter['value'].' 00:00:00"';
     175          break;
     176        case 'after':
     177          $where[] = 'date_available > "'.$filter['value'].' 23:59:59"';
     178          break;
     179        case 'the_crea':
     180          $where[] = 'date_creation BETWEEN "'.$filter['value'].' 00:00:00" AND "'.$filter['value'].' 23:59:59"';
     181          break;
     182        case 'before_crea':
     183          $where[] = 'date_creation < "'.$filter['value'].' 00:00:00"';
     184          break;
     185        case 'after_crea':
     186          $where[] = 'date_creation > "'.$filter['value'].' 23:59:59"';
     187          break;
     188      }
    183189    }
    184190    // limit
Note: See TracChangeset for help on using the changeset viewer.