Ignore:
Timestamp:
Mar 10, 2013, 5:12:50 PM (11 years ago)
Author:
mistic100
Message:

some code corrections

File:
1 edited

Legend:

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

    r21340 r21441  
    6666    AND email != "'.$exclude.'"
    6767';
    68   $subscriptions = hash_from_query($query, 'email');
     68  $subscriptions = hash_from_query($query, 'id');
     69 
     70  if (count($subscriptions)==0) return;
    6971 
    7072  set_make_full_url();
     
    551553function get_picture_infos($image_id, $with_thumb=true)
    552554{
     555  if (empty($image_id)) return array();
     556 
    553557  $query = '
    554558SELECT
     
    584588 * @return: array (id, name, url, thumbnail)
    585589 */
    586 function get_category_infos($cat_id, $with_thumb=true)
     590function get_category_infos($cat_id, $with_thumb=true, $user_id=null)
    587591{
    588592  global $conf;
     593 
     594  if ($user_id===null) $user_id = $conf['guest_id'];
    589595 
    590596  $query = '
     
    593599    cat.name,
    594600    cat.permalink,
     601    ucc.count_images,
     602    cat.uppercats,
    595603    img.id AS image_id,
    596604    img.path
    597605  FROM '.CATEGORIES_TABLE.' AS cat
    598606    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc
    599       ON ucc.cat_id = cat.id AND ucc.user_id = '.$conf['guest_id'].'
     607      ON ucc.cat_id = cat.id AND ucc.user_id = '.$user_id.'
    600608    LEFT JOIN '.IMAGES_TABLE.' AS img
    601609      ON img.id = ucc.user_representative_picture_id
     
    603611;';
    604612  $element = pwg_db_fetch_assoc(pwg_query($query));
    605   // we use guest_id for user_cache because we don't know the status of recipient
    606613 
    607614  $element['url'] = make_index_url(array(
     
    612619  if ($with_thumb)
    613620  {
    614     $element['thumbnail'] = DerivativeImage::thumb_url(array(
    615       'id'=>$element['image_id'],
    616       'path'=>$element['path'],
    617       ));
     621    if (empty($element['image_id']) and $conf['allow_random_representative'])
     622    {
     623      $image = get_picture_infos(get_random_image_in_category($element));
     624      $element['thumbnail'] = $image['thumbnail'];
     625    }
     626    else
     627    {
     628      $element['thumbnail'] = DerivativeImage::thumb_url(array(
     629        'id'=>$element['image_id'],
     630        'path'=>$element['path'],
     631        ));
     632    }
    618633  }
    619634 
Note: See TracChangeset for help on using the changeset viewer.