Back to top

Autore Topic: mail registrazione  (Letto 9638 volte)

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
mail registrazione
« il: 21 Nov 2007, 16:45:33 »
Ciao! :D
Ho un problema banale da risolvere... Spero che qualcuno mi aiuti perché sono alle prime armi e non saprei cosa fare! ;D
Vorrei che alla registrazione del cliente, che precede la fase di checkout (è necessaria solo in caso di acquisto, dunque), non arrivasse una mail di notifica anche al negoziante.
Inoltre, mi potete dire come e dove modificare la mail di registrazione (non quella con il link da attivare)? Al momento il testo è qualcosa tipo: Benvenuto e grazie di esserti registrato a ... Dovrei inserire il nome del sito! ;)
Grazie mille!
Sara

Offline fcforum

  • Esploratore
  • **
  • Post: 103
  • Sesso: Maschio
    • Mostra profilo
Re: mail registrazione
« Risposta #1 il: 21 Nov 2007, 17:19:06 »
Per modificare i messaggi vari di virtuemart, c'è un componente apposito che facilita il tutto: Language Manager Component (VirtueMartLanguageManager.tar.gz) che puoi scaricare da virtuemart.net - downloads - virtuemart - Misc.
Questo componente che si installa dall'installer di joomla permette una facile manipolazione di tutti i testi di VM.

Ciao

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #2 il: 21 Nov 2007, 17:56:02 »
Grazie per la rispostaaaaa! :-*
Ho installato il componente, ma entrando non so bene cosa devo fare... In pratica mi permette di modificare english.php? ???
Notare che ho la versione inglese e non italian.php... ::)

Offline fcforum

  • Esploratore
  • **
  • Post: 103
  • Sesso: Maschio
    • Mostra profilo
Re: mail registrazione
« Risposta #3 il: 22 Nov 2007, 08:51:35 »
Si, è esatto, ti permette di modificare il file, nel tuo caso inglese. Ora, una volta dentro all'editor, vedrai due colonne, quella a sx elenca le variabili, quella a dx i messaggi ad esse associati. In questa colonna (dx) puoi modificare i messaggi come vuoi (anche in italiano), poi salvi ed è fatta. Magari per scrupolo fai una copia del file e rinominalo tipo: english old.php prima di modificarlo. Se installi nuove lingue per VM, è da qui che potrai modificarle, nello stesso modo.

Ciao

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #4 il: 23 Nov 2007, 17:09:37 »
Grazie mille... :D
Funziona perfettamente!
Ho solo un dubbio, che però forse non è rapportabile al file english.php o italian.php e quindi gestibile con il language manager.
Al momento alla fine dell'ordine viene mostrata questa pagina al cliente:

Vorrei cambiarne il testo, in quanto la parola ordine non è adeguata ai servizi forniti dal sito. Come posso fare? ::)
Ancora un grandissimo grazie a fcforum!!! :-*

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #5 il: 23 Nov 2007, 17:25:26 »
Sempre un problema analogo in tutto il processo, riguardandolo. ???
Non so come modificare il pulsante che porta dal riepilogo al checkout, chiamato "cassa" (ma io devo impostare il tutto per un modulo di richiesta preventivo...), titolo anche nelle fasi seguenti; non riesco a trovare i campi per cambiare il testo neanche riguardo alla fatturazione (Sei un Nuovo Cliente? Inserisci i Dati per la Fattura; Informazioni per la Fatturazione).

Offline fcforum

  • Esploratore
  • **
  • Post: 103
  • Sesso: Maschio
    • Mostra profilo
Re: mail registrazione
« Risposta #6 il: 23 Nov 2007, 17:41:11 »
Guarda bene il file italian.php con languagemanager, se non sbaglio ci dovrebbero essere anche quelle voci.

Ciao

Offline thepisu

  • Appassionato
  • ***
  • Post: 369
  • Sesso: Maschio
  • .. still looking for ..
    • Mostra profilo
Re: mail registrazione
« Risposta #7 il: 23 Nov 2007, 23:05:09 »
La stringa del pulsante Cassa è questa:

var $_PHPSHOP_CHECKOUT_TITLE

La trovi proprio tra le prime righe del file administrator/components/com_virtuemart/languages/italian.php. Puoi cambiarla come vuoi, ad esempio:

var $_PHPSHOP_CHECKOUT_TITLE = 'Procedi';

Stefano "Pisu" Bagnatica | VirtueMart Italia

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #8 il: 25 Nov 2007, 13:03:37 »
Grazie milleeeeeeee!!! ;)
Alla fine non riuscivo a trovarlo sul component e ho aperto direttamente il file php e modificato i parametri. Mi sembra che tutto funzioni, ma se c'è qualche problema non esiterò a postare! ;D
Thanks so much,
Sara

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #9 il: 05 Dic 2007, 15:06:07 »
Sono di nuovo io...
Che voi sappiate il file di conferma ordine da modificare è uno solo? Ho modificato /administrator/components/com_virtuemart/html/templates/order_emails/email_italian.html ma la mail che arriva al cliente penso sia ok, mentre al riveditore non risulta uguale... Almeno da quanto ho capito... E' possibile? :o
Mi sapreste dire come risolvere? ::)
Grazieeeeeeee... ;)

Offline thepisu

  • Appassionato
  • ***
  • Post: 369
  • Sesso: Maschio
  • .. still looking for ..
    • Mostra profilo
Re: mail registrazione
« Risposta #10 il: 06 Dic 2007, 00:34:45 »
I contenuti delle mail shopper e venditore sono uguali; cambiano solo intestazione e footer... cmq non c'è un altro "template" da cambiare, se vuoi approfondire, aprire il file classes/ps_checkout.php, e cerca la funzione email_receipt!
Stefano "Pisu" Bagnatica | VirtueMart Italia

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #11 il: 20 Gen 2008, 14:31:03 »
Riuppo... ;D
Eccomi di nuovo qua.
Risolto il problema dell'email , mi se ne pone un altro. Avrei bisogno di cancellare dei campi obbligatori nella procedura di registrazione utenti... Ho trovato due file: ps_shopper.php e checkout_register_form.php. Ho provato a modificarli e funzionano sin quando non metto mano alle stringhe riguardanti i required fields. Mi sapreste dare qualche dritta? ;)

Offline thepisu

  • Appassionato
  • ***
  • Post: 369
  • Sesso: Maschio
  • .. still looking for ..
    • Mostra profilo
