1
|
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); |
2
|
|
|
|
3
|
|
|
class Status extends My_Public { |
4
|
|
|
|
5
|
|
|
public function __construct() { |
6
|
|
|
parent::__construct(); |
7
|
|
|
$this->load->model('computing-support/status_model', 'status_model'); |
8
|
|
|
} |
9
|
|
|
|
10
|
|
View Code Duplication |
public function index() { |
|
|
|
|
11
|
|
|
|
12
|
|
|
$data = array(); |
13
|
|
|
$data['status'] = $this->status_model->view(); |
14
|
|
|
|
15
|
|
|
$this->load->view('templates/header', $data); |
16
|
|
|
$this->load->view('computing-support/status/view'); |
17
|
|
|
$this->load->view('templates/footer'); |
18
|
|
|
} |
19
|
|
|
|
20
|
|
View Code Duplication |
public function display() { |
|
|
|
|
21
|
|
|
|
22
|
|
|
$data = array(); |
23
|
|
|
$data['status'] = $this->status_model->view(); |
24
|
|
|
|
25
|
|
|
$this->load->view('templates/header', $data); |
26
|
|
|
$this->load->view('computing-support/status/display'); |
27
|
|
|
$this->load->view('templates/footer'); |
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
public function auto() { |
31
|
|
|
|
32
|
|
|
$data = array(); |
33
|
|
|
$data['status'] = $this->status_model->auto(); |
34
|
|
|
$this->load->view('computing-support/status/auto', $data); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
View Code Duplication |
public function reset() { |
|
|
|
|
38
|
|
|
|
39
|
|
|
if (in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
40
|
|
|
|
41
|
|
|
if (isset($_GET['sid'])) { |
42
|
|
|
|
43
|
|
|
$sid = $_GET['sid']; |
44
|
|
|
$this->status_model->reset($sid); |
45
|
|
|
|
46
|
|
|
$function = 'reset_status_monitor_'.$sid; |
47
|
|
|
$this->user_model->function_log($function); |
48
|
|
|
|
49
|
|
|
redirect($_SERVER['HTTP_REFERER']); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
redirect($_SERVER['HTTP_REFERER']); |
53
|
|
|
} else { |
54
|
|
|
redirect($_SERVER['HTTP_REFERER']); |
55
|
|
|
} |
56
|
|
|
} |
57
|
|
|
|
58
|
|
View Code Duplication |
public function delete() { |
|
|
|
|
59
|
|
|
|
60
|
|
|
if (in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
61
|
|
|
|
62
|
|
|
if (isset($_GET['sid'])) { |
63
|
|
|
|
64
|
|
|
$sid = $_GET['sid']; |
65
|
|
|
$this->status_model->delete($sid); |
66
|
|
|
|
67
|
|
|
$function = 'delete_status_monitor_'.$sid; |
68
|
|
|
$this->user_model->function_log($function); |
69
|
|
|
|
70
|
|
|
redirect('computing-support/status'); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
redirect($_SERVER['HTTP_REFERER']); |
74
|
|
|
} else { |
75
|
|
|
redirect($_SERVER['HTTP_REFERER']); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
public function edit() { |
80
|
|
|
|
81
|
|
|
if (in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups']) || |
82
|
|
|
in_array('CN=DG06,OU=Distribution Groups,OU=Email Groups,OU=Accounts,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
83
|
|
|
|
84
|
|
|
if (isset($_GET['sid'])) { |
85
|
|
|
$sid = $_GET['sid']; |
86
|
|
|
|
87
|
|
|
$data = array(); |
88
|
|
|
$data['get_current'] = $this->status_model->edit_get($sid); |
89
|
|
|
} |
90
|
|
|
$this->load->helper('form'); |
91
|
|
|
$this->load->library('form_validation'); |
92
|
|
|
|
93
|
|
|
// validation rules |
94
|
|
|
$this->form_validation->set_rules('name', 'Service name', 'trim|required|min_length[3]'); |
95
|
|
|
$this->form_validation->set_rules('icon', 'Icon', 'trim|required|min_length[4]'); |
96
|
|
|
|
97
|
|
|
if ($this->form_validation->run() === false) { |
98
|
|
|
|
99
|
|
|
$this->load->view('templates/header'); |
100
|
|
|
$this->load->view('computing-support/status/edit', $data); |
|
|
|
|
101
|
|
|
$this->load->view('templates/footer'); |
102
|
|
|
} else { |
103
|
|
|
|
104
|
|
|
$id = $this->input->post('id'); |
105
|
|
|
$name = $this->input->post('name'); |
106
|
|
|
$icon = $this->input->post('icon'); |
107
|
|
|
$url = $this->input->post('url'); |
108
|
|
|
$comment = $this->input->post('comment'); |
109
|
|
|
$category = $this->input->post('category'); |
110
|
|
|
$status = $this->input->post('status'); |
111
|
|
|
$username = $_SESSION['username']; |
112
|
|
|
|
113
|
|
|
if ($this->status_model->edit_update($id, $name, $icon, $url, $comment, $category, $status, $username)) { |
114
|
|
|
|
115
|
|
|
$function = 'edit_status_monitor_'.$sid; |
|
|
|
|
116
|
|
|
$this->user_model->function_log($function); |
117
|
|
|
|
118
|
|
|
$this->load->view('templates/header'); |
119
|
|
|
$this->load->view('computing-support/status/updated'); |
120
|
|
|
$this->load->view('templates/footer'); |
121
|
|
|
} else { |
122
|
|
|
|
123
|
|
|
$function = 'edit_status_monitor_error_'.$sid; |
124
|
|
|
$this->user_model->function_log($function); |
125
|
|
|
|
126
|
|
|
$data = new stdClass(); |
127
|
|
|
$data->error = 'There was a problem editing this service. Please try again.'; |
128
|
|
|
|
129
|
|
|
// failed to create user |
130
|
|
|
$this->load->view('templates/header'); |
131
|
|
|
$this->load->view('computing-support/status/edit', $data); |
132
|
|
|
$this->load->view('templates/footer'); |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
} |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
public function create() { |
139
|
|
|
|
140
|
|
|
if (in_array('CN=Dashboard_Admin,OU=Dashboard_Group,OU=Intranet_Group,OU=Groups,DC=cant-col,DC=ac,DC=uk', $_SESSION['ldap']['groups'])) { |
141
|
|
|
|
142
|
|
|
$this->load->helper('form'); |
143
|
|
|
$this->load->library('form_validation'); |
144
|
|
|
|
145
|
|
|
// validation rules |
146
|
|
|
$this->form_validation->set_rules('name', 'Service name', 'trim|required|min_length[3]'); |
147
|
|
|
$this->form_validation->set_rules('icon', 'Icon', 'trim|required|min_length[4]'); |
148
|
|
|
|
149
|
|
|
if ($this->form_validation->run() === false) { |
150
|
|
|
|
151
|
|
|
$this->load->view('templates/header'); |
152
|
|
|
$this->load->view('computing-support/status/edit'); |
153
|
|
|
$this->load->view('templates/footer'); |
154
|
|
|
} else { |
155
|
|
|
|
156
|
|
|
$name = $this->input->post('name'); |
157
|
|
|
$icon = $this->input->post('icon'); |
158
|
|
|
$url = $this->input->post('url'); |
159
|
|
|
$category = $this->input->post('category'); |
160
|
|
|
$status = $this->input->post('status'); |
161
|
|
|
$username = $_SESSION['username']; |
162
|
|
|
|
163
|
|
View Code Duplication |
if ($this->status_model->create($name, $icon, $url, $category, $status, $username)) { |
|
|
|
|
164
|
|
|
|
165
|
|
|
$function = 'create_status_monitor_'.$sid; |
|
|
|
|
166
|
|
|
$this->user_model->function_log($function); |
167
|
|
|
|
168
|
|
|
$this->load->view('templates/header'); |
169
|
|
|
$this->load->view('computing-support/status/created'); |
170
|
|
|
$this->load->view('templates/footer'); |
171
|
|
|
} else { |
172
|
|
|
|
173
|
|
|
$function = 'create_status_monitor_error_'.$sid; |
174
|
|
|
$this->user_model->function_log($function); |
175
|
|
|
|
176
|
|
|
$data = new stdClass(); |
177
|
|
|
$data->error = 'There was a problem editing this service. Please try again.'; |
178
|
|
|
|
179
|
|
|
// failed to create user |
180
|
|
|
$this->load->view('templates/header'); |
181
|
|
|
$this->load->view('computing-support/status/edit', $data); |
182
|
|
|
$this->load->view('templates/footer'); |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
} |
187
|
|
|
|
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
// END controller |
191
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.