Location: PHPKode > projects > SOA For Virtuemart (WebServices) > com_vm_soa/admin/services/VM_UsersService.php
<?php

define( '_VALID_MOS', 1 );
define( '_JEXEC', 1 );

/**
 * Virtuemart User SOA Connector
 *
 * Virtuemart User SOA Connector (Provide functions GetUsers, Authentification ...)
 *
 * @package    com_vm_soa
 * @subpackage modules
 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
 * @copyright  2010 Mickael Cabanas
 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version    $Id:$
 */
global $mosConfig_absolute_path, $sess;
global $jscook_type, $jscookMenu_style, $jscookTree_style;

$mosConfig_absolute_path= realpath( dirname(__FILE__).'/../../../..' );

// Load the joomla main cfg
if( file_exists(dirname(__FILE__).'/configuration.php' )) {
	require_once( $mosConfig_absolute_path.'/configuration.php' );
	
} else {
	require_once( $mosConfig_absolute_path.'/configuration.php');
}

/** init joomla cfg**/
define('JPATH_BASE', $mosConfig_absolute_path );
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
$mainframe =& JFactory::getApplication('site');

/**
 * INITIALISE THE APPLICATION
 */
// set the language
$mainframe->initialise();

// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php' )) {
	require_once( dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php' );
	$mosConfig_absolute_path = realpath( dirname(__FILE__).'/../..' );
} else {
	require_once( dirname(__FILE__).'/../../../../components/com_virtuemart/virtuemart_parser.php');
}

