Location: PHPKode > projects > Esvon Personals > esvon-personals/modules/Mailing_Lists/hw_event.php
<?php

// --------------------------------------------------------------------------
//
// Esvon Classifieds v.4.0
// Copyright(C), Esvon LTD, 2001-2010, All Rights Reserved.
// E-mail: hide@address.com
//
// All forms of reproduction, including, but not limited to, internet posting, 
// printing, e-mailing, faxing and recording are strictly prohibited.
// One license required per site running Esvon Classifieds. 
// To obtain a license for using Esvon Classifieds, please register at
// http://www.esvon.com/pg/products/p_classifieds/
//
// --------------------------------------------------------------------------

function Mailing_Lists_Event($event,&$args){
global $db;

  $HW_MOD = 'Mailing_Lists';
  $TBL_ML = hwModTable($HW_MOD,'list');
  $TBL_ML_IDX = hwModTable($HW_MOD,'idx');

  switch($event){
          
    case 'onUserProfileFS':
      
      if(hwSessionGetVar('userid') || defined('ADMIN_AREA')) return;
      
      hwModLoadLng($HW_MOD);
      $res = $db->query('SELECT * FROM '.$TBL_ML_IDX.' WHERE id>0 AND hide=0 ORDER BY id');
      $num = mysql_num_rows($res);
      if(!$num) return;
      $i = 0;
      $s = "";
      while($v = mysql_fetch_assoc($res)){
        $s .= $v['name'];
        $i++;
        if($i<$num)$s .= ',';
      }
      global $O_HW;
      $MOD_CFG = $O_HW->GetModOptions($HW_MOD);
      $val = $MOD_CFG['EN_OPT_IN'] ? str_repeat('1',$num) : '';
      $args['A_F'][] = 'ufm_ml_idx|hw_ml_list|'.hwLng('ml_add').'||checkboxes|||1|||'.$val.'|No|No|No|Yes|'.$s;
      break;

   case 'onUserAdd':

   	  if(!$_POST['ufm_ml_idx'] || !is_array($_POST['ufm_ml_idx']) || !IsEmail($_POST['email'])) return;
   	  	  
   	  $cnt = count($_POST['ufm_ml_idx']);
  	  $a_ml = $db->one_col_array('SELECT id FROM '.$TBL_ML_IDX.' WHERE id>0 AND hide=0 ORDER BY id');
 	    $ql = '';
   	  $email = $db->quote($_POST['email']);
   	  foreach(array_keys($_POST['ufm_ml_idx']) as $k){
        if(!isset($a_ml[$k])) continue;
   	    $ql .= "('".$a_ml[$k]."','$email',".SQL_NOW."),";
   	  }
   	  if($ql){ 
        $ql = 'INSERT IGNORE INTO '.$TBL_ML.' (list_id,email,date) VALUES '.substr($ql,0,-1);
        $db->query($ql);
      }
      break;

    case 'onUserDelete':
      
      if($db->version()>=40100){
        $db->query('DELETE FROM '.hwModTable($HW_MOD,'unsub').' WHERE email IN( SELECT email FROM '.TBL_USER.' WHERE id IN ('.$args['STR_IDS'].') )');
      }
      else{
        $em = $db->one_col_array('SELECT email FROM '.TBL_USER.' WHERE id IN ('.$args['STR_IDS'].')');
        $em = '"'.implode('","', array_map(array($db,'quote'), $em)).'"';
        $db->query('DELETE FROM '.hwModTable($HW_MOD,'unsub').' WHERE email IN('.$em.')');
      }
      break;

   case 'onCronExecute':

      include SITE_PATH.'modules/'.$HW_MOD.'/cron.php';
      Mailing_Lists_Run();
      break;

  }

}

?>
Return current item: Esvon Personals