Re: mail registrazione
« Risposta #12 il: 20 Gen 2008, 22:55:18 »
Esatto, nel file checkout.register_form.php devi togliere i campi che non vuoi dall'array required_fields. Ad esempio per avere il telefono opzionale...

questa riga:
Codice: [Seleziona]
$required_fields = Array( 'first_name', 'last_name', 'address_1', 'city', 'zip', 'country', 'phone_1' );



diventa:
Codice: [Seleziona]
$required_fields = Array( 'first_name', 'last_name', 'address_1', 'city', 'zip', 'country');


Dovrebbe proprio bastare questo...
Stefano "Pisu" Bagnatica | VirtueMart Italia

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #13 il: 30 Gen 2008, 15:56:17 »
Aggiorno la situazione... :o
Non sono riuscita a risolvere, ma solo a peggiorare la situazione, tant'è che il processo non funziona più. :-\
A questo punto uppo i files come allegati, tutti quelli che ho modificato riguardanti la registrazione, sperando in qualche anima pia. Mi affido a voi, perché non so cosa fare ed è abbastanza urgente. :-[
In breve, ecco quello che vorrei fare:
------------------------
Informazioni personali
Azienda 
Nome* 
Indirizzo completo* 
Tel.* 
Cellulare 
------------------------
considerando che Nome è controllato da name, Indirizzo completo da address_1, Tel. da phone_1, cell da phone_2

Un mega-grazie a chiunque possa aiutarmi e rispondere! :)

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #14 il: 30 Gen 2008, 16:02:20 »
checkout_register_form.php
Codice: [Seleziona]
<?php 
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @version $Id: checkout_register_form.php 617 2007-01-04 19:43:08Z soeren_nb $
* @package VirtueMart
* @subpackage html
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/
mm_showMyFileName__FILE__ );

$country mosGetParam$_REQUEST'country'$vendor_country_3_code);
$state mosGetParam$_REQUEST'state''');

$missing mosGetParam$_REQUEST"missing""" );
$missing_style "color:red; font-weight:bold;";

if (!empty( 
$missing )) {
echo "<script type=\"text/javascript\">alert('".$VM_LANG->_CONTACT_FORM_NC."'); </script>\n";
}
$label_div_style 'float:left;width:30%;text-align:right;vertical-align:bottom;font-weight: bold;padding-right: 5px;';
$field_div_style 'float:left;width:60%;';
/**
 * This section will be changed in future releases of VirtueMart,
 * when we have a registration form manager
 */
$required_fields = Array( 'first_name''address_1''phone_1' );

$shopper_fields = array();
// This is a list of all fields in the form
// They are structured into fieldset
// where the begin of the fieldset is marked by 
// an index called uniqid('fieldset_begin')
// and the end uniqid('fieldset_end')

