Changeset 26139


Ignore:
Timestamp:
12/23/13 21:17:28 (5 years ago)
Author:
mistic100
Message:

update for 2.6

Location:
extensions/Subscribe_to_comments
Files:
5 added
3 deleted
11 edited
2 copied
3 moved

Legend:

Unmodified
Added
Removed
  • extensions/Subscribe_to_comments/admin.php

    r21608 r26139  
    11<?php 
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    33 
    44global $template, $page, $conf; 
     
    88include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php'); 
    99$page['tab'] = (isset($_GET['tab'])) ? $_GET['tab'] : 'subscriptions'; 
    10    
     10 
    1111$tabsheet = new tabsheet(); 
    1212$tabsheet->add('subscriptions', l10n('Manage'), SUBSCRIBE_TO_ADMIN . '-subscriptions'); 
     
    2424  'SUBSCRIBE_TO_ADMIN' => SUBSCRIBE_TO_ADMIN, 
    2525  )); 
    26    
     26 
    2727$template->assign_var_from_handle('ADMIN_CONTENT', 'stc_admin'); 
    28  
    29 ?> 
  • extensions/Subscribe_to_comments/admin/config.php

    r21608 r26139  
    11<?php 
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    33 
    4 // +-----------------------------------------------------------------------+ 
    5 //                         Save configuration                              | 
    6 // +-----------------------------------------------------------------------+ 
    7 if (isset($_POST['config_submit']))  
     4if (isset($_POST['config_submit'])) 
    85{ 
    96  $conf['Subscribe_to_Comments'] = array( 
     
    118    'allow_global_subscriptions' => isset($_POST['allow_global_subscriptions']), 
    129    ); 
    13    
     10 
    1411  conf_update_param('Subscribe_to_Comments', serialize($conf['Subscribe_to_Comments'])); 
    15   array_push($page['infos'], l10n('Information data registered in database')); 
    16 }   
     12  $page['infos'][] = l10n('Information data registered in database'); 
     13} 
    1714 
    1815 
    19 // +-----------------------------------------------------------------------+ 
    20 //                               Template                                  | 
    21 // +-----------------------------------------------------------------------+   
    2216$template->assign($conf['Subscribe_to_Comments']); 
    2317 
    2418$template->set_filename('stc_admin', realpath(SUBSCRIBE_TO_PATH . 'admin/template/config.tpl')); 
    25  
    26 ?> 
  • extensions/Subscribe_to_comments/admin/subscriptions.php

    r21608 r26139  
    11<?php 
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    33 
    44if (isset($_GET['delete'])) 
     
    6464      ); 
    6565  } 
    66    
     66 
    6767  $row['type'] = str_replace('-', '_', $row['type']); // fields are accessed in Smarty, incompatible with keys containing a '-' 
    6868  $users[ $row['email'] ]['subs'][ $row['type'] ]++; 
     
    7676  { 
    7777    uasort($users, 'stc_sort_'.$_POST['order_by']); 
    78      
     78 
    7979    if ($_POST['direction'] == 'DESC') 
    8080    { 
     
    156156  return strcasecmp($a['username'].$a['email'], $b['username'].$b['email']); 
    157157} 
    158  
    159 ?> 
  • extensions/Subscribe_to_comments/admin/template/config.tpl

    r21608 r26139  
    55<form method="post" action="" class="properties"> 
    66  <fieldset> 
    7     <legend>{'Configuration'|@translate}</legend> 
     7    <legend>{'Configuration'|translate}</legend> 
    88    <ul> 
    99      <li> 
    1010        <label> 
    11           <span class="property">{'Notify administrators when a user take a new subscription'|@translate}</span> 
    1211          <input type="checkbox" name="notify_admin_on_subscribe" value="1" {if $notify_admin_on_subscribe}checked="checked"{/if}> 
     12          <b>{'Notify administrators when a user take a new subscription'|translate}</b> 
    1313        </label> 
    1414      </li> 
    1515      <li> 
    1616        <label> 
    17           <span class="property">{'Allow users to subscribe to global notifications'|@translate}</span> 
    1817          <input type="checkbox" name="allow_global_subscriptions" value="1" {if $allow_global_subscriptions}checked="checked"{/if}> 
     18          <b>{'Allow users to subscribe to global notifications'|translate}</b> 
    1919        </label> 
    20       </li>   
     20      </li> 
    2121    </ul> 
    2222  </fieldset> 
    2323 
    24   <p><input class="submit" type="submit" value="{'Submit'|@translate}" name="config_submit"/></p> 
     24  <p><input class="submit" type="submit" value="{'Submit'|translate}" name="config_submit"/></p> 
    2525</form> 
  • extensions/Subscribe_to_comments/admin/template/subscriptions.tpl

    r21608 r26139  
    1 {combine_css path=$SUBSCRIBE_TO_PATH|@cat:"admin/template/style.css"} 
     1{combine_css path=$SUBSCRIBE_TO_PATH|cat:'admin/template/style.css'} 
    22 
    33<div class="titrePage"> 
     
    77<form class="filter" method="post" name="filter" action="{$F_FILTER_ACTION}"> 
    88<fieldset> 
    9   <legend>{'Filter'|@translate}</legend> 
     9  <legend>{'Filter'|translate}</legend> 
    1010 
    1111  <label> 
    12     {'User'|@translate} 
     12    {'User'|translate} 
    1313    <input type="text" name="username" value="{$F_USERNAME}" size="30"> 
    1414  </label> 
    1515 
    1616  <label> 
    17     {'Sort by'|@translate} 
     17    {'Sort by'|translate} 
    1818    {html_options name=order_by options=$order_options selected=$order_selected} 
    1919  </label> 
    2020 
    2121  <label> 
    22     {'Sort order'|@translate} 
     22    {'Sort order'|translate} 
    2323    {html_options name=direction options=$direction_options selected=$direction_selected} 
    2424  </label> 
     
    2626  <label> 
    2727    &nbsp; 
    28     <span><input class="submit" type="submit" name="filter" value="{'Submit'|@translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|@translate}</a></span> 
     28    <span><input class="submit" type="submit" name="filter" value="{'Submit'|translate}"> <a href="{$F_FILTER_ACTION}">{'Reset'|translate}</a></span> 
    2929  </label> 
    3030 
     
    3636  <thead> 
    3737    <tr class="throw"> 
    38       <td class="user">{'User'|@translate}</td> 
    39       <td class="date">{'First subscription'|@translate}</td> 
    40       <td class="date">{'Last subscription'|@translate}</td> 
    41       <td class="total">{'Photos'|@translate}</td> 
    42       <td class="total" style="font-size:0.7em;">{'All album photos'|@translate}</td> 
    43       {if $COA_ACTIVATED}<td class="total">{'Albums'|@translate}</td>{/if} 
     38      <td class="user">{'User'|translate}</td> 
     39      <td class="date">{'First subscription'|translate}</td> 
     40      <td class="date">{'Last subscription'|translate}</td> 
     41      <td class="total">{'Photos'|translate}</td> 
     42      <td class="total" style="font-size:0.7em;">{'All album photos'|translate}</td> 
     43      {if $COA_ACTIVATED}<td class="total">{'Albums'|translate}</td>{/if} 
    4444      <td class="action">&nbsp;</td> 
    4545    </tr> 
     
    5252    <td style="text-align:center;">{$user.nice_max_date}</td> 
    5353  {if $user.subs.all_images} 
    54     <td colspan="2" class="all">{'All'|@translate} 
     54    <td colspan="2" class="all">{'All'|translate} 
    5555  {else} 
    5656    <td>{$user.subs.image}</td> 
     
    5858  {/if} 
    5959  {if $user.subs.all_albums && $COA_ACTIVATED} 
    60     <td class="all">{'All'|@translate} 
    61   {elseif $COA_ACTIVATED} 
     60    <td class="all">{'All'|translate} 
     61  {else if $COA_ACTIVATED} 
    6262    <td>{$user.subs.album}</td> 
    6363  {/if} 
    64     <td><a href="{$user.u_delete}" title="{'delete'|@translate}" onclick="return confirm('{'Are you sure?'|@translate}');"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'delete'|@translate}"></a> 
     64    <td><a href="{$user.u_delete}" title="{'delete'|translate}" onclick="return confirm('{'Are you sure?'|translate}');"><img src="{$ROOT_URL}{$themeconf.admin_icon_dir}/delete.png" class="button" alt="{'delete'|translate}"></a> 
     65  </tr> 
     66  {foreachelse} 
     67  <tr class="row2"> 
     68    <td colspan="6" style="text-align:center;font-style:italic;">{'No result'|translate}</td> 
    6569  </tr> 
    6670  {/foreach} 
    67    
    68   {if not $USERS} 
    69   <tr class="row2"> 
    70     <td colspan="6" style="text-align:center;font-style:italic;">{'No result'|@translate}</td> 
    71   </tr> 
    72   {/if} 
    7371</table> 
    7472 
    75 <p>{'&#9733; : registered users'|@translate}</p> 
     73<p>{'&#9733; : registered users'|translate}</p> 
  • extensions/Subscribe_to_comments/include/events.inc.php

    r24342 r26139  
    11<?php 
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    33 
    44/** 
     
    88{ 
    99  global $tokens, $page, $conf; 
    10    
     10 
    1111  if ($tokens[0] == 'subscriptions') 
    1212  { 
    13     add_event_handler('loc_begin_page_header', 'stc_page_header'); 
    14      
    1513    $page['section'] = 'subscriptions'; 
     14    $page['body_id'] = 'theSubscriptionsPage'; 
     15    $page['is_homepage'] = false; 
     16    $page['is_external'] = true; 
     17 
    1618    $page['title'] = l10n('Comments notifications'); 
    17     $page['section_title'] = '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator'].l10n('Comments notifications'); 
    18   } 
    19 } 
    20  
    21 function stc_page_header() 
     19  } 
     20} 
     21 
     22function stc_load_section() 
    2223{ 
    2324  global $page; 
    24   $page['body_id'] = 'theSubscriptionsPage'; 
    25 } 
    26  
    27 function stc_load_section() 
    28 { 
    29   global $page; 
    3025 
    3126  if (isset($page['section']) and $page['section'] == 'subscriptions') 
    3227  { 
    33     include(SUBSCRIBE_TO_PATH.'include/subscribtions_page.inc.php'); 
     28    include(SUBSCRIBE_TO_PATH.'include/subscriptions_page.inc.php'); 
    3429  } 
    3530} 
     
    4338{ 
    4439  global $page, $template; 
    45    
     40 
    4641  if ($comm['action'] == 'validate') 
    4742  { 
    4843    send_comment_to_subscribers($comm); 
    4944  } 
    50    
    51   if ( !empty($_POST['stc_mode']) and $_POST['stc_mode'] != -1 ) 
     45 
     46  if (!empty($_POST['stc_mode']) and $_POST['stc_mode'] != -1) 
    5247  { 
    5348    if ($comm['action'] != 'reject') 
     
    6156            break; 
    6257          case 'album-images': 
    63             if (empty($page['category']['id'])) break; 
    64             subscribe_to_comments(@$_POST['email'], 'album-images', $page['category']['id']); 
     58            if (!empty($page['category']['id'])) 
     59            { 
     60              subscribe_to_comments(@$_POST['email'], 'album-images', $page['category']['id']); 
     61            } 
    6562            break; 
    6663          case 'image': 
     
    9794function stc_comment_validation($comm_ids, $type='image') 
    9895{ 
    99   if (!is_array($comm_ids)) $comm_ids = array($comm_ids); 
    100    
     96  if (!is_array($comm_ids)) 
     97  { 
     98    $comm_ids = array($comm_ids); 
     99  } 
     100 
    101101  if ($type == 'image') 
    102102  { 
     
    111111;'; 
    112112  } 
    113   else if ($type == 'category') 
     113  else if ($type == 'album' && defined('COA_TABLE')) 
    114114  { 
    115115    $query = ' 
     
    123123;'; 
    124124  } 
    125    
    126   $comms = hash_from_query($query, 'id'); 
    127   foreach ($comms as $comm) 
    128   { 
    129     send_comment_to_subscribers($comm); 
     125 
     126  if (isset($query)) 
     127  { 
     128    $comms = query2array($query); 
     129    foreach ($comms as $comm) 
     130    { 
     131      send_comment_to_subscribers($comm); 
     132    } 
    130133  } 
    131134} 
     
    138141{ 
    139142  global $template, $picture, $page, $user, $conf; 
    140    
     143 
    141144  // standalone subscription 
    142145  if (isset($_POST['stc_submit'])) 
     
    148151        break; 
    149152      case 'album-images': 
    150         if (empty($page['category']['id'])) break; 
    151         subscribe_to_comments(@$_POST['stc_mail'], 'album-images', $page['category']['id']); 
     153        if (!empty($page['category']['id'])) 
     154        { 
     155          subscribe_to_comments(@$_POST['stc_mail'], 'album-images', $page['category']['id']); 
     156        } 
    152157        break; 
    153158      case 'image': 
     
    157162  } 
    158163  else if (isset($_GET['stc_unsubscribe'])) 
    159   {     
     164  { 
    160165    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe'])) 
    161166    { 
    162       array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); 
    163     } 
    164   } 
    165    
     167      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.'); 
     168    } 
     169  } 
     170 
    166171  // if registered user with mail we check if already subscribed 
    167   if ( !is_a_guest() and !empty($user['email']) ) 
     172  if (!is_a_guest() and !empty($user['email'])) 
    168173  { 
    169174    $subscribed = false; 
    170      
    171     // registered to all pictures 
    172     if (!$subscribed) 
    173     { 
    174       $query = ' 
     175 
     176    $base_query = ' 
    175177SELECT id 
    176178  FROM '.SUBSCRIBE_TO_TABLE.' 
    177179  WHERE 
    178180    email = "'.$user['email'].'" 
    179     AND type = "all-images" 
    180181    AND validated = "true" 
    181 ;'; 
    182       $result = pwg_query($query); 
    183        
     182'; 
     183 
     184    // registered to all pictures 
     185    if (!$subscribed) 
     186    { 
     187      $result = pwg_query($base_query . 'AND type = "all-images";'); 
     188 
    184189      if (pwg_db_num_rows($result)) 
    185190      { 
    186191        list($stc_id) = pwg_db_fetch_row($result); 
    187         $template->assign(array( 
    188           'SUBSCRIBED' => 'all-images', 
    189           'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)), 
    190           )); 
    191         $subscribed = true; 
     192        $subscribed = 'all-images'; 
    192193      } 
    193194    } 
    194195 
    195196    // registered to pictures in this album 
    196     if ( !$subscribed and !empty($page['category']['id']) ) 
    197     { 
    198       $query = ' 
    199 SELECT id 
    200   FROM '.SUBSCRIBE_TO_TABLE.' 
    201   WHERE 
    202     email = "'.$user['email'].'" 
    203     AND element_id = '.$page['category']['id'].' 
    204     AND type = "album-images" 
    205     AND validated = "true" 
    206 ;'; 
    207       $result = pwg_query($query); 
    208        
     197    if (!$subscribed and !empty($page['category']['id'])) 
     198    { 
     199      $result = pwg_query($base_query . 'AND type = "album-images" AND element_id = '.$page['category']['id'].';'); 
     200 
    209201      if (pwg_db_num_rows($result)) 
    210202      { 
    211203        list($stc_id) = pwg_db_fetch_row($result); 
    212         $template->assign(array( 
    213           'SUBSCRIBED' => 'album-images', 
    214           'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)), 
    215           )); 
    216         $subscribed = true; 
    217       } 
    218     } 
    219      
     204        $subscribed = 'album-images'; 
     205      } 
     206    } 
     207 
    220208    // registered to this picture 
    221209    if (!$subscribed) 
    222210    { 
    223       $query = ' 
    224 SELECT id 
    225   FROM '.SUBSCRIBE_TO_TABLE.' 
    226   WHERE 
    227     email = "'.$user['email'].'" 
    228     AND element_id = '.$picture['current']['id'].' 
    229     AND type = "image" 
    230     AND validated = "true" 
    231 ;'; 
    232       $result = pwg_query($query); 
    233        
     211      $result = pwg_query($base_query . 'AND type = "image" AND element_id = '.$picture['current']['id'].';'); 
     212 
    234213      if (pwg_db_num_rows($result)) 
    235214      { 
    236215        list($stc_id) = pwg_db_fetch_row($result); 
    237         $template->assign(array( 
    238           'SUBSCRIBED' => 'image', 
    239           'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)), 
    240           )); 
    241         $subscribed = true; 
    242       } 
     216        $subscribed = 'image'; 
     217      } 
     218    } 
     219 
     220    if ($subscribed) 
     221    { 
     222      $template->assign(array( 
     223        'SUBSCRIBED' => $subscribed, 
     224        'UNSUB_LINK' => add_url_params($picture['current']['url'], array('stc_unsubscribe'=>$stc_id)), 
     225        )); 
    243226    } 
    244227  } 
     
    247230    $template->assign('STC_ASK_MAIL', true); 
    248231  } 
    249    
     232 
    250233  $template->assign(array( 
    251234    'STC_ON_PICTURE' => true, 
     
    254237    'SUBSCRIBE_TO_PATH' => SUBSCRIBE_TO_PATH, 
    255238    )); 
    256    
     239 
    257240  $template->set_prefilter('picture', 'stc_main_prefilter'); 
    258241} 
     
    265248{ 
    266249  global $page, $template, $user, $conf; 
    267    
     250 
    268251  if ( 
    269252      !defined('COA_ID') or script_basename() != 'index' or 
     
    273256    return; 
    274257  } 
    275    
     258 
    276259        // standalone subscription 
    277260  if (isset($_POST['stc_submit'])) 
     
    291274    if (un_subscribe_to_comments(null, $_GET['stc_unsubscribe'])) 
    292275    { 
    293       array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); 
    294     } 
    295   } 
    296    
     276      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.'); 
     277    } 
     278  } 
     279 
    297280  // if registered user we check if already subscribed 
    298281  if ( !is_a_guest() and !empty($user['email']) ) 
     
    302285      'category' => $page['category'], 
    303286      )); 
    304            
     287 
    305288    $subscribed = false; 
    306      
    307     // registered to all albums 
    308     if (!$subscribed) 
    309     { 
    310       $query = ' 
     289 
     290    $base_query = ' 
    311291SELECT id 
    312292  FROM '.SUBSCRIBE_TO_TABLE.' 
    313293  WHERE 
    314294    email = "'.$user['email'].'" 
    315     AND type = "all-albums" 
    316295    AND validated = "true" 
    317 ;'; 
    318       $result = pwg_query($query); 
    319        
     296'; 
     297 
     298    // registered to all albums 
     299    if (!$subscribed) 
     300    { 
     301      $result = pwg_query($base_query . 'AND type = "all-albums"'); 
     302 
    320303      if (pwg_db_num_rows($result)) 
    321304      { 
    322305        list($stc_id) = pwg_db_fetch_row($result); 
    323         $template->assign(array( 
    324           'SUBSCRIBED' => 'all-albums', 
    325           'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)), 
    326           )); 
    327         $subscribed = true; 
    328       } 
    329     } 
    330      
     306        $subscribed = 'all-albums'; 
     307      } 
     308    } 
     309 
    331310    // registered to this album 
    332311    if (!$subscribed) 
    333312    { 
    334       $query = ' 
    335 SELECT id 
    336   FROM '.SUBSCRIBE_TO_TABLE.' 
    337   WHERE 
    338     email = "'.$user['email'].'" 
    339     AND element_id = '.$page['category']['id'].' 
    340     AND type = "album" 
    341     AND validated = "true" 
    342 ;'; 
    343       $result = pwg_query($query); 
    344        
     313      $result = pwg_query($base_query . 'AND type = "album" AND element_id = '.$page['category']['id'].';'); 
     314 
    345315      if (pwg_db_num_rows($result)) 
    346316      { 
    347317        list($stc_id) = pwg_db_fetch_row($result); 
    348         $template->assign(array( 
    349           'SUBSCRIBED' => 'album', 
    350           'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)), 
    351           )); 
    352         $subscribed = true; 
    353       } 
     318        $subscribed = 'album'; 
     319      } 
     320    } 
     321 
     322    if ($subscribed) 
     323    { 
     324      $template->assign(array( 
     325        'SUBSCRIBED' => $subscribed, 
     326        'UNSUB_LINK' => add_url_params($element_url, array('stc_unsubscribe'=>$stc_id)), 
     327        )); 
    354328    } 
    355329  } 
     
    358332    $template->assign('STC_ASK_MAIL', true); 
    359333  } 
    360    
     334 
    361335  $template->assign(array( 
    362336    'STC_ON_ALBUM' => true, 
     
    378352  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_standalone.tpl'); 
    379353  $content = str_replace($search, $replace.$search, $content); 
    380    
     354 
    381355  ## subscribe while add a comment ## 
    382356  $search = '{$comment_add.CONTENT}</textarea></p>'; 
    383357  $replace = file_get_contents(SUBSCRIBE_TO_PATH.'template/form_comment.tpl'); 
    384358  $content = str_replace($search, $search.$replace, $content); 
    385    
     359 
    386360  return $content; 
    387361} 
     
    395369  $query = ' 
    396370DELETE FROM '.SUBSCRIBE_TO_TABLE.' 
    397   WHERE  
     371  WHERE 
    398372    element_id IN ('.implode(',', $ids).') 
    399373    AND type = "image" 
     
    405379  $query = ' 
    406380DELETE FROM '.SUBSCRIBE_TO_TABLE.' 
    407   WHERE  
     381  WHERE 
    408382    element_id IN ('.implode(',', $ids).') 
    409383    AND (type = "album" OR type = "album-images") 
     
    419393{ 
    420394  global $template, $user; 
    421    
     395 
    422396  if (!empty($user['email'])) 
    423397  { 
     
    430404  $search = '<p class="bottomButtons">'; 
    431405  $replace = '<p style="font-size:1.1em;text-decoration:underline;"><a href="{$MANAGE_LINK}" rel="nofollow">{\'Manage my subscriptions\'|@translate}</a></p>'; 
    432    
     406 
    433407  return str_replace($search, $replace.$search, $content); 
    434408} 
    435  
    436 ?> 
  • extensions/Subscribe_to_comments/include/functions.inc.php

    r21608 r26139  
    11<?php 
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
    3  
    4 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    53 
    64/** 
     
    108function send_comment_to_subscribers($comm) 
    119{ 
    12   if ( empty($comm) or !is_array($comm) ) 
    13   { 
    14     trigger_error('send_comment_to_subscribers: undefineded comm', E_USER_WARNING); 
    15     return false; 
    16   } 
    17    
     10  if (empty($comm) or !is_array($comm)) 
     11  { 
     12    trigger_error('send_comment_to_subscribers: undefined comm', E_USER_WARNING); 
     13    return false; 
     14  } 
     15 
    1816  global $conf, $page, $user, $template; 
    19    
     17 
    2018  // create search clauses 
    2119  $where_clauses = array(); 
     
    2422    $element_id = $comm['image_id']; 
    2523    $element_type = 'image'; 
    26      
    27     array_push($where_clauses, 'type = "image" AND element_id = '.$element_id.''); 
    28     if (!empty($page['category']['id'])) array_push($where_clauses, 'type = "album-images" AND element_id = '.$page['category']['id'].''); 
    29     array_push($where_clauses, 'type = "all-images"'); 
     24 
     25    $where_clauses[] = '(type = "image" AND element_id = '.$element_id.')'; 
     26    $where_clauses[] = 'type = "all-images"'; 
     27    if (!empty($page['category']['id'])) 
     28    { 
     29      $where_clauses[] = '(type = "album-images" AND element_id = '.$page['category']['id'].')'; 
     30    } 
    3031  } 
    3132  else if (isset($comm['category_id'])) 
     
    3334    $element_id = $comm['category_id']; 
    3435    $element_type = 'category'; 
    35      
    36     array_push($where_clauses, 'type = "album" AND element_id = '.$element_id.''); 
    37     array_push($where_clauses, 'type = "all-albums"'); 
     36 
     37    $where_clauses[] = '(type = "album" AND element_id = '.$element_id.')'; 
     38    $where_clauses[] = 'type = "all-albums"'; 
    3839  } 
    3940  else 
     
    4142    return; 
    4243  } 
    43    
     44 
    4445  // exclude current user 
    4546  $exclude = null; 
     
    5253    $exclude = $user['email']; 
    5354  } 
    54    
     55 
    5556  // get subscribers datas 
    5657  $query = ' 
     
    6162  FROM '.SUBSCRIBE_TO_TABLE.' 
    6263  WHERE ( 
    63       ('.implode(")\n      OR (", $where_clauses).') 
     64      '.implode("\n      OR ", $where_clauses).' 
    6465    ) 
    6566    AND validated = true 
    6667    AND email != "'.$exclude.'" 
     68  GROUP BY email 
    6769'; 
    68   $subscriptions = hash_from_query($query, 'id'); 
    69    
    70   if (count($subscriptions)==0) return; 
    71    
     70  $subscriptions = query2array($query); 
     71 
     72  if (count($subscriptions)==0) 
     73  { 
     74    return; 
     75  } 
     76 
    7277  set_make_full_url(); 
    73    
     78 
    7479  // get element infos 
    7580  if ($element_type == 'image') 
     
    8186    $element = get_category_infos($comm['category_id']); 
    8287  } 
    83    
     88 
    8489  // format comment 
    85   if ($comm['author'] == 'guest') $comm['author'] = l10n('guest'); 
     90  if ($comm['author'] == 'guest') 
     91  { 
     92    $comm['author'] = l10n('guest'); 
     93  } 
     94 
    8695  $comm['author'] = trigger_event('render_comment_author', $comm['author']); 
    8796  $comm['content'] = trigger_event('render_comment_content', $comm['content']); 
    88    
    89   // mail content 
    90   $subject = '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name']; 
    91      
    92   $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/notification.tpl')); 
     97 
     98  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
    9399 
    94100  foreach ($subscriptions as $row) 
     
    103109      $row['user_id'] = $conf['guest_id']; 
    104110    } 
    105      
     111 
    106112    // check permissions 
    107113    if (!user_can_view_element($row['user_id'], $element_id, $element_type)) 
     
    109115      continue; 
    110116    } 
    111      
    112     // send mail 
    113     switch_lang_to($row['language']); 
    114     load_language('plugin.lang', SUBSCRIBE_TO_PATH); 
    115      
    116     $comm['caption'] = sprintf('<b>%s</b> wrote on <i>%s</i>', $comm['author'], format_date(date('Y-m-d H:i:s'))); 
    117      
    118     $template->assign('STC', array( 
    119       'element' => $element, 
    120       'comment' => $comm, 
    121       'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']), 
    122       'MANAGE_URL' => make_stc_url('manage', $row['email']), 
    123       'GALLERY_TITLE' => $conf['gallery_title'], 
    124       )); 
    125      
    126     $content = $template->parse('stc_mail', true); 
    127  
    128     stc_send_mail($row['email'], $content, $subject); 
     117 
     118    switch_lang_to($language); 
     119 
     120    $comm['date'] = format_date(date('Y-m-d H:i:s')); 
     121 
     122    pwg_mail( 
     123      $row['email'], 
     124      array( 
     125        'subject' => '['.strip_tags($conf['gallery_title']).'] Re:'.$element['name'], 
     126        ), 
     127      array( 
     128        'filename' => 'notification', 
     129        'dirname' => SUBSCRIBE_TO_PATH . 'template', 
     130        'assign' => array( 
     131          'ELEMENT' => $element, 
     132          'COMMENT' => $comm, 
     133          'UNSUB_URL' => make_stc_url('unsubscribe', $row['email'], $row['id']), 
     134          'MANAGE_URL' => make_stc_url('manage', $row['email']), 
     135          ), 
     136        ) 
     137      ); 
     138 
    129139    switch_lang_back(); 
    130140  } 
    131    
     141 
    132142  load_language('plugin.lang', SUBSCRIBE_TO_PATH); 
    133143  unset_make_full_url(); 
     
    149159    return false; 
    150160  } 
    151    
    152   if ( !in_array($type, array('all-images','all-albums')) and $element_id == 'NULL' ) 
     161 
     162  if (!in_array($type, array('all-images','all-albums')) and $element_id == 'NULL') 
    153163  { 
    154164    trigger_error('subscribe_to_comment: missing element_id', E_USER_WARNING); 
    155165    return false; 
    156166  } 
    157    
     167 
    158168  global $page, $conf, $user, $template, $picture; 
    159    
     169 
    160170  // check email 
    161   if ( !empty($email) and !email_check_format($email) ) 
    162   { 
    163     array_push($page['errors'], l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)')); 
    164     return false; 
    165   } 
    166   if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 
    167   { 
    168     array_push($page['errors'], l10n('Invalid email adress, your are not subscribed to comments.')); 
    169     return false; 
    170   } 
    171   else if ( !is_a_guest() and empty($email) ) 
     171  if (!empty($email) and !email_check_format($email)) 
     172  { 
     173    $page['errors'][] = l10n('mail address must be like xxx@yyy.eee (example : jack@altern.org)'); 
     174    return false; 
     175  } 
     176  if ( (is_a_guest() or empty($user['email'])) and empty($email) ) 
     177  { 
     178    $page['errors'][] = l10n('Invalid email address, your are not subscribed to comments.'); 
     179    return false; 
     180  } 
     181  else if (!is_a_guest() and empty($email)) 
    172182  { 
    173183    $email = $user['email']; 
    174184  } 
    175    
    176   // search if already registered (can't use ODKU because we want to get the id of inserted OR updated row) 
     185 
     186  // search if already registered 
    177187  $query = ' 
    178188SELECT id 
     
    184194;'; 
    185195  $result = pwg_query($query); 
    186    
     196 
    187197  if (pwg_db_num_rows($result)) 
    188198  { 
    189     list($inserted_id) = pwg_db_fetch_row($result); 
    190   } 
    191   else 
    192   { 
    193     $query = ' 
     199    return false; 
     200  } 
     201 
     202  $query = ' 
    194203INSERT INTO '.SUBSCRIBE_TO_TABLE.'( 
    195204    type, 
     
    209218  ) 
    210219;'; 
    211     pwg_query($query); 
    212      
    213     $inserted_id = pwg_db_insert_id(); 
    214   } 
    215    
    216   // notify admins 
    217   if ( pwg_db_changes() != 0 and $conf['Subscribe_to_Comments']['notify_admin_on_subscribe'] ) 
    218   { 
    219     stc_mail_notification_admins($email, $type, $element_id, $inserted_id); 
    220   } 
    221    
    222   // send validation mail 
    223   if ( is_a_guest() and pwg_db_changes() != 0 ) 
    224   { 
    225     set_make_full_url(); 
    226      
    227     $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/confirm.tpl')); 
    228      
    229     $subject = '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscribtion to comments'); 
    230        
     220  pwg_query($query); 
     221 
     222  $stc_id = pwg_db_insert_id(); 
     223 
     224  include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); 
     225 
     226  set_make_full_url(); 
     227 
     228  if (!is_a_guest() or $conf['Subscribe_to_Comments']['notify_admin_on_subscribe']) 
     229  { 
    231230    switch ($type) 
    232231    { 
    233232      case 'image': 
    234233        $element = get_picture_infos($element_id); 
    235         $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']); 
     234        $element['on'] = l10n('the picture <a href="%s">%s</a>', $element['url'], $element['name']); 
    236235        break; 
    237236      case 'album-images': 
    238237        $element = get_category_infos($element_id); 
    239         $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']); 
     238        $element['on'] = l10n('all pictures of the album <a href="%s">%s</a>', $element['url'], $element['name']); 
    240239        break; 
    241240      case 'all-images': 
     
    245244      case 'album': 
    246245        $element = get_category_infos($element_id); 
    247         $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']); 
     246        $element['on'] = l10n('the album <a href="%s">%s</a>', $element['url'], $element['name']); 
    248247        break; 
    249248      case 'all-albums': 
     
    252251        break; 
    253252    } 
    254      
    255     $template->assign('STC', array( 
    256       'element' => $element, 
    257       'VALIDATE_URL' => make_stc_url('validate', $email, $inserted_id), 
    258       'MANAGE_URL' => make_stc_url('manage', $email), 
    259       'GALLERY_TITLE' => $conf['gallery_title'], 
    260       )); 
    261      
    262     $content = $template->parse('stc_mail', true); 
    263  
    264     stc_send_mail($email, $content, $subject); 
    265     unset_make_full_url(); 
    266      
    267     array_push($page['infos'], l10n('Please check your email inbox to confirm your subscription.')); 
    268     return true; 
     253  } 
     254 
     255  // send validation mail 
     256  if (is_a_guest()) 
     257  { 
     258    pwg_mail( 
     259      $email, 
     260      array( 
     261        'subject' => '['.strip_tags($conf['gallery_title']).'] '.l10n('Confirm your subscription to comments'), 
     262        ), 
     263      array( 
     264        'filename' => 'confirm', 
     265        'dirname' => SUBSCRIBE_TO_PATH . 'template', 
     266        'assign' => array( 
     267          'ELEMENT' => $element, 
     268          'VALIDATE_URL' => make_stc_url('validate', $email, $stc_id), 
     269          'MANAGE_URL' => make_stc_url('manage', $email), 
     270          ), 
     271        ) 
     272      ); 
     273 
     274    $page['infos'][] = l10n('Please check your email in-box to confirm your subscription.'); 
    269275  } 
    270276  // just display confirmation message 
    271   else if (pwg_db_changes() != 0) 
    272   { 
    273     array_push($page['infos'], l10n('You have been added to the list of subscribers.')); 
    274     return true; 
    275   } 
    276    
    277   return false; 
     277  else 
     278  { 
     279    $page['infos'][] = l10n('You have been added to the list of subscribers.'); 
     280  } 
     281 
     282  // notify admins 
     283  if ($conf['Subscribe_to_Comments']['notify_admin_on_subscribe']) 
     284  { 
     285    $keyargs_content = array( 
     286      get_l10n_args('Hi administrators,'), 
     287      get_l10n_args(''), 
     288      get_l10n_args('%s has subscribed to comments on %s.', array($email, $element['on'])), 
     289      get_l10n_args('', ''), 
     290      get_l10n_args('Connected user: %s', stripslashes($user['username'])), 
     291      get_l10n_args('IP: %s', $_SERVER['REMOTE_ADDR']), 
     292      get_l10n_args('Browser: %s', $_SERVER['HTTP_USER_AGENT']), 
     293      ); 
     294 
     295    pwg_mail_notification_admins( 
     296      get_l10n_args('%s has subscribed to comments on %s.', array($email, '')), 
     297      $keyargs_content 
     298      ); 
     299  } 
     300 
     301  unset_make_full_url(); 
     302 
     303  return true; 
    278304} 
    279305 
     
    285311 * @return: bool 
    286312 */ 
    287 function un_subscribe_to_comments($email, $id) 
    288 {   
    289   if ( !empty($email) and !email_check_format($email) ) 
     313function un_subscribe_to_comments($email, $ids) 
     314{ 
     315  if (!empty($email) and !email_check_format($email)) 
    290316  { 
    291317    trigger_error('un_subscribe_to_comment: bad email', E_USER_WARNING); 
    292318    return false; 
    293319  } 
    294    
    295   if (!preg_match('#^[0-9]+$#', $id)) 
     320  if (empty($ids)) 
    296321  { 
    297322    trigger_error('un_subscribe_to_comment: bad id', E_USER_WARNING); 
    298323    return false; 
    299324  } 
    300    
    301   global $template, $user; 
    302    
     325 
     326  global $user; 
     327 
    303328  // check email 
    304   if ( ( is_a_guest() or empty($user['email']) ) and empty($email) ) 
    305   { 
    306     return false; 
    307   } 
    308   else if ( !is_a_guest() and empty($email) ) 
     329  if ( (is_a_guest() or empty($user['email'])) and empty($email) ) 
     330  { 
     331    return false; 
     332  } 
     333  else if (!is_a_guest() and empty($email)) 
    309334  { 
    310335    $email = $user['email']; 
    311336  } 
    312    
     337 
     338  if (!is_array($ids)) 
     339  { 
     340    $ids = array($ids); 
     341  } 
     342  $ids = array_map('intval', $ids); 
     343 
    313344  // delete subscription 
    314345  $query = ' 
    315346DELETE FROM '.SUBSCRIBE_TO_TABLE.' 
    316   WHERE  
     347  WHERE 
    317348    email = "'.pwg_db_real_escape_string($email).'" 
    318     AND id = '.$id.' 
     349    AND id IN('. implode(',', $ids) .') 
    319350;'; 
    320351  pwg_query($query); 
    321    
     352 
    322353  return (pwg_db_changes() != 0); 
    323354} 
     
    330361 * @return: bool 
    331362 */ 
    332 function validate_subscriptions($email, $id) 
     363function validate_subscriptions($email, $ids) 
    333364{ 
    334365  if (!email_check_format($email)) 
     
    337368    return false; 
    338369  } 
    339    
    340   if (!preg_match('#^[0-9]+$#', $id)) 
     370  if (empty($ids)) 
    341371  { 
    342372    trigger_error('validate_subscriptions: bad id', E_USER_WARNING); 
    343373    return false; 
    344374  } 
    345    
     375 
     376  if (!is_array($ids)) 
     377  { 
     378    $ids = array($ids); 
     379  } 
     380  $ids = array_map('intval', $ids); 
     381 
    346382  $query = ' 
    347383UPDATE '.SUBSCRIBE_TO_TABLE.' 
    348384  SET validated = "true" 
    349   WHERE  
     385  WHERE 
    350386    email = "'.pwg_db_real_escape_string($email).'" 
    351     AND id = '.$id.' 
     387    AND id IN('. implode(',', $ids) .') 
    352388;'; 
    353389  pwg_query($query); 
    354    
     390 
    355391  return (pwg_db_changes() != 0); 
    356 } 
    357  
    358  
    359 /** 
    360  * send notification to admins 
    361  * @param: string email 
    362  * @param: string type (image|album-images|all-images|album|all-albums) 
    363  * @param: int element_id 
    364  * @param: int subscription id 
    365  */ 
    366 function stc_mail_notification_admins($email, $type, $element_id, $inserted_id) 
    367 { 
    368   global $user, $conf, $template; 
    369    
    370   $admins = get_admins_email(); 
    371   if (empty($admins)) return; 
    372    
    373   set_make_full_url(); 
    374   switch_lang_to(get_default_language()); 
    375   load_language('plugin.lang', SUBSCRIBE_TO_PATH); 
    376    
    377   $template->set_filename('stc_mail', realpath(SUBSCRIBE_TO_PATH . 'template/mail/admin.tpl')); 
    378      
    379   $subject = '['.strip_tags($conf['gallery_title']).'] '.sprintf(l10n('%s has subscribed to comments on %s.'), is_a_guest()?$email:$user['username'], null); 
    380      
    381   switch ($type) 
    382   { 
    383     case 'image': 
    384       $element = get_picture_infos($element_id, false); 
    385       $element['on'] = sprintf(l10n('the picture <a href="%s">%s</a>'), $element['url'], $element['name']); 
    386       break; 
    387     case 'album-images': 
    388       $element = get_category_infos($element_id, false); 
    389       $element['on'] = sprintf(l10n('all pictures of the album <a href="%s">%s</a>'), $element['url'], $element['name']); 
    390       break; 
    391     case 'all-images': 
    392       $element['on'] = l10n('all pictures of the gallery'); 
    393       break; 
    394     case 'album': 
    395       $element = get_category_infos($element_id, false); 
    396       $element['on'] = sprintf(l10n('the album <a href="%s">%s</a>'), $element['url'], $element['name']); 
    397       break; 
    398     case 'all-albums': 
    399       $element['on'] = l10n('all albums of the gallery'); 
    400       break; 
    401   } 
    402    
    403   $technical_infos[] = sprintf(l10n('Connected user: %s'), stripslashes($user['username'])); 
    404   $technical_infos[] = sprintf(l10n('IP: %s'), $_SERVER['REMOTE_ADDR']); 
    405   $technical_infos[] = sprintf(l10n('Browser: %s'), $_SERVER['HTTP_USER_AGENT']); 
    406    
    407   $template->assign('STC', array( 
    408     'ELEMENT' => $element['on'], 
    409     'USER' => is_a_guest() ? '<b>'.$email.'</b>' : '<b>'.$user['username'].'</b> ('.$email.')',  
    410     'GALLERY_TITLE' => $conf['gallery_title'], 
    411     'TECHNICAL' => implode('<br>', $technical_infos), 
    412     )); 
    413    
    414   $content = $template->parse('stc_mail', true); 
    415  
    416   stc_send_mail($admins, $content, $subject); 
    417    
    418   unset_make_full_url(); 
    419   switch_lang_back(); 
    420   load_language('plugin.lang', SUBSCRIBE_TO_PATH); 
    421392} 
    422393 
     
    431402function make_stc_url($action, $email, $id=null) 
    432403{ 
    433   if ( empty($action) or empty($email) ) 
     404  if (empty($action) or empty($email)) 
    434405  { 
    435406    trigger_error('make_stc_url: missing action and/or mail', E_USER_WARNING); 
    436407    return null; 
    437408  } 
    438    
     409 
    439410  global $conf; 
    440411  set_make_full_url(); 
    441    
    442   $url_params = array( 
    443     'action' => $action, 
    444     'email' => $email, 
    445     ); 
    446    
     412 
     413  $url_params = compact('action', 'email'); 
    447414  if (!empty($id)) 
    448415  { 
    449416    $url_params['id'] = $id; 
    450417  } 
    451    
     418 
    452419  $url_params['key'] = crypt_value( 
    453     $action.$email.(isset($url_params['id'])?$url_params['id']:null),  
     420    $action.$email.$id, 
    454421    $conf['secret_key'] 
    455422    ); 
    456    
     423 
    457424  $url = add_url_params( 
    458     make_index_url( array('section' => 'subscriptions') ), 
     425    make_index_url(array('section' => 'subscriptions')), 
    459426    $url_params 
    460427    ); 
    461      
     428 
    462429  unset_make_full_url(); 
    463430  return $url; 
    464 } 
    465  
    466  
    467 /** 
    468  * send mail with STC style 
    469  * @param: string to 
    470  * @param: string content 
    471  * @param: string subject 
    472  * @return: bool 
    473  */ 
    474 function stc_send_mail($to, $content, $subject) 
    475 { 
    476   global $conf, $conf_mail, $page, $template; 
    477    
    478   // inputs 
    479   if (empty($to)) 
    480   { 
    481     return false; 
    482   } 
    483  
    484   if (empty($content)) 
    485   { 
    486     return false; 
    487   } 
    488    
    489   if (empty($subject)) 
    490   { 
    491     $subject = 'Piwigo'; 
    492   } 
    493   else 
    494   { 
    495     $subject = trim(preg_replace('#[\n\r]+#s', '', $subject)); 
    496     $subject = encode_mime_header($subject); 
    497   } 
    498    
    499   if (!isset($conf_mail)) 
    500   { 
    501     $conf_mail = get_mail_configuration(); 
    502   } 
    503  
    504   $args['from'] = $conf_mail['formated_email_webmaster']; 
    505    
    506   set_make_full_url(); 
    507    
    508   // hearders 
    509   $headers = 'From: '.$args['from']."\n";   
    510   $headers.= 'MIME-Version: 1.0'."\n"; 
    511   $headers.= 'X-Mailer: Piwigo Mailer'."\n"; 
    512   $headers.= 'Content-Transfer-Encoding: 8bit'."\n"; 
    513   $headers.= 'Content-Type: text/html; charset="'.get_pwg_charset().'";'."\n"; 
    514    
    515   // template 
    516   $template->set_filenames(array( 
    517     'stc_mail_header' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/header.tpl'), 
    518     'stc_mail_footer' => realpath(SUBSCRIBE_TO_PATH . 'template/mail/footer.tpl'), 
    519     )); 
    520   $stc_mail_css = file_get_contents(realpath(SUBSCRIBE_TO_PATH . 'template/mail/style.css')); 
    521      
    522   $template->assign(array( 
    523     'GALLERY_URL' => get_gallery_home_url(), 
    524     'PHPWG_URL' => PHPWG_URL, 
    525     'STC_MAIL_CSS' => str_replace("\n", null, $stc_mail_css), 
    526     )); 
    527    
    528   $content = $template->parse('stc_mail_header', true) . $content . $template->parse('stc_mail_footer', true); 
    529    
    530   $content = wordwrap($content, 70, "\n", false); 
    531  
    532   unset_make_full_url(); 
    533    
    534   // send mail 
    535   return 
    536     trigger_event('send_mail', 
    537       false, /* Result */ 
    538       trigger_event('send_mail_to', get_strict_email_list($to)), 
    539       trigger_event('send_mail_subject', $subject), 
    540       trigger_event('send_mail_content', $content), 
    541       trigger_event('send_mail_headers', $headers), 
    542       $args 
    543     ); 
    544431} 
    545432 
     
    553440function get_picture_infos($image_id, $with_thumb=true) 
    554441{ 
    555   if (empty($image_id)) return array(); 
    556    
     442  if (empty($image_id)) 
     443  { 
     444    return array(); 
     445  } 
     446 
    557447  $query = ' 
    558448SELECT 
     
    565455;'; 
    566456  $element = pwg_db_fetch_assoc(pwg_query($query)); 
    567      
     457 
    568458  if (empty($element['name'])) 
    569459  { 
     
    571461  } 
    572462  $element['name'] = trigger_event('render_element_name', $element['name']); 
    573    
     463 
    574464  $element['url'] = make_picture_url(array( 
    575465    'image_id'=>$element['id'] 
    576466    )); 
    577    
     467 
    578468  if ($with_thumb) 
    579469  { 
    580470    $element['thumbnail'] = DerivativeImage::thumb_url($element); 
    581471  } 
    582    
     472 
    583473  return $element; 
    584474} 
     
    593483{ 
    594484  global $conf; 
    595    
    596   if ($user_id===null) $user_id = $conf['guest_id']; 
    597    
     485 
     486  if ($user_id===null) 
     487  { 
     488    $user_id = $conf['guest_id']; 
     489  } 
     490 
    598491  $query = ' 
    599492SELECT 
     
    606499    img.path 
    607500  FROM '.CATEGORIES_TABLE.' AS cat 
    608     LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc  
     501    LEFT JOIN '.USER_CACHE_CATEGORIES_TABLE.' AS ucc 
    609502      ON ucc.cat_id = cat.id AND ucc.user_id = '.$user_id.' 
    610503    LEFT JOIN '.IMAGES_TABLE.' AS img 
     
    613506;'; 
    614507  $element = pwg_db_fetch_assoc(pwg_query($query)); 
    615    
     508 
    616509  $element['url'] = make_index_url(array( 
    617510    'section'=>'categories', 
    618511    'category'=>$element, 
    619512    )); 
    620      
     513 
    621514  $element['name'] = trigger_event('render_category_name', $element['name']); 
    622    
     515 
    623516  if ($with_thumb) 
    624517  { 
     
    636529    } 
    637530  } 
    638    
     531 
    639532  return $element; 
    640533} 
     
    647540{ 
    648541  global $conf, $user; 
    649    
     542 
    650543  $admins = array(); 
    651    
     544 
    652545  $query = ' 
    653546SELECT 
     
    655548    u.'.$conf['user_fields']['email'].' AS email 
    656549  FROM '.USERS_TABLE.' AS u 
    657     JOIN '.USER_INFOS_TABLE.' AS i  
     550    JOIN '.USER_INFOS_TABLE.' AS i 
    658551      ON i.user_id =  u.'.$conf['user_fields']['id'].' 
    659552  WHERE i.status IN ("webmaster", "admin") 
     
    686579{ 
    687580  global $conf; 
    688    
     581 
    689582  $old_conf = $conf['external_authentification']; 
    690583  $conf['external_authentification'] = false; 
    691584  $user = getuserdata($user_id, true); 
    692585  $conf['external_authentification'] = $old_conf; 
    693    
     586 
    694587  if ($type == 'image') 
    695588  { 
     
    715608 */ 
    716609function crypt_value($value, $key) 
    717 {   
     610{ 
    718611  if (extension_loaded('mcrypt')) 
    719612  { 
     
    733626    } 
    734627  } 
    735    
     628 
    736629  $result = base64url_encode($result); 
    737   return trim($result);  
     630  return trim($result); 
    738631} 
    739632 
     
    746639function decrypt_value($value, $key) 
    747640{ 
    748   $value = base64url_decode($value);  
    749    
     641  $value = base64url_decode($value); 
     642 
    750643  if (extension_loaded('mcrypt')) 
    751644  { 
     
    765658    } 
    766659  } 
    767    
     660 
    768661  return trim($result); 
    769662} 
     
    773666 * http://php.net/manual/en/function.base64-encode.php#103849 
    774667 */ 
    775 function base64url_encode($data) 
    776 { 
    777   return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 
    778 } 
    779 function base64url_decode($data) 
    780 { 
    781   return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 
    782 }  
    783  
    784 ?> 
     668if (!function_exists('base64url_encode')) 
     669{ 
     670  function base64url_encode($data) 
     671  { 
     672    return rtrim(strtr(base64_encode($data), '+/', '-_'), '='); 
     673  } 
     674  function base64url_decode($data) 
     675  { 
     676    return base64_decode(str_pad(strtr($data, '-_', '+/'), strlen($data) % 4, '=', STR_PAD_RIGHT)); 
     677  } 
     678} 
  • extensions/Subscribe_to_comments/include/subscriptions_page.inc.php

    r24342 r26139  
    1 <?php  
    2 if (!defined('SUBSCRIBE_TO_PATH')) die('Hacking attempt!'); 
     1<?php 
     2defined('SUBSCRIBE_TO_PATH') or die('Hacking attempt!'); 
    33 
    44global $template, $conf, $page, $user; 
    55 
    66// check input parameters 
    7 if ( empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key']) ) 
     7if (empty($_GET['action']) or empty($_GET['email']) or empty($_GET['key'])) 
    88{ 
    99  $_GET['action'] = null; 
     
    1111else 
    1212{ 
    13   $_GET['verif_key'] = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null); 
    14  
    15   if ( decrypt_value($_GET['key'], $conf['secret_key']) !== $_GET['verif_key'] ) 
     13  $verif_key = $_GET['action'].$_GET['email'].(isset($_GET['id'])?$_GET['id']:null); 
     14 
     15  if (decrypt_value($_GET['key'], $conf['secret_key']) !== $verif_key) 
    1616  { 
    1717    $_GET['action'] = null; 
     
    2121 
    2222 
    23 if ( !empty($_GET['action']) ) 
     23if (!empty($_GET['action'])) 
    2424{ 
    2525  // unsubscribe all 
    26   if ( isset($_POST['unsubscribe_all']) and isset($_POST['unsubscribe_all_check']) ) 
     26  if (isset($_POST['unsubscribe_all']) and isset($_POST['unsubscribe_all_check'])) 
    2727  { 
    2828    $query = ' 
     
    3232    pwg_query($query); 
    3333  } 
    34    
     34 
    3535  // bulk action 
    3636  else if (isset($_POST['apply_bulk']) and !empty($_POST['selected'])) 
    3737  { 
    38     foreach ($_POST['selected'] as $id) 
    39     { 
    40       switch ($_POST['action']) 
    41       { 
    42         case 'unsubscribe': 
    43           un_subscribe_to_comments($_GET['email'], $id); 
    44           break; 
    45         case 'validate': 
    46           validate_subscriptions($_GET['email'], $id); 
    47           break; 
    48       } 
    49     } 
    50   } 
    51    
     38    switch ($_POST['action']) 
     39    { 
     40      case 'unsubscribe': 
     41        un_subscribe_to_comments($_GET['email'], $_POST['selected']); 
     42        break; 
     43      case 'validate': 
     44        validate_subscriptions($_GET['email'], $_POST['selected']); 
     45        break; 
     46    } 
     47  } 
     48 
    5249  // unsubscribe from manage page 
    5350  else if (isset($_GET['unsubscribe'])) 
     
    5552    if (un_subscribe_to_comments($_GET['email'], $_GET['unsubscribe'])) 
    5653    { 
    57       array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); 
    58     } 
    59     else 
    60     { 
    61       array_push($page['errors'], l10n('Not found.')); 
    62     } 
    63   } 
    64    
     54      $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.'); 
     55    } 
     56    else 
     57    { 
     58      $page['errors'][] = l10n('Not found.'); 
     59    } 
     60  } 
     61 
    6562  // validate from manage page 
    6663  else if (isset($_GET['validate'])) 
     
    6865    if (validate_subscriptions($_GET['email'], $_GET['validate'])) 
    6966    { 
    70       array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.')); 
    71     } 
    72     else 
    73     { 
    74       array_push($page['infos'], l10n('Already validated.')); 
    75     } 
    76   } 
    77    
     67      $page['infos'][] = l10n('Your subscribtion has been validated, thanks you.'); 
     68    } 
     69    else 
     70    { 
     71      $page['infos'][] = l10n('Already validated.'); 
     72    } 
     73  } 
     74 
    7875  $template->assign('MANAGE_LINK', make_stc_url('manage', $_GET['email'])); 
    7976} 
     
    8986SELECT type, element_id 
    9087  FROM '.SUBSCRIBE_TO_TABLE.' 
    91   WHERE  
     88  WHERE 
    9289    email = "'.$_GET['email'].'" 
    9390    AND id = '.$_GET['id'].' 
    9491;'; 
    9592    $result = pwg_query($query); 
    96      
     93 
    9794    if (!pwg_db_num_rows($result)) 
    9895    { 
    99       array_push($page['errors'], l10n('Not found.')); 
     96      $page['errors'][] = l10n('Not found.'); 
    10097    } 
    10198    else 
     
    103100      if (validate_subscriptions($_GET['email'], $_GET['id'])) 
    104101      { 
    105         array_push($page['infos'], l10n('Your subscribtion has been validated, thanks you.')); 
     102        $page['infos'][] = l10n('Your subscription has been validated, thanks you.'); 
    106103      } 
    107104      else 
    108105      { 
    109         array_push($page['infos'], l10n('Already validated.')); 
    110       } 
    111        
     106        $page['infos'][] = l10n('Already validated.'); 
     107      } 
     108 
    112109      list($type, $element_id) = pwg_db_fetch_row($result); 
    113        
     110 
    114111      switch ($type) 
    115112      { 
     
    124121          $element = null; 
    125122      } 
    126        
     123 
    127124      $template->assign(array( 
    128125        'type' => $type, 
     
    130127        )); 
    131128    } 
    132      
     129 
    133130    $template->assign('IN_VALIDATE', true); 
    134131    break; 
    135132  } 
    136    
     133 
    137134  /* unsubscribe */ 
    138135  case 'unsubscribe': 
     
    143140    element_id 
    144141  FROM '.SUBSCRIBE_TO_TABLE.' 
    145   WHERE  
     142  WHERE 
    146143    email = "'.$_GET['email'].'" 
    147144    AND id = '.$_GET['id'].' 
    148145;'; 
    149146    $result = pwg_query($query); 
    150      
     147 
    151148    if (!pwg_db_num_rows($result)) 
    152149    { 
    153       array_push($page['errors'], l10n('Not found.')); 
     150      $page['errors'][] = l10n('Not found.'); 
    154151    } 
    155152    else 
     
    157154      if (un_subscribe_to_comments($_GET['email'], $_GET['id'])) 
    158155      { 
    159         array_push($page['infos'], l10n('Successfully unsubscribed your email address from receiving notifications.')); 
     156        $page['infos'][] = l10n('Successfully unsubscribed your email address from receiving notifications.'); 
    160157      } 
    161158      else 
    162159      { 
    163         array_push($page['errors'], l10n('Not found.')); 
    164       } 
    165        
     160        $page['errors'][] = l10n('Not found.'); 
     161      } 
     162 
    166163      list($type, $element_id) = pwg_db_fetch_row($result); 
    167        
     164 
    168165      switch ($type) 
    169166      { 
     
    178175          $element = null; 
    179176      } 
    180        
     177 
    181178      $template->assign(array( 
    182179        'type' => $type, 
     
    184181        )); 
    185182    } 
    186      
     183 
    187184    $template->assign('IN_UNSUBSCRIBE', true); 
    188185    break; 
    189186  } 
    190    
     187 
    191188  /* manage */ 
    192189  case 'manage': 
     
    199196;'; 
    200197    $result = pwg_query($query); 
    201      
     198 
    202199    if (pwg_db_num_rows($result)) 
    203200    { 
     
    205202      { 
    206203        $subscription['registration_date'] = format_date($subscription['registration_date'], true); 
    207          
     204 
    208205        switch ($subscription['type']) 
    209206        { 
     
    220217            continue(2); 
    221218        } 
    222          
     219 
    223220        $template->append('subscriptions', $subscription); 
    224221      } 
     
    226223    else 
    227224    { 
    228       array_push($page['infos'], l10n('You are not subscribed to any comment.')); 
     225      $page['infos'][] = l10n('You are not subscribed to any comment.'); 
    229226    } 
    230227    break; 
    231228  } 
    232    
     229 
    233230  default: 
    234231  { 
    235232    set_status_header(403); 
    236     array_push($page['errors'], l10n('Bad query')); 
     233    $page['errors'][] = l10n('Bad query'); 
    237234  } 
    238235} 
     
    244241  'COA_ACTIVATED' => defined('COA_ID'), 
    245242  )); 
    246    
     243 
    247244if (!empty($_GET['email'])) 
    248245{ 
    249   $template->assign('TITLE', '<a href="'.get_absolute_root_url().'">'.l10n('Home').'</a>'.$conf['level_separator']. 
    250                               sprintf(l10n('Subscriptions of %s'), '<i>'.$_GET['email'].'</i>')); 
    251 } 
    252  
    253 $template->set_filename('index', realpath(SUBSCRIBE_TO_PATH . 'template/subscribtions_page.tpl')); 
    254  
    255 ?> 
     246  $template->concat('TITLE', $conf['level_separator'] . l10n('Subscriptions of %s', '<i>'.$_GET['email'].'</i>')); 
     247} 
     248 
     249$template->set_filename('subscribe_to_comments', realpath(SUBSCRIBE_TO_PATH . 'template/subscriptions_page.tpl')); 
     250$template->assign_var_from_handle('CONTENT', 'subscribe_to_comments'); 
  • extensions/Subscribe_to_comments/main.inc.php

    r21608 r26139  
    1 <?php  
     1<?php 
    22/* 
    33Plugin Name: Subscribe To Comments 
    44Version: auto 
    55Description: This plugin allows to subscribe to comments by email. 
    6 Plugin URI: http://piwigo.org/ext/extension_view.php?eid=587 
     6Plugin URI: auto 
    77Author: Mistic 
    88Author URI: http://www.strangeplanet.fr 
    99*/ 
    1010 
    11 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     11defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 
    1212 
    1313global $prefixeTable; 
    1414 
    15 defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__))); 
     15define('SUBSCRIBE_TO_ID',      basename(dirname(__FILE__))); 
    1616define('SUBSCRIBE_TO_PATH' ,   PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/'); 
    1717define('SUBSCRIBE_TO_TABLE',   $prefixeTable . 'subscribe_to_comments'); 
     
    2525function stc_init() 
    2626{ 
    27   global $conf, $user, $pwg_loaded_plugins; 
    28    
     27  global $conf, $user; 
     28 
    2929  // no comments on luciano 
    30   if ($user['theme'] == 'luciano') return; 
    31    
    32   // apply upgrade if needed 
    33   if ( 
    34     SUBSCRIBE_TO_VERSION == 'auto' or 
    35     $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] == 'auto' or 
    36     version_compare($pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'], SUBSCRIBE_TO_VERSION, '<') 
    37   ) 
     30  if ($user['theme'] == 'luciano') 
    3831  { 
    39     include_once(SUBSCRIBE_TO_PATH . 'include/install.inc.php'); 
    40     stc_install(); 
    41      
    42     if ( $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] != 'auto' and SUBSCRIBE_TO_VERSION != 'auto' ) 
    43     { 
    44       $query = ' 
    45 UPDATE '. PLUGINS_TABLE .' 
    46 SET version = "'. SUBSCRIBE_TO_VERSION .'" 
    47 WHERE id = "'. SUBSCRIBE_TO_ID .'"'; 
    48       pwg_query($query); 
    49        
    50       $pwg_loaded_plugins[SUBSCRIBE_TO_ID]['version'] = SUBSCRIBE_TO_VERSION; 
    51        
    52       if (defined('IN_ADMIN')) 
    53       { 
    54         $_SESSION['page_infos'][] = 'Subscribe to comments updated to version '. SUBSCRIBE_TO_VERSION; 
    55       } 
    56     } 
     32    return; 
    5733  } 
    58    
    59   // load language and conf 
     34 
     35  include_once(SUBSCRIBE_TO_PATH . 'maintain.inc.php'); 
     36  $maintain = new Subscribe_to_Comments_maintain(SUBSCRIBE_TO_ID); 
     37  $maintain->autoUpdate(SUBSCRIBE_TO_VERSION, 'install'); 
     38 
     39 
    6040  load_language('plugin.lang', SUBSCRIBE_TO_PATH); 
    6141  $conf['Subscribe_to_Comments'] = unserialize($conf['Subscribe_to_Comments']); 
    62    
    63    
     42 
     43 
    6444  include_once(SUBSCRIBE_TO_PATH.'include/functions.inc.php'); 
    65   include_once(SUBSCRIBE_TO_PATH.'include/subscribe_to_comments.inc.php'); 
     45  include_once(SUBSCRIBE_TO_PATH.'include/events.inc.php'); 
    6646 
    67    
     47 
     48  if (!defined('IN_ADMIN')) 
     49  { 
     50    // subscribe 
     51    add_event_handler('loc_end_picture', 'stc_on_picture'); 
     52    add_event_handler('loc_begin_coa', 'stc_on_album'); 
     53 
     54    // management 
     55    add_event_handler('loc_end_section_init', 'stc_detect_section'); 
     56    add_event_handler('loc_begin_page_header', 'stc_load_section'); 
     57 
     58    // profile link 
     59    add_event_handler('loc_begin_profile', 'stc_profile_link'); 
     60  } 
     61  else 
     62  { 
     63    // config page 
     64    add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu'); 
     65  } 
     66 
    6867  // send mails 
    6968  add_event_handler('user_comment_insertion', 'stc_comment_insertion'); 
    7069  add_event_handler('user_comment_validation', 'stc_comment_validation', EVENT_HANDLER_PRIORITY_NEUTRAL, 2); 
    7170 
    72   // subscribe 
    73   add_event_handler('loc_end_picture', 'stc_on_picture'); 
    74   add_event_handler('loc_begin_coa', 'stc_on_album'); 
    75  
    76   // management 
    77   add_event_handler('loc_end_section_init', 'stc_detect_section'); 
    78   add_event_handler('loc_begin_page_header', 'stc_load_section'); 
    79    
    8071  // items deletion 
    8172  add_event_handler('begin_delete_elements', 'stc_delete_elements'); 
    8273  add_event_handler('delete_categories', 'stc_delete_categories'); 
    83  
    84   // profile link 
    85   add_event_handler('loc_begin_profile', 'stc_profile_link'); 
    86    
    87   // config page 
    88   add_event_handler('get_admin_plugin_menu_links', 'stc_admin_menu'); 
    8974} 
    9075 
    9176 
    92 function stc_admin_menu($menu)  
     77function stc_admin_menu($menu) 
    9378{ 
    94   array_push($menu, array( 
     79  $menu[] = array( 
    9580    'NAME' => 'Subscribe to Comments', 
    9681    'URL' => SUBSCRIBE_TO_ADMIN, 
    97   )); 
     82    ); 
    9883  return $menu; 
    9984} 
    100  
    101 ?> 
  • extensions/Subscribe_to_comments/maintain.inc.php

    r21441 r26139  
    11<?php 
    2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 
     2defined('PHPWG_ROOT_PATH') or die('Hacking attempt!'); 
    33 
    4 defined('SUBSCRIBE_TO_ID') or define('SUBSCRIBE_TO_ID', basename(dirname(__FILE__))); 
    5 include_once(PHPWG_PLUGINS_PATH . SUBSCRIBE_TO_ID . '/include/install.inc.php'); 
    6    
     4class Subscribe_to_Comments_maintain extends PluginMaintain 
     5{ 
     6  private $installed = false; 
    77 
    8 function plugin_install()  
    9 { 
    10   stc_install(); 
    11   define('stc_installed', true); 
    12 } 
     8  private $default_conf = array( 
     9    'notify_admin_on_subscribe' => false, 
     10    'allow_global_subscriptions' => true, 
     11    ); 
    1312 
    14 function plugin_activate() 
    15 { 
    16   if (!defined('stc_installed')) 
     13  private $table; 
     14 
     15  function __construct($plugin_id) 
    1716  { 
    18     stc_install(); 
     17    parent::__construct($plugin_id); 
     18 
     19    global $prefixeTable; 
     20    $this->table = $prefixeTable . 'subscribe_to_comments'; 
     21  } 
     22 
     23  function install($plugin_version, &$errors=array()) 
     24  { 
     25    global $conf; 
     26 
     27    // config parameter 
     28    if (empty($conf['Subscribe_to_Comments'])) 
     29    { 
     30      $conf['Subscribe_to_Comments'] = serialize($this->default_config); 
     31      conf_update_param('Subscribe_to_Comments', $conf['Subscribe_to_Comments']); 
     32    } 
     33 
     34    // subscriptions table 
     35    pwg_query(' 
     36CREATE TABLE IF NOT EXISTS `'. $this->table .'` ( 
     37  `id` int(11) unsigned NOT NULL AUTO_INCREMENT, 
     38  `type` enum("image","album-images","album","all-images","all-albums") NOT NULL DEFAULT "image", 
     39  `element_id` mediumint(8) DEFAULT NULL, 
     40  `language` varchar(64) NOT NULL, 
     41  `email` varchar(255) NOT NULL, 
     42  `registration_date` datetime NOT NULL, 
     43  `validated` enum("true","false") NOT NULL DEFAULT "false", 
     44  PRIMARY KEY (`id`), 
     45  UNIQUE KEY `UNIQUE` (`email` , `type` , `element_id`) 
     46) DEFAULT CHARSET=utf8 
     47;'); 
     48 
     49    // table structure upgrade in 1.1 
     50    $result = pwg_query('SHOW COLUMNS FROM `'. $this->table .'` LIKE "element_id";'); 
     51    if (!pwg_db_num_rows($result)) 
     52    { 
     53      // backup subscriptions 
     54      $query = 'SELECT * FROM `'. $this->table .'` ORDER BY registration_date;'; 
     55      $subscriptions = query2array($query, 'id'); 
     56 
     57      // upgrade the table 
     58      pwg_query('TRUNCATE TABLE `'. $this->table .'`;'); 
     59      pwg_query('ALTER TABLE `'. $this->table .'` DROP `image_id`, DROP `category_id`;'); 
     60      pwg_query('ALTER TABLE `'. $this->table .'` AUTO_INCREMENT = 1;'); 
     61 
     62      $query = ' 
     63ALTER TABLE `'. $this->table .'` 
     64  ADD `type` enum("image", "album-images", "album", "all-images", "all-albums") NOT NULL DEFAULT "image" AFTER `id`, 
     65  ADD `element_id` mediumint(8) NULL AFTER `type`, 
     66  ADD `language` varchar(64) NOT NULL AFTER `element_id` 
     67;'; 
     68      pwg_query($query); 
     69 
     70      pwg_query('ALTER TABLE `'. $this->table .'`  DROP INDEX `UNIQUE`, ADD UNIQUE `UNIQUE` (`email`, `type`, `element_id`);'); 
     71 
     72      // convert datas and fill the table 
     73      $inserts = array(); 
     74 
     75      foreach ($subscriptions as $row) 
     76      { 
     77        if (!empty($row['category_id'])) 
     78        { 
     79          $row['type'] = 'album'; 
     80          $row['element_id'] = $row['category_id']; 
     81        } 
     82        else if (!empty($row['image_id'])) 
     83        { 
     84          $row['type'] = 'image'; 
     85          $row['element_id'] = $row['image_id']; 
     86        } 
     87        else 
     88        { 
     89          continue; 
     90        } 
     91 
     92        unset($row['id'], $row['image_id'], $row['category_id']); 
     93        $row['language'] = 'en_UK'; 
     94 
     95        array_push($inserts, $row); 
     96      } 
     97 
     98      if (count($inserts) > 0) 
     99      { 
     100        $dbfields = array('type', 'element_id', 'language', 'email', 'registration_date', 'validated'); 
     101        mass_inserts($this->table, $dbfields, $inserts); 
     102      } 
     103    } 
     104 
     105    $this->installed = true; 
     106  } 
     107 
     108  function activate($plugin_version, &$errors=array()) 
     109  { 
     110    if (!$this->installed) 
     111    { 
     112      $this->install($plugin_version, $errors); 
     113    } 
     114  } 
     115 
     116  function deactivate() 
     117  { 
     118  } 
     119 
     120  function uninstall() 
     121  { 
     122    conf_delete_param('Subscribe_to_Comments'); 
     123 
     124    pwg_query('DROP TABLE `'. $this->table .'`;'); 
    19125  } 
    20126} 
    21  
    22 function plugin_uninstall()  
    23 { 
    24   global $prefixeTable; 
    25    
    26   pwg_query('DROP TABLE `'. $prefixeTable . 'subscribe_to_comments`;'); 
    27   pwg_query('DELETE FROM `'. CONFIG_TABLE .'` WHERE param = "Subscribe_to_Comments" LIMIT 1;'); 
    28 } 
    29 ?> 
  • extensions/Subscribe_to_comments/template/form_comment.tpl

    r21439 r26139  
    22 
    33<p> 
    4   {'Notify me of followup comments'|@translate} :<br> 
    5   <label><input type="radio" name="stc_mode" value="-1" {if !$STC_MODE}checked="checked"{/if}> {'No'|@translate}</label> 
     4  {'Notify me of followup comments'|translate} :<br> 
     5  <label><input type="radio" name="stc_mode" value="-1" {if !$STC_MODE}checked{/if}> {'No'|translate}</label> 
    66  {if $STC_ON_PICTURE} 
    7     {if $STC_ALLOW_GLOBAL}  
    8       <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked="checked"{/if}> {'this picture'|@translate}</label> 
    9       {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images" {if $STC_MODE=="album-images"}checked="checked"{/if}> {'all pictures of this album'|@translate}</label>{/if} 
    10       <label><input type="radio" name="stc_mode" value="all-images" {if $STC_MODE=="all-images"}checked="checked"{/if}> {'all pictures of the gallery'|@translate}</label> 
     7    {if $STC_ALLOW_GLOBAL} 
     8      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked{/if}> {'this picture'|translate}</label> 
     9      {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images" {if $STC_MODE=="album-images"}checked{/if}> {'all pictures of this album'|translate}</label>{/if} 
     10      <label><input type="radio" name="stc_mode" value="all-images" {if $STC_MODE=="all-images"}checked{/if}> {'all pictures of the gallery'|translate}</label> 
    1111    {else} 
    12       <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked="checked"{/if}> {'Yes'|@translate}</label> 
     12      <label><input type="radio" name="stc_mode" value="image" {if $STC_MODE=="image"}checked{/if}> {'Yes'|translate}</label> 
    1313    {/if} 
    1414  {elseif $STC_ON_ALBUM} 
    1515    {if $STC_ALLOW_GLOBAL} 
    16       <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked="checked"{/if}> {'this album'|@translate}</label> 
    17       <label><input type="radio" name="stc_mode" value="all-albums" {if $STC_MODE=="all-albums"}checked="checked"{/if}> {'all albums of the gallery'|@translate}</label> 
     16      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked{/if}> {'this album'|translate}</label> 
     17      <label><input type="radio" name="stc_mode" value="all-albums" {if $STC_MODE=="all-albums"}checked{/if}> {'all albums of the gallery'|translate}</label> 
    1818    {else} 
    19       <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked="checked"{/if}> {'Yes'|@translate}</label> 
     19      <label><input type="radio" name="stc_mode" value="album" {if $STC_MODE=="album"}checked{/if}> {'Yes'|translate}</label> 
    2020    {/if} 
    2121  {/if} 
     
    2323 
    2424{if $STC_ASK_MAIL} 
    25 {footer_script require="jquery"}{literal} 
     25{footer_script require='jquery'} 
     26(function($){ 
    2627        var $stc_email_input = $("#addComment input[name='email']"); 
    2728  var stc_bordercolor = $stc_email_input.css('border-color'); 
    28    
     29 
    2930  $("#addComment input[name='stc_mode']").change(function() { 
    3031    if ($(this).val() != "-1") { 
     
    4041    $(this).css('border-color', stc_bordercolor); 
    4142  }); 
    42 {/literal}{/footer_script} 
     43}(jQuery)); 
     44{/footer_script} 
    4345{/if} 
    4446 
  • extensions/Subscribe_to_comments/template/form_standalone.tpl

    r21439 r26139  
    1 {combine_css path=$SUBSCRIBE_TO_PATH|@cat:'template/style_form.css'} 
     1{combine_css path=$SUBSCRIBE_TO_PATH|cat:'template/style_form.css'} 
    22 
    33{if $STC_ALLOW_GLOBAL} 
    4   {footer_script require="jquery"}{literal} 
     4{footer_script require='jquery'} 
    55  jQuery("#stc_submit").hide(); 
    66  jQuery("#stc_standalone input[name='stc_mode']").change(function() { 
    77    jQuery("#stc_submit").show(); 
    88  }); 
    9   {/literal}{/footer_script} 
     9{/footer_script} 
    1010{/if} 
    1111 
     
    1616  {if $SUBSCRIBED} 
    1717    {if $SUBSCRIBED=='all-images'} 
    18       {assign var=str value='all pictures of the gallery'|@translate} 
     18      {assign var=str value='all pictures of the gallery'|translate} 
    1919    {elseif $SUBSCRIBED=='album-images'} 
    20       {assign var=str value='all pictures of this album'|@translate} 
     20      {assign var=str value='all pictures of this album'|translate} 
    2121    {elseif $SUBSCRIBED=='image'} 
    22       {assign var=str value='this picture'|@translate} 
     22      {assign var=str value='this picture'|translate} 
    2323    {elseif $SUBSCRIBED=='all-albums'} 
    24       {assign var=str value='all albums of the gallery'|@translate} 
     24      {assign var=str value='all albums of the gallery'|translate} 
    2525    {elseif $SUBSCRIBED=='album'} 
    26       {assign var=str value='this album'|@translate} 
     26      {assign var=str value='this album'|translate} 
    2727    {/if} 
    28      
    29     {'You are currently subscribed to comments on %s.'|@translate|sprintf:$str} 
    30     <a href="{$UNSUB_LINK}">{'Unsubscribe'|@translate}</a> 
     28 
     29    {'You are currently subscribed to comments on %s.'|translate|sprintf:$str} 
     30    <a href="{$UNSUB_LINK}">{'Unsubscribe'|translate}</a> 
    3131  {else} 
    32     <legend>{'Subscribe to mail notifications'|@translate}</legend> 
     32    <legend>{'Subscribe to mail notifications'|translate}</legend> 
    3333    {if $STC_ON_PICTURE} 
    3434      {if $STC_ALLOW_GLOBAL} 
    35         <label><input type="radio" name="stc_mode" value="image"> {'this picture'|@translate}</label> 
    36         {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images"> {'all pictures of this album'|@translate}</label>{/if} 
    37         <label><input type="radio" name="stc_mode" value="all-images"> {'all pictures of the gallery'|@translate}</label> 
     35        <label><input type="radio" name="stc_mode" value="image"> {'this picture'|translate}</label> 
     36        {if $STC_ALLOW_ALBUM_IMAGES}<label><input type="radio" name="stc_mode" value="album-images"> {'all pictures of this album'|translate}</label>{/if} 
     37        <label><input type="radio" name="stc_mode" value="all-images"> {'all pictures of the gallery'|translate}</label> 
    3838      {else} 
    3939        <input type="hidden" name="stc_mode" value="image"> 
     
    4141    {elseif $STC_ON_ALBUM} 
    4242      {if $STC_ALLOW_GLOBAL} 
    43         <label><input type="radio" name="stc_mode" value="album"> {'this album'|@translate}</label> 
    44         <label><input type="radio" name="stc_mode" value="all-albums"> {'all albums of the gallery'|@translate}</label> 
     43        <label><input type="radio" name="stc_mode" value="album"> {'this album'|translate}</label> 
     44        <label><input type="radio" name="stc_mode" value="all-albums"> {'all albums of the gallery'|translate}</label> 
    4545      {else} 
    4646        <input type="hidden" name="stc_mode" value="album"> 
     
    5050    <span id="stc_submit"> 
    5151    {if $STC_ASK_MAIL} 
    52         <label>{'Email'|@translate} <input type="text" name="stc_mail" size="30"></label> 
     52        <label>{'Email'|translate} <input type="text" name="stc_mail" size="30"></label> 
    5353    {/if} 
    54       <label><input type="submit" name="stc_submit" value="{'Subscribe'|@translate}"></label> 
     54      <label><input type="submit" name="stc_submit" value="{'Subscribe'|translate}"></label> 
    5555    </span> 
    5656  {/if} 
  • extensions/Subscribe_to_comments/template/style.css

    r21340 r26139  
    3535    vertical-align:top; 
    3636  } 
    37    
     37 
    3838.subscriptions_list tr.row2 { background-color:#222; } 
    3939.subscriptions_list tr.row1 { background-color:#333; } 
     
    4646} 
    4747.subscriptions_list tr.header th, .subscriptions_list tr.footer.row1 td { 
    48    
     48 
    4949  background: #333333; 
    5050  background: -moz-linear-gradient(top,  #333333 0%, #222222 100%); 
    51   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#333333), color-stop(100%,#222222)); 
    5251  background: -webkit-linear-gradient(top,  #333333 0%,#222222 100%); 
    5352  background: -o-linear-gradient(top,  #333333 0%,#222222 100%); 
     
    5958  background: #222222; 
    6059  background: -moz-linear-gradient(top,  #222222 0%, #333333 100%); 
    61   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#222222), color-stop(100%,#333333)); 
    6260  background: -webkit-linear-gradient(top,  #222222 0%,#333333 100%); 
    6361  background: -o-linear-gradient(top,  #222222 0%,#333333 100%); 
     
    6765} 
    6866 
    69  
    70 .stc p { 
    71   text-align:center; 
    72 } 
    73  
    74 .stc label { 
    75   display:block; 
    76 } 
    77  
    78 img.thumbnail { 
     67.subscriptions_list img.thumbnail { 
    7968  max-width:120px; 
    8069  max-height:90px; 
    8170} 
    8271 
     72.subscriptions_list a.unsub  { 
     73  color:#f66; 
     74} 
     75.subscriptions_list a.unsub:hover { 
     76  color:#f11; 
     77} 
  • extensions/Subscribe_to_comments/template/subscriptions_page.tpl

    r24342 r26139  
    1 {combine_css path=$SUBSCRIBE_TO_PATH|@cat:'template/style.css'} 
     1{combine_css path=$SUBSCRIBE_TO_PATH|cat:'template/style.css'} 
    22 
    3 {* <!-- Menubar & titrePage --> *} 
    4 {if $themeconf.name == "stripped" or $themeconf.parent == "stripped"} 
    5   {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/stripped.tpl'} 
    6   {assign var="clear" value="true"} 
    7 {elseif $themeconf.name == "simple-grey" or $themeconf.parent == "simple"} 
    8   {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/simple.tpl'} 
    9   {assign var="clear" value="true"} 
    10 {else} 
    11   {include file=$SUBSCRIBE_TO_ABS_PATH|@cat:'template/themes/default.tpl'} 
    12 {/if} 
    133 
    14 {include file='infos_errors.tpl'} 
    15  
    16   
    174{if $IN_VALIDATE or $IN_UNSUBSCRIBE} 
    185<p> 
     
    207  <a href="{$MANAGE_LINK}">{'Manage my subscriptions'|@translate}</a> 
    218</p> 
    22 {/if} 
    23    
     9 
     10{else} 
    2411<form action="{$MANAGE_LINK}" method="post"> 
    2512  {if !empty($global_subscriptions)} 
     
    3219          {if $sub.type == 'all-images'} 
    3320            {assign var=str value='all pictures of the gallery'|@translate} 
    34             <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png">  
     21            <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> 
    3522          {else $sub.type == 'all-albums'} 
    3623            {assign var=str value='all albums of the gallery'|@translate} 
     
    4128        <td style="white-space:nowrap;"> 
    4229          <div class="actions"> 
    43             <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}">{'Unsubscribe'|@translate}</a> 
     30            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}" class="unsub">{'Unsubscribe'|@translate}</a> 
    4431            {if $sub.validated == 'false'}<br> <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if} 
    4532          </div> 
     
    5340  </fieldset> 
    5441  {/if} 
    55    
     42 
    5643  {if !empty($subscriptions)} 
    5744  <fieldset> 
     
    6350        <th class="date">{'Followed on'|@translate}</th> 
    6451      </tr> 
    65        
     52 
    6653      {foreach from=$subscriptions item=sub name=subs_loop} 
    6754      <tr class="{if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if} {if $sub.validated == 'false'}not-validated{/if}"> 
     
    7360 
    7461          <div class="actions"> 
    75             <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}">{'Unsubscribe'|@translate}</a> 
     62            <a href="{$MANAGE_LINK}&amp;unsubscribe={$sub.id}" class="unsub">{'Unsubscribe'|@translate}</a> 
    7663            {if $sub.validated == 'false'}| <a href="{$MANAGE_LINK}&amp;validate={$sub.id}">{'Validate'|@translate}</a>{/if} 
    7764          </div> 
     
    8269      </tr> 
    8370      {/foreach} 
    84        
     71 
    8572      <tr class="footer {if $smarty.foreach.subs_loop.index is odd}row1{else}row2{/if}"><td colspan="4"> 
    8673        <select name="action"> 
     
    9279      </td></tr> 
    9380    </table> 
    94      
     81 
    9582    <p> 
    96       <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> {'comments on a picture'|@translate}.  
     83      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/image.png"> {'comments on a picture'|@translate}. 
    9784      <img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album-images.png"> {'comments on all pictures of an album'|@translate}. 
    9885      {if $COA_ACTIVATED}<img src="{$ROOT_URL}{$SUBSCRIBE_TO_PATH}template/album.png"> {'comments on an album'|@translate}.{/if} 
     
    10087  </fieldset> 
    10188  {/if} 
    102    
     89 
    10390  {if !empty($global_subscriptions) or !empty($subscriptions)} 
    10491    <p> 
     
    10996</form> 
    11097 
    111 {footer_script require="jquery"}{literal} 
     98{footer_script require="jquery"} 
    11299jQuery("#check_all").change(function() { 
    113   if ($(this).is(":checked")) 
    114     $("input[name^='selected']").attr('checked', 'checked'); 
    115   else 
    116     $("input[name^='selected']").removeAttr('checked'); 
     100  if (jQuery(this).is(":checked")) { 
     101    jQuery("input[name^='selected']").attr('checked', 'checked'); 
     102  } 
     103  else { 
     104    jQuery("input[name^='selected']").removeAttr('checked'); 
     105  } 
    117106}); 
    118 {/literal}{/footer_script} 
     107{/footer_script} 
    119108 
    120 {if $clear}<div style="clear: both;"></div> 
    121 </div>{/if} 
    122 </div> <!-- content --> 
     109{/if} 
  • extensions/Subscribe_to_comments/template/text/html/confirm.tpl

    r24342 r26139  
    1 <div id="the_header"> 
    2 {'Subscribe to comments on %s'|@translate|sprintf:$STC.GALLERY_TITLE}</b> 
    3 </div> 
     1<style> 
     2.button { 
     3  padding:8px 15px; 
     4  background:#A80D24; 
     5  color:#bbb; 
     6  border:1px solid #CE2E5A; 
     7  text-decoration:none; 
     8  font-size:14px; 
     9  font-weight:bold; 
     10} 
     11</style> 
    412 
    5 <div id="the_content"> 
     13<p>{'You requested to subscribe by email to comments on %s'|translate:$ELEMENT.on}.</p> 
    614 
    7 <p>{'You requested to subscribe by email to comments on %s'|@translate|sprintf:$STC.element.on}.</p> 
    8  
    9 {if not empty($STC.element.thumbnail)} 
    10 <p id="the_image"><img src="{$STC.element.thumbnail}" alt="{$STC.element.name}"></p> 
     15{if not empty($ELEMENT.thumbnail)} 
     16<p><img src="{$ELEMENT.thumbnail}" alt="{$ELEMENT.name}" class="photo"></p> 
    1117{/if} 
    1218 
    13 <p>{'To activate, click the confirm button. If you believe this is an error, please just ignore this message.'|@translate}</p> 
     19<p>{'To activate, click the confirm button. If you believe this is an error, please just ignore this message.'|translate}</p> 
    1420 
    15 <p><a href="{$STC.VALIDATE_URL}" class="button">{'Confirm subscription'|@translate}</a></p> 
     21<p><a href="{$VALIDATE_URL}" class="button">{'Confirm subscription'|translate}</a></p> 
    1622 
    17 <p>{'Want to edit your notifications options?'|@translate} <a href="{$STC.MANAGE_URL}">{'Manage my subscriptions'|@translate}</a>.</p> 
    18  
    19 </div> 
     23<p>{'Want to edit your notifications options?'|translate} <a href="{$MANAGE_URL}">{'Manage my subscriptions'|translate}</a>.</p> 
  • extensions/Subscribe_to_comments/template/text/html/notification.tpl

    r24342 r26139  
    1 <div id="the_header"> 
    2 {'New comment on %s'|@translate|sprintf:$STC.GALLERY_TITLE}</b> 
    3 </div> 
    4  
    5 <div id="the_content"> 
    6  
    7 <p id="the_image"> 
    8   <a href="{$STC.element.url}">{$STC.element.name}<br> 
    9   <img src="{$STC.element.thumbnail}" alt="{$STC.element.name}"></a> 
     1<p> 
     2  <a href="{$ELEMENT.url}">{$ELEMENT.name}<br> 
     3  <img src="{$ELEMENT.thumbnail}" alt="{$ELEMENT.name}" class="photo"></a> 
    104</p> 
    115 
    126<p> 
    13   {$STC.comment.caption}: 
    14   <blockquote>{$STC.comment.content}</blockquote> 
     7  {'<b>%s</b> wrote on <i>%s</i>'|translate:$COMMENT.author:$COMMENT.date} : 
     8  <blockquote>{$COMMENT.content}</blockquote> 
    159</p> 
    1610 
    1711<p> 
    18   <a href="{$STC.UNSUB_URL}">{'Stop receiving notifications'|@translate}</a><br> 
    19   <a href="{$STC.MANAGE_URL}">{'Manage my subscriptions'|@translate}</a> 
     12  <a href="{$UNSUB_URL}">{'Stop receiving notifications'|translate}</a><br> 
     13  <a href="{$MANAGE_URL}">{'Manage my subscriptions'|translate}</a> 
    2014</p> 
    21  
    22 </div> 
Note: See TracChangeset for help on using the changeset viewer.