No autoload and refactoring of SMS lib and Message Controller to be consistent with the rest of libraries (#693)

This commit is contained in:
FrancescoUK
2016-06-23 09:05:30 +01:00
parent 67a2912537
commit 2ca3911d56
7 changed files with 35 additions and 28 deletions

View File

@@ -58,7 +58,7 @@ $autoload['packages'] = array();
|
| $autoload['libraries'] = array('user_agent' => 'ua');
*/
$autoload['libraries'] = array('database', 'form_validation', 'session', 'user_agent', 'pagination', 'sms');
$autoload['libraries'] = array('database', 'form_validation', 'session', 'user_agent', 'pagination');
/*
| -------------------------------------------------------------------

View File

@@ -7,6 +7,8 @@ class Messages extends Secure_Controller
public function __construct()
{
parent::__construct('messages');
$this->load->library('sms_lib');
}
public function index()
@@ -28,15 +30,10 @@ class Messages extends Secure_Controller
public function send()
{
$username = $this->config->item('msg_uid');
$password = $this->config->item('msg_pwd');
$phone = $this->input->post('phone');
$message = $this->input->post('message');
$originator = $this->config->item('msg_src');
$phone = $this->input->post('phone');
$message = $this->input->post('message');
$response = $this->sms->sendSMS($username, $password, $phone, $message, $originator);
$phone = $this->xss_clean($phone);
$response = $this->sms_lib->sendSMS($phone, $message);
if($response)
{
@@ -50,20 +47,14 @@ class Messages extends Secure_Controller
public function send_form($person_id = -1)
{
$username = $this->config->item('msg_uid');
$password = $this->config->item('msg_pwd');
$phone = $this->input->post('phone');
$message = $this->input->post('message');
$originator = $this->config->item('msg_src');
$phone = $this->input->post('phone');
$message = $this->input->post('message');
$response = $this->sms->sendSMS($username, $password, $phone, $message, $originator);
$phone = $this->xss_clean($phone);
$person_id = $this->xss_clean($person_id);
$response = $this->sms_lib->sendSMS($phone, $message);
if($response)
{
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('messages_successfully_sent') . ' ' . $phone, 'person_id' => $person_id));
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('messages_successfully_sent') . ' ' . $phone, 'person_id' => $this->xss_clean($person_id)));
}
else
{

View File

@@ -1,4 +1,4 @@
<?php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
use emberlabs\Barcode\BarcodeBase;
require APPPATH.'/views/barcodes/BarcodeBase.php';
@@ -229,4 +229,5 @@ class Barcode_lib
return substr($font_file_name, 0, -4);
}
}
?>

View File

@@ -1,4 +1,4 @@
<?php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Item_lib
{

View File

@@ -1,4 +1,5 @@
<?php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Receiving_lib
{
var $CI;
@@ -370,4 +371,5 @@ class Receiving_lib
return $total;
}
}
?>

View File

@@ -1,4 +1,5 @@
<?php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Sale_lib
{
var $CI;
@@ -706,4 +707,5 @@ class Sale_lib
return TRUE;
}
}
?>

View File

@@ -1,17 +1,28 @@
<?php
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Sms
class Sms_lib
{
var $CI;
public function __construct()
{
$this->CI =& get_instance();
}
/*
* SMS send function
* Example of use: $response = sendSMS('myUsername', 'myPassword', '4477777777', 'My test message', 'My company');
* Example of use: $response = sendSMS('4477777777', 'My test message');
*/
function sendSMS($username, $password, $phone, $message, $originator)
public function sendSMS($phone, $message)
{
$username = $this->CI->config->item('msg_uid');
$password = $this->CI->config->item('msg_pwd');
$originator = $this->CI->config->item('msg_src');
$response = FALSE;
// if any of the parameters is empty return with a FALSE
if( empty($username) || empty($password) || empty($phone) || empty($message) || empty($originator) )
if(empty($username) || empty($password) || empty($phone) || empty($message) || empty($originator))
{
//echo $username . ' ' . $password . ' ' . $phone . ' ' . $message . ' ' . $originator;
}