Code Duplication    Length = 25-29 lines in 6 locations

web_interface/astpp/application/modules/email/controllers/email.php 1 location

@@ 164-190 (lines=27) @@
161
162
		$this->load->view('view_email_add_edit', $data);
163
	}
164
	function email_save() {
165
		$add_array = $this->input->post();
166
		$data['form'] = $this->form->build_form($this->email_form->get_form_fields_email(), $add_array);
167
		if ($add_array['id'] != '') {
168
			$data['page_title'] = 'Edit email List';
169
			if ($this->form_validation->run() == FALSE) {
170
				$data['validation_errors'] = validation_errors();
171
				echo $data['validation_errors'];
172
				exit;
173
			} else {
174
				$this->email_model->edit_email($add_array, $add_array['id']);
175
				echo json_encode(array("SUCCESS"=> "Email list updated successfully!"));
176
				exit;
177
			}
178
		} else {
179
			$data['page_title'] = 'Create Email List';
180
			if ($this->form_validation->run() == FALSE) {
181
				$data['validation_errors'] = validation_errors();
182
				echo $data['validation_errors'];
183
				exit;
184
			} else {
185
				$this->email_model->add_email($add_array);
186
				echo json_encode(array("SUCCESS"=> "Email list added successfully!"));
187
				exit;
188
			}
189
		}
190
	}
191
	function email_re_send($edit_data) {
192
	$this->email_lib->send_email('',$edit_data,'',$edit_data['attachment'],1);
193
	$this->session->set_flashdata('astpp_errormsg', 'Email resend successfully!');

web_interface/astpp/application/modules/freeswitch/controllers/freeswitch.php 1 location

@@ 973-1001 (lines=29) @@
970
		$this->load->view('view_fsserver_add_edit', $data);
971
	}
972
973
	function fsserver_save() {
974
		$add_array = $this->input->post();
975
976
		$data['form'] = $this->form->build_form($this->freeswitch_form->get_form_fsserver_fields(), $add_array);
977
		if ($add_array['id'] != '') {
978
			$data['page_title'] = 'Edit Freeswitch Server';
979
			if ($this->form_validation->run() == FALSE) {
980
				$data['validation_errors'] = validation_errors();
981
				echo $data['validation_errors'];
982
				exit;
983
			} else {
984
				$this->freeswitch_model->edit_fsserver($add_array, $add_array['id']);
985
				echo json_encode(array("SUCCESS"=> " Freeswitch Server Updated Successfully!"));
986
				exit;
987
			}
988
		} else {
989
			$data['page_title'] = 'Freeswich Server';
990
			if ($this->form_validation->run() == FALSE) {
991
				$data['validation_errors'] = validation_errors();
992
				echo $data['validation_errors'];
993
				exit;
994
			} else {
995
				$this->freeswitch_model->add_fssever($add_array);
996
				echo json_encode(array("SUCCESS"=> "Freeswitch Server Added Successfully!"));
997
				exit;
998
			}
999
		}
1000
		$this->load->view('view_callshop_details', $data);
1001
	}
1002
1003
	function fsserver_delete($id) {
1004
		$this->freeswitch_model->fsserver_delete($id);

web_interface/astpp/application/modules/opensips/controllers/opensips.php 3 locations

@@ 143-170 (lines=28) @@
140
		return "0";
141
	}
142
143
function user_opensips_save($user_flg = false) {
144
		$array_add = $this->input->post();
145
//        
146
		$data['form'] = $this->form->build_form($this->opensips_form->get_opensips_form_fields_for_customer($array_add["accountcode"]), $array_add);
147
		if ($array_add['id'] != '') {
148
			$data['page_title'] = 'Edit Opensips';
149
			if ($this->form_validation->run() == FALSE) {
150
				$data['validation_errors'] = validation_errors();
151
				echo $data['validation_errors'];
152
				exit;
153
			} else {
154
				$this->opensips_model->edit_opensipsdevices($array_add, $array_add['id']);
155
				echo json_encode(array("SUCCESS"=> "Opensips Updated Successfully!"));
156
				exit;
157
			}
158
		}else{
159
		  $data['page_title'] = 'Add Opensips';
160
		  if ($this->form_validation->run() == FALSE) {
161
				$data['validation_errors'] = validation_errors();
162
				echo $data['validation_errors'];
163
				exit;
164
			}else{
165
		$this->opensips_model->add_opensipsdevices($array_add);
166
				echo json_encode(array("SUCCESS"=> "Opensips Added Successfully!"));
167
				exit;
168
		}
169
		}
170
	}
171
172
	function customer_opensips_save($user_flg = false) {
173
		$add_array = $this->input->post();
@@ 172-199 (lines=28) @@
169
		}
