  |
1 | 1 | | <?php |
| |
2 | 2 | | /* |
  |
3 | | - | $Id: account.php 734 2006-08-20 17:56:47Z hpdl $ |
| |
| 3 | + | $Id: account.php 811 2006-08-27 15:13:33Z hpdl $ |
|
4 | 4 | | |
| |
5 | 5 | | osCommerce, Open Source E-Commerce Solutions |
| |
6 | 6 | | http://www.oscommerce.com |
| |
|
|
 |
… |
|
41 | 41 | | function createEntry($data) { |
| |
42 | 42 | | global $osC_Database, $osC_Session, $osC_Language, $osC_ShoppingCart, $osC_Customer, $osC_NavigationHistory; |
| |
43 | 43 | | |
  |
44 | | - | $osC_Database->startTransaction(); |
| |
45 | | - | |
| |
46 | | - | $Qcustomer = $osC_Database->query('insert into :table_customers (customers_firstname, customers_lastname, customers_email_address, customers_newsletter, customers_status, customers_ip_address, customers_password, customers_gender, customers_dob) values (:customers_firstname, :customers_lastname, :customers_email_address, :customers_newsletter, :customers_status, :customers_ip_address, :customers_password, :customers_gender, :customers_dob)'); |
| |
| 44 | + | $Qcustomer = $osC_Database->query('insert into :table_customers (customers_firstname, customers_lastname, customers_email_address, customers_newsletter, customers_status, customers_ip_address, customers_password, customers_gender, customers_dob, number_of_logons, date_account_created) values (:customers_firstname, :customers_lastname, :customers_email_address, :customers_newsletter, :customers_status, :customers_ip_address, :customers_password, :customers_gender, :customers_dob, :number_of_logons, :date_account_created)'); |
|
47 | 45 | | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
| |
48 | 46 | | $Qcustomer->bindValue(':customers_firstname', $data['firstname']); |
| |
49 | 47 | | $Qcustomer->bindValue(':customers_lastname', $data['lastname']); |
| |
|
|
 |
… |
|
54 | 52 | | $Qcustomer->bindValue(':customers_password', osc_encrypt_string($data['password'])); |
| |
55 | 53 | | $Qcustomer->bindValue(':customers_gender', (((ACCOUNT_GENDER > -1) && isset($data['gender']) && (($data['gender'] == 'm') || ($data['gender'] == 'f'))) ? $data['gender'] : '')); |
| |
56 | 54 | | $Qcustomer->bindValue(':customers_dob', ((ACCOUNT_DATE_OF_BIRTH == '1') ? date('Ymd', $data['dob']) : '')); |
  |
| 55 | + | $Qcustomer->bindInt(':number_of_logons', 0); |
| |
| 56 | + | $Qcustomer->bindRaw(':date_account_created', 'now()'); |
|
57 | 57 | | $Qcustomer->execute(); |
| |
58 | 58 | | |
| |
59 | 59 | | if ($Qcustomer->affectedRows() === 1) { |
| |
60 | 60 | | $customer_id = $osC_Database->nextID(); |
| |
61 | 61 | | |
  |
62 | | - | $Qci = $osC_Database->query('insert into :table_customers_info (customers_info_id, customers_info_number_of_logons, customers_info_date_account_created) values (:customers_info_id, :customers_info_number_of_logons, :customers_info_date_account_created)'); |
| |
63 | | - | $Qci->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO); |
| |
64 | | - | $Qci->bindInt(':customers_info_id', $customer_id); |
| |
65 | | - | $Qci->bindInt(':customers_info_number_of_logons', 0); |
| |
66 | | - | $Qci->bindRaw(':customers_info_date_account_created', 'now()'); |
| |
67 | | - | $Qci->execute(); |
| |
| 62 | + | if (SERVICE_SESSION_REGENERATE_ID == '1') { |
| |
| 63 | + | $osC_Session->recreate(); |
| |
| 64 | + | } |
|
68 | 65 | | |
  |
69 | | - | if ($Qci->affectedRows() === 1) { |
| |
70 | | - | $osC_Database->commitTransaction(); |
| |
| 66 | + | $osC_Customer->setCustomerData($customer_id); |
|
71 | 67 | | |
  |
72 | | - | if (SERVICE_SESSION_REGENERATE_ID == '1') { |
| |
73 | | - | $osC_Session->recreate(); |
| |
74 | | - | } |
| |
75 | | - | |
| |
76 | | - | $osC_Customer->setCustomerData($customer_id); |
| |
77 | | - | |
|
78 | 68 | | // restore cart contents |
  |
79 | | - | $osC_ShoppingCart->synchronizeWithDatabase(); |
| |
| 69 | + | $osC_ShoppingCart->synchronizeWithDatabase(); |
|
80 | 70 | | |
  |
81 | | - | $osC_NavigationHistory->removeCurrentPage(); |
| |
| 71 | + | $osC_NavigationHistory->removeCurrentPage(); |
|
82 | 72 | | |
| |
83 | 73 | | // build the message content |
  |
84 | | - | if ((ACCOUNT_GENDER > -1) && isset($data['gender'])) { |
| |
85 | | - | if ($data['gender'] == 'm') { |
| |
86 | | - | $email_text = sprintf($osC_Language->get('email_addressing_gender_male'), $osC_Customer->getLastName()) . "\n\n"; |
| |
87 | | - | } else { |
| |
88 | | - | $email_text = sprintf($osC_Language->get('email_addressing_gender_female'), $osC_Customer->getLastName()) . "\n\n"; |
| |
89 | | - | } |
| |
90 | | - | } else { |
| |
91 | | - | $email_text = sprintf($osC_Language->get('email_addressing_gender_unknown'), $osC_Customer->getName()) . "\n\n"; |
| |
92 | | - | } |
| |
| 74 | + | if ((ACCOUNT_GENDER > -1) && isset($data['gender'])) { |
| |
| 75 | + | if ($data['gender'] == 'm') { |
| |
| 76 | + | $email_text = sprintf($osC_Language->get('email_addressing_gender_male'), $osC_Customer->getLastName()) . "\n\n"; |
| |
| 77 | + | } else { |
| |
| 78 | + | $email_text = sprintf($osC_Language->get('email_addressing_gender_female'), $osC_Customer->getLastName()) . "\n\n"; |
| |
| 79 | + | } |
| |
| 80 | + | } else { |
| |
| 81 | + | $email_text = sprintf($osC_Language->get('email_addressing_gender_unknown'), $osC_Customer->getName()) . "\n\n"; |
| |
| 82 | + | } |
|
93 | 83 | | |
  |
94 | | - | $email_text .= sprintf($osC_Language->get('email_create_account_body'), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS); |
| |
| 84 | + | $email_text .= sprintf($osC_Language->get('email_create_account_body'), STORE_NAME, STORE_OWNER_EMAIL_ADDRESS); |
|
95 | 85 | | |
  |
96 | | - | osc_email($osC_Customer->getName(), $osC_Customer->getEmailAddress(), sprintf($osC_Language->get('email_create_account_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); |
| |
| 86 | + | osc_email($osC_Customer->getName(), $osC_Customer->getEmailAddress(), sprintf($osC_Language->get('email_create_account_subject'), STORE_NAME), $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS); |
|
97 | 87 | | |
  |
98 | | - | return true; |
| |
99 | | - | } else { |
| |
100 | | - | $osC_Database->rollbackTransaction(); |
| |
101 | | - | } |
| |
102 | | - | } else { |
| |
103 | | - | $osC_Database->rollbackTransaction(); |
| |
| 88 | + | return true; |
|
104 | 89 | | } |
| |
105 | 90 | | |
| |
106 | 91 | | return false; |
| |
|
|
 |
… |
|
109 | 94 | | function saveEntry($data) { |
| |
110 | 95 | | global $osC_Database, $osC_Customer; |
| |
111 | 96 | | |
  |
112 | | - | $Qcustomer = $osC_Database->query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob where customers_id = :customers_id'); |
| |
| 97 | + | $Qcustomer = $osC_Database->query('update :table_customers set customers_gender = :customers_gender, customers_firstname = :customers_firstname, customers_lastname = :customers_lastname, customers_email_address = :customers_email_address, customers_dob = :customers_dob, date_account_last_modified = :date_account_last_modified where customers_id = :customers_id'); |
|
113 | 98 | | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
| |
114 | 99 | | $Qcustomer->bindValue(':customers_gender', ((ACCOUNT_GENDER > -1) && isset($data['gender']) && (($data['gender'] == 'm') || ($data['gender'] == 'f'))) ? $data['gender'] : ''); |
| |
115 | 100 | | $Qcustomer->bindValue(':customers_firstname', $data['firstname']); |
| |
116 | 101 | | $Qcustomer->bindValue(':customers_lastname', $data['lastname']); |
| |
117 | 102 | | $Qcustomer->bindValue(':customers_email_address', $data['email_address']); |
| |
118 | 103 | | $Qcustomer->bindValue(':customers_dob', (ACCOUNT_DATE_OF_BIRTH == '1') ? date('Ymd', $data['dob']) : ''); |
  |
| 104 | + | $Qcustomer->bindRaw(':date_account_last_modified', 'now()'); |
|
119 | 105 | | $Qcustomer->bindInt(':customers_id', $osC_Customer->getID()); |
| |
120 | 106 | | $Qcustomer->execute(); |
| |
121 | 107 | | |
| |
122 | 108 | | if ($Qcustomer->affectedRows() === 1) { |
  |
123 | | - | $Qupdate = $osC_Database->query('update :table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = :customers_info_id'); |
| |
124 | | - | $Qupdate->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO); |
| |
125 | | - | $Qupdate->bindInt(':customers_info_id', $osC_Customer->getID()); |
| |
126 | | - | $Qupdate->execute(); |
| |
127 | | - | |
|
128 | 109 | | return true; |
| |
129 | 110 | | } |
| |
130 | 111 | | |
| |
|
|
 |
… |
|
138 | 119 | | $customer_id = $osC_Customer->getID(); |
| |
139 | 120 | | } |
| |
140 | 121 | | |
  |
141 | | - | $Qcustomer = $osC_Database->query('update :table_customers set customers_password = :customers_password where customers_id = :customers_id'); |
| |
| 122 | + | $Qcustomer = $osC_Database->query('update :table_customers set customers_password = :customers_password, date_account_last_modified = :date_account_last_modified where customers_id = :customers_id'); |
|
142 | 123 | | $Qcustomer->bindTable(':table_customers', TABLE_CUSTOMERS); |
| |
143 | 124 | | $Qcustomer->bindValue(':customers_password', osc_encrypt_string($password)); |
  |
| 125 | + | $Qcustomer->bindRaw(':date_account_last_modified', 'now()'); |
|
144 | 126 | | $Qcustomer->bindInt(':customers_id', $customer_id); |
| |
145 | 127 | | $Qcustomer->execute(); |
| |
146 | 128 | | |
| |
147 | 129 | | if ($Qcustomer->affectedRows() === 1) { |
  |
148 | | - | $Qupdate = $osC_Database->query('update :table_customers_info set customers_info_date_account_last_modified = now() where customers_info_id = :customers_info_id'); |
| |
149 | | - | $Qupdate->bindTable(':table_customers_info', TABLE_CUSTOMERS_INFO); |
| |
150 | | - | $Qupdate->bindInt(':customers_info_id', $customer_id); |
| |
151 | | - | $Qupdate->execute(); |
| |
152 | | - | |
  |
153 | 130 | | return true; |
| |
154 | 131 | | } |
| |
155 | 132 | | |