Location: PHPKode > projects > MembersGear > membersgear/admin/admin_user_action.php
<?php
  require_once "../config/config.php";
  require_once INCLUDE_DIR."/phpmailer/Functions.php";
  require_once INCLUDE_DIR."/users_class.php";
  require_once INCLUDE_DIR."/product_class.php";
  require_once INCLUDE_DIR."/cannedemail_class.php";
  require_once INCLUDE_DIR."/autoresponder.php"; 
 
  /* update by nikunj for list mail pro setting **********************/

$listmailProStatus=false;   
if(function_exists('listmailpro_check_Plugin_structure') and function_exists('listmailpro_getListMailPro_status') and function_exists('listmailpro_getListMailPro_table_Prefix') and function_exists('listmailpro_connect_to_db') and function_exists('listmailpro_disconnect_db') and function_exists('listmailpro_get_list_mailpro_user') and function_exists('listmailpro_get_all_list_mailpro_lists') and function_exists('listmailpro_addUserToListMailPro') and function_exists('listmailpro_updateUserToListMailPro') and function_exists('listmailpro_updateUserToListMailProAndEmail') and function_exists('listmailpro_deleteUserFromListMailPro') and function_exists('listmailpro_unique_id') and function_exists('listmailpro_remlists') and function_exists('listmailpro_getlistopts') and function_exists('listmailpro_addlists'))
 {
    $listmailProStatus=listmailpro_getListMailPro_status();
   
 }  
