/
edit.php
62 lines (45 loc) · 1.83 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Copyright (c) 2005-2013 Laposa Ltd (http://laposa.co.uk)
* Licensed under the New BSD License. See the file LICENSE.txt for details.
*
*/
class Onxshop_Controller_Component_Client_Edit extends Onxshop_Controller {
/**
* main action
*/
public function mainAction() {
if ($_SESSION['client']['customer']['id'] == 0 && !Onxshop_Bo_Authentication::getInstance()->isAuthenticated()) {
msg('client_edit: You must be logged in first.', 'error');
onxshopGoTo("/");
}
require_once('models/client/client_customer.php');
$Customer = new client_customer();
$Customer->setCacheable(false);
$customer_id = $_SESSION['client']['customer']['id'];
if (!is_numeric($customer_id)) return false;
if ($_POST['save']) {
$_POST['client']['customer']['id'] = $customer_id;
// do not allow to set certain properties
unset($_POST['client']['customer']['status']);
unset($_POST['client']['customer']['group_id']);
unset($_POST['client']['customer']['account_type']);
unset($_POST['client']['customer']['other_data']);
if ($Customer->updateClient($_POST['client'])) {
msg(I18N_CUSTOMER_DATA_UPDATED);
} else {
msg("Can't update client data", 'error');
}
}
$client_data = $Customer->getClientData($customer_id);
$client_data['customer']['newsletter'] = ($client_data['customer']['newsletter'] == 1) ? 'checked="checked" ' : '';
// format birthday only if available to avoid 01/01/1970 by default
if ($client_data['customer']['birthday'] != '') $client_data['customer']['birthday'] = strftime('%d/%m/%Y', strtotime($client_data['customer']['birthday']));
$this->tpl->assign('CLIENT', $client_data);
/**
* show password field only if previously set
*/
if ($client_data['customer']['password']) $this->tpl->parse('content.password');
return true;
}
}