170
	}
171
172
	function customer_opensips_save($user_flg = false) {
173
		$add_array = $this->input->post();
174
//         print_r($array_add);exit;
175
		$data['form'] = $this->form->build_form($this->opensips_form->get_opensips_form_fields_for_customer($add_array["accountcode"]), $add_array);
176
		if ($add_array['id'] != '') {
177
			$data['page_title'] = 'Edit Opensips';
178
			if ($this->form_validation->run() == FALSE) {
179
				$data['validation_errors'] = validation_errors();
180
				echo $data['validation_errors'];
181
				exit;
182
			} else {
183
				$this->opensips_model->edit_opensipsdevices($add_array, $add_array['id']);
184
				echo json_encode(array("SUCCESS"=> "OpenSips Updated Successfully!"));
185
				exit;
186
			}
187
		}else{
188
			  $data['page_title'] = 'Add Opensips';
189
		  if ($this->form_validation->run() == FALSE) {
190
				$data['validation_errors'] = validation_errors();
191
				echo $data['validation_errors'];
192
				exit;
193
			 }else{
194
		$this->opensips_model->add_opensipsdevices($add_array);
195
				echo json_encode(array("SUCCESS"=> "OpenSips Added Successfully!"));
196
				exit;
197
		}
198
		}
199
	}
200
201
	function customer_opensips_json($accountid,$accounttype) {
202
	
@@ 299-323 (lines=25) @@
296
		$data['form'] = $this->form->build_form($this->opensips_form->get_dispatcher_form_fields(), $edit_data);
297
		$this->load->view('view_dispatcher_add_edit', $data);
298
	}
299
	function dispatcher_save() {
300
		$add_array = $this->input->post();
301
		$data['form'] = $this->form->build_form($this->opensips_form->get_dispatcher_form_fields(), $add_array);
302
		if ($add_array['id'] != '') {
303
			$data['page_title'] = 'Edit Dispatcher';
304
			if ($this->form_validation->run() == FALSE) {
305
				$data['validation_errors'] = validation_errors();
306
				echo $data['validation_errors'];exit;
307
			} else {
308
				$this->opensips_model->edit_opensipsdispatcher($add_array, $add_array['id']);
309
				echo json_encode(array("SUCCESS"=> "Dispatcher Updated Successfully!"));
310
				exit;
311
			}
312
		} else {
313
			$data['page_title'] = 'Add Dispatcher';
314
			if ($this->form_validation->run() == FALSE) {
315
				$data['validation_errors'] = validation_errors();
316
				 echo $data['validation_errors'];exit;
317
			} else {
318
				$this->opensips_model->add_opensipsdispatcher($add_array);
319
				echo json_encode(array("SUCCESS"=> "Dispatcher Added Successfully!"));
320
				exit;
321
			}
322
		} 
323
	}
324
325
	function dispatcher_remove($id) {
326
		$this->opensips_model->remove_dispatcher($id);

web_interface/astpp/application/modules/user/controllers/user.php 1 location

@@ 1317-1343 (lines=27) @@
1314
		$data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($edit_id), $sipdevice_info);
1315
		$this->load->view('view_user_sipdevices_add_edit', $data);
1316
	}
1317
	function user_sipdevices_save(){
1318
		$add_array = $this->input->post();
1319
		$data['form'] = $this->form->build_form($this->user_form->build_user_sipdevices_form($add_array['id']), $add_array);
1320
		if ($add_array['id'] != '') {
1321
			$data['page_title'] = 'Edit SIP Devices';
1322
			if ($this->form_validation->run() == FALSE) {
1323
				$data['validation_errors'] = validation_errors();
1324
				echo $data['validation_errors'];
1325
				exit;
1326
			} else {
1327
				$this->user_model->user_sipdevice_edit($add_array, $add_array['id']);
1328
				echo json_encode(array("SUCCESS"=> "SIP Device Updated Successfully!"));
1329
				exit;
1330
			}
1331
		} else {
1332
			$data['page_title'] = 'Create SIP Device';
1333
			if ($this->form_validation->run() == FALSE) {
1334
				$data['validation_errors'] = validation_errors();
1335
				echo $data['validation_errors'];
1336
				exit;
1337
			} else {
1338
				$this->user_model->user_sipdevice_add($add_array);
1339
				echo json_encode(array("SUCCESS"=> "SIP Device Added Successfully!"));
1340
				exit;
1341
			}
1342
		}
1343
	}
1344
	function user_sipdevices_delete($id) {
1345
		$this->db->delete('sip_devices',array('id'=>$id));
1346
		$this->session->set_flashdata('astpp_notification', 'SIP Device Removed Sucessfully!');