/*******************************************************************/  
  
  $loUserClass = new users_class();
  $loProductClass = new product_class();
  $loCannedEmail = new cannedemail_class();
  if($loUserClass->IsAdminhavePermission($_SESSION[SESSION_PREFIX.'Admin_UserID'],'Can send Email messages')==false)
  {
    Redirect('admin_nopermission.php',true);  
      
  }
  
  if(!isset($_GET['userid']) or $_GET['userid'] == '' or !(is_numeric($_GET['userid'])))
   {
       Redirect('admin_users_v.php'); 
   }
   
   $userid = $_GET['userid'];
   /*   
  if(isset($_GET['userid']) and $_GET['userid'] != '')
  {
        $userid =(int)$_GET['userid'];  
         
        if($userid==0)
        {
           Redirect('./admin_users_v.php');
        }  
  }
  else
  {
      Redirect('./admin_users_v.php');  
      
  }    
    */
  switch($_action) {
    case 'delete_user':
              $lsUserID =$_REQUEST['userid'];
             /* $userTablequery = 'DELETE FROM '.TABLE_PREFIX.'users WHERE id=?';
              $usersinrolesTableQuery = 'DELETE FROM '.TABLE_PREFIX.'users_in_roles WHERE userid=?';
              $tempproductusersTableQuery = 'DELETE FROM '.TABLE_PREFIX.'product_users WHERE userid=?';
              
              $laUserID = array($_REQUEST['userid']);
              /*$isDeleted = $loUserClass->delete($userTablequery,$laUserID,null);
              if($isDeleted > 0)
              {
                       $isDeleted = $loUserClass->delete($usersinrolesTableQuery,$laUserID,null);
                       if($isDeleted > 0)
                       {
                                $isDeleted1 = $loUserClass->delete($tempproductusersTableQuery,$laUserID,null);   
                       }
              }
              
              if($isDeleted > 0)
              {
                      $message->SetMessage('User deleted successfully.');
                      Redirect('admin_users_v.php');  
              }
              else
              {
                    $message->SetMessage('Some error occure while deleting user.');
                    Redirect('admin_user_action.php?userid='.$UserID);
              }  */
              
               /* update by nikunj for listmailpro setiing ***********************************************************************************/           
                if($listmailProStatus)
                { 
                    $prod_class_obj=new product_class();
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array($lsUserID);
                    $laUserData = $prod_class_obj->View($userQuery,$lsUsersValues,null);
                    $userEmail=$laUserData[0]['email'];
                }    
               /*******************************************************************************************************************************/     
              $loUserClass->deleteuser($lsUserID);
              $message->SetMessage('User deleted successfully.');
              
              /* update by nikunj for listmailpro setiing ***********************************************************************************/           
                if($listmailProStatus)
                { 
                   
                    listmailpro_deleteUserFromListMailPro($userEmail); 
                    $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                    @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
                    
                }
                
              /**********************************************************************************************************************************/   
              Redirect('admin_users_v.php'); 
              break;
              
    case 'send_sign_email':
            $UserID = $_REQUEST['userid'];
            $ProductList = $_REQUEST['chkProductList'];
            foreach($ProductList as $key=>$value)
            {
                //echo $UserID."->";
                //echo $value."<br/>";
                    
                    if($value != '')
                    {
                           //echo "send email to ".$value['id']." id number.<br/>";
                              if(EMAIL_PRODUCT_SIGNUP == 'true')
                              {
                                  
                                   $templateQuery = 'SELECT id,status FROM '.TABLE_PREFIX.'email_templates WHERE productid=? AND name=?';
                                   $lstemplateValues = array($value,EMAIL_PRODUCT_SIGNUP_TEMPLATE_NAME);
                                   $laTemplateData = $loCannedEmail->View($templateQuery,$lstemplateValues,null);
                                   $templateID = 0;
                                    if($laTemplateData != '')
                                    {
                                           $templateID = $laTemplateData[0]['id'];
                                           $productID  = $value['productid'];
                                    }
                                    else
                                    { 
                                            $templateID = EMAIL_PRODUCT_SIGNUP_TEMPLATE_ID;
                                            $productID  = 0;  
                                    }
                                   
                                   $userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
                                   $lsUsersValues = array($UserID);
                                   $laUserData = $loUserClass->View($userQuery,$lsUsersValues,null);
                                   
                                   $productTableQuery = 'SELECT name,singupemail,protectedurl FROM '.TABLE_PREFIX.'products WHERE id=?';
                                   $laProductValues = array($value);
                                   $laProductData = $loProductClass->View($productTableQuery,$laProductValues,null);
                                   
                                   /*  if($laUserData[0]['isunsubscribedfromemails'] == 0 and $laProductData[0]['singupemail'] != 'DONOTSEND')
                                     {
                                         SendCannedEmailsAutoresponse($templateID,$productID,'',$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
                                     }*/
                                    
                                    SendCannedEmailsAutoresponse($templateID,$productID,'',$laProductData[0]['name'],$laProductData[0]['protectedurl'],$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
                                     
                              }
                    }
            }
            
           
           $message->SetMessage('Signup Email has been sent.');
                  
           Redirect('admin_user_action.php?userid='.$UserID);
            //die;
            break;
            
    case 'send_user_email':
            $username = $_REQUEST['hdnUsername'];
            $emailID  = $_REQUEST['hdnUserEmail'];
            $emailSubject = $_REQUEST['txtSubject'];
            $emailContent = $_REQUEST['txtContent'];
            sendMail($emailID,$username,$emailSubject,$emailContent);
            
            $message->SetMessage('Email has been sent.');
                  
            Redirect('admin_user_action.php?userid='.$_REQUEST['userid']);
            break;
    
    default :
       $modUrl=$_GET['url'];
       $smarty->assign('modUrl',$modUrl);
       
       if($message->IsMessageExists())
        {    
            $smarty->assign('msg',$message->GetMessage());
        }
       
        $query = 'SELECT pu.email,concat(pu.firstname,\' \',pu.lastname) as `username`,pu.username as `realuesrname`
                 FROM '.TABLE_PREFIX.'users pu
                 where pu.id=?;';
      
       $lsValues = array($userid);
       
       $laResult1 = $loUserClass->View($query,$lsValues,null);
     
        //if(!is_array($laResult))
//        {
//            Redirect('admin_users_v.php');
//        }
     
       $smarty->assign('username',$laResult1[0]['username']);
       $smarty->assign('useremail',$laResult1[0]['email']);
       $smarty->assign('user_name',$laResult1[0]['realuesrname']);
       
       $query = 'SELECT pp.name,pp.id,pu.email,concat(pu.firstname,\' \',pu.lastname) as `username`,pu.username as `realuesrname`
                 FROM '.TABLE_PREFIX.'product_users ptp
                        join '.TABLE_PREFIX.'products pp on pp.id = ptp.productid
                        join '.TABLE_PREFIX.'users pu on pu.id = ptp.userid
                 where userid=?;';
       $lsValues = array($userid);
       
       $laResult = $loUserClass->View($query,$lsValues,null);
       if(is_array($laResult))
       { 
        $smarty->assign('SignupProduct',$laResult);
       }
       else
       {
          $smarty->assign('SignupProduct','');    
       }    
       $smarty->assign('userid' ,$userid);
       $smarty->display('admin_user_action.tpl');
  }   
?>
Return current item: MembersGear