Ignore:
Timestamp:
Dec 23, 2013, 9:17:28 PM (10 years ago)
Author:
mistic100
Message:

update for 2.6

File:
1 moved

Legend:

Unmodified
Added
Removed
  • 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');
Note: See TracChangeset for help on using the changeset viewer.