Changeset 16105


Ignore:
Timestamp:
Jun 27, 2012, 11:10:50 PM (8 years ago)
Author:
mistic100
Message:

delete subscriptions on image/category deletion
check if is_valid_email() don't exist yet

Location:
extensions/Subscribe_to_comments
Files:
3 edited

Legend:

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

    r15656 r16105  
    690690 * @return: bool
    691691 */
    692 function is_valid_email($mail_address)
    693 {
    694   if (version_compare(PHP_VERSION, '5.2.0') >= 0)
    695   {
    696     return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
    697   }
    698   else
    699   {
    700     $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
    701     $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
    702     $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
    703 
    704     if (!preg_match($regex, $mail_address)) return false;
    705     return true;
     692if (!function_exists('is_valid_email'))
     693{
     694  function is_valid_email($mail_address)
     695  {
     696    if (version_compare(PHP_VERSION, '5.2.0') >= 0)
     697    {
     698      return filter_var($mail_address, FILTER_VALIDATE_EMAIL)!==false;
     699    }
     700    else
     701    {
     702      $atom   = '[-a-z0-9!#$%&\'*+\\/=?^_`{|}~]';   // before  arobase
     703      $domain = '([a-z0-9]([-a-z0-9]*[a-z0-9]+)?)'; // domain name
     704      $regex = '/^' . $atom . '+' . '(\.' . $atom . '+)*' . '@' . '(' . $domain . '{1,63}\.)+' . $domain . '{2,63}$/i';
     705
     706      if (!preg_match($regex, $mail_address)) return false;
     707      return true;
     708    }
    706709  }
    707710}
  • extensions/Subscribe_to_comments/include/subscribe_to_comments.inc.php

    r15641 r16105  
    373373
    374374/**
     375 * delete subscriptions to deleted images or categories
     376 */
     377function stc_delete_elements($ids)
     378{
     379  $query = '
     380DELETE FROM '.SUBSCRIBE_TO_TABLE.'
     381  WHERE element_id IN ('.implode(',', $ids).')
     382';
     383  pwg_query($query);
     384}
     385
     386
     387/**
    375388 * add link to management page for registered users
    376389 */
  • extensions/Subscribe_to_comments/main.inc.php

    r15641 r16105  
    4242  add_event_handler('loc_end_section_init', 'stc_detect_section');
    4343  add_event_handler('loc_begin_page_header', 'stc_load_section');
     44 
     45  // items deletion
     46  add_event_handler('begin_delete_elements', 'stc_delete_elements');
     47  add_event_handler('delete_categories', 'stc_delete_elements');
    4448
    4549  // profile link
Note: See TracChangeset for help on using the changeset viewer.