if (!$my->id && VM_SILENT_REGISTRATION != '1' ) {
// These are the fields for registering a completely new user!

// Create a new fieldset
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_ORDER_PRINT_CUST_INFO_LBL;
$shopper_fields['username'] = $VM_LANG->_REGISTER_UNAME;
$shopper_fields['email'] = $VM_LANG->_REGISTER_EMAIL;
$shopper_fields['password'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_1;
$shopper_fields['password2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PASSWORD_2;
// Finish the fieldset
$shopper_fields[uniqid('fieldset_end')] = "";
// Add the new required fields into the existing array of required fields
$required_fields array_merge$required_fields, Array( 'email''username','password','password2') );
}
// Now the fields for customer information...Bill To !
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_USER_FORM_BILLTO_LBL;
$shopper_fields['company'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_COMPANY_NAME;
$shopper_fields['first_name'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_FIRST_NAME;
$shopper_fields['address_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_ADDRESS_1;
$shopper_fields['phone_1'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE;
$shopper_fields['phone_2'] = $VM_LANG->_PHPSHOP_SHOPPER_FORM_PHONE2;
if (!$my->id && VM_SILENT_REGISTRATION == '1') {
$shopper_fields['email'] = $VM_LANG->_REGISTER_EMAIL;
$required_fields[] = 'email';
}

// Extra Fields when defined in the language file
for( $i=1$i<6$i++ ) {
$property "_PHPSHOP_SHOPPER_FORM_EXTRA_FIELD_$i";
if( $VM_LANG->$property != "" ) {
$shopper_fields['extra_field_'.$i] = $VM_LANG->$property;
}
}

$shopper_fields[uniqid('fieldset_end')] = "";

// Is entering bank account information possible?
if (LEAVE_BANK_DATA == '1') { 
    
$selected[0] = @$_REQUEST['bank_account_type']=="Checking" 'selected="selected"' '';
    
$selected[1] = @$_REQUEST['bank_account_type']=="Business Checking" 'selected="selected"' '';
    
$selected[2] = @$_REQUEST['bank_account_type']=="Savings" 'selected="selected"' '';
    
    
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_PHPSHOP_ACCOUNT_BANK_TITLE;
    $shopper_fields['bank_account_holder'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_HOLDER;
    $shopper_fields['bank_account_nr'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_ACCOUNT_NR;
    $shopper_fields['bank_sort_code'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_SORT_CODE;
    $shopper_fields['bank_name'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_NAME;
    $shopper_fields['bank_account_type'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE;
    $shopper_fields['bank_iban'] = $VM_LANG->_PHPSHOP_ACCOUNT_LBL_BANK_IBAN;
    
$shopper_fields[uniqid('fieldset_end')] = "";
}

// Does the customer have to agree to your Terms & Conditions?
if (MUST_AGREE_TO_TOS == '1') {
$shopper_fields[uniqid('fieldset_begin')] = $VM_LANG->_BUTTON_SEND_REG;
// This label is a JS link with a noscript alternative for non-JS users
$shopper_fields['agreed'] = '<script type="text/javascript">//<![CDATA[
document.write(\'<label for="agreed_field">'
.htmlspecialchars$VM_LANG->_PHPSHOP_I_AGREE_TO_TOSENT_QUOTES ).'</label><a href="javascript:void window.open(\\\''$mosConfig_live_site .'/index2.php?option=com_virtuemart&page=shop.tos&pop=1\\\', \\\'win2\\\', \\\'status=no,toolbar=no,scrollbars=yes,titlebar=no,menubar=no,resizable=yes,width=640,height=480,directories=no,location=no\\\');">\');
document.write(\' ('
.$VM_LANG->_PHPSHOP_STORE_FORM_TOS .')</a>\');
//]]></script>
<noscript>
<label for="agreed_field">'
$VM_LANG->_PHPSHOP_I_AGREE_TO_TOS .'</label>
<a target="_blank" href="'
$mosConfig_live_site .'/index.php?option=com_virtuemart&page=shop.tos" title="'$VM_LANG->_PHPSHOP_I_AGREE_TO_TOS .'">
 ('
.$VM_LANG->_PHPSHOP_STORE_FORM_TOS.')
</a></noscript>'
;
$required_fields[] = 'agreed';
$shopper_fields[uniqid('fieldset_end')] = "";
}
// Form validation function
vmCommonHTML::printJS_formvalidation$required_fields );
?>

<script language="javascript" type="text/javascript" src="includes/js/mambojavascript.js"></script>

<form action="<?php echo $mm_action_url ?>index.php" method="post" name="adminForm">

<div style="width:90%;">
<div style="padding:5px;text-align:center;"><strong>(* = <?php echo $VM_LANG->_CMN_REQUIRED ?>)</strong></div>
   <?php
   
foreach( $shopper_fields as $fieldname => $label) {
   
if( stristr$fieldname'fieldset_begin' )) {
   
echo '<fieldset>
     <legend class="sectiontableheader">'
.$label.'</legend>
     '
;
   
continue;
   
}
   
if( stristr$fieldname'fieldset_end' )) {
   
echo '</fieldset>
     '
;
   
continue;
   
}
   
echo '<div id="'.$fieldname.'_div" style="'.$label_div_style;
   
if (stristr($missing,$fieldname)) {
   
echo $missing_style;
   
}
   
echo '">';
        echo 
'<label for="'.$fieldname.'_field">'.$label.'</label>';
        if( 
in_array$fieldname$required_fields)) {
        
echo '<strong>* </strong>';
        }
      
echo ' </div>
      <div style="'
.$field_div_style.'">'."\n";
      

      
/**
        * This is the most important part of this file
        * Here we print the field & its contents!
        */
   
switch( $fieldname ) {
   
case 'title':
   
$ps_html->list_user_title(mosGetParam$_REQUEST'title'''), "id=\"user_title\"");
   
break;
   

   
case 'country':
   
if( CAN_SELECT_STATES ) {
   
$onchange "onchange=\"changeStateList();\"";
   
}
   
else {
   
$onchange "";
   
}
   
$ps_html->list_country("country"$country"id=\"country_field\" $onchange");
   
break;
   

   
case 'state':
   
echo $ps_html->dynamic_state_lists"country""state"$country$state );
    echo "<noscript>\n";
    $ps_html->list_states("state"$state"""id=\"state\"");
    echo "</noscript>\n";
   
break;
    
case 'bank_account_type':
echo '<select class="inputbox" name="bank_account_type">
            <option '
$selected[0] .' value="Checking">'$VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_CHECKING .'</option>
            <option '
$selected[1] .' value="Business Checking">'$VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_BUSINESSCHECKING .'</option>
            <option '
$selected[2] .' value="Savings">'$VM_LANG->_PHPSHOP_ACCOUNT_LBL_ACCOUNT_TYPE_SAVINGS .'</option>
          </select>'
;
break;

case 'agreed':
echo '<input type="checkbox" id="agreed_field" name="agreed" value="1" class="inputbox" />';
break;
case 'password':
case 'password2':
echo '<input type="password" id="'.$fieldname.'_field" name="'.$fieldname.'" size="30" class="inputbox" />'."\n";
    break;
   
    case 'extra_field_4': case 'extra_field_5':
    eval( "\$ps_html->list_$fieldname( mosGetParam( \$_REQUEST, '$fieldname'), \"id=\\\"$fieldname\\\"\");" );
    break;
   
   
default:
        echo '<input type="text" id="'.$fieldname.'_field" name="'.$fieldname.'" size="30" value="'mosGetParam$_REQUEST$fieldname) .'" class="inputbox" />'."\n";
    break;
   
}
   

   
echo '</div>
      <br/><br/>'
;
   }
   
    echo 
'
<div align="center">'
;
    
if( !$mosConfig_useractivation && VM_SILENT_REGISTRATION != '1') {
echo '<input type="checkbox" name="remember" value="yes" id="remember_login2" checked="checked" />
<label for="remember_login2">'
$VM_LANG->_REMEMBER_ME .'</label><br /><br />';
}
else {
echo '<input type="hidden" name="remember" value="yes" />';
}
echo '
<input type="submit" value="'
$VM_LANG->_BUTTON_SEND_REG '" class="button" onclick="return( submitregistration());" />
</div>
<input type="hidden" name="Itemid" value="'
$sess->getShopItemid() .'" />
<input type="hidden" name="gid" value="'
$my->gid .'" />
<input type="hidden" name="id" value="'
$my->id .'" />
<input type="hidden" name="user_id" value="'
$my->id .'" />
<input type="hidden" name="option" value="com_virtuemart" />

<input type="hidden" name="useractivation" value="'
$mosConfig_useractivation .'" />
<input type="hidden" name="func" value="shopperadd" />
<input type="hidden" name="page" value="checkout.index" />
</form>
</div>'
;

?>
« Ultima modifica: 30 Gen 2008, 16:10:36 da LunaLovegood »

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #15 il: 30 Gen 2008, 16:12:02 »
ps_perm.php
Codice: [Seleziona]
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
/**
*
* @version $Id: ps_perm.php 617 2007-01-04 19:43:08Z soeren_nb $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/**
 * The permission handler class for VirtueMart.
 *
 */
class ps_perm {

// Can be easily extended
// Another permissions array must then
// be changed in ps_user.php!!
var $permissions = array(
"shopper"  =>  "1",
"demo"  =>  "2",
"storeadmin" =>  "4",
"admin"  =>  "8"
);

/**
* This function does the basic authentication
* for a user in the shop.
* It assigns permissions, the name, country, zip  and
* the shopper group id with the user and the session.
* @return array Authentication information
*/
function doAuthentication$shopper_group ) {

global $my$acl$user$_VERSION;
$db = new ps_DB;
$auth = array();

if( VM_PRICE_ACCESS_LEVEL != '' ) {
// Get the usertype property when not present
if( empty( $my->usertype ) ) {
if( empty( $my->id )) { 
$gid 29
}
else {
$gid $my->gid;
}
$fieldname = ($_VERSION->RELEASE >= 1.1 && $_VERSION->PRODUCT == 'Joomla!' ) ? 'id' 'group_id';
$db->query'SELECT `name` FROM `#__core_acl_aro_groups` WHERE `'.$fieldname.'` ='.$gid );
$db->next_record();
$my->usertype $db->f'name' );
}

$this->prepareACL();

// Is the user allowed to see the prices?
// this code will change when Joomla has a good ACL implementation
if( is_callable( array( $user'authorize'))) {
$auth['show_prices']  = $user->authorize'virtuemart''prices' );
}
else {
$auth['show_prices']  = $acl->acl_check'virtuemart''prices''users'strtolower($my->usertype), nullnull );
}
}
else {
$auth['show_prices'] = 1;
}

if (!empty($my->id)) { // user has already logged in

$auth["user_id"]   = $my->id;
$auth["username"] = $my->username;

if ($this->is_registered_customer($my->id)) {

$q "SELECT perms,first_name,last_name,country,zip FROM #__{vm}_user_info WHERE user_id='".$my->id."'";
$db->query($q);
$db->next_record();

$auth["perms"]  = $db->f("perms");

$auth["first_name"] = $db->f("first_name");
$auth["last_name"] = $db->f("last_name");
$auth["country"] = $db->f("country");
$auth["zip"] = $db->f("zip");

// Shopper is the default value
// We must prevent that Administrators or Managers are 'just' shoppers
if( $auth["perms"] == "shopper" ) {
if (stristr($my->usertype,"Administrator")) {
$auth["perms"]  = "admin";
}
elseif (stristr($my->usertype,"Manager")) {
$auth["perms"]  = "storeadmin";
}
}
$auth["shopper_group_id"] = $shopper_group["shopper_group_id"];
$auth["shopper_group_discount"] = $shopper_group["shopper_group_discount"];
$auth["show_price_including_tax"] = $shopper_group["show_price_including_tax"];
$auth["default_shopper_group"] = $shopper_group["default_shopper_group"];
$auth["is_registered_customer"] = true;
}

// user is no registered customer
else {
if (stristr($my->usertype,"Administrator")) {
$auth["perms"]  = "admin";
}
elseif (stristr($my->usertype,"Manager")) {
$auth["perms"]  = "storeadmin";
}
else {
$auth["perms"]  = "shopper"// DEFAULT
}
$auth["shopper_group_id"] = $shopper_group["default_shopper_group"];
$auth["shopper_group_discount"] = $shopper_group["shopper_group_discount"];
$auth["show_price_including_tax"] = $shopper_group["show_price_including_tax"];
$auth["default_shopper_group"] = 1;
$auth["is_registered_customer"] = false;
}

// user is not logged in
else {

$auth["user_id"] = 0;
$auth["username"] = "demo";
$auth["perms"]  = "";
$auth["first_name"] = "guest";
$auth["last_name"] = "";
$auth["shopper_group_id"] = $shopper_group["shopper_group_id"];
$auth["shopper_group_discount"] = $shopper_group["shopper_group_discount"];
$auth["show_price_including_tax"] = $shopper_group["show_price_including_tax"];
$auth["default_shopper_group"] = 1;
$auth["is_registered_customer"] = false;
}

// register $auth into SESSION
$_SESSION["auth"] = $auth;

return $auth;

}

/**
 * Validates the permission to do something.
 *
 * @param string $perms
 * @return boolean Check successful or not
 * @example $perm->check( 'admin', 'storeadmin' );
 *  returns true when the user is admin or storeadmin
 */
function check($perms) {

$auth $_SESSION["auth"];

// Parse all permissions in argument, comma separated
// It is assumed auth_user only has one group per user.
if ($perms == "none") {
return True;
}
else {
$p1 explode(","$auth['perms']);
$p2 explode(","$perms);
while (list($key1$value1) = each($p1)) {
while (list($key2$value2) = each($p2)) {
if ($value1 == $value2) {
return True;
}
}
}
}
return False;

}
/**
 * Checks if the user has higher permissions than $perm
 *
 * @param string $perm
 * @return boolean
 * @example $perm->hasHigherPerms( 'storeadmin' );
 *  returns true when user is admin
 */
function hasHigherPerms$perm ) {
$auth $_SESSION["auth"];

if( $this->permissions[$perm] <= $this->permissions[$auth['perms']] ) {
return true;
}
else {
return false;
}

}

/**
 * lists the permission levels in a select box
 * @author pablo
 * @param string $name The name of the select element
 * @param string $group_name The preselected key
 */
function list_perms$name$group_name ) {
global $VM_LANG;
$auth $_SESSION['auth'];

$db = new ps_DB;
  
// Get users current permission value 
$dvalue $this->permissions[$auth["perms"]];
echo "<select class=\"inputbox\" name=\"$name\">\n";
echo "<option value=\"0\">".$VM_LANG->_PHPSHOP_SELECT ."</option>\n";
while( list($key,$value) = each($this->permissions) ) {
// Display only those permission that this user can set
if ($value <= $dvalue)
if ($key == $group_name) {
echo "<option value=\"".$key."\" selected=\"selected\">$key</option>\n";
}
else {
echo "<option value=\"$key\">$key</option>\n";
}
}
echo "</select>\n";
}


/**************************************************************************
** name: is_registered_customer()
** created by: soeren
** description: Validates if someone is registered customer.
**            by checking if one has a billing address
** parameters: user_id
** returns: true if the user has a BT address
**          false if the user has none
***************************************************************************/
/**
 * Check if a user is registered in the shop (=customer)
 *
 * @param int $user_id
 * @return boolean
 */
function is_registered_customer($user_id) {
global $page$func$auth;
/**
if( @is_bool( $auth["is_registered_customer"]) && ($page!="checkout.index" && strtolower($func)!="shopperupdate")) {
return $auth["is_registered_customer"];
}
else {
*/
$db_check = new ps_DB;
$q  "SELECT #__users.id, #__{vm}_user_info.user_id from #__users, #__{vm}_user_info 
WHERE #__users.id='" 
$user_id "' AND #__users.id=#__{vm}_user_info.user_id 
AND #__{vm}_user_info.address_type='BT' AND #__{vm}_user_info.first_name != '' 
AND #__{vm}_user_info.last_name != '' AND #__{vm}_user_info.city != ''"
;
$db_check->query($q);

// Query failed or not?
if ($db_check->num_rows() > 0) {
return true;
}
else {
return false;
}
//}
}

/**
 * HERE WE INSERT GROUPS THAT ARE ALLOWED TO VIEW PRICES
 *
 */
function prepareACL() {
global $acl;

// The basic ACL integration in Mambo/Joomla is not awesome
$child_groups ps_perm::getChildGroups'#__core_acl_aro_groups''g1.group_id, g1.name, COUNT(g2.name) AS level', 'g1.name'nullVM_PRICE_ACCESS_LEVEL );
foreach( $child_groups as $child_group ) {
ps_perm::_addToGlobalACL'virtuemart''prices''users'$child_group->namenullnull );
}
$admin_groups ps_perm::getChildGroups'#__core_acl_aro_groups''g1.group_id, g1.name, COUNT(g2.name) AS level', 'g1.name'null'Public Backend' );
foreach( $admin_groups as $child_group ) {
ps_perm::_addToGlobalACL'virtuemart''prices''users'$child_group->namenullnull );
}

}

/**
 * Function from an old Mambo phpgacl integration function
 * @deprecated (but necessary, sigh!)
 * @static 
 * @param string $table
 * @param string $fields
 * @param string $groupby
 * @param int $root_id
 * @param string $root_name
 * @param boolean $inclusive
 * @return array
 */
function getChildGroups$table$fields$groupby=null$root_id=null$root_name=null$inclusive=true ) {
global $database$_VERSION;

$root = new stdClass();
$root->lft 0;
$root->rgt 0;
if( $_VERSION->PRODUCT == 'Joomla!' && $_VERSION->RELEASE >= 1.1 ) {
$fields str_replace'group_id''id'$fields );
}

if ($root_id) {
} else if ($root_name) {
$database->setQuery"SELECT `lft`, `rgt` FROM `$table` WHERE `name`='$root_name'" );
$database->loadObject$root );
}

$where '';
if ($root->lft+$root->rgt != 0) {
if ($inclusive) {
$where "WHERE g1.lft BETWEEN $root->lft AND $root->rgt";
} else {
$where "WHERE g1.lft BETWEEN $root->lft+1 AND $root->rgt-1";
}
}

$database->setQuery"SELECT $fields"
"\nFROM $table AS g1"
"\nINNER JOIN $table AS g2 ON g1.lft BETWEEN g2.lft AND g2.rgt"
"\n$where"
. ($groupby "\nGROUP BY $groupby"")
"\nORDER BY g1.lft"
);

//echo $database->getQuery();
return $database->loadObjectList();
}

/**
* This is a temporary function to allow 3PD's to add basic ACL checks for their
* modules and components.  NOTE: this information will be compiled in the db
* in future versions
 * @static 
 * @param unknown_type $aco_section_value
 * @param unknown_type $aco_value
 * @param unknown_type $aro_section_value
 * @param unknown_type $aro_value
 * @param unknown_type $axo_section_value
 * @param unknown_type $axo_value
 */
function _addToGlobalACL$aco_section_value$aco_value,
$aro_section_value$aro_value$axo_section_value=NULL$axo_value=NULL ) {
global $acl;
$acl->acl[] = array( $aco_section_value$aco_value$aro_section_value$aro_value$axo_section_value$axo_value );
$acl->acl_count count$acl->acl );
}

/**
 * Returns a tree with the children of the root group id
 * @static 
 * @param int $root_id
 * @param string $root_name
 * @param boolean $inclusive
 * @return unknown
 */
function getGroupChildrenTree$root_id=null$root_name=null$inclusive=true ) {
global $database$_VERSION;

$tree ps_perm::getChildGroups'#__core_acl_aro_groups',
'g1.group_id, g1.name, COUNT(g2.name) AS level',
'g1.name',
$root_id$root_name$inclusive );

// first pass get level limits
$n count$tree );
$min $tree[0]->level;
$max $tree[0]->level;
for ($i=0$i $n$i++) {
$min min$min$tree[$i]->level );
$max max$max$tree[$i]->level );
}

$indents = array();
foreach (range$min$max ) as $i) {
$indents[$i] = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
}
// correction for first indent
$indents[$min] = '';

$list = array();
for ($i=$n-1$i >= 0$i--) {
$shim '';
foreach (range$min$tree[$i]->level ) as $j) {
$shim .= $indents[$j];
}

if (@$indents[$tree[$i]->level+1] == '.&nbsp;') {
$twist '&nbsp;';
} else {
$twist "-&nbsp;";
}

if( $_VERSION->PRODUCT == 'Joomla!' && $_VERSION->RELEASE >= 1.1 ) {
$tree[$i]->group_id $tree[$i]->id;
}
$list[$i] = mosHTML::makeOption$tree[$i]->group_id$shim.$twist.$tree[$i]->name );
if ($tree[$i]->level < @$tree[$i-1]->level) {
$indents[$tree[$i]->level+1] = '.&nbsp;';
}
}

ksort($list);
return $list;
}
}

?>

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #16 il: 30 Gen 2008, 16:13:00 »
ps_shopper.php
Codice: [Seleziona]
<?php
defined
'_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' ); 
/**
*
* @version $Id: ps_shopper.php 690 2007-02-20 14:01:10Z soeren_nb $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2005 Soeren Eberhardt. All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

/**
*
* The class is meant to manage shopper entries
*/
class ps_shopper {
  var 
$classname "ps_shopper";
  
/**************************************************************************
** name: validate_add()
** created by:
** description:
** parameters:
** returns:
  ***************************************************************************/
function validate_add(&$d) {
global $my$perm;

$db = new ps_DB;

$provided_required true;
$missing "";

if( empty( $my->id ) ) {
if( VM_SILENT_REGISTRATION != '1') {
if (empty($d['username'])) { $provided_required false$missing .= "username,"; }
if (empty($d['password'])) { $provided_required false$missing .= "password,"; }
if (empty($d['password2'])) { $provided_required false$missing .= "password2,"; }
}
if (empty($d['email'])) { $provided_required false$missing .= "email,"; }
}

if (empty($d['first_name'])) { $provided_required false$missing .= "first_name,"; }
//if (empty($d['company']))  { $provided_required = false; $missing .= "company,"; }
if (empty($d['address_1']))  { $provided_required false$missing .= "address_1,"; }
//if (empty($d['phone_1'])) { $provided_required = false; $missing .= "phone_1"; }

if (MUST_AGREE_TO_TOS == '1'&& !$perm->is_registered_customer$my->id )) { 
if( empty( $d['agreed'] )) {
$provided_required false;
$missing .= "agreed,";
}
}

if (!$provided_required) {
$_REQUEST['missing'] = $missing;
return false;
/*
$url="username=".$d['username'];
$url.="&email=".$d['email'];
$url.="&first_name=".$d['first_name'];
$url.="&last_name=".$d['last_name'];
$url.="&middle_name=".$d['middle_name'];
$url.="&title=".$d['title'];
$url.="&company=".$d['company'];
$url.="&address_1=".$d['address_1'];
$url.="&address_2=".$d['address_2'];
$url.="&city=".$d['city'];
$url.="&zip=".$d['zip'];
$url.="&state=".$d['state'];
$url.="&country=".$d['country'];
$url.="&phone_1=".$d['phone_1'];
$url.="&fax=".$d['fax'];
$url.="&bank_account_nr=".@$d['bank_account_nr'];
$url.="&bank_sort_code=".@$d['bank_sort_code'];
$url.="&bank_name=".@$d['bank_name'];
$url.="&bank_iban=".@$d['bank_iban'];
$url.="&bank_account_holder=".@$d['bank_account_holder'];
$url.="&bank_account_type=".@$d['bank_account_type'];

mosRedirect( "index.php?option=com_virtuemart&page=".$_SESSION['last_page']."&missing=$missing&$url", _CONTACT_FORM_NC );
*/
}

$d['user_email'] = mosGetParam$d'email'$my->email );
$d['perms'] = 'shopper';

return $provided_required;
  }

/**************************************************************************
** name: validate_update()
** created by:
** description:
** parameters:
** returns:
***************************************************************************/
function validate_update(&$d) {
global $my$perm$vmLogger;

if ($my->id == 0){
  $vmLogger->err"Please Login first." );
  
  return false;
}
return $this->validate_add$d );

}

/**************************************************************************
** name: validate_delete()
** created by:
** description:
** parameters:
** returns:
***************************************************************************/
function validate_delete(&$d) {
global $my;
 
if ($my->id == 0){
  $vmLogger->err"Please Login first." );
return false;
}
if (!$d["user_id"]) {
$vmLogger->err"Please select a user to delete." );
return False;
}
else {
return True;
}
}

  
/**
* Function to add a new Shopper into the Shop and Joomla
*/
function add( &$d ) {
global $my$ps_user$mainframe$mosConfig_absolute_path$sess,
$VM_LANG$database$option$mosConfig_useractivation$vmInputFilter;

$ps_vendor_id $_SESSION["ps_vendor_id"];
$hash_secret "VirtueMartIsCool";
$db = new ps_DB;
$timestamp time();

if (!$this->validate_add($d)) {
  return False;
}
// Use InputFilter class to prevent SQL injection or HTML tags
$d =$vmInputFilter->process$d );

if ($VM_LANG->_PHPSHOP_SHOPPER_FORM_EXTRA_FIELD_4 and $d["extra_field_4"] == "") {
  $d["extra_field_4"] = "N";
}
if ($VM_LANG->_PHPSHOP_SHOPPER_FORM_EXTRA_FIELD_5 and $d["extra_field_5"] == "") {
  $d["extra_field_5"] = "N";

if( empty( $my->id ) ) {

$_POST['name'] = $d['first_name']." ".$d['last_name'];
if( VM_SILENT_REGISTRATION == '1' ) {
$silent_username substrstr_replace'-''_'$d['email'] ), 025 );
$db->query'SELECT username FROM `#__users` WHERE username=\''.$silent_username.'\'');
$i 0;
while( $db->next_record()) {
$silent_username substr_replace$silent_username$istrlen($silent_username)-);
$db->query'SELECT username FROM `#__users` WHERE username=\''.$silent_username.'\'');
$i++;
}
$_POST['username'] = $d['username'] = $silent_username;
$_POST['password'] = $d['password'] = mosMakePassword();
$_POST['password2'] = $_POST['password'];
}
// Process Mambo/Joomla registration stuff
if( !$this->saveRegistration() ) {
return false;
}

$database->setQuery"SELECT id FROM #__users WHERE username='".$d['username']."'" );
$database->loadObject$userid );
$uid $userid->id;
}
else {
$uid $my->id;
$d['email'] = $_POST['email'] = $my->email;

}
$db->query'SELECT user_id FROM #__{vm}_user_info WHERE user_id='.$my->id );
$db->next_record();

if( $db->f('user_id')) {
return $this->update$d );
}

// Insert billto
$q "INSERT INTO #__{vm}_user_info VALUES (";
$q .= "'" md5(uniqid$hash_secret)) . "',";
$q .= "'" $uid "',";
$q .= "'BT',";
$q .= "'-default-',";
$q .= "'" .$d["company"] . "',";
$q .= "'" .$d["title"] . "',";
$q .= "'" .$d["last_name"] . "',";
$q .= "'" .$d["first_name"] . "',";
$q .= "'" .$d["middle_name"] . "',";
$q .= "'" .$d["phone_1"] . "',";
$q .= "'" .@$d["phone_2"] . "',";
$q .= "'" .$d["fax"] . "',";
$q .= "'" .$d["address_1"] . "',";
$q .= "'" .$d["address_2"] . "',";
$q .= "'" .$d["city"] . "',";
$q .= "'" .@$d["state"] . "',";
$q .= "'" .$d["country"] . "',";
$q .= "'" .$d["zip"] . "',";
$q .= "'" .$d["email"] . "',";
$q .= "'" .@$d["extra_field_1"] . "',";
$q .= "'" .@$d["extra_field_2"] . "',";
$q .= "'" .@$d["extra_field_3"] . "',";
$q .= "'" .@$d["extra_field_4"] . "',";
$q .= "'" .@$d["extra_field_5"] . "',";
$q .= "'" .$timestamp "',";
$q .= "'" .$timestamp "',";
$q .= "'shopper', ";
$q .= "'" . @$d["bank_account_nr"] . "', ";
$q .= "'" . @$d["bank_name"] . "', ";
$q .= "'" . @$d["bank_sort_code"] . "', ";
$q .= "'" . @$d["bank_iban"] . "', ";
$q .= "'" . @$d["bank_account_holder"] . "', ";
$q .= "'" . @$d["bank_account_type"] . "') ";

$db->query($q);


// Insert vendor relationship
$q "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
$q .= " VALUES ";
$q .= "('" $uid "','";
$q .= $ps_vendor_id "') ";
$db->query($q);

// Insert Shopper -ShopperGroup - Relationship    
$q =  "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
$q .= "`default`='1' ";
   
$db->query($q);
if (!$db->num_rows()) {  // take the first in the table
   
$q =  "SELECT shopper_group_id from #__{vm}_shopper_group";
$db->query($q);
}
$db->next_record();
$d['shopper_group_id'] = $db->f("shopper_group_id");

$customer_nr uniqidrand() );

$q  "INSERT INTO #__{vm}_shopper_vendor_xref ";
$q .= "(user_id,vendor_id,shopper_group_id,customer_number) ";
$q .= "VALUES ('$uid', '$ps_vendor_id','".$d['shopper_group_id']."', '$customer_nr')";
$db->query($q);

if( !$my->id && $mosConfig_useractivation == '0') {
if( defined('_JEXEC') || class_exists('mambocore')) {
$mainframe->login($d['username'], $d['password'] );
} else {
$mainframe->login($d['username'], md5$d['password'] ));
}
if( !empty( $_SESSION['cart']['idx'])) {
$redirect_to_page 'checkout.index';
} else {
$redirect_to_page HOMEPAGE;
}
mosRedirect$sess->url'index.php?page='.$redirect_to_page ), $VM_LANG->_REG_COMPLETE );
}
elseif( $my->id ) {
mosRedirect$sess->url'index.php?page=checkout.index' ) );
}
else {
mosRedirect$sess->url'index.php?page='.HOMEPAGE ), $VM_LANG->_REG_COMPLETE_ACTIVATE );
}

return True;
    
}

/**
 * The function from com_registration!
 * Registers a user into Mambo/Joomla
 *
 * @return boolean True when the registration process was successful, False when not
 */
function saveRegistration() {
global $database$acl$VM_LANG$vmLogger;
global $mosConfig_sitename$mosConfig_live_site$mosConfig_useractivation$mosConfig_allowUserRegistration;
global $mosConfig_mailfrom$mosConfig_fromname$mosConfig_mailfrom$mosConfig_fromname;

if ($mosConfig_allowUserRegistration=='0') {
mosNotAuth(); 
return false;
}

$row = new mosUser$database );

if (!$row->bind$_POST'usertype' )) {
$error vmHtmlEntityDecode$row->getError() );
$vmLogger->err$error );
echo "<script type=\"text/javascript\"> alert('"$error"');</script>\n";
return false;
}

mosMakeHtmlSafe($row);

$usergroup 'Registered';
$row->id 0;
$row->usertype $usergroup;
$row->gid $acl->get_group_id$usergroup'ARO' );

if ($mosConfig_useractivation == '1') {
$row->activation md5mosMakePassword() );
$row->block '1';
}

if (!$row->check()) {
$error vmHtmlEntityDecode$row->getError() );
$vmLogger->err$error );
echo "<script type=\"text/javascript\"> alert('"$error"');</script>\n";
return false;
}

$pwd  $row->password;
$row->password  md5$row->password );
$row->registerDate  date('Y-m-d H:i:s');

if (!$row->store()) {
$error vmHtmlEntityDecode$row->getError() );
$vmLogger->err$error );
echo "<script type=\"text/javascript\"> alert('"$error"');</script>\n";
return false;
}
$row->checkin();

$name  $row->name;
$email  $row->email;
$username  $row->username;

$subject  sprintf ($VM_LANG->_SEND_SUB$name$mosConfig_sitename);
$subject  vmHtmlEntityDecode($subjectENT_QUOTES);
if ($mosConfig_useractivation=="1"){
$message sprintf ($VM_LANG->_USEND_MSG_ACTIVATE$name$mosConfig_sitename$mosConfig_live_site."/index.php?option=com_registration&task=activate&activation=".$row->activation$mosConfig_live_site$username$pwd);
} else {
$message sprintf ($VM_LANG->_PHPSHOP_USER_SEND_REGISTRATION_DETAILS$name$mosConfig_sitename$mosConfig_live_site$username$pwd);
}

$message vmHtmlEntityDecode($messageENT_QUOTES);
// Send email to user
if ($mosConfig_mailfrom != "" && $mosConfig_fromname != "") {
$adminName2 $mosConfig_fromname;
$adminEmail2 $mosConfig_mailfrom;
} else {
$query "SELECT name, email"
"\n FROM #__users"
"\n WHERE LOWER( usertype ) = 'superadministrator'"
"\n OR LOWER( usertype ) = 'super administrator'"
;
$database->setQuery$query );
$rows $database->loadObjectList();
$row2  $rows[0];
$adminName2  $row2->name;
$adminEmail2  $row2->email;
}

mosMail($adminEmail2$adminName2$email$subject$message);

// Send notification to all administrators
$subject2 sprintf $VM_LANG->_SEND_SUB$name$mosConfig_sitename);
$message2 sprintf $VM_LANG->_ASEND_MSG$adminName2$mosConfig_sitename$row->name$email$username);
$subject2 vmHtmlEntityDecode($subject2ENT_QUOTES);
$message2 vmHtmlEntityDecode($message2ENT_QUOTES);

// get superadministrators id
$admins $acl->get_group_objects25'ARO' );

foreach ( $admins['users'] AS $id ) {
$query "SELECT email, sendEmail"
"\n FROM #__users"
."\n WHERE id = $id"
;
$database->setQuery$query );
$rows $database->loadObjectList();

$row $rows[0];

if ($row->sendEmail) {
mosMail($adminEmail2$adminName2$row->email$subject2$message2);
}
}

if ( $mosConfig_useractivation == ){
echo $VM_LANG->_REG_COMPLETE_ACTIVATE;
} else {
echo $VM_LANG->_REG_COMPLETE;
}
return true;
}

  
/**
* Function to update a Shopper Entry
* (uses who have perms='shopper')
*/
function update(&$d) {
global $my$perm$sess$vmLogger;

$auth $_SESSION['auth'];

$db = new ps_DB;

$d $GLOBALS['vmInputFilter']->safeSQL$d );

if (@$d["user_id"] != $my->id && $auth["perms"] != "admin") {
  $vmLogger->crit"Tricky tricky, but we know about this one." );
  return False;
}

require_once(CLASSPATH'ps_user.php' );
if( !empty($d['username'])) {
$_POST['username'] = $d['username'];
}
else {
$_POST['username'] = $my->username;
}
$_POST['name'] = $d['first_name']." "$d['last_name'];
$_POST['id'] = $auth["user_id"];
$_POST['gid'] = $my->gid;
$d['error'] = "";

ps_user::saveUser$d );
if( !empty( $d['error']) ) {

return false;
}

if (!$this->validate_update($d)) {
$_SESSION['last_page'] = "checkout.index";
return false;
}
$user_id $auth["user_id"];

/* Update Bill To */
$q  "UPDATE #__{vm}_user_info SET ";
if (!empty($d['company'])) {
$q .= "company='" $d["company"] . "', ";
} else { 
$q .= "company='', "
}
$q .= "title='" $d["title"] . "', ";
$q .= "last_name='" $d["last_name"] . "', ";
$q .= "first_name='" $d["first_name"] . "', ";
if (!empty($d['middle_name'])) {
$q .= "middle_name='" $d["middle_name"] . "', ";
}
else {
$q .= "middle_name='', ";
}
$q .= "phone_1='" $d["phone_1"] . "', ";
if (!empty($d['phone_2'])) {
$q .= "phone_2='" $d["phone_2"] . "',";
} else {
$q .= "phone_2='',";
}
if (!empty($d['fax'])) {
$q .= "fax='" $d["fax"] . "', ";
} else {
$q .= "fax='', ";
}
$q .=  "address_1='" $d["address_1"] . "', ";
$q .= "address_2='" . @$d["address_2"] . "', ";
$q .= "city='" $d["city"] . "', ";
if (!empty($d['state'])){
$q .= "state='" $d["state"] . "', ";
} else {
$q .= "state='', ";
}
$q .= "country='" $d["country"] . "', ";
$q .= "zip='" $d["zip"] . "', ";
$q .= "extra_field_1='" . @$d["extra_field_1"] . "', ";
$q .= "extra_field_2='" . @$d["extra_field_2"] . "', ";
$q .= "extra_field_3='" . @$d["extra_field_3"] . "', ";
$q .= "extra_field_4='" . @$d["extra_field_4"] . "', ";
$q .= "extra_field_5='" . @$d["extra_field_5"] . "' ";
if (!empty($d['bank_iban'])) {
$q .= ",bank_iban='" $d["bank_iban"] . "' ";
} else {
$q .= ",bank_iban='' ";
}
if (!empty($d['bank_account_nr'])){
$q .= ",bank_account_nr='" $d["bank_account_nr"] . "' ";
} else { 
$q .= ",bank_account_nr='' ";
}
if (!empty($d['bank_sort_code'])) {
$q .= ",bank_sort_code='" $d["bank_sort_code"] . "' ";
} else { 
$q .= ",bank_sort_code='' ";
}
if (!empty($d['bank_name'])) {
$q .= ",bank_name='" $d["bank_name"] . "'";
} else {
$q .= ",bank_name=''";
}
if (!empty($d['bank_account_holder'])) {
$q .= ", bank_account_holder='" $d["bank_account_holder"] . "' ";
} else {
$q .= ", bank_account_holder='' ";
}
if (mShop_validateEmail(@$d['email'])) {
$q .= ",user_email = '".@$d['email']."' ";
}
$q .= "WHERE user_id=" intval$user_id ). " AND address_type='BT'";
  
$db->query($q);
  
// UPDATE #__{vm}_shopper group relationship
$q "SELECT shopper_group_id FROM #__{vm}_shopper_vendor_xref ";
$q .= "WHERE user_id = '".$user_id."'";
$db->query($q);

if (!$db->num_rows()) {
//add

$shopper_db = new ps_DB;
// get the default shopper group
$q =  "SELECT shopper_group_id from #__{vm}_shopper_group WHERE ";
$q .= "`default`='1'";
$shopper_db->query($q);
if (!$shopper_db->num_rows()) {  // when there is no "default", take the first in the table 
$q =  "SELECT shopper_group_id from #__{vm}_shopper_group";
$shopper_db->query($q);
}

$shopper_db->next_record();
$my_shopper_group_id $shopper_db->f("shopper_group_id");
if (empty($d['customer_number'])) 
$d['customer_number'] = "";

$q  "INSERT INTO #__{vm}_shopper_vendor_xref ";
$q .= "(user_id,vendor_id,shopper_group_id) ";
$q .= "VALUES ('";
$q .= $_SESSION['auth']['user_id'] . "','";
$q .= $_SESSION['ps_vendor_id'] . "','";
$q .= $my_shopper_group_id"')";
$db->query($q);
}
$q "SELECT user_id FROM #__{vm}_auth_user_vendor ";
$q .= "WHERE user_id = '".$_SESSION['auth']['user_id']."'";
$db->query($q);
if (!$db->num_rows()) {
// Insert vendor relationship
$q "INSERT INTO #__{vm}_auth_user_vendor (user_id,vendor_id)";
$q .= " VALUES ";
$q .= "('" $_SESSION['auth']['user_id'] . "','";
$q .= $_SESSION['ps_vendor_id'] . "') ";
$db->query($q);
}

return True;
}
  
/**
* Function to delete a Shopper
*/
function delete(&$d) {
global $my;
  
$db = new ps_DB;

if (!$this->validate_delete($d)) {
return False;
}

// Delete user_info entries
// and Shipping addresses
$q "DELETE FROM #__{vm}_user_info where user_id='" $d["user_id"] . "'"
$db->query($q);

// Delete shopper_vendor_xref entries
$q "DELETE FROM #__{vm}_shopper_vendor_xref where user_id='" $d["user_id"] . "'"
$db->query($q);

$q "DELETE FROM #__{vm}_auth_user_vendor where user_id='" $d["user_id"] . "'"
$db->query($q);
return True;
}
}
$ps_shopper = new ps_shopper;
?>


Scusate gli svariati post, ma non sono riuscita ad allegare i files. :)

Offline LunaLovegood

  • Esploratore
  • **
  • Post: 75
    • Mostra profilo
Re: mail registrazione
« Risposta #17 il: 01 Feb 2008, 16:28:37 »
nessun volontario? :'(

 



Web Design Bolzano Kreatif