Location: PHPKode > projects > MembersGear > membersgear/member/user_edit_profile.php
<?php

 require_once "../config/config.php"; 
 require_once INCLUDE_DIR."/users_signup_class.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();
   
 }  
/*******************************************************************/ 

     
 //**********************************************Begin Page code**********************************************     
require_once INCLUDE_DIR."/users_class.php";
require_once INCLUDE_DIR."/cannedemail_class.php";
require_once  INCLUDE_DIR."/autoresponder.php";
require_once INCLUDE_DIR."/fields_class.php";  
$loManageFields = new fields_class();    

$users=new users_class();
$loCannedEmail = new cannedemail_class();
//$controlresult=$loManageFields->renderDynamiControlOnPage('profile',11);
//$lsvalidationresult=$loManageFields->renderDynamiControlvalidation('profile',"frmsignup",'frmvalidator');
//$smarty->assign('controlvalidationresult',$lsvalidationresult);;
//$smarty->assign('controlresult',$controlresult); 

/*require_once INCLUDE_DIR."/ctl_isusernameavailable.php"; 
if(MEMBER_UNIQUE_EMAIL=='true')
  {
      require_once INCLUDE_DIR."/ctl_isemailavailable.php"; 
   }
require_once INCLUDE_DIR."/fill_states.php";
phpajax::init(); */  
$_action = strtoupper($_action);
switch($_action)
{
    case 'UPDATE':
    $lsUserid=$_SESSION[SESSION_PREFIX.'UserID']; 
    if(MEMBER_USE_ADDRESS_INFO=='invisible')
            {    
            $query="update ".TABLE_PREFIX ."users set firstname=?,lastname=?, modifiedon=?,modifiedby=?,modifiedipaddress=? where id=?";  
            }
            else
            {
                      $query="update ".TABLE_PREFIX ."users set firstname=?,lastname=?,modifiedon=?,modifiedby=?,modifiedipaddress=?  where id=?"; 
            }            
   
            //$ladyncltValues=$_POST;
         
            $lsValues = array(); 
            
            $lsValues[]=$_POST['fname'];
            $lsValues[]= $_POST['lname'];
            //$lsValues[]=$_POST['email'];
            //$lsValues[]=$_POST['phone'];
            $lsValues[]=mktime();
            $lsValues[]=0;
            $lsValues[]=$_SERVER['REMOTE_ADDR'];
            /*if(MEMBER_USE_ADDRESS_INFO!='invisible')
            {
                $lsValues[]=$_POST['country'];
                $lsValues[]=$_POST['state'];
                $lsValues[]=$_POST['city'];
                $lsValues[]=$_POST['address'];
                $lsValues[]=' ';
                $lsValues[]=$_POST['zipcode'];
            } */ 
            $lsValues[]=$lsUserid;
            
            $lTypes = false;
            
            $lsUpdatedrows = $users->Update($query,$lsValues,null); 
            if($lsUpdatedrows>0)
            {
                 //$smarty->assign('msg','your Profile Updated Successfully.');
                 
                 /*********************************************************************************************/
                 /*                            Update by jayesh                                               */
                 /*********************************************************************************************/
                 if(EMAIL_CHANGE_PROFILE == 'true')
                 {
                     $templateQuery = 'SELECT id,status FROM '.TABLE_PREFIX.'email_templates WHERE name=\'Profile updated\' AND productid=0';
                     $laTemplateData = $loCannedEmail->View($templateQuery);
                     
                     $userQuery = 'SELECT username,password,email,firstname,lastname,isunsubscribedfromemails FROM '.TABLE_PREFIX.'users WHERE id=?';
                     $lsUsersValues = array($lsUserid);
                     $laUserData = $users->View($userQuery,$lsUsersValues,null);

                     if($laTemplateData[0]['status'] == 1 and $laUserData[0]['isunsubscribedfromemails'] == 0)
                     {
                         $ladyncltValues['products']=9;   
                         SendCannedEmailsAutoresponse(EMAIL_CHANGE_PROFILE_TEMPLATE_ID,0,EMAIL_CHANGE_PROFILE_TEMPLATE_NAME,'','',$laUserData[0]['username'],$laUserData[0]['password'],$laUserData[0]['email'],$laUserData[0]['firstname'],$laUserData[0]['lastname']);
                     }
                 }
                 /****************Dynamic Control Update ****************/
                 
                 //$loManageFields->insertsignupformdata('profile',$ladyncltValues,$lsUserid);  
                 
                 /****************End mic Control Update****************/
                                                     
                 /*********************************************************************************************/                                            
                                                             
                 $message->SetMessage('Your Profile Updated Successfully.');
                 //$LOGINPAGE = $smarty->fetch('user_edit_profile.tpl');  
                 
               /* update by nikunj for listMailPro **********************************************************************/
                if($listmailProStatus)
                { 
                   listmailpro_updateUserToListMailPro($laUserData[0]['firstname'],$laUserData[0]['lastname'],$laUserData[0]['email']); 
                   $linkid =@mysql_connect(MEMBERSGEAR_DB_HOST,MEMBERSGEAR_DB_USER,MEMBERSGEAR_DB_PASSWORD);
                    @mysql_select_db(MEMBERSGEAR_DB_NAME, $linkid);
                 
                }
              /************************************************************************************************************/                                              
                /* Entry For Dyanmic Control*/
             $ladyncltValues=$_POST;   
             $loManageFields->insertsignupformdata('profile',$ladyncltValues,$lsUserid);  
             /*End*/
  
                 Redirect(WEB_URL.'/member/user_edit_profile.php?action=edit',true);
            }
           break;
      case 'DELETE':
            $smarty->assign('userdeletemsg','You are about to delete your account. If you are sure, click on the "Confirm Delete" button. This action will not be undo.');
            $affiliateSettings=$users->getAffiliateSettings($_SESSION[SESSION_PREFIX."UserID"]); 
            if(is_array($affiliateSettings))
                   $smarty->assign('affiliate_text','Your Affiliate Link');     
            else
                 $smarty->assign('affiliate_text','Become An Affiliate'); 
            $smarty->assign('Isdelete','yes'); 
            $LOGINPAGE = $smarty->fetch('user_edit_profile.tpl');
            break;
            
      case 'DELCONFIRM':
     
              /* $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(trim($_SESSION[SESSION_PREFIX.'UserID']));
              $isDeleted = $users->delete($userTablequery,$laUserID,null);
              if($isDeleted > 0)
              {
                       $isDeleted = $users->delete($usersinrolesTableQuery,$laUserID,null);
                       if($isDeleted > 0)
                       {
                                 $query="delete from ".TABLE_PREFIX."emails_log  where sentto_userid=?";
                                 $lsdeletedrows = $users->delete($query, $laUserID,null);
                                 $query="delete from  ".TABLE_PREFIX."users_log where userid=?";
                                 $lsdeletedrows = $users->delete($query, $laUserID,null);
                                 $isDeleted1 = $users->delete($tempproductusersTableQuery,$laUserID,null);   
                                 $query="delete from ".TABLE_PREFIX."signupformdata where userid=?";
                                 $isDeleted1 = $users->delete($query,$laUserID,null);
                                    
                       }
              } */
              
              /* update by nikunj for listmailpro setiing ***********************************************************************************/
                
                 if($listmailProStatus)
                { 
                    $userQuery = 'SELECT email  FROM '.TABLE_PREFIX.'users WHERE id=?';
                    $lsUsersValues = array(trim($_SESSION[SESSION_PREFIX.'UserID']));
                    $laUserData = $users->View($userQuery,$lsUsersValues,null);
                    $userEmail=$laUserData[0]['email'];
                    
                }
                
              /**********************************************************************************************************************************/   
               
             $isDeleted= $users->deleteuser(trim($_SESSION[SESSION_PREFIX.'UserID']));
              
              if($isDeleted > 0)
              {
                     $users->userLogout();
                     
                     /* 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("../user_login.php"); 
                      //('User deleted successfully.');
                     // Redirect('./user_logout.php');  
              }
              else
              {
                    //$message->SetMessage('Some error occure while deleting user.');
                    $smarty->assign('msg','Some error occure while deleting user.');
                    Redirect('./user_edit_profile.php?action=edit',true);
              }
              
              break;
            
        
        DEFAULT:     
             $lsupdateid[0]=$users_config->UserID;
             
             $laedituserinfo = $users->view("SELECT * FROM ".TABLE_PREFIX ."users where id=$lsupdateid[0]");  
             //$lastate=$laedituserinfo[0]['country'];
             //$Stateresult=array();
             /*if($lastate!=null)
             {
                $query= "SELECT id,name FROM ".TABLE_PREFIX."location where parentid=$lastate  order by `name`";
                $Stateresult = $users->View($query);
              }*/
            //  phpajax::init();
              //$query= "SELECT id,name FROM ".TABLE_PREFIX."location order by `name`";
              //$result = $users->View($query);
              //$smarty->assign('country',$result);
              //$smarty->assign('state',$Stateresult);
              
              $priceGroup=0;
              if(isset($_GET['group']))
                 $priceGroup=$_GET['group'];
                 
              $controlresult=$loManageFields->renderDynamiControlOnPage('profile',0);
              $lsvalidationresult=$loManageFields->renderDynamiControlvalidation('profile',"frmsignup",'frmvalidator');
              $smarty->assign('controlvalidationresult',$lsvalidationresult);
              $smarty->assign('controlresult',$controlresult);
     
              $smarty->assign('userdata',$laedituserinfo);    
              $smarty->assign('IsEdit','yes'); 
        
              $smarty->assign('msg',$message->GetMessage()); 
               $affiliateSettings=$users->getAffiliateSettings($_SESSION[SESSION_PREFIX."UserID"]); 
                if(is_array($affiliateSettings))
                   $smarty->assign('affiliate_text','Your Affiliate Link');     
               else
                 $smarty->assign('affiliate_text','Become An Affiliate'); 
                      
               $LOGINPAGE = $smarty->fetch('user_edit_profile.tpl'); 
         
}  
     
//**********************************************End Page code**********************************************
//Common Line
$smarty->assign('USER_CONTENT',     $LOGINPAGE); 

$smarty->display('user_page_main.tpl');

?>
Return current item: MembersGear