Changeset 21441


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

some code corrections

Location:
extensions/Subscribe_to_comments
Files:
5 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 
  • extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php

    r21439 r21441  
    264264function stc_on_album()
    265265{
    266   global $page, $template, $pwg_loaded_plugins, $user, $conf;
     266  global $page, $template, $user, $conf;
    267267 
    268268  if (
    269       script_basename() != 'index' or !isset($page['section']) or
    270       !isset($pwg_loaded_plugins['Comments_on_Albums']) or
    271       $page['section'] != 'categories' or !isset($page['category'])
     269      !defined('COA_ID') or script_basename() != 'index' or
     270      @$page['section'] != 'categories' or !isset($page['category'])
    272271    )
    273272  {
  • extensions/Subscribe_to_comments/include/subscribtions_page.inc.php

    r21439 r21441  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
    4 global $template, $conf, $page, $pwg_loaded_plugins;
     4global $template, $conf, $page, $user;
    55
    66// check input parameters
     
    213213          case 'album-images':
    214214          case 'album':
    215             $subscription['infos'] = get_category_infos($subscription['element_id']);
     215            $subscription['infos'] = get_category_infos($subscription['element_id'], true, $user['id']);
    216216            break;
    217217          default:
     
    238238}
    239239
    240 if (isset($pwg_loaded_plugins['Comments_on_Albums']))
    241 {
    242   $template->assign('COA_ACTIVATED', true);
    243 }
    244240
    245241$template->assign(array(
    246242  'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH,
    247243  'SUBSCRIBE_TO_ABS_PATH' => realpath(SUBSCRIBE_TO_PATH).'/',
     244  'COA_ACTIVATED' => defined('COA_ID'),
    248245  ));
    249246 
  • extensions/Subscribe_to_comments/main.inc.php

    r21340 r21441  
    99*/
    1010
     11/*
     12 * potential problem : if the permissions of a user change, he receives notifications
     13 * about photos and albums he can't see anymore
     14 */
     15
    1116if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    1217
    1318global $prefixeTable;
    1419
    15 define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . 'Subscribe_to_Comments/');
     20defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
     21define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/');
    1622define('SUBSCRIBE_TO_TABLE',   $prefixeTable . 'subscribe_to_comments');
    1723define('SUBSCRIBE_TO_VERSION', 'auto');
     
    3137  if (
    3238    SUBSCRIBE_TO_VERSION == 'auto' or
    33     $pwg_loaded_plugins['Subscribe_to_Comments']['version'] == 'auto' or
    34     version_compare($pwg_loaded_plugins['Subscribe_to_Comments']['version'], SUBSCRIBE_TO_VERSION, '<')
     39    $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] == 'auto' or
     40    version_compare($pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'], SUBSCRIBE_TO_VERSION, '<')
    3541  )
    3642  {
     
    3844    stc_install();
    3945   
    40     if ( $pwg_loaded_plugins['Subscribe_to_Comments']['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' )
     46    if ( $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' )
    4147    {
    4248      $query = '
    4349UPDATE '. PLUGINS_TABLE .'
    4450SET version = "'. SUBSCRIBE_TO_VERSION .'"
    45 WHERE id = "Subscribe_to_Comments"';
     51WHERE id = "'. SUBSCRIBE_TO_ID .'"';
    4652      pwg_query($query);
    4753     
    48       $pwg_loaded_plugins['Subscribe_to_Comments']['version'] = SUBSCRIBE_TO_VERSION;
     54      $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] = SUBSCRIBE_TO_VERSION;
    4955     
    5056      if (defined('IN_ADMIN'))
     
    9298  array_push($menu, array(
    9399    'NAME' => 'Subscribe to Comments',
    94     'URL' => get_root_url().'admin.php?page=plugin-' . basename(dirname(__FILE__))
     100    'URL' => get_root_url().'admin.php?page=plugin-' . SUBSCRIBE_TO_ID,
    95101  ));
    96102  return $menu;
  • extensions/Subscribe_to_comments/maintain.inc.php

    r17923 r21441  
    22if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    33
    4 include_once(PHPWG_PLUGINS_PATH . 'Subscribe_to_Comments/include/install.inc.php');
     4defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__)));
     5include_once(PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/include/install.inc.php');
    56 
    67
Note: See TracChangeset for help on using the changeset viewer.