1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* Account Management Controller |
5
|
|
|
*/ |
6
|
|
|
class Account extends MY_Controller { |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Constructor |
10
|
|
|
*/ |
11
|
|
|
public function __construct() |
12
|
|
|
{ |
13
|
|
|
parent::__construct(); |
14
|
|
|
$this->page->set_foot_js_group('js'); |
15
|
|
|
$this->page->set_title('Account'); |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
// -------------------------------------------------------------------------- |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Dashboard |
22
|
|
|
*/ |
23
|
|
|
public function index() |
24
|
|
|
{ |
25
|
|
|
$data = $this->todo->get_user_account_by_id($this->session->userdata('uid')); |
26
|
|
|
$this->page->build('account/status', $data); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
// -------------------------------------------------------------------------- |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Password change form |
33
|
|
|
*/ |
34
|
|
|
public function password() |
35
|
|
|
{ |
36
|
|
|
//Don't let the guest change the password |
37
|
|
|
if($this->session->userdata('username') == 'guest') |
38
|
|
|
{ |
39
|
|
|
$this->todo->redirect_303('account'); |
40
|
|
|
return; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
if($this->input->post('pass_sub') == "Change Password") |
44
|
|
|
{ |
45
|
|
|
$val = $this->todo->validate_pass(); |
46
|
|
|
if($val === TRUE) |
47
|
|
|
{ |
48
|
|
|
$this->todo->update_pass(); |
49
|
|
|
//Redirect to index |
50
|
|
|
$this->todo->redirect_303('task/list'); |
51
|
|
|
} |
52
|
|
|
else |
53
|
|
|
{ |
54
|
|
|
$data = [ |
55
|
|
|
'err' => $val |
56
|
|
|
]; |
57
|
|
|
$this->page->build('account/password', $data); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
else |
61
|
|
|
{ |
62
|
|
|
$this->page->build('account/password'); |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
// -------------------------------------------------------------------------- |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Timezone update |
70
|
|
|
*/ |
71
|
|
View Code Duplication |
public function update_tz() |
72
|
|
|
{ |
73
|
|
|
$timezone = $this->input->post('timezone'); |
74
|
|
|
|
75
|
|
|
$this->db->set('timezone', $timezone) |
76
|
|
|
->where('id', $this->session->userdata('uid')) |
77
|
|
|
->update('user'); |
78
|
|
|
|
79
|
|
|
if($this->db->affected_rows() == 1) |
80
|
|
|
{ |
81
|
|
|
$this->output->set_output('1'); |
82
|
|
|
} |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
// -------------------------------------------------------------------------- |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* Number format update |
89
|
|
|
*/ |
90
|
|
View Code Duplication |
public function update_nf() |
91
|
|
|
{ |
92
|
|
|
$num_format = (int)$this->input->post('num_format'); |
93
|
|
|
|
94
|
|
|
$this->db->set('num_format', $num_format) |
95
|
|
|
->where('id', $this->session->userdata('uid')) |
96
|
|
|
->update('user'); |
97
|
|
|
|
98
|
|
|
if($this->db->affected_rows() == 1) |
99
|
|
|
{ |
100
|
|
|
$this->session->set_userdata('num_format', $num_format); |
101
|
|
|
$this->output->set_output('1'); |
102
|
|
|
} |
103
|
|
|
} |
104
|
|
|
} |
105
|
|
|
// End of controllers/account.php |