// Load the mailer class
$mosConfig_absolute_path= realpath( dirname(__FILE__).'/../../../..' );
$phpmailer_classname='phpmailer';
if( file_exists( $mosConfig_absolute_path . '/libraries/phpmailer/phpmailer.php') ) {
	$phpmailer_path = $mosConfig_absolute_path . '/libraries/phpmailer/phpmailer.php';
}elseif( file_exists( $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php')) {
	$phpmailer_path = $mosConfig_absolute_path . '/includes/phpmailer/class.phpmailer.php';
	$phpmailer_classname = 'mosphpmailer';
}
require_once( $phpmailer_path );

require_once(CLASSPATH.'ps_order_status.php');
require_once(CLASSPATH.'ps_user.php');
require_once(CLASSPATH.'ps_shopper.php');
require_once(CLASSPATH.'ps_shopper_group.php');
require_once(CLASSPATH.'ps_vendor.php');
require_once(CLASSPATH.'ps_vendor_category.php');
require_once(CLASSPATH.'ps_manufacturer.php');
require_once(CLASSPATH.'ps_manufacturer_category.php');
require_once(CLASSPATH.'zw_waiting_list.php');


require_once(dirname(__FILE__).'/../../../../libraries/joomla/plugin/helper.php');

include('../vm_soa_conf.php');

global $mosConfig_live_site;
$URL_BASE ='';
if( $mosConfig_live_site[strlen( $mosConfig_live_site)-1] == '/' ) {
	$URL_BASE = $mosConfig_live_site;
}
else {
	$URL_BASE = $mosConfig_live_site.'/';
}


/**
 * Class User
 *
 * Class "User" with attribute : id, name, code,
 * 
 *
 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
 * @copyright  Mickael cabanas
 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version    Release:
 */
	class User {
	
		public $id="";
		public $login="";
		public $password="";		
		public $email="";	
		public $firstname="";
		public $lastname="";	
		public $description="";	
		public $address="";	
		public $address2="";	
		public $state_region="";
		public $title="";	
		public $city="";
		public $country ="";
		public $zipcode="";	
		public $phone="";	
		public $fax="";			
		public $mobile="";	
		
		public $cdate="";	
		public $mdate="";	
		public $perms="";	
		public $bank_account_nr="";	
		public $bank_name="";	
		public $bank_sort_code="";	
		public $bank_iban="";	
		public $bank_account_holder="";	
		public $bank_account_type="";	
		public $shopper_group_id="";	
		public $customer_number="";
		public $groupe_id="";
		public $user_info_id="";
		public $address_type="";
		public $address_type_name="";
		public $company="";
		public $middle_name="";
		public $phone_2="";
		public $extra_field_1="";
		public $extra_field_2="";
		public $extra_field_3="";
		public $extra_field_4="";
		public $extra_field_5="";
		
		function __construct($id, $login,$password,$email,$firstname,$lastname,$description,$address,$address2,$state_region,$title,$city,$country,$zipcode,$phone,$fax,$mobile,
							$cdate, $mdate, $perms, $bank_account_nr, $bank_name, $bank_sort_code, $bank_iban, $bank_account_holder, $bank_account_type, $shopper_group_id,
							$customer_number, $groupe_id, $user_info_id, $address_type,$address_type_name, $company,$middle_name,$phone_2, $extra_field_1, $extra_field_2, $extra_field_3, $extra_field_4, $extra_field_5 ){
		
			$this->id=$id;
			$this->login=$login;
			$this->password=$password;		
			$this->email=$email;	
			$this->firstname=$firstname;	
			$this->lastname=$lastname;	
			$this->description=$description;	
			$this->address=$address;	
			$this->address2=$address2;
			$this->state_region=$state_region;
			$this->title=$title;	
			$this->city=$city;	
			$this->country = $country;
			$this->zipcode=$zipcode;	
			$this->phone=$phone;	
			$this->fax=$fax;			
			$this->mobile=$mobile;	
			$this->cdate=$cdate;
			$this->mdate=$mdate;
			$this->perms=$perms;
			$this->bank_account_nr=$bank_account_nr;
			$this->bank_name=$bank_name;
			$this->bank_sort_code=$bank_sort_code;
			$this->bank_iban=$bank_iban;
			$this->bank_account_holder=$bank_account_holder;
			$this->bank_account_type=$bank_account_type;
			$this->shopper_group_id=$shopper_group_id;
			$this->customer_number=$customer_number;
			$this->groupe_id=$groupe_id;
			$this->user_info_id=$user_info_id;
			$this->address_type=$address_type;
			$this->address_type_name=$address_type_name;
			$this->company=$company;
			$this->middle_name=$middle_name;
			$this->phone_2=$middle_name;
			$this->extra_field_1=$middle_name;
			$this->extra_field_2=$middle_name;
			$this->extra_field_3=$middle_name;
			$this->extra_field_4=$middle_name;
			$this->extra_field_5=$middle_name;
		}
	
	}
	
	/**
	 * Class Country
	 *
	 * Class "Country" with attribute : country_id, zone_id, country_name,country_3_code, country_2_code
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class Country {
	
		public $country_id="";
		public $zone_id="";
		public $country_name="";		
		public $country_3_code="";	
		public $country_2_code="";
		
		function __construct($country_id, $zone_id,$country_name,$country_3_code,$country_2_code){
		
			$this->country_id=$country_id;
			$this->zone_id=$zone_id;
			$this->country_name=$country_name;		
			$this->country_3_code=$country_3_code;	
			$this->country_2_code=$country_2_code;	
			
		}
	}
  
  	/**
	 * Class AuthGroup
	 *
	 * Class "AuthGroup" with attribute : group_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class AuthGroup {
	
		public $group_id="";
		public $group_name="";
		public $group_level="";		
		
		function __construct($group_id, $group_name,$group_level){
		
			$this->group_id=$group_id;
			$this->group_name=$group_name;
			$this->group_level=$group_level;		
		}
	}
  
  	/**
	 * Class State
	 *
	 * Class "State" with attribute : state_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class State {
	
		public $state_id="";
		public $country_id="";
		public $state_name="";		
		public $state_3_code="";	
		public $state_2_code="";
		
		function __construct($state_id, $country_id,$state_name,$state_3_code,$state_2_code){
		
			$this->state_id=$state_id;
			$this->country_id=$country_id;
			$this->state_name=$state_name;		
			$this->state_3_code=$state_3_code;	
			$this->state_2_code=$state_2_code;	
		}
	}
  
    /**
	 * Class ShopperGroup
	 *
	 * Class "ShopperGroup" with attribute :  shopper_group_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class ShopperGroup {
	
		public $shopper_group_id="";
		public $vendor_id="";
		public $shopper_group_name="";		
		public $shopper_group_desc="";	
		public $shopper_group_discount="";
		public $show_price_including_tax="";
		public $default="";
		
		function __construct($shopper_group_id, $vendor_id,$shopper_group_name,$shopper_group_desc,$shopper_group_discount,$show_price_including_tax,$default){
		
			$this->shopper_group_id=$shopper_group_id;
			$this->vendor_id=$vendor_id;
			$this->shopper_group_name=$shopper_group_name;		
			$this->shopper_group_desc=$shopper_group_desc;	
			$this->shopper_group_discount=$shopper_group_discount;	
			$this->show_price_including_tax=$show_price_including_tax;	
			$this->default=$default;	
		}
	}
  
 /**
 * Class User
 *
 * Class "Vendor" with attribute : vendor_id...
 * 
 *
 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
 * @copyright  Mickael cabanas
 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version    Release:
 */
	class Vendor {
	
		public $vendor_id="";
		public $vendor_name="";
		public $contact_last_name="";		
		public $contact_first_name="";	
		public $contact_middle_name="";
		public $contact_title="";	
		public $contact_phone_1="";	
		public $contact_phone_2="";	
		public $contact_fax="";	
		public $contact_email="";
		public $vendor_phone="";	
		public $vendor_address_1="";
		public $vendor_address_2 ="";
		public $vendor_city="";	
		public $vendor_state="";	
		public $vendor_country="";			
		public $vendor_zip="";	
		public $vendor_store_name="";
		public $vendor_store_desc="";
		public $vendor_category_id="";		
		public $vendor_thumb_image="";	
		public $vendor_full_image="";
		public $vendor_currency="";	
		public $cdate="";	
		public $mdate="";	
		public $vendor_image_path="";	
		public $vendor_terms_of_service="";
		public $vendor_url="";	
		public $vendor_min_pov="";
		public $vendor_freeshipping ="";
		public $vendor_currency_display_style="";	
		public $vendor_accepted_currencies="";	
		public $vendor_address_format="";			
		public $vendor_date_format="";	

		
		function __construct($vendor_id, $vendor_name,$contact_last_name,$contact_first_name,$contact_middle_name,$contact_title,$contact_phone_1,$contact_phone_2,
		$contact_fax,$contact_email,$vendor_phone,$vendor_address_1,$vendor_address_2,$vendor_city,$vendor_state,$vendor_country,$vendor_zip,
		$vendor_store_name, $vendor_store_desc,$vendor_category_id,$vendor_thumb_image,$vendor_full_image,$vendor_currency,$cdate,$mdate,
		$vendor_image_path,$vendor_terms_of_service,$vendor_url,$vendor_min_pov,$vendor_freeshipping,$vendor_currency_display_style,$vendor_accepted_currencies,$vendor_address_format,$vendor_date_format){
		
			$this->vendor_id=$vendor_id;
			$this->vendor_name=$vendor_name;
			$this->contact_last_name=$contact_last_name;		
			$this->contact_first_name=$contact_first_name;	
			$this->contact_middle_name=$contact_middle_name;	
			$this->contact_title=$contact_title;	
			$this->contact_phone_1=$contact_phone_1;	
			$this->contact_phone_2=$contact_phone_2;	
			$this->contact_fax=$contact_fax;
			$this->contact_email=$contact_email;
			$this->vendor_phone=$vendor_phone;	
			$this->vendor_address_1=$vendor_address_1;	
			$this->vendor_address_2 = $vendor_address_2;
			$this->vendor_city=$vendor_city;	
			$this->vendor_state=$vendor_state;	
			$this->vendor_country=$vendor_country;			
			$this->vendor_zip=$vendor_zip;	
			$this->vendor_store_name=$vendor_store_name;
			$this->vendor_store_desc=$vendor_store_desc;
			$this->vendor_category_id=$vendor_category_id;		
			$this->vendor_thumb_image=$vendor_thumb_image;	
			$this->vendor_full_image=$vendor_full_image;	
			$this->vendor_currency=$vendor_currency;	
			$this->cdate=$cdate;	
			$this->mdate=$mdate;	
			$this->vendor_image_path=$vendor_image_path;
			$this->vendor_terms_of_service=$vendor_terms_of_service;
			$this->vendor_url=$vendor_url;	
			$this->vendor_min_pov=$vendor_min_pov;	
			$this->vendor_freeshipping = $vendor_freeshipping;
			$this->vendor_currency_display_style=$vendor_currency_display_style;	
			$this->vendor_accepted_currencies=$vendor_accepted_currencies;	
			$this->vendor_address_format=$vendor_address_format;			
			$this->vendor_date_format=$vendor_date_format;	
		}
	
	} 
	
	  	/**
	 * Class VendorCategory
	 *
	 * Class "VendorCategory" with attribute : vendor_category_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class VendorCategory {
	
		public $vendor_category_id="";
		public $vendor_category_name="";
		public $vendor_category_desc="";		
		
		function __construct($vendor_category_id, $vendor_category_name,$vendor_category_desc){
		
			$this->vendor_category_id=$vendor_category_id;
			$this->vendor_category_name=$vendor_category_name;
			$this->vendor_category_desc=$vendor_category_desc;		
		}
	}
	 /**
	 * Class Manufacturer
	 *
	 * Class "Manufacturer" with attribute :  manufacturer_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class Manufacturer {
	
		public $manufacturer_id="";
		public $mf_name="";
		public $mf_email="";		
		public $mf_desc="";	
		public $mf_category_id="";
		public $mf_url="";
		
		function __construct($manufacturer_id, $mf_name,$mf_email,$mf_desc,$mf_category_id,$mf_url){
		
			$this->manufacturer_id=$manufacturer_id;
			$this->mf_name=$mf_name;
			$this->mf_email=$mf_email;		
			$this->mf_desc=$mf_desc;	
			$this->mf_category_id=$mf_category_id;	
			$this->mf_url=$mf_url;	
		}
	}
	
		 /**
	 * Class ManufacturerCat
	 *
	 * Class "ManufacturerCat" with attribute :  mf_category_id ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class ManufacturerCat {
	
		public $mf_category_id="";
		public $mf_category_name="";
		public $mf_category_desc="";		

		
		function __construct($mf_category_id, $mf_category_name,$mf_category_desc){
		
			$this->mf_category_id=$mf_category_id;
			$this->mf_category_name=$mf_category_name;
			$this->mf_category_desc=$mf_category_desc;		
			
		}
	}
	
	/**
 * Class AvalaibleImage
 *
 * Class "AvalaibleImage" with attribute : id, name, code, 
 *
 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
 * @copyright  Mickael cabanas
 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
 * @version    Release:
 */
	class AvalaibleImage {
		public $image_name="";
		public $image_url="";
		public $realpath="";

		//constructeur
		/**
		 * Enter description here...
		 *
		 * @param String $image_name
		 * @param String $image_url
		 */
		function __construct($image_name, $image_url, $realpath) {
			$this->image_name = $image_name;
			$this->image_url = $image_url;	
			$this->realpath = $realpath;				
		}
	}	
	
	
	 /**
	 * Class Session
	 *
	 * Class "Session" with attribute :  username ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class Session {
	
		public $username="";
		public $time="";
		public $session_id="";		
		public $guest="";	
		public $userid="";
		public $usertype="";
		public $gid="";
		public $client_id="";
		public $data="";
		
		function __construct($username, $time,$session_id,$guest,$userid,$usertype,$gid,$client_id,$data){
		
			$this->username=$username;
			$this->time=$time;
			$this->session_id=$session_id;		
			$this->guest=$guest;	
			$this->userid=$userid;	
			$this->usertype=$usertype;	
			$this->gid=$gid;	
			$this->client_id=$client_id;	
			$this->data=$data;	
			
		}
	}
	
	 /**
	 * Class WaitingList
	 *
	 * Class "WaitingList" with attribute :  username ...
	 * 
	 *
	 * @author     Mickael cabanas (cabanas.mickael|at|gmail.com)
	 * @copyright  Mickael cabanas
	 * @license    http://www.gnu.org/copyleft/gpl.html GNU/GPL
	 * @version    Release:
	 */
	class WaitingList {
	
		public $waiting_list_id="";
		public $product_id="";
		public $user_id="";		
		public $notify_email="";	
		public $notified="";	
		public $notify_date="";
		
		function __construct($waiting_list_id, $product_id,$user_id,$notify_email,$notified,$notify_date){
		
			$this->waiting_list_id=$waiting_list_id;
			$this->product_id=$product_id;
			$this->user_id=$user_id;		
			$this->notify_email=$notify_email;	
			$this->notified=$notified;	
			$this->notify_date=$notify_date;	
		
		}
	}
	
	
	
	
	/**
    * This function GetSessions return all sessions 
	* (expose as WS)
    * @param 
    * @return array of Users
	*/
	function GetSessions($params) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_getall']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$limite_start = $params->limite_start;
			$limite_end = $params->limite_end;
			if (empty($params->limite_start)){
				$limite_start = "0";
			}
			if (empty($params->limite_end)){
				$limite_end = "100";
			}
			
			$db = new ps_DB;
			$q  = "SELECT * FROM #__session WHERE 1 ";
			
			if ($params->guest != ""){
				$q .= " AND guest = '$params->guest' " ;
			}
			if ($params->usertype != ""){
				$q .= " AND usertype = '$params->usertype' " ;
			}
			if ($params->gid != ""){
				$q .= " AND gid = '$params->gid' " ;
			}
			if ($params->client_id != ""){
				$q .= " AND client_id = '$params->client_id' " ;
			}
			
			$q .= " ORDER BY time DESC  ";
			$q .= " LIMIT $limite_start,$limite_end ";
			$db->query($q);
			
			//return new SoapFault("GetSessions", "SQL Error \n ".$q);
			
			while ($db->next_record()) {
			
				$data="";
				if ($params->with_data == "Y"){
					$data = $db->f("data");
				}
				$Session = new Session($db->f("username"),$db->f("time"),$db->f("session_id"), $db->f("guest"), 
							$db->f("userid"), $db->f("usertype"), $db->f("gid"), $db->f("client_id"), $data  );
				$arraySession[]= $Session;
			}
			$errMsg=  $db->getErrorMsg();	
			if ($errMsg==null){
				return $arraySession;
			} else {
				return new SoapFault("GetSessions", "SQL Error \n ".$errMsg);
			}
			
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
		

	}
	
	/**
    * This function GetWaitingList return waiting list 
	* (expose as WS)
    * @param 
    * @return array of Users
	*/
	function GetWaitingList($params) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_getall']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$limite_start = $params->limite_start;
			$limite_end = $params->limite_end;
			if (empty($params->limite_start)){
				$limite_start = "0";
			}
			if (empty($params->limite_end)){
				$limite_end = "100";
			}
			  
			$db = new ps_DB;
			$q  = "SELECT * FROM #__{vm}_waiting_list WHERE 1 ";
			
			if ($params->waiting_list_id != ""){
				$q .= " AND waiting_list_id = '$params->waiting_list_id' " ;
			}
			if ($params->product_id != ""){
				$q .= " AND product_id = '$params->product_id' " ;
			}
			if ($params->user_id != ""){
				$q .= " AND user_id = '$params->user_id' " ;
			}
			if ($params->notify_email != ""){
				$q .= " AND notify_email = '$params->notify_email' " ;
			}
			if ($params->notified != ""){
				$q .= " AND notified = '$params->notified' " ;
			}
			if ($params->notify_date != ""){
				$q .= " AND notify_date > '$params->notify_date' " ;
			}
		
			$q .= " ORDER BY waiting_list_id DESC  ";
			$q .= " LIMIT $limite_start,$limite_end ";
			$db->query($q);
			
			//return new SoapFault("GetSessions", "SQL Error \n ".$q);
			
			while ($db->next_record()) {
			
				$WaitingList = new WaitingList($db->f("waiting_list_id"),$db->f("product_id"),$db->f("user_id"), $db->f("notify_email"), 
							$db->f("notified"), $db->f("notify_date")  );
				$arrayWaitingList[]= $WaitingList;
			}
			
			$errMsg=  $db->getErrorMsg();	
			if ($errMsg==null){
				return $arrayWaitingList;
			} else {
				return new SoapFault("GetSessions", "SQL Error \n ".$errMsg);
			}
			
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
		

	}
	
	
	/**
    * This function Notify Waiting List users
	* (expose as WS)
    * @param 
    * @return array of Users
	*/
	function NotifyWaitingList($params) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_getall']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			$mosConfig_lang = $params->loginInfo->lang;
			$zw_waiting_list = new zw_waiting_list();
			
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$prod_id = $params->ids->id[$i];
					$ret = $zw_waiting_list->notify_list($prod_id);
				}
			}else {
				
				$prod_id = $params->ids->id;
				$ret = $zw_waiting_list->notify_list($prod_id);
			}
			
			if ($ret==True){
				return "NotifyWaitingList OK";
			} else {
				return new SoapFault("NotifyWaitingListFault", "Error while notify waiting list");
			}
			
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
		

	}
	
	
	
  	/**
    * This function GetUsers return all users 
	* (expose as WS)
    * @param 
    * @return array of Users
	*/
	function GetUsers($params) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_getall']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$limite_start = $params->limite_start;
			$limite_end = $params->limite_end;
			if (empty($params->limite_start)){
				$limite_start = "0";
			}
			if (empty($params->limite_end)){
				$limite_end = "50";
			}
			
			$db = new ps_DB;
			$q  = "SELECT * FROM #__{vm}_user_info ui,`#__users` u,#__{vm}_shopper_vendor_xref rf WHERE address_type ='BT' AND ui.user_id=u.id AND rf.user_id=u.id GROUP BY ui.user_id ORDER BY ui.user_id DESC ";
			$q .= " LIMIT $limite_start,$limite_end ";
			$db->query($q);
			while ($db->next_record()) {
				$User = new User($db->f("user_id"),$db->f("username"),"*******",$db->f("user_email"), $db->f("first_name"), $db->f("last_name"), $db->f("extra_field_1"), $db->f("address_1"), $db->f("address_2"), $db->f("state"), $db->f("title"), $db->f("city"), $db->f("country"), $db->f("zip"), $db->f("phone_1"), $db->f("fax"), $db->f("phone_2"),
									$db->f("cdate"), $db->f("mdate"), $db->f("perms"), $db->f("bank_account_nr"), $db->f("bank_name"), $db->f("bank_sort_code"), $db->f("bank_iban"), $db->f("bank_account_holder"), $db->f("bank_account_type"), $db->f("shopper_group_id"), $db->f("customer_number"),
				$db->f("groupe_id"),$db->f("user_info_id"),$db->f("address_type"),$db->f("address_type_name"),$db->f("company"),$db->f("middle_name"),$db->f("phone_2"),$db->f("extra_field_1"),$db->f("extra_field_2"),$db->f("extra_field_3"),$db->f("extra_field_4"),$db->f("extra_field_5"));
				$arrayUser[]= $User;
			}
			return $arrayUser;
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
		

	}
	
  	/**
    * This function GetUsers return all users 
	* (expose as WS)
    * @param 
    * @return array of Users
	*/
	function AddUser($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_adduser']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$ps_user= new ps_user();
			
			$_SESSION["ps_vendor_id"]= "1";
			$_SESSION["auth"]= "admin";
			
			//$user['id'] =$params->User->id;		
			
			//$user['gid'] = '18';
			$user['username'] = $params->User->login;
			$user['title'] = $params->User->title;
			$user['email'] = $params->User->email;
			$user['password'] = $params->User->password;
			$user['password2'] = $params->User->password;
			$user['first_name'] = $params->User->firstname;
			$user['last_name'] = $params->User->lastname;
			$user['address_1'] = $params->User->address;
			$user['address_2'] = $params->User->address2;
			$user['city'] = $params->User->city;
			$user['zip'] = $params->User->zipcode;
			$user['country'] = $params->User->country;
			$user['state'] = $params->User->state_region;
			$user['phone_1'] = $params->User->phone;
			$user['phone_2'] = $params->User->mobile;
			$user['fax'] = $params->User->fax;
			$user['agreed'] = $params->User->password;
			if (empty($params->User->customer_number)){
				$user['customer_number'] = md5($params->User->email);
			}else {
				$user['customer_number'] = $params->User->customer_number;
			}
			
			
			
			
			$_POST['email']	= $user['email'];
			$_POST['usertype']	= "Registered";
			$_POST['agreed']	= "1";
			$_POST['block']	= "0";
			$_POST['sendEmail']	= "0";
			$_POST['username'] = $user['username'];
			$_POST['name'] = $user['username'];
			$_POST['password'] = $user['password'];
			$_POST['password2'] = $user['password'];
			if (empty($params->User->groupe_id)){
				$_POST['gid']	= "18"; //registred
			}else {
				$_POST['gid'] = $params->User->groupe_id;
			}
			
			
			$user['perms'] = $params->User->perms;
			if (empty($params->User->perms)) {
				$user['perms'] = "shopper";
			}
			
			$user['shopper_group_id'] = $params->User->shopper_group_id;
			if (empty($params->User->shopper_group_id)) {
				$user['shopper_group_id'] = "5";
			}
			
			$user['shopper_group_id'] = $params->User->shopper_group_id;
			$user['bank_account_nr'] = $params->User->bank_account_nr;
			$user['bank_name'] = $params->User->bank_name;
			$user['bank_sort_code'] = $params->User->bank_sort_code;
			$user['bank_iban'] = $params->User->bank_iban;
			$user['bank_account_holder'] = $params->User->bank_account_holder;
			$user['bank_account_type'] = $params->User->bank_account_type;

			//$uid = add($user);
			$uid = $ps_user->add($user);
			//$ps_shopper = new ps_shopper();
			//$uid = $ps_shopper->add($user);
			//$user['user_id'] = $params->User->id;
			
			//$ps_user->delete($user);
			//$addOk = $ps_shopper->add($user);
			
			if ($uid  == false){
				return new SoapFault("JoomlaAddUserFault", "Cannot create user: ".$params->User->login);
			} else {
				return $user['username']." successfully created";
			}

			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update User
	* (expose as WS)
    * @param 
    * @return result
	*/
	function UpdateUser($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upuser']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$ps_user= new ps_user();
			
			$_SESSION["ps_vendor_id"]= "1";
			$_SESSION["auth"]= "admin";
			
			//$user['id'] =$params->User->id;		
			
			//$user['gid'] = '18';
			$user['id'] = $params->User->id;
			$user['user_id'] = $params->User->id;
			$user['username'] = $params->User->login;
			$user['title'] = $params->User->title;
			$user['email'] = $params->User->email;
			$user['password'] = $params->User->password;
			$user['password2'] = $params->User->password;
			$user['first_name'] = $params->User->firstname;
			$user['last_name'] = $params->User->lastname;
			$user['address_1'] = $params->User->address;
			$user['address_2'] = $params->User->address2;
			$user['city'] = $params->User->city;
			$user['zip'] = $params->User->zipcode;
			$user['country'] = $params->User->country;
			$user['state'] = $params->User->state_region;
			$user['phone_1'] = $params->User->phone;
			$user['phone_2'] = $params->User->mobile;
			$user['fax'] = $params->User->fax;
			$user['agreed'] = $params->User->password;
			if (empty($params->User->customer_number)){
				$user['customer_number'] = md5($params->User->email);
			}else {
				$user['customer_number'] = $params->User->customer_number;
			}
			
			$_POST['email']	= $user['email'];
			$_POST['usertype']	= "Registered";
			$_POST['agreed']	= "1";
			$_POST['block']	= "0";
			$_POST['sendEmail']	= "0";
			$_POST['username'] = $user['username'];
			$_POST['name'] = $user['username'];
			$_POST['password'] = $user['password'];
			$_POST['password2'] = $user['password'];
			if (empty($params->User->groupe_id)){
				$_POST['gid']	= "18"; //registred
			}else {
				$_POST['gid'] = $params->User->groupe_id;
			}
			
			$user['perms'] = $params->User->perms;
			if (empty($params->User->perms)) {
				$user['perms'] = "shopper";
			}
			
			$user['shopper_group_id'] = $params->User->shopper_group_id;
			if (empty($params->User->shopper_group_id)) {
				$user['shopper_group_id'] = "5";
			}
			
			$user['shopper_group_id'] = $params->User->shopper_group_id;
			$user['bank_account_nr'] = $params->User->bank_account_nr;
			$user['bank_name'] = $params->User->bank_name;
			$user['bank_sort_code'] = $params->User->bank_sort_code;
			$user['bank_iban'] = $params->User->bank_iban;
			$user['bank_account_holder'] = $params->User->bank_account_holder;
			$user['bank_account_type'] = $params->User->bank_account_type;

			//$uid = add($user);
			$ret = $ps_user->update($user);
			//$ps_shopper = new ps_shopper();
			//$uid = $ps_shopper->add($user);
			//$user['user_id'] = $params->User->id;
			
			//$ps_user->delete($user);
			//$addOk = $ps_shopper->add($user);
			
			if ($ret  == false){
				return new SoapFault("UpdateUserFault", "Cannot Update user: ".$params->User->login);
			} else {
				return $user['username']." successfully updated";
			}

			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}

  	/**
    * This function DeleteUser delete a user
	* (expose as WS)
    * @param 
    * @return result
	*/
	function DeleteUser($params) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_deluser']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$ps_user= new ps_user();
			
			$_SESSION["ps_vendor_id"]= "1";
			$_SESSION["auth"]= "admin";
			$user['user_id'] = $params->user_id;
			
			$del = $ps_user->delete($user);
			
			if ($del   == true){
				return "Customer Deleted";
			} else {
				return new SoapFault("JoomlaDeleteUserFault", "Cannot delete user: ".$params->user_id);
			}

		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
		
	}
	
  	/**
    * This function sendMail 
	* (expose as WS)
    * @param 
    * @return result
	*/
	function SendMail($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_sendmail']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
		
				
				if (is_array($params->EmailParams->images->Image)){
				
					$count = count($params->EmailParams->images->Image);
					for ($i = 0; $i < $count; $i++) {
						$mailImag['path']= $params->EmailParams->images->Image->path[$i];
						$mailImag['name']= $params->EmailParams->images->Image->name[$i];
						$mailImag['filename']= $params->EmailParams->images->Image->filename[$i];
						$mailImag['encoding']= $params->EmailParams->images->Image->encoding[$i];
						$mailImag['mimetype']= $params->EmailParams->images->Image->mimetype[$i];
						
						$mailImage[]=$mailImag;
					}
				
				} else {
					$mailImage['path']= $params->EmailParams->images->Image->path;
					$mailImage['name']= $params->EmailParams->images->Image->name;
					$mailImage['filename']= $params->EmailParams->images->Image->filename;
					$mailImage['encoding']= $params->EmailParams->images->Image->encoding;
					$mailImage['mimetype']= $params->EmailParams->images->Image->mimetype;
				
				}
			
				$ret = vmMail( $params->EmailParams->from_mail, $params->EmailParams->from_name, $params->EmailParams->recipient, $params->EmailParams->subject, $params->EmailParams->body, $params->EmailParams->altbody,$params->EmailParams->mode,$params->EmailParams->cc,$params->EmailParams->bcc,$mailImage,$params->EmailParams->attachment,$params->EmailParams->replyto);
				
				if ($params->EmailParams->removeAttachmentOnFinish == "Y" && file_exists($params->EmailParams->attachment)){
					unlink($params->EmailParams->attachment);
				}
				if (ret){
					return "Email send to ".$params->EmailParams->recipient;
				}else{
					return new SoapFault("JoomlaSendMailFault", "Email can not be send to".$params->EmailParams->recipient);
				}

			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}	

	/**
    * This function to research an user (By email or by username)
	* (expose as WS)
    * @param 
    * @return result
	*/
	function GetUserFromEmailOrUsername($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_search']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;
			
			
			//request for username/lastname/firstname
			$value=$params->username;
			$field="last_name";
			$q = "SELECT *  FROM #__{vm}_user_info vu, #__users ju  WHERE `$field` LIKE  '%$value%' AND address_type ='BT' AND ju.id=vu.user_id OR `first_name` LIKE  '%$value%' AND address_type ='BT' AND ju.id=vu.user_id OR `username` LIKE  '%$value%' AND address_type ='BT' AND ju.id=vu.user_id OR `email` LIKE  '%$value%' AND address_type ='BT' AND ju.id=vu.user_id ";
			
			//request for email
			if ($params->searchtype=="email"){
				$field="email";
				$value=$params->email;
				$q = "SELECT *  FROM #__{vm}_user_info vu, #__users ju  WHERE address_type ='BT' AND `$field` LIKE '%$value%' AND ju.id=vu.user_id";
				
			} else if ($params->searchtype=="user_id"){ //request for user_ids
			
				$field="user_id";
				$q = "SELECT *  FROM #__{vm}_user_info vu, #__users ju  WHERE address_type ='BT' AND ";	
				
				if (is_array($params->user_ids->user_id)){
			
					$count = count($params->user_ids->user_id);
					for ($i = 0; $i < $count; $i++) {
						$value=$params->user_ids->user_id[$i];
						if ($i == $count-1){
							$q .= "`$field` = '$value' AND ju.id=vu.user_id";
						} else {
							$q .= "`$field` = '$value' AND ju.id=vu.user_id OR ";
						}
					}
					//$q .= " AND ju.id=vu.user_id";
				}else {
					$value=$params->user_ids->user_id;
					$q = "SELECT *  FROM #__{vm}_user_info vu, #__users ju  WHERE address_type ='BT' AND `$field` = '$value' AND ju.id=vu.user_id";
				}
				
			} else if ($params->searchtype=="username"){ //request for USERNAME
				$field="username";
				$value=$params->username;
				$q = "SELECT *  FROM #__{vm}_user_info vu, #__users ju  WHERE address_type ='BT' AND`$field` LIKE  '%$value%' AND ju.id=vu.user_id";
			}
			
			$db->query($q);
			while ($db->next_record()) {
				$User = new User($db->f("user_id"),$db->f("username"),"********",$db->f("user_email"), $db->f("first_name"), $db->f("last_name"), $db->f("extra_field_1"), $db->f("address_1"), $db->f("address_2"), $db->f("state"), $db->f("title"), $db->f("city"), $db->f("country"), $db->f("zip"), $db->f("phone_1"), $db->f("fax"), $db->f("phone_2"),
									$db->f("cdate"), $db->f("mdate"), $db->f("perms"), $db->f("bank_account_nr"), $db->f("bank_name"), $db->f("bank_sort_code"), $db->f("bank_iban"), $db->f("bank_account_holder"), $db->f("bank_account_type"), $db->f("shopper_group_id"), $db->f("customer_number"),
									$db->f("groupe_id"),$db->f("user_info_id"),$db->f("address_type"),$db->f("address_type_name"),$db->f("company"),$db->f("middle_name"),$db->f("phone_2"),$db->f("extra_field_1"),$db->f("extra_field_2"),$db->f("extra_field_3"),$db->f("extra_field_4"),$db->f("extra_field_5"));
				
				$UserArray[] = $User;
			}
			return $UserArray;

		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}	
	
	
	/**
    * This function to Get Additional User Info
	* (expose as WS)
    * @param 
    * @return result
	*/
	function GetAdditionalUserInfo($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_search']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;
			
			
			//request for username/lastname/firstname
			$value=$params->username;
			
			$q  = "SELECT * FROM #__{vm}_user_info ui join #__users u on ui.user_id=u.id WHERE 1 ";
			
			if (!empty($params->user_id)){
				$q .= " AND ui.user_id = '$params->user_id'";
			}
			if (!empty($params->login)){
				$q .= " AND u.username  = '$params->login'";
			}
			if (!empty($params->email)){
				$q .= " AND u.email = '$params->email'";
			}
			
			$q .= " LIMIT 0,100 ";
			
			$db->query($q);
			while ($db->next_record()) {
				$User = new User($db->f("user_id"),$db->f("username"),"********",$db->f("user_email"), $db->f("first_name"), $db->f("last_name"), $db->f("extra_field_1"), $db->f("address_1"), $db->f("address_2"), $db->f("state"), $db->f("title"), $db->f("city"), $db->f("country"), $db->f("zip"), $db->f("phone_1"), $db->f("fax"), $db->f("phone_2"),
									$db->f("cdate"), $db->f("mdate"), $db->f("perms"), $db->f("bank_account_nr"), $db->f("bank_name"), $db->f("bank_sort_code"), $db->f("bank_iban"), $db->f("bank_account_holder"), $db->f("bank_account_type"), $db->f("shopper_group_id"), $db->f("customer_number"),
									$db->f("groupe_id"),$db->f("user_info_id"),$db->f("address_type"),$db->f("address_type_name"),$db->f("company"),$db->f("middle_name"),$db->f("phone_2"),$db->f("extra_field_1"),$db->f("extra_field_2"),$db->f("extra_field_3"),$db->f("extra_field_4"),$db->f("extra_field_5"));
				
				$UserArray[] = $User;
			}
			$errMsg=  $db->getErrorMsg();	
			if ($errMsg==null){
				return $UserArray;
			}else {
				return new SoapFault("GetAdditionalUserInfoFault", "SQL Error : ".$errMsg);
			}
			

		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}	
	
	

	/**
    * This function  GetUserInfo From OrderID
	* (expose as WS)
    * @param 
    * @return result
	*/
	function GetUserInfoFromOrderID($params) {
	
		include('../vm_soa_conf.php');
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_search']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;
			
			
			
			$q  = "SELECT * FROM #__{vm}_order_user_info ui join #__users u on ui.user_id=u.id WHERE 1 ";
			
			if (!empty($params->order_id)){
				$q .= " AND ui.order_id = '$params->order_id'";
			}
						
			$q .= " LIMIT 0,100 ";
			
			$db->query($q);
			while ($db->next_record()) {
				$User = new User($db->f("user_id"),$db->f("username"),"********",$db->f("user_email"), $db->f("first_name"), $db->f("last_name"), $db->f("extra_field_1"), $db->f("address_1"), $db->f("address_2"), $db->f("state"), $db->f("title"), $db->f("city"), $db->f("country"), $db->f("zip"), $db->f("phone_1"), $db->f("fax"), $db->f("phone_2"),
									$db->f("cdate"), $db->f("mdate"), $db->f("perms"), $db->f("bank_account_nr"), $db->f("bank_name"), $db->f("bank_sort_code"), $db->f("bank_iban"), $db->f("bank_account_holder"), $db->f("bank_account_type"), $db->f("shopper_group_id"), $db->f("customer_number"),
									$db->f("groupe_id"),$db->f("user_info_id"),$db->f("address_type"),$db->f("address_type_name"),$db->f("company"),$db->f("middle_name"),$db->f("phone_2"),$db->f("extra_field_1"),$db->f("extra_field_2"),$db->f("extra_field_3"),$db->f("extra_field_4"),$db->f("extra_field_5"));
				
				$UserArray[] = $User;
			}
			$errMsg=  $db->getErrorMsg();	
			if ($errMsg==null){
				return $UserArray;
			}else {
				return new SoapFault("GetUserInfoFromOrderIDFault", "SQL Error : ".$errMsg);
			}
			

		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}	


	
  	/**
    * This function GetAllCountryCode return all country code 
	* (expose as WS)
    * @param 
    * @return array of Country
	*/
	function GetAllCountryCode($params2) {
	
		include('../vm_soa_conf.php');
			
		/* Authenticate*/
		$result = onAdminAuthenticate($params2->login, $params2->password);
		if ($conf['auth_users_getcountry']=="off"){
			$result = "true";
		}
		//Auth OK
		if ($result == "true"){
			
			$db = new ps_DB;
			$q = "SELECT * FROM #__{vm}_country WHERE 1 ";
			$db->query($q);
			while ($db->next_record()) {
				$Country = new Country($db->f("country_id"),$db->f("zone_id"), $db->f("country_name"), $db->f("country_3_code"), $db->f("country_2_code"));
				$arrayCountry[]= $Country;
			}
			return $arrayCountry;
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params2->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params2->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params2->login);
		}
	}
	
	/**
    * This function get Get AuthGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAuthGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getauthgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_auth_group WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$AuthGroup = new AuthGroup($db->f("group_id"),$db->f("group_name"),$db->f("group_level"));
				$arrayAuthGroup[]=$AuthGroup;
			
			}
			return $arrayAuthGroup;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function Add AuthGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddAuthGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addautgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		

			$gn = $params->AuthGroup->group_name;
			$gl = $params->AuthGroup->group_level;
			$list  = "INSERT INTO #__{vm}_auth_group (group_name,group_level) VALUES ('".$gn."','".$gl."') ";
			$db = new ps_DB;
			$result = $db->query($list);	
			$errMsg=  $db->getErrorMsg();	
			
			if ($result){
				return "AuthGroup added sucessfully : \n".$gid  ;
			}else {
				return new SoapFault("AddAuthGroupFault", "Cannot add authGroup  : ".$gn." ".$errMsg);
			}
			
			return "AuthGroup Added sucessfully : \n".$gn  ;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
		/**
    * This function Delete AuthGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteAuthGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delauthgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$gid = $params->group_id;
			$list  = "DELETE FROM #__{vm}_auth_group WHERE group_id = '$gid' ";
			$db = new ps_DB;
			$result = $db->query($list);	
			
			if ($result){
				return "AuthGroup deleted sucessfully : ".$gid  ;
			}else {
				return new SoapFault("DeleteAuthGroupFault", "Cannot delete authGroup  : ".$gid);
			}
			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
		/**
    * This function GetAllStates
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAllStates($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_getstate']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;
			if (!empty($params->country_id)){
				$list  = "SELECT * FROM #__{vm}_state WHERE country_id = '".$params->country_id."'";
			} else {
				$list  = "SELECT * FROM #__{vm}_state WHERE 1";
			}
			
			$db->query($list);
			
			while ($db->next_record()) {
			
				$State = new State($db->f("state_id"),$db->f("country_id"),$db->f("state_name"),$db->f("state_3_code"),$db->f("state_2_code"));
				$arrayState[]=$State;
			
			}
			return $arrayState;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Add States
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddStates($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addstate']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
		$cpnIdsStr = "";
		$db = new ps_DB;
		$allOk=true;
		if (is_array($params->States->State)){
			
				$count = count($params->States->State);
				for ($i = 0; $i < $count; $i++) {
				
					//$state_id = $params->States->State[$i]->state_id;
					$country_id = $params->States->State[$i]->country_id;
					$state_name = $params->States->State[$i]->state_name;
					$state_3_code = $params->States->State[$i]->state_3_code;
					$state_2_code = $params->States->State[$i]->state_2_code;
					$list  = "INSERT INTO #__{vm}_state (country_id,state_name,state_3_code,state_2_code) VALUES ('".$country_id."', '".$state_name."','".$state_3_code."' ,'".$state_2_code."') ";
					$result = $db->query($list);	
					$errMsg=  $db->getErrorMsg();	
					if ($result){
						$cpnIdsStr .= $params->States->State[$i]->state_name." ";
					}else{
						$allOk=false;
					}
				}
			
			} else {
				$country_id = $params->States->State->country_id;
				$state_name = $params->States->State->state_name;
				$state_3_code = $params->States->State->state_3_code;
				$state_2_code = $params->States->State->state_2_code;
				$list  = "INSERT INTO #__{vm}_state (country_id,state_name,state_3_code,state_2_code) VALUES ('".$country_id."','".$state_name."','".$state_3_code."' ,'".$state_2_code."') ";
				$result = $db->query($list);	
				$errMsg=  $db->getErrorMsg();	
				if ($result){
					return "State added sucessfully : \n".$state_name  ;
				}else {
					return new SoapFault("AddStatesFault", "Cannot add state  :".$state_name."\n".$errMsg);
				}
			}

			if ($allOk){
				return "All States successfully added : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteStatesFault", "Not all States added, only states  : ".$cpnIdsStr."\n".$errMsg);
			}	
			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
		/**
    * This function Delete States
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteStates($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delstate']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$db = new ps_DB;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$state_id = $params->ids->id[$i];
					$list  = "DELETE FROM #__{vm}_state WHERE state_id = '$state_id' ";
					$result = $db->query($list);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$state_id = $params->ids->id;
				$list  = "DELETE FROM #__{vm}_state WHERE state_id = '$state_id' ";
				$cpnIdsStr .= $params->ids->id." ";
				$result = $db->query($list);
				if ($result){
					return "States deleted sucessfully : ".$state_id  ;
				}else {
					return new SoapFault("DeleteAuthGroupFault", "Cannot delete State  : ".$state_id);
				}
			}
			if ($allOk){
				return "All States successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteStatesFault", "Not all States deleted, only states id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
		/**
    * This function get shopperGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetShopperGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getshopgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_shopper_group WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$ShopperGroup = new ShopperGroup($db->f("shopper_group_id"),$db->f("vendor_id"),$db->f("shopper_group_name"),$db->f("shopper_group_desc"),$db->f("shopper_group_discount"),$db->f("show_price_including_tax"),$db->f("default"));
				$arrayShopperGroup[]=$ShopperGroup;
			
			}
			return $arrayShopperGroup;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function Add ShopperGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddShopperGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addshopgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$cpnIdsStr = "";
			$db = new ps_DB;
			$ps_shopper_group = new ps_shopper_group;
			$allOk=true;
			if (is_array($params->shoppergroups->shoppergroup)){
				
				$count = count($params->shoppergroups->shoppergroup);
				for ($i = 0; $i < $count; $i++) {
				
					//$state_id = $params->States->State[$i]->state_id;
					$_SESSION["ps_vendor_id"] = $params->shoppergroups->shoppergroup[$i]->vendor_id;
					$d['vendor_id'] = $params->shoppergroups->shoppergroup[$i]->vendor_id;
					$d['shopper_group_name'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_name;
					$d['shopper_group_desc'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_desc;
					$d['shopper_group_discount'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_discount;
					$d['show_price_including_tax'] = $params->shoppergroups->shoppergroup[$i]->show_price_including_tax;
					$d['default']= $params->shoppergroups->shoppergroup[$i]->default;
					
					$result = $ps_shopper_group->add($d); 
					if ($result){
						$cpnIdsStr .= $params->shoppergroups->shoppergroup[$i]->shopper_group_name." ";
					}else{
						$allOk=false;
					}
				}
			
			} else {
				$_SESSION["ps_vendor_id"] =  $params->shoppergroups->shoppergroup->vendor_id;
				$d['vendor_id'] = $params->shoppergroups->shoppergroup->vendor_id;
				$d['shopper_group_name'] = $params->shoppergroups->shoppergroup->shopper_group_name;
				$d['shopper_group_desc'] = $params->shoppergroups->shoppergroup->shopper_group_desc;
				$d['shopper_group_discount'] = $params->shoppergroups->shoppergroup->shopper_group_discount;
				$d['show_price_including_tax'] = $params->shoppergroups->shoppergroup->show_price_including_tax;
				$d['default'] = $params->shoppergroups->shoppergroup->default;
				
				$result = $ps_shopper_group->add($d); 
				if ($result){
					return "ShopperGroup added sucessfully : ".$d['shopper_group_name']  ;
				}else {
					return new SoapFault("AddShopperGroupFault", "Cannot add ShopperGroup  :".$d['shopper_group_name'] );
				}
			}

			if ($allOk){
				return "All ShopperGroup successfully added : ".$cpnIdsStr;
			} else {
				return new SoapFault("ShopperGroupFault", "Not all ShopperGroup added, only ShopperGroup  : ".$cpnIdsStr);
			}		
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update ShopperGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function UpdateShopperGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upshopgrp']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$cpnIdsStr = "";
			$ps_shopper_group = new ps_shopper_group;
			$allOk=true;
			if (is_array($params->shoppergroups->shoppergroup)){
				
				$count = count($params->shoppergroups->shoppergroup);
				for ($i = 0; $i < $count; $i++) {
					$_SESSION["ps_vendor_id"] = $params->shoppergroups->shoppergroup[$i]->vendor_id;
					$d['shopper_group_id'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_id;
					$d['vendor_id'] = $params->shoppergroups->shoppergroup[$i]->vendor_id;
					$d['shopper_group_name'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_name;
					$d['shopper_group_desc'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_desc;
					$d['shopper_group_discount'] = $params->shoppergroups->shoppergroup[$i]->shopper_group_discount;
					$d['show_price_including_tax'] = $params->shoppergroups->shoppergroup[$i]->show_price_including_tax;
					$d['default']= $params->shoppergroups->shoppergroup[$i]->default;
					
					$result = $ps_shopper_group->update($d); 
					if ($result){
						$cpnIdsStr .= $params->shoppergroups->shoppergroup[$i]->shopper_group_name." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$_SESSION["ps_vendor_id"] = $params->shoppergroups->shoppergroup->vendor_id;
				$d['shopper_group_id'] = $params->shoppergroups->shoppergroup->shopper_group_id;
				$d['vendor_id'] = $params->shoppergroups->shoppergroup->vendor_id;
				$d['shopper_group_name'] = $params->shoppergroups->shoppergroup->shopper_group_name;
				$d['shopper_group_desc'] = $params->shoppergroups->shoppergroup->shopper_group_desc;
				$d['shopper_group_discount'] = $params->shoppergroups->shoppergroup->shopper_group_discount;
				$d['show_price_including_tax'] = $params->shoppergroups->shoppergroup->show_price_including_tax;
				$d['default'] = $params->shoppergroups->shoppergroup->default;
				
				$result = $ps_shopper_group->update($d); 
				if ($result){
					return "ShopperGroup updated sucessfully : ".$d['shopper_group_name']  ;
				}else {
					return new SoapFault("UpdateShopperGroupFault", "Cannot update ShopperGroup  :".$d['shopper_group_name'] );
				}
			}

			if ($allOk){
				return "All ShopperGroup successfully updated : ".$cpnIdsStr;
			} else {
				return new SoapFault("ShopperGroupFault", "Not all ShopperGroup updated, only ShopperGroup  : ".$cpnIdsStr);
			}	
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Delete ShopperGroup
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteShopperGroup($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delshopgroup']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$ps_shopper_group = new ps_shopper_group;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$d['shopper_group_id']  = $params->ids->id[$i];
					$result = $ps_shopper_group->delete($d);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$d['shopper_group_id'] = $params->ids->id;
				$cpnIdsStr .= $params->ids->id." ";
				$result = $ps_shopper_group->delete($d);
				if ($result){
					return "ShopperGroup deleted sucessfully : ".$d['shopper_group_id']  ;
				}else {
					return new SoapFault("DeleteShopperGroupFault", "Cannot delete ShopperGroup  : ".$d['shopper_group_id']);
				}
			}
			if ($allOk){
				return "All ShopperGroup successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteShopperGroupFault", "Not all ShopperGroup deleted, only ShopperGroup id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	
		/**
    * This function  Get All Vendor
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAllVendor($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getvendor']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_vendor WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$Vendor = new Vendor($db->f("vendor_id"),$db->f("vendor_name"),$db->f("contact_last_name"),$db->f("contact_first_name"),$db->f("contact_middle_name"),$db->f("contact_title"),$db->f("contact_phone_1"),
				$db->f("contact_phone_2"),$db->f("contact_fax"),$db->f("contact_email"),$db->f("vendor_phone"),$db->f("vendor_address_1"),$db->f("vendor_address_2"),$db->f("vendor_city"),
				$db->f("vendor_state"),$db->f("vendor_country"),$db->f("vendor_zip"),$db->f("vendor_store_name"),$db->f("vendor_store_desc"),$db->f("vendor_category_id"),$db->f("vendor_thumb_image"),
				$db->f("vendor_full_image"),$db->f("vendor_currency"),$db->f("cdate"),$db->f("mdate"),$db->f("vendor_image_path"),$db->f("vendor_terms_of_service"),$db->f("vendor_url"),
				$db->f("vendor_min_pov"),$db->f("vendor_freeshipping"),$db->f("vendor_currency_display_style"),$db->f("vendor_accepted_currencies"),$db->f("vendor_address_format"),$db->f("vendor_date_format"));
				$arrayVendor[]=$Vendor;
			
			}
			return $arrayVendor;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function  Add Vendor
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddVendor($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addvendor']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			
			$d['display_style'] = explode("|",$params->Vendor->vendor_currency_display_style);
			
			$d = array( 'vendor_name' => $params->Vendor->vendor_name,
						'contact_last_name' =>  $params->Vendor->contact_last_name,
						'contact_first_name' =>  $params->Vendor->contact_first_name,
						'contact_middle_name' =>  $params->Vendor->contact_middle_name,
						'contact_title' =>  $params->Vendor->contact_title,
						'contact_phone_1' =>  $params->Vendor->contact_phone_1,
						'contact_phone_2' =>  $params->Vendor->contact_phone_2,
						'contact_fax' =>  $params->Vendor->contact_fax,
						'contact_email' =>  $params->Vendor->contact_email,
						'vendor_phone' =>  $params->Vendor->vendor_phone,
						'vendor_address_1' =>  $params->Vendor->vendor_address_1,
						'vendor_address_2' =>  $params->Vendor->vendor_address_2,
						'vendor_city' =>  $params->Vendor->vendor_city,
						'vendor_state' =>  $params->Vendor->vendor_state,
						'vendor_country' =>  $params->Vendor->vendor_country,
						'vendor_zip' =>  $params->Vendor->vendor_zip,
						'vendor_store_name' =>  $params->Vendor->vendor_store_name,
						'vendor_store_desc' =>  $params->Vendor->vendor_store_desc,
						'vendor_category_id' =>  $params->Vendor->vendor_category_id,
						'vendor_image_path' =>  $params->Vendor->vendor_image_path,
						'vendor_thumb_image' =>  $params->Vendor->vendor_thumb_image,
						'vendor_full_image' =>  $params->Vendor->vendor_full_image,
						'vendor_currency' =>  $params->Vendor->vendor_currency,
						'vendor_url' =>  $params->Vendor->vendor_url,
						'cdate' => $timestamp,
						'mdate' => $timestamp,
						'vendor_terms_of_service' =>  $params->Vendor->vendor_terms_of_service,
						'vendor_min_pov' =>  $params->Vendor->vendor_min_pov,
						'vendor_currency_display_style' => $params->Vendor->vendor_currency_display_style,
						'vendor_freeshipping' =>  $params->Vendor->vendor_freeshipping,
						'vendor_accepted_currencies' =>  $params->Vendor->vendor_accepted_currencies,
						'vendor_address_format' =>  $params->Vendor->vendor_address_format,
						'vendor_date_format' =>  $params->Vendor->vendor_date_format
						);
			
			$ps_vendor = new ps_vendor;
			$ret = $ps_vendor->add($d);
			
			//after  update, change image file name
			$type='UPDATE';
			$db = new ps_DB;
			$values['vendor_thumb_image']=$params->Vendor->vendor_thumb_image;
			$values['vendor_full_image']=$params->Vendor->vendor_full_image;
			
			$whereClause = " WHERE vendor_id =".$_REQUEST['vendor_id']."";
			$db->buildQuery($type,"#__{vm}_vendor",$values,$whereClause);
			$ret2 = $db->query();

			if ($ret){
				return "Vendor successfully added : ".$_REQUEST['vendor_id'];
			} else {
				return new SoapFault("AddVendorFault", "Cannot add Vendor  : ".$d['vendor_name']);
			}		
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update Vendor
	* (expose as WS)
    * @param string
    * @return result
    */
	function UpdateVendor($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upvendor']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$d['display_style'] = explode("|",$params->Vendor->vendor_currency_display_style);
			
			$d = array( 'vendor_id' => $params->Vendor->vendor_id,
						'vendor_name' => $params->Vendor->vendor_name,
						'contact_last_name' =>  $params->Vendor->contact_last_name,
						'contact_first_name' =>  $params->Vendor->contact_first_name,
						'contact_middle_name' =>  $params->Vendor->contact_middle_name,
						'contact_title' =>  $params->Vendor->contact_title,
						'contact_phone_1' =>  $params->Vendor->contact_phone_1,
						'contact_phone_2' =>  $params->Vendor->contact_phone_2,
						'contact_fax' =>  $params->Vendor->contact_fax,
						'contact_email' =>  $params->Vendor->contact_email,
						'vendor_phone' =>  $params->Vendor->vendor_phone,
						'vendor_address_1' =>  $params->Vendor->vendor_address_1,
						'vendor_address_2' =>  $params->Vendor->vendor_address_2,
						'vendor_city' =>  $params->Vendor->vendor_city,
						'vendor_state' =>  $params->Vendor->vendor_state,
						'vendor_country' =>  $params->Vendor->vendor_country,
						'vendor_zip' =>  $params->Vendor->vendor_zip,
						'vendor_store_name' =>  $params->Vendor->vendor_store_name,
						'vendor_store_desc' =>  $params->Vendor->vendor_store_desc,
						'vendor_category_id' =>  $params->Vendor->vendor_category_id,
						'vendor_image_path' =>  $params->Vendor->vendor_image_path,
						'vendor_thumb_image' =>  $params->Vendor->vendor_thumb_image,
						'vendor_full_image' =>  $params->Vendor->vendor_full_image,
						'vendor_currency' =>  $params->Vendor->vendor_currency,
						'vendor_url' =>  $params->Vendor->vendor_url,
						'cdate' => $timestamp,
						'mdate' => $timestamp,
						'vendor_terms_of_service' =>  $params->Vendor->vendor_terms_of_service,
						'vendor_min_pov' =>  $params->Vendor->vendor_min_pov,
						'vendor_currency_display_style' => $params->Vendor->vendor_currency_display_style,
						'vendor_freeshipping' =>  $params->Vendor->vendor_freeshipping,
						'vendor_accepted_currencies' =>  $params->Vendor->vendor_accepted_currencies,
						'vendor_address_format' =>  $params->Vendor->vendor_address_format,
						'vendor_date_format' =>  $params->Vendor->vendor_date_format
						);
			
			$ps_vendor = new ps_vendor;
			$ret = $ps_vendor->update($d);
			
			//after  update, change image file name
			$type='UPDATE';
			$db = new ps_DB;
			$values['vendor_thumb_image']=$params->Vendor->vendor_thumb_image;
			$values['vendor_full_image']=$params->Vendor->vendor_full_image;
			
			$whereClause = " WHERE vendor_id =".$params->Vendor->vendor_id."";
			$db->buildQuery($type,"#__{vm}_vendor",$values,$whereClause);
			$ret2 = $db->query();
			

			if ($ret){
				return "Vendor successfully updated : ".$d['vendor_name'];
			} else {
				return new SoapFault("UpdateVendorFault", "Cannot update Vendor  : ".$d['vendor_name']);
			}		
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function  Delete Vendor
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteVendor($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delvendor']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$ps_vendor = new ps_vendor;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$d['_id']  = $params->ids->id[$i];
					$d['vendor_id'] = $params->ids->id[$i];
					$result = $ps_vendor->delete($d);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$d['_id'] = $params->ids->id;
				$d['vendor_id'] = $params->ids->id;
				$cpnIdsStr .= $params->ids->id." ";
				$result = $ps_vendor->delete($d);
				if ($result){
					return "Vendor deleted sucessfully : ".$d['_id']  ;
				}else {
					return new SoapFault("DeleteVendorault", "Cannot delete Vendor  : ".$d['_id']);
				}
			}
			if ($allOk){
				return "All Vendors successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteVendorFault", "Not all Vendor deleted, only Vendor id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function  Get All Vendor Category
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAllVendorCategory($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getvendorcat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_vendor_category WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$VendorCategory = new VendorCategory($db->f("vendor_category_id"),$db->f("vendor_category_name"),$db->f("vendor_category_desc"));
				$arrayVendorCategory[]=$VendorCategory;
			
			}
			return $arrayVendorCategory;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function  Add VendorCategory
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddVendorCategory($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addvendorcat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
		
			$d = array(	'vendor_category_id' =>  "0", /* vendor_category_id not used but needed*/
						'vendor_category_name' =>  $params->VendorCategory->vendor_category_name,
						'vendor_category_desc' =>  $params->VendorCategory->vendor_category_desc
						);
			
			$ps_vendor_category = new ps_vendor_category;
			$ret = $ps_vendor_category->add($d);

			if ($ret){
				return "VendorCategory successfully added : ".$_REQUEST['vendor_category_id'];
			} else {
				return new SoapFault("AddVendorCategoryFault", "Cannot add Vendor Category  : ".$d['vendor_category_name']);
			}		
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update VendorCategory
	* (expose as WS)
    * @param string
    * @return result
    */
	function UpdateVendorCategory($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upvendorcat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$d = array(	'vendor_category_id' =>  $params->VendorCategory->vendor_category_id,
						'vendor_category_name' =>  $params->VendorCategory->vendor_category_name,
						'vendor_category_desc' =>  $params->VendorCategory->vendor_category_desc
						);
			
			$ps_vendor_category = new ps_vendor_category;
			$ret = $ps_vendor_category->update($d);

			if ($ret){
				return "VendorCategory successfully updated : ".$d['vendor_category_name'];
			} else {
				return new SoapFault("UpdateVendorCategoryFault", "Cannot update Vendor Category  : ".$d['vendor_category_name']);
			}		
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function  Delete VendorCategory
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteVendorCategory($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delvendorcat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$ps_vendor_category = new ps_vendor_category;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$d['vendor_category_id']  = $params->ids->id[$i];
					$result = $ps_vendor_category->delete($d);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$d['vendor_category_id'] = $params->ids->id;
				$cpnIdsStr .= $params->ids->id." ";
				$result = $ps_vendor_category->delete($d);
				if ($result){
					return "Vendor deleted sucessfully : ".$d['vendor_category_id']  ;
				}else {
					return new SoapFault("DeleteVendorault", "Cannot delete Vendor  : ".$d['vendor_category_id']);
				}
			}
			if ($allOk){
				return "All Vendors Categories successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteVendorCategoryFault", "Not all Vendor Category deleted, only Vendor Category id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function   Get All Manufacturer
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAllManufacturer($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getmanufacturer']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_manufacturer WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$Manufacturer = new Manufacturer($db->f("manufacturer_id"),$db->f("mf_name"),$db->f("mf_email"),$db->f("mf_desc"),$db->f("mf_category_id"),$db->f("mf_url"));
				$arrayManufacturer[]=$Manufacturer;
			
			}
			return $arrayManufacturer;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function  Add Manufacturer
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddManufacturer($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addmanufacturer']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$_REQUEST['mf_category_id'] = $params->Manufacturer->mf_category_id;
			$d = array(	'manufacturer_id' =>  "0", /* vendor_category_id not used but needed*/
						'mf_name' =>  $params->Manufacturer->mf_name,
						'mf_email' =>  $params->Manufacturer->mf_email,
						'mf_desc' =>  $params->Manufacturer->mf_desc,
						'mf_category_id' =>  $params->Manufacturer->mf_category_id,
						'mf_url' =>  $params->Manufacturer->mf_url
						);
			
			$ps_manufacturer = new ps_manufacturer;
			$ret = $ps_manufacturer->add($d);

			if ($ret){
				return "Manufacturer successfully added : ".$_REQUEST['manufacturer_id'];
			} else {
				return new SoapFault("AddManufacturerFault", "Cannot add Manufacter  : ".$d['mf_name']);
			}		
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update Manufacturer
	* (expose as WS)
    * @param string
    * @return result
    */
	function UpdateManufacturer($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upmanufacturer']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$_REQUEST['mf_category_id'] = $params->Manufacturer->mf_category_id;
			
			$d = array(	'manufacturer_id' => $params->Manufacturer->manufacturer_id,
						'mf_name' =>  $params->Manufacturer->mf_name,
						'mf_email' =>  $params->Manufacturer->mf_email,
						'mf_desc' =>  $params->Manufacturer->mf_desc,
						'mf_category_id' =>  $params->Manufacturer->mf_category_id,
						'mf_url' =>  $params->Manufacturer->mf_url
						);
			
			$ps_manufacturer = new ps_manufacturer;
			$ret = $ps_manufacturer->update($d);

			if ($ret){
				return "Manufacturer successfully updated : ".$d['mf_name'];
			} else {
				return new SoapFault("ManufacturerFault", "Cannot update Manufacturer  : ".$d['mf_name']);
			}		
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function  Delete Manufacturer
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteManufacturer($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delmanufacturer']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$ps_manufacturer = new ps_manufacturer;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$d['manufacturer_id']  = $params->ids->id[$i];
					$result = $ps_manufacturer->delete($d);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$d['manufacturer_id'] = $params->ids->id;
				$cpnIdsStr .= $params->ids->id." ";
				$result = $ps_manufacturer->delete($d);
				if ($result){
					return "Manufacturer deleted sucessfully : ".$d['manufacturer_id']  ;
				}else {
					return new SoapFault("DeleteManufacturerFault", "Cannot delete Manufacturer  : ".$d['manufacturer_id']);
				}
			}
			if ($allOk){
				return "All Manufacturer successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteManufacturerFault", "Not all Manufacturer deleted, only Manufacturer id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function   Get All Manufacturer cat
	* (expose as WS)
    * @param string
    * @return result
    */
	function GetAllManufacturerCat($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getmanufacturercat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$db = new ps_DB;

			$list  = "SELECT * FROM #__{vm}_manufacturer_category WHERE 1";
			$db->query($list);
			
			while ($db->next_record()) {
			
				$ManufacturerCat = new ManufacturerCat($db->f("mf_category_id"),$db->f("mf_category_name"),$db->f("mf_category_desc"));
				$arrayManufacturerCat[]=$ManufacturerCat;
			
			}
			return $arrayManufacturerCat;
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}
	}
	
	/**
    * This function  Add Manufacturer cat
	* (expose as WS)
    * @param string
    * @return result
    */
	function AddManufacturerCat($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_addmanufacturercat']=="off"){
			$result = "true";
		}	
		$GLOBALS['vmInputFilter'] = $vmInputFilter = new vmInputFilter();
		//Auth OK
		if ($result == "true"){
		
		
			$d = array(	'mf_category_id' =>  "0", /* vendor_category_id not used but needed*/
						'mf_category_name' =>  $params->ManufacturerCat->mf_category_name,
						'mf_category_desc' =>  $params->ManufacturerCat->mf_category_desc
						);
			
			$ps_manufacturer_category = new ps_manufacturer_category;
			$ret = $ps_manufacturer_category->add($d);

			if ($ret){
				return "ManufacturerCat successfully added : ".$_REQUEST['mf_category_id'];
			} else {
				return new SoapFault("AddManufacturerCatFault", "Cannot add Manufacter  : ".$d['mf_category_name']);
			}		
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function Update ManufacturerCat
	* (expose as WS)
    * @param string
    * @return result
    */
	function UpdateManufacturerCat($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_upmanufacturercat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
		
			$GLOBALS['vmInputFilter'] = $vmInputFilter = new vmInputFilter();
		
			$d = array(	'mf_category_id' =>  $params->ManufacturerCat->mf_category_id,
						'mf_category_name' =>  $params->ManufacturerCat->mf_category_name,
						'mf_category_desc' =>  $params->ManufacturerCat->mf_category_desc
						);
			
			$ps_manufacturer_category = new ps_manufacturer_category;
			$ret = $ps_manufacturer_category->update($d);

			if ($ret){
				return "ManufacturerCat successfully updated : ".$d['mf_category_name'];
			} else {
				return new SoapFault("UpdateManufacturerCatFault", "Cannot update Manufacturer cat  : ".$d['mf_category_name']);
			}		
			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function  Delete ManufacturerCat
	* (expose as WS)
    * @param string
    * @return result
    */
	function DeleteManufacturerCat($params) {
	
		include('../vm_soa_conf.php');
				
		/* Authenticate*/
		$result = onAdminAuthenticate($params->loginInfo->login, $params->loginInfo->password);
		if ($conf['auth_users_delmanufacturercat']=="off"){
			$result = "true";
		}	
		
		//Auth OK
		if ($result == "true"){
					
			$ps_manufacturer_category = new ps_manufacturer_category;
			$allOk=true;
			$cpnIdsStr="";
						
			if (is_array($params->ids->id)){
			
				$count = count($params->ids->id);
				for ($i = 0; $i < $count; $i++) {
					$d['mf_category_id']  = $params->ids->id[$i];
					$result = $ps_manufacturer_category->delete($d);
					if ($result){
						$cpnIdsStr .= $params->ids->id[$i]." ";
					}else{
						$allOk=false;
					}
				}
			} else {
				$d['mf_category_id'] = $params->ids->id;
				$cpnIdsStr .= $params->ids->id." ";
				$result = $ps_manufacturer_category->delete($d);
				if ($result){
					return "Manufacturer cat deleted sucessfully : ".$d['mf_category_id']  ;
				}else {
					return new SoapFault("DeleteManufacturerCatFault", "Cannot delete Manufacturer cat  : ".$d['mf_category_id']);
				}
			}
			if ($allOk){
				return "All Manufacturer cat successfully deleted : ".$cpnIdsStr;
			} else {
				return new SoapFault("DeleteManufacturerCatFault", "Not all Manufacturer cat deleted, only Manufacturer id : ".$cpnIdsStr);
			}			
				
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->loginInfo->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->loginInfo->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->loginInfo->login);
		}
	}
	
	/**
    * This function get Get Available vendor Images on server (dir components/com_virtuemart/shop_image/vendor)
	* (expose as WS)
    * @param string
    * @return array of products
   */
	function GetAvailableVendorImages($params) {
	
		include('../vm_soa_conf.php');
		
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getvendorimg']=="off"){
			$result = "true";
		}
		
		//Auth OK
		if ($result == "true"){
		
			$mosConfig_absolute_path= realpath( dirname(__FILE__).'/../../../..' );
			// Load the joomla main cfg
			if( file_exists(dirname(__FILE__).'/configuration.php' )) {
				require_once( $mosConfig_absolute_path.'/configuration.php' );
				
			} else {
				require_once( $mosConfig_absolute_path.'/configuration.php');
			}
		
			global $mosConfig_live_site;
			$URL_BASE;
			if( $mosConfig_live_site[strlen( $mosConfig_live_site)-1] == '/' ) {
				$URL_BASE = $mosConfig_live_site;
			}
			else {
				$URL_BASE = $mosConfig_live_site.'/';
			}
			
			$INSTALLURL = '';
			if (empty($conf['BASESITE']) && empty($conf['URL'])){
				$INSTALLURL = $URL_BASE;
			} else if (!empty($conf['BASESITE'])){
				$INSTALLURL = 'http://'.$conf['URL'].'/'.$conf['BASESITE'].'/';
			} else {
				$INSTALLURL = 'http://'.$conf['URL'].'/';
			}
			
			$dir = realpath( dirname(__FILE__).'/../../../../components/com_virtuemart/shop_image/vendor' );
			$dirname = $dir;
			//$dir = "/tmp/php5";
			// Ouvre un dossier bien connu, et liste tous les fichiers
			if (is_dir($dir)) {
				if ($dh = opendir($dir)) {
					while (($file = readdir($dh)) !== false) {
						//echo "fichier : $file : type : " . filetype($dir . $file) . "\n";
						if ($file =="." || $file ==".." || $file =="index.html"){
							
						} else {
							$AvalaibleImage = new AvalaibleImage($file,$INSTALLURL.'components/com_virtuemart/shop_image/vendor/'.$file,$dirname);
							$AvalaibleImageArray[] = $AvalaibleImage;
						}
					}
					closedir($dh);
				}
			}
					
			return $AvalaibleImageArray;

			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}		
	}
	
		/**
    * This function Get Versions
	* (expose as WS)
    * @param string
    * @return 
   */
	function GetVersions($params) {
	
		include('../vm_soa_conf.php');
		$mosConfig_absolute_path= realpath( dirname(__FILE__).'/../../../..' );
		include($mosConfig_absolute_path.'/administrator/components/com_virtuemart/version.php');
		
		
		/* Authenticate*/
		$result = onAdminAuthenticate($params->login, $params->password);
		if ($conf['auth_users_getversion']=="off"){
			$result = "true";
		}
		
		//Auth OK
		if ($result == "true"){
		
			$_VERSION = new JVersion();
			$VMVERSION = new vmVersion();
			global $database;
			
			$version['SOA_For_Virtuemart_Version'] = "1.5.10";//$conf['version'];
			$version['Joomla_Version'] = $_VERSION->RELEASE;
			$version['Virtuemart_Version'] = $VMVERSION->RELEASE;
			$version['Database_Version'] = $database->getVersion();
			$version['Author'] = $conf['author'];
					
			return $version;

			
		}else if ($result == "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}		
	}
	
	
	/**
    *  function Authentification
	* (expose as WS)
    * @param login/pass
    * @return order details
   */
	function Authentification($params) {
		
		$result = onAdminAuthenticate($params->login, $params->password);
		
		if ($result == "true"){
			return "Autification OK for ".$params->login; 
		}else if ($result== "false"){
			return new SoapFault("JoomlaServerAuthFault", "Autification KO for : ".$params->login);
		}else if ($result == "no_admin"){
			return new SoapFault("JoomlaServerAuthFault", "User is not a Super Administrator : ".$params->login);
		}else{
			return new SoapFault("JoomlaServerAuthFault", "User does not exist : ".$params->login);
		}

	}
	
	/**
    *  function onAuthenticate
	* (not expose as WS)
    * @param login/pass
    * @return true/false
   */
	function onAuthenticate($login,$passwd){
	
		jimport('joomla.user.helper');
		$response="false";
		$db = new ps_DB;

		$list  = "SELECT id, username, password FROM `#__users` ";
		$list .= "WHERE username='".$login."' ";
		
		$response=$list;
		//$list .= $q . " LIMIT 0,100 "; 
		
		$db = new ps_DB;
		$db->query($list);

		/* function inspired by onAuthenticate (joomla.php) | Verify password is good*/
		if($db->next_record())
		{
			$parts	= explode( ':', $db->f("password") );
			$crypt	= $parts[0];
			$salt	= @$parts[1];
			$testcrypt = JUserHelper::getCryptedPassword($passwd, $salt);

			if ($crypt == $testcrypt) {
				$response= "true";
			} else {
				$response= "false";
			}
		}
		else
		{
			$response="no_user";
		}
		/////////////////////////////
		return $response;
	}
	
	/**
    *  function onAuthenticate
	* (not expose as WS)
    * @param login/pass
    * @return true/false
   */
	function onAdminAuthenticate($login,$passwd){
	
		jimport('joomla.user.helper');
		$response="false";
		$db = new ps_DB;

		$list  = "SELECT id, username, password, usertype FROM `#__users` ";
		$list .= "WHERE username='".$login."' ";
		
		$response=$list;
		//$list .= $q . " LIMIT 0,100 "; 
		
		$db = new ps_DB;
		$db->query($list);

		/* function inspired by onAuthenticate (joomla.php) | Verify password is good*/
		if($db->next_record())
		{
			$parts	= explode( ':', $db->f("password") );
			$crypt	= $parts[0];
			$salt	= @$parts[1];
			$testcrypt = JUserHelper::getCryptedPassword($passwd, $salt);

			if ($crypt == $testcrypt ) {
				$response= "no_admin";
				if ( $db->f("usertype") == "Super Administrator" || $db->f("usertype") == "Administrator" ){
					$response= "true";
				}
			} else {
				$response= "false";
			}
		}
		else
		{
			$response="no_user";
		}
		/////////////////////////////
		return $response;
	}
	
	/* SOAP SETTINGS */
	if ($conf['users_actif']=="on"){	

		/* SOAP SETTINGS */
		$cache = "0";
		if ($conf['users_cache'] == "on")$cache = "1";
		ini_set("soap.wsdl_cache_enabled", $cache); // wsdl cache settings
		
		if ($conf['soap_version'] == "SOAP_1_1"){
			$options = array('soap_version' => SOAP_1_1);
		}else {
			$options = array('soap_version' => SOAP_1_2);
		}
		
		
		if (empty($conf['BASESITE']) && empty($conf['URL'])){
			$server = new SoapServer($URL_BASE.'administrator/components/com_vm_soa/services/VM_UsersWSDL.php');
		}else if (!empty($conf['BASESITE'])){
			$server = new SoapServer('http://'.$conf['URL'].'/'.$conf['BASESITE'].'/administrator/components/com_vm_soa/services/VM_UsersWSDL.php');
		}else {
			$server = new SoapServer('http://'.$conf['URL'].'/administrator/components/com_vm_soa/services/VM_UsersWSDL.php');
		}
		
		/*if (!empty($conf['BASESITE'])){
			$server = new SoapServer('http://'.$conf['URL'].'/'.$conf['BASESITE'].'/administrator/components/com_vm_soa/services/VM_UsersWSDL.php');
		}else {
			$server = new SoapServer('http://'.$conf['URL'].'/administrator/components/com_vm_soa/services/VM_UsersWSDL.php');
		}*/
		
		//$server = new SoapServer($mosConfig_live_site.'/VM_UsersWSDL.php');
		
		/* Add Functions */
		$server->addFunction("GetUsers");
		$server->addFunction("Authentification");
		$server->addFunction("AddUser");
		$server->addFunction("DeleteUser");
		$server->addFunction("SendMail");
		$server->addFunction("GetUserFromEmailOrUsername");
		$server->addFunction("GetAllCountryCode");
		$server->addFunction("GetAuthGroup");
		$server->addFunction("AddAuthGroup");
		$server->addFunction("DeleteAuthGroup");	
		$server->addFunction("GetAllStates");
		$server->addFunction("AddStates");
		$server->addFunction("DeleteStates");		
		$server->addFunction("GetShopperGroup");
		$server->addFunction("AddShopperGroup");		
		$server->addFunction("UpdateShopperGroup");
		$server->addFunction("DeleteShopperGroup");
		$server->addFunction("UpdateUser");
		$server->addFunction("AddVendor");
		$server->addFunction("GetAllVendor");
		$server->addFunction("UpdateVendor");
		$server->addFunction("DeleteVendor");
		$server->addFunction("GetAllVendorCategory");
		$server->addFunction("AddVendorCategory");
		$server->addFunction("UpdateVendorCategory");
		$server->addFunction("DeleteVendorCategory");	
		$server->addFunction("GetAllManufacturer");
		$server->addFunction("AddManufacturer");
		$server->addFunction("UpdateManufacturer");
		$server->addFunction("DeleteManufacturer");
		$server->addFunction("GetAllManufacturerCat");
		$server->addFunction("AddManufacturerCat");
		$server->addFunction("UpdateManufacturerCat");
		$server->addFunction("DeleteManufacturerCat");
		$server->addFunction("GetAvailableVendorImages");
		$server->addFunction("GetVersions");
		$server->addFunction("GetAdditionalUserInfo");
		$server->addFunction("GetSessions");
		$server->addFunction("GetWaitingList");
		$server->addFunction("NotifyWaitingList");
		$server->addFunction("GetUserInfoFromOrderID");
		

		$server->handle();
	}else{
		echo "This Web Service (Users) is disabled";
	}
?> 
Return current item: SOA For Virtuemart (WebServices)