@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined ( 'BASEPATH' )) { |
|
4 | - exit ( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('BASEPATH')) { |
|
4 | + exit ('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /* |
7 | 7 | * | ------------------------------------------------------------------- |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | * | conversion used by the Text helper |
12 | 12 | * | |
13 | 13 | */ |
14 | -$foreign_characters = array ( |
|
14 | +$foreign_characters = array( |
|
15 | 15 | '/ä|æ|ǽ/' => 'ae', |
16 | 16 | '/ö|œ/' => 'oe', |
17 | 17 | '/ü/' => 'ue', |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if (! defined ( 'BASEPATH' )) { |
|
4 | - exit ( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('BASEPATH')) { |
|
4 | + exit ('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /* |
7 | 7 | * | ------------------------------------------------------------------- |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * | |
42 | 42 | */ |
43 | 43 | |
44 | -$autoload ['packages'] = array (); |
|
44 | +$autoload ['packages'] = array(); |
|
45 | 45 | |
46 | 46 | /* |
47 | 47 | * | ------------------------------------------------------------------- |
@@ -56,7 +56,7 @@ discard block |
||
56 | 56 | */ |
57 | 57 | |
58 | 58 | // $autoload['libraries'] = array('database','session'); |
59 | -$autoload ['libraries'] = array ( |
|
59 | +$autoload ['libraries'] = array( |
|
60 | 60 | 'database', |
61 | 61 | 'session', |
62 | 62 | 'locale', |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * | $autoload['helper'] = array('url', 'file'); |
73 | 73 | */ |
74 | 74 | |
75 | -$autoload ['helper'] = array ( |
|
75 | +$autoload ['helper'] = array( |
|
76 | 76 | 'url', |
77 | 77 | 'template_inheritance', |
78 | 78 | 'form' |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * | |
92 | 92 | */ |
93 | 93 | |
94 | -$autoload ['config'] = array (); |
|
94 | +$autoload ['config'] = array(); |
|
95 | 95 | |
96 | 96 | /* |
97 | 97 | * | ------------------------------------------------------------------- |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * | |
107 | 107 | */ |
108 | 108 | |
109 | -$autoload ['language'] = array (); |
|
109 | +$autoload ['language'] = array(); |
|
110 | 110 | |
111 | 111 | /* |
112 | 112 | * | ------------------------------------------------------------------- |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | * | |
119 | 119 | */ |
120 | 120 | |
121 | -$autoload ['model'] = array ( |
|
121 | +$autoload ['model'] = array( |
|
122 | 122 | 'common_model', |
123 | 123 | 'db_model' |
124 | 124 | ); |
@@ -2,8 +2,8 @@ discard block |
||
2 | 2 | if(!defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' ); |
3 | 3 | |
4 | 4 | class Router { |
5 | - public static $_domain = ''; |
|
6 | - public function route() { |
|
5 | + public static $_domain = ''; |
|
6 | + public function route() { |
|
7 | 7 | if(isset($_SERVER["HTTP_HOST"]) && $_SERVER["HTTP_HOST"] != ''){ |
8 | 8 | require_once(BASEPATH.'database/DB.php'); |
9 | 9 | $db = DB(); // getting hold of a DAO instance |
@@ -12,17 +12,17 @@ discard block |
||
12 | 12 | $res = $db->get("invoice_conf"); |
13 | 13 | $domain = $res->result(); |
14 | 14 | if(!empty($domain) && $domain[0]->domain != ""){ |
15 | - self::$_domain = "http://".$domain[0]->domain."/"; |
|
15 | + self::$_domain = "http://".$domain[0]->domain."/"; |
|
16 | 16 | } |
17 | 17 | } |
18 | - } |
|
18 | + } |
|
19 | 19 | |
20 | - public function config() { |
|
20 | + public function config() { |
|
21 | 21 | if(self::$_domain != ""){ |
22 | - $RTR = load_class('Router','core'); |
|
23 | - $RTR->config->config['base_url'] = self::$_domain; |
|
24 | - return true; |
|
22 | + $RTR = load_class('Router','core'); |
|
23 | + $RTR->config->config['base_url'] = self::$_domain; |
|
24 | + return true; |
|
25 | + } |
|
25 | 26 | } |
26 | - } |
|
27 | 27 | } |
28 | 28 | ?> |
@@ -1,25 +1,25 @@ |
||
1 | 1 | <?php |
2 | -if(!defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' ); |
|
2 | +if ( ! defined('BASEPATH')) exit('No direct script access allowed'); |
|
3 | 3 | |
4 | 4 | class Router { |
5 | - public static $_domain = ''; |
|
5 | + public static $_domain = ''; |
|
6 | 6 | public function route() { |
7 | - if(isset($_SERVER["HTTP_HOST"]) && $_SERVER["HTTP_HOST"] != ''){ |
|
7 | + if (isset($_SERVER["HTTP_HOST"]) && $_SERVER["HTTP_HOST"] != '') { |
|
8 | 8 | require_once(BASEPATH.'database/DB.php'); |
9 | 9 | $db = DB(); // getting hold of a DAO instance |
10 | 10 | $db->select("domain"); |
11 | 11 | $db->where(array("domain"=>$_SERVER["HTTP_HOST"])); |
12 | 12 | $res = $db->get("invoice_conf"); |
13 | 13 | $domain = $res->result(); |
14 | - if(!empty($domain) && $domain[0]->domain != ""){ |
|
14 | + if ( ! empty($domain) && $domain[0]->domain != "") { |
|
15 | 15 | self::$_domain = "http://".$domain[0]->domain."/"; |
16 | 16 | } |
17 | 17 | } |
18 | 18 | } |
19 | 19 | |
20 | 20 | public function config() { |
21 | - if(self::$_domain != ""){ |
|
22 | - $RTR = load_class('Router','core'); |
|
21 | + if (self::$_domain != "") { |
|
22 | + $RTR = load_class('Router', 'core'); |
|
23 | 23 | $RTR->config->config['base_url'] = self::$_domain; |
24 | 24 | return true; |
25 | 25 | } |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if(!defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' ); |
|
2 | +if(!defined( 'BASEPATH' ) ) { |
|
3 | + exit( 'No direct script access allowed' ); |
|
4 | +} |
|
3 | 5 | |
4 | 6 | class Router { |
5 | 7 | public static $_domain = ''; |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) { |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) { |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | } |
26 | 26 | class Timezone { |
27 | 27 | function __construct() { |
28 | - $this->CI = & get_instance (); |
|
29 | - $this->CI->load->library ( 'session' ); |
|
30 | - $this->CI->load->database (); |
|
28 | + $this->CI = & get_instance(); |
|
29 | + $this->CI->load->library('session'); |
|
30 | + $this->CI->load->database(); |
|
31 | 31 | } |
32 | 32 | function uset_timezone() { |
33 | - $account_data = $this->CI->session->userdata ( 'accountinfo' ); |
|
33 | + $account_data = $this->CI->session->userdata('accountinfo'); |
|
34 | 34 | return $account_data ['timezone_id']; |
35 | 35 | } |
36 | 36 | function display_GMT($currDate, $fulldate = 1, $timezone_id = "") { |
37 | 37 | // Added condition |
38 | - $number = ($timezone_id == "") ? $this->uset_timezone () : $timezone_id; |
|
38 | + $number = ($timezone_id == "") ? $this->uset_timezone() : $timezone_id; |
|
39 | 39 | $SERVER_GMT = '0'; |
40 | 40 | |
41 | - $result = $this->CI->db->query ( "select gmtoffset from timezone where id =" . $number ); |
|
42 | - $timezone_offset = $result->result (); |
|
41 | + $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number); |
|
42 | + $timezone_offset = $result->result(); |
|
43 | 43 | |
44 | 44 | $USER_GMT = $timezone_offset ['0']->gmtoffset; |
45 | 45 | |
46 | - $date_time_array = getdate ( strtotime ( $currDate ) ); |
|
46 | + $date_time_array = getdate(strtotime($currDate)); |
|
47 | 47 | |
48 | 48 | $hours = $date_time_array ['hours']; |
49 | 49 | $minutes = $date_time_array ['minutes']; |
@@ -51,13 +51,13 @@ discard block |
||
51 | 51 | $month = $date_time_array ['mon']; |
52 | 52 | $day = $date_time_array ['mday']; |
53 | 53 | $year = $date_time_array ['year']; |
54 | - $timestamp = mktime ( $hours, $minutes, $seconds, $month, $day, $year ); |
|
54 | + $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year); |
|
55 | 55 | |
56 | 56 | $timestamp = $timestamp + ($USER_GMT - $SERVER_GMT); |
57 | 57 | if ($fulldate == 1) { |
58 | - $date = date ( "Y-m-d H:i:s", $timestamp ); |
|
58 | + $date = date("Y-m-d H:i:s", $timestamp); |
|
59 | 59 | } else { |
60 | - $date = date ( "Y-m-d", $timestamp ); |
|
60 | + $date = date("Y-m-d", $timestamp); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | return $date; |
@@ -65,28 +65,28 @@ discard block |
||
65 | 65 | function convert_to_GMT($currDate, $fulldate = 1, $timezone_id = '') { |
66 | 66 | |
67 | 67 | // Added condition |
68 | - $number = ($timezone_id == "") ? $this->uset_timezone () : $timezone_id; |
|
68 | + $number = ($timezone_id == "") ? $this->uset_timezone() : $timezone_id; |
|
69 | 69 | $SERVER_GMT = '0'; |
70 | 70 | |
71 | - $result = $this->CI->db->query ( "select gmtoffset from timezone where id =" . $number ); |
|
72 | - $timezone_offset = $result->result (); |
|
71 | + $result = $this->CI->db->query("select gmtoffset from timezone where id =".$number); |
|
72 | + $timezone_offset = $result->result(); |
|
73 | 73 | |
74 | 74 | $USER_GMT = $timezone_offset ['0']->gmtoffset; |
75 | 75 | |
76 | - $date_time_array = getdate ( strtotime ( $currDate ) ); |
|
76 | + $date_time_array = getdate(strtotime($currDate)); |
|
77 | 77 | $hours = $date_time_array ['hours']; |
78 | 78 | $minutes = $date_time_array ['minutes']; |
79 | 79 | $seconds = $date_time_array ['seconds']; |
80 | 80 | $month = $date_time_array ['mon']; |
81 | 81 | $day = $date_time_array ['mday']; |
82 | 82 | $year = $date_time_array ['year']; |
83 | - $timestamp = mktime ( $hours, $minutes, $seconds, $month, $day, $year ); |
|
83 | + $timestamp = mktime($hours, $minutes, $seconds, $month, $day, $year); |
|
84 | 84 | |
85 | 85 | $timestamp = $timestamp - ($SERVER_GMT - $USER_GMT); |
86 | 86 | if ($fulldate == 1) { |
87 | - $date = date ( "Y-m-d H:i:s", $timestamp ); |
|
87 | + $date = date("Y-m-d H:i:s", $timestamp); |
|
88 | 88 | } else { |
89 | - $date = date ( "Y-m-d", $timestamp ); |
|
89 | + $date = date("Y-m-d", $timestamp); |
|
90 | 90 | } |
91 | 91 | return $date; |
92 | 92 | } |
@@ -20,8 +20,8 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Dynamically build forms for display |
@@ -42,46 +42,46 @@ discard block |
||
42 | 42 | public $company_website = ''; |
43 | 43 | public $account_id = ''; |
44 | 44 | function __construct($library_name = '') { |
45 | - $this->CI = & get_instance (); |
|
46 | - $this->CI->load->model ( 'db_model' ); |
|
47 | - $this->CI->load->library ( 'email' ); |
|
48 | - $this->CI->load->library ( 'session' ); |
|
45 | + $this->CI = & get_instance(); |
|
46 | + $this->CI->load->model('db_model'); |
|
47 | + $this->CI->load->library('email'); |
|
48 | + $this->CI->load->library('session'); |
|
49 | 49 | } |
50 | 50 | function get_email_settings() { |
51 | - $where = array ( |
|
51 | + $where = array( |
|
52 | 52 | 'group_title' => 'email' |
53 | 53 | ); |
54 | - $query = $this->CI->db_model->getSelect ( "*", "system", $where ); |
|
55 | - $query = $query->result_array (); |
|
56 | - foreach ( $query as $key => $val ) { |
|
57 | - $tempvar = strtolower ( $val ['name'] ); |
|
54 | + $query = $this->CI->db_model->getSelect("*", "system", $where); |
|
55 | + $query = $query->result_array(); |
|
56 | + foreach ($query as $key => $val) { |
|
57 | + $tempvar = strtolower($val ['name']); |
|
58 | 58 | $this->$tempvar = $val ['value']; |
59 | 59 | } |
60 | 60 | } |
61 | 61 | function get_template($type) { |
62 | - $where = array ( |
|
62 | + $where = array( |
|
63 | 63 | 'name' => $type |
64 | 64 | ); |
65 | - $query = $this->CI->db_model->getSelect ( "*", "default_templates", $where ); |
|
66 | - $query = $query->result (); |
|
65 | + $query = $this->CI->db_model->getSelect("*", "default_templates", $where); |
|
66 | + $query = $query->result(); |
|
67 | 67 | $this->message = $query [0]->template; |
68 | 68 | $this->subject = $query [0]->subject; |
69 | 69 | } |
70 | 70 | function get_account_info($accountid) { |
71 | - $where = array ( |
|
71 | + $where = array( |
|
72 | 72 | 'id' => $accountid |
73 | 73 | ); |
74 | - $query = $this->CI->db_model->getSelect ( "*", "accounts", $where ); |
|
75 | - $query = $query->result_array (); |
|
76 | - if (isset ( $query [0] ['email'] ) && $query [0] ['email'] != '') { |
|
77 | - $query [0] ['currency_name'] = $this->CI->common->get_field_name ( 'currency', 'currency', $query [0] ['currency_id'] ); |
|
78 | - $query [0] ['timezone_name'] = $this->CI->common->get_field_name ( 'gmtzone', 'timezone', $query [0] ['timezone_id'] ); |
|
79 | - $query [0] ['country_name'] = $this->CI->common->get_field_name ( 'country', 'countrycode', $query [0] ['country_id'] ); |
|
74 | + $query = $this->CI->db_model->getSelect("*", "accounts", $where); |
|
75 | + $query = $query->result_array(); |
|
76 | + if (isset ($query [0] ['email']) && $query [0] ['email'] != '') { |
|
77 | + $query [0] ['currency_name'] = $this->CI->common->get_field_name('currency', 'currency', $query [0] ['currency_id']); |
|
78 | + $query [0] ['timezone_name'] = $this->CI->common->get_field_name('gmtzone', 'timezone', $query [0] ['timezone_id']); |
|
79 | + $query [0] ['country_name'] = $this->CI->common->get_field_name('country', 'countrycode', $query [0] ['country_id']); |
|
80 | 80 | $this->to = $query [0] ['email']; |
81 | 81 | $this->account_id = $query [0] ['id']; |
82 | - unset ( $query [0] ['id'] ); |
|
82 | + unset ($query [0] ['id']); |
|
83 | 83 | $query [0] ['username'] = $query [0] ['number']; |
84 | - unset ( $query [0] ['number'] ); |
|
84 | + unset ($query [0] ['number']); |
|
85 | 85 | return $query [0]; |
86 | 86 | } |
87 | 87 | return false; |
@@ -92,22 +92,22 @@ discard block |
||
92 | 92 | * @param string $detail_type |
93 | 93 | */ |
94 | 94 | function get_info($id, $detail_type) { |
95 | - $where = array ( |
|
95 | + $where = array( |
|
96 | 96 | 'id' => $id |
97 | 97 | ); |
98 | - $query = $this->CI->db_model->getSelect ( "*", $detail_type, $where ); |
|
99 | - $query = $query->result_array (); |
|
100 | - if (isset ( $query [0] ['accountid'] )) { |
|
101 | - $query = $this->get_account_info ( $query [0] ['accountid'] ); |
|
98 | + $query = $this->CI->db_model->getSelect("*", $detail_type, $where); |
|
99 | + $query = $query->result_array(); |
|
100 | + if (isset ($query [0] ['accountid'])) { |
|
101 | + $query = $this->get_account_info($query [0] ['accountid']); |
|
102 | 102 | return $query [0]; |
103 | 103 | } |
104 | 104 | return false; |
105 | 105 | } |
106 | 106 | function get_admin_details() { |
107 | - $where = array (); |
|
108 | - $query = $this->CI->db_model->getSelect ( "*", "invoice_conf", $where ); |
|
109 | - $query = $query->result (); |
|
110 | - if (isset ( $query [0]->emailaddress ) && $query [0]->emailaddress != '') { |
|
107 | + $where = array(); |
|
108 | + $query = $this->CI->db_model->getSelect("*", "invoice_conf", $where); |
|
109 | + $query = $query->result(); |
|
110 | + if (isset ($query [0]->emailaddress) && $query [0]->emailaddress != '') { |
|
111 | 111 | $this->company_website = $query [0]->website; |
112 | 112 | $this->from = $query [0]->emailaddress; |
113 | 113 | $this->company_name = $query [0]->company_name; |
@@ -116,16 +116,16 @@ discard block |
||
116 | 116 | return false; |
117 | 117 | } |
118 | 118 | function build_template($template_type, $detail, $detail_type = '') { |
119 | - if (! is_array ( $template_type )) |
|
120 | - $this->get_template ( $template_type ); |
|
119 | + if ( ! is_array($template_type)) |
|
120 | + $this->get_template($template_type); |
|
121 | 121 | else { |
122 | 122 | $this->message = $template_type ['message']; |
123 | 123 | $this->subject = $template_type ['subject']; |
124 | 124 | $template_type = ''; |
125 | 125 | } |
126 | - if (is_array ( $detail )) { |
|
126 | + if (is_array($detail)) { |
|
127 | 127 | $templateinfo = $detail; |
128 | - if (isset ( $detail ['email'] )) { |
|
128 | + if (isset ($detail ['email'])) { |
|
129 | 129 | $this->to = $detail ['email']; |
130 | 130 | } |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | * Email test |
135 | 135 | * *** |
136 | 136 | */ |
137 | - if (isset ( $templateinfo ['number'] )) { |
|
137 | + if (isset ($templateinfo ['number'])) { |
|
138 | 138 | $templateinfo ['username'] = $templateinfo ['number']; |
139 | 139 | } |
140 | 140 | |
@@ -142,44 +142,44 @@ discard block |
||
142 | 142 | * ********** |
143 | 143 | */ |
144 | 144 | $this->account_id = $templateinfo ['accountid']; |
145 | - unset ( $templateinfo ['number'] ); |
|
146 | - } else if (! is_array ( $detail ) && $detail_type == '') { |
|
147 | - $templateinfo = $this->get_account_info ( $detail ); |
|
145 | + unset ($templateinfo ['number']); |
|
146 | + } else if ( ! is_array($detail) && $detail_type == '') { |
|
147 | + $templateinfo = $this->get_account_info($detail); |
|
148 | 148 | } else { |
149 | - $templateinfo = $this->get_info ( $detail, $detail_type ); |
|
149 | + $templateinfo = $this->get_info($detail, $detail_type); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ($this->get_admin_details () && is_array ( $templateinfo ) && isset ( $templateinfo ['first_name'] ) && $templateinfo ['first_name'] != '') { |
|
153 | - $this->message = html_entity_decode ( $this->message ); |
|
154 | - $this->message = str_replace ( "#COMPANY_EMAIL#", $this->from, $this->message ); |
|
155 | - $this->message = str_replace ( "#COMPANY_NAME#", $this->company_name, $this->message ); |
|
156 | - $this->message = str_replace ( "#COMPANY_WEBSITE#", $this->company_website, $this->message ); |
|
157 | - $this->message = str_replace ( '#NAME#', $templateinfo ['first_name'] . " " . $templateinfo ['last_name'], $this->message ); |
|
158 | - $this->message = str_replace ( '#USERNAME#', $templateinfo ['username'], $this->message ); |
|
159 | - $this->message = str_replace ( '#PIN#', $templateinfo ['pin'], $this->message ); |
|
160 | - $this->message = str_replace ( '#BALANCE#', $templateinfo ['balance'], $this->message ); |
|
161 | - $this->message = str_replace ( '#PASSWORD#', $templateinfo ['password'], $this->message ); |
|
162 | - $this->subject = str_replace ( "#NAME#", $templateinfo ['first_name'] . " " . $templateinfo ['last_name'], $this->subject ); |
|
163 | - $this->subject = str_replace ( "#COMPANY_NAME#", $this->company_name, $this->subject ); |
|
152 | + if ($this->get_admin_details() && is_array($templateinfo) && isset ($templateinfo ['first_name']) && $templateinfo ['first_name'] != '') { |
|
153 | + $this->message = html_entity_decode($this->message); |
|
154 | + $this->message = str_replace("#COMPANY_EMAIL#", $this->from, $this->message); |
|
155 | + $this->message = str_replace("#COMPANY_NAME#", $this->company_name, $this->message); |
|
156 | + $this->message = str_replace("#COMPANY_WEBSITE#", $this->company_website, $this->message); |
|
157 | + $this->message = str_replace('#NAME#', $templateinfo ['first_name']." ".$templateinfo ['last_name'], $this->message); |
|
158 | + $this->message = str_replace('#USERNAME#', $templateinfo ['username'], $this->message); |
|
159 | + $this->message = str_replace('#PIN#', $templateinfo ['pin'], $this->message); |
|
160 | + $this->message = str_replace('#BALANCE#', $templateinfo ['balance'], $this->message); |
|
161 | + $this->message = str_replace('#PASSWORD#', $templateinfo ['password'], $this->message); |
|
162 | + $this->subject = str_replace("#NAME#", $templateinfo ['first_name']." ".$templateinfo ['last_name'], $this->subject); |
|
163 | + $this->subject = str_replace("#COMPANY_NAME#", $this->company_name, $this->subject); |
|
164 | 164 | switch ($template_type) { |
165 | 165 | case 'email_add_user' : |
166 | - $this->message = str_replace ( '#NUMBER#', $templateinfo ['username'], $this->message ); |
|
166 | + $this->message = str_replace('#NUMBER#', $templateinfo ['username'], $this->message); |
|
167 | 167 | break; |
168 | 168 | case 'email_calling_card' : |
169 | - $this->message = str_replace ( '#CARDNUMBER#', $templateinfo ['cardnumber'], $this->message ); |
|
169 | + $this->message = str_replace('#CARDNUMBER#', $templateinfo ['cardnumber'], $this->message); |
|
170 | 170 | break; |
171 | 171 | case 'email_new_invoice' : |
172 | - $this->message = str_replace ( '#AMOUNT#', $templateinfo ['amount'], $this->message ); |
|
173 | - $this->message = str_replace ( '#INVOICE_NUMBER#', $templateinfo ['id'], $this->message ); |
|
174 | - $this->subject = str_replace ( "#INVOICE_NUMBER#", $templateinfo ['id'], $this->subject ); |
|
172 | + $this->message = str_replace('#AMOUNT#', $templateinfo ['amount'], $this->message); |
|
173 | + $this->message = str_replace('#INVOICE_NUMBER#', $templateinfo ['id'], $this->message); |
|
174 | + $this->subject = str_replace("#INVOICE_NUMBER#", $templateinfo ['id'], $this->subject); |
|
175 | 175 | break; |
176 | 176 | case 'email_add_did' : |
177 | - $this->message = str_replace ( '#NUNBER#', $templateinfo ['number'], $this->message ); |
|
178 | - $this->subject = str_replace ( "#NUNBER#", $templateinfo ['number'], $this->subject ); |
|
177 | + $this->message = str_replace('#NUNBER#', $templateinfo ['number'], $this->message); |
|
178 | + $this->subject = str_replace("#NUNBER#", $templateinfo ['number'], $this->subject); |
|
179 | 179 | break; |
180 | 180 | case 'email_remove_did' : |
181 | - $this->message = str_replace ( '#NUNBER#', $templateinfo ['number'], $this->message ); |
|
182 | - $this->subject = str_replace ( "#NUNBER#", $templateinfo ['number'], $this->subject ); |
|
181 | + $this->message = str_replace('#NUNBER#', $templateinfo ['number'], $this->message); |
|
182 | + $this->subject = str_replace("#NUNBER#", $templateinfo ['number'], $this->subject); |
|
183 | 183 | break; |
184 | 184 | } |
185 | 185 | } |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | * @param string $attachment |
191 | 191 | */ |
192 | 192 | function mail_history($attachment) { |
193 | - $send_mail_details = array ( |
|
193 | + $send_mail_details = array( |
|
194 | 194 | 'from' => $this->from, |
195 | 195 | 'to' => $this->to, |
196 | 196 | 'subject' => $this->subject, |
@@ -199,26 +199,26 @@ discard block |
||
199 | 199 | 'status' => '1', |
200 | 200 | 'attachment' => $attachment |
201 | 201 | ); |
202 | - $this->CI->db->insert ( 'mail_details', $send_mail_details ); |
|
203 | - return $this->CI->db->insert_id (); |
|
202 | + $this->CI->db->insert('mail_details', $send_mail_details); |
|
203 | + return $this->CI->db->insert_id(); |
|
204 | 204 | } |
205 | 205 | function update_mail_history($id) { |
206 | - $this->CI->db->where ( array ( |
|
206 | + $this->CI->db->where(array( |
|
207 | 207 | 'id' => $id |
208 | - ) ); |
|
209 | - $send_mail_details = array ( |
|
208 | + )); |
|
209 | + $send_mail_details = array( |
|
210 | 210 | 'status' => '0' |
211 | 211 | ); |
212 | - $this->CI->db->update ( 'mail_details', $send_mail_details ); |
|
212 | + $this->CI->db->update('mail_details', $send_mail_details); |
|
213 | 213 | } |
214 | 214 | function set_email_paramenters($details) { |
215 | - if (! is_array ( $details )) { |
|
216 | - $this->get_admin_details (); |
|
217 | - $where = array ( |
|
215 | + if ( ! is_array($details)) { |
|
216 | + $this->get_admin_details(); |
|
217 | + $where = array( |
|
218 | 218 | 'id' => $details |
219 | 219 | ); |
220 | - $query = $this->CI->db_model->getSelect ( "*", "mail_details", $where ); |
|
221 | - $query = $query->result_array (); |
|
220 | + $query = $this->CI->db_model->getSelect("*", "mail_details", $where); |
|
221 | + $query = $query->result_array(); |
|
222 | 222 | $details = $query [0]; |
223 | 223 | } |
224 | 224 | $this->message = $details ['body']; |
@@ -238,50 +238,50 @@ discard block |
||
238 | 238 | $config ['charset'] = "utf-8"; |
239 | 239 | $config ['mailtype'] = "html"; |
240 | 240 | $config ['newline'] = "\r\n"; |
241 | - $this->CI->email->initialize ( $config ); |
|
241 | + $this->CI->email->initialize($config); |
|
242 | 242 | } |
243 | 243 | function send_email($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) { |
244 | - $this->get_email_settings (); |
|
245 | - if (! $this->email) { |
|
246 | - if (! $resend) { |
|
247 | - $this->build_template ( $template_type, $details, $detail_type ); |
|
244 | + $this->get_email_settings(); |
|
245 | + if ( ! $this->email) { |
|
246 | + if ( ! $resend) { |
|
247 | + $this->build_template($template_type, $details, $detail_type); |
|
248 | 248 | } else { |
249 | - $this->set_email_paramenters ( $details ); |
|
249 | + $this->set_email_paramenters($details); |
|
250 | 250 | } |
251 | 251 | |
252 | - if (! $brodcast) |
|
253 | - $history_id = $this->mail_history ( $attachment ); |
|
252 | + if ( ! $brodcast) |
|
253 | + $history_id = $this->mail_history($attachment); |
|
254 | 254 | else |
255 | 255 | $history_id = $details ['history_id']; |
256 | - if (isset ( $this->from ) && $this->from != '' && isset ( $this->to ) && $this->to != '' && ! $mass_mail) { |
|
257 | - if (! $this->smtp) { |
|
258 | - $this->get_smtp_details (); |
|
256 | + if (isset ($this->from) && $this->from != '' && isset ($this->to) && $this->to != '' && ! $mass_mail) { |
|
257 | + if ( ! $this->smtp) { |
|
258 | + $this->get_smtp_details(); |
|
259 | 259 | } |
260 | - $this->CI->email->from ( $this->from, $this->company_name ); |
|
261 | - $this->CI->email->to ( $this->to ); |
|
262 | - $this->CI->email->subject ( $this->subject ); |
|
263 | - $this->CI->email->set_mailtype ( "html" ); |
|
264 | - eval ( "\$message = \"" . $this->message . "\";" ); |
|
265 | - $this->CI->email->message ( $this->message ); |
|
260 | + $this->CI->email->from($this->from, $this->company_name); |
|
261 | + $this->CI->email->to($this->to); |
|
262 | + $this->CI->email->subject($this->subject); |
|
263 | + $this->CI->email->set_mailtype("html"); |
|
264 | + eval ("\$message = \"".$this->message."\";"); |
|
265 | + $this->CI->email->message($this->message); |
|
266 | 266 | |
267 | 267 | if ($attachment != "") { |
268 | - $attac_exp = explode ( ",", $attachment ); |
|
269 | - foreach ( $attac_exp as $key => $value ) { |
|
268 | + $attac_exp = explode(",", $attachment); |
|
269 | + foreach ($attac_exp as $key => $value) { |
|
270 | 270 | if ($value != '') { |
271 | - $this->CI->email->attach ( getcwd () . "/attachments/" . $value ); |
|
271 | + $this->CI->email->attach(getcwd()."/attachments/".$value); |
|
272 | 272 | } |
273 | 273 | $mail_data ['attachment'] [$key] = $value; |
274 | 274 | } |
275 | 275 | } |
276 | - $this->CI->email->send (); |
|
277 | - $mail_data ['from'] = isset ( $this->from ) ? $this->from : ''; |
|
278 | - $mail_data ['to'] = isset ( $this->to ) ? $this->to : ''; |
|
279 | - $mail_data ['subject'] = isset ( $this->subject ) ? $this->subject : ''; |
|
276 | + $this->CI->email->send(); |
|
277 | + $mail_data ['from'] = isset ($this->from) ? $this->from : ''; |
|
278 | + $mail_data ['to'] = isset ($this->to) ? $this->to : ''; |
|
279 | + $mail_data ['subject'] = isset ($this->subject) ? $this->subject : ''; |
|
280 | 280 | if (common_model::$global_config ['system_config'] ['mail_debug'] == 0) { |
281 | - $this->CI->email->print_debugger_email ( $mail_data, common_model::$global_config ['system_config'] ['log_path'] ); |
|
281 | + $this->CI->email->print_debugger_email($mail_data, common_model::$global_config ['system_config'] ['log_path']); |
|
282 | 282 | } |
283 | - $this->CI->email->clear ( true ); |
|
284 | - $this->update_mail_history ( $history_id ); |
|
283 | + $this->CI->email->clear(true); |
|
284 | + $this->update_mail_history($history_id); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | } |
@@ -291,31 +291,31 @@ discard block |
||
291 | 291 | * * |
292 | 292 | */ |
293 | 293 | function send_mail($template_type, $details, $detail_type = '', $attachment = '', $resend = 0, $mass_mail = 0, $brodcast = 0) { |
294 | - $this->get_email_settings (); |
|
295 | - if (! $this->email) { |
|
294 | + $this->get_email_settings(); |
|
295 | + if ( ! $this->email) { |
|
296 | 296 | |
297 | - if (! $resend) { |
|
298 | - $this->build_template ( $template_type, $details, $detail_type ); |
|
297 | + if ( ! $resend) { |
|
298 | + $this->build_template($template_type, $details, $detail_type); |
|
299 | 299 | } else { |
300 | - $this->set_email_paramenters ( $details ); |
|
300 | + $this->set_email_paramenters($details); |
|
301 | 301 | } |
302 | 302 | |
303 | - if (! $brodcast) |
|
304 | - $history_id = $this->mail_history ( $attachment ); |
|
303 | + if ( ! $brodcast) |
|
304 | + $history_id = $this->mail_history($attachment); |
|
305 | 305 | else |
306 | 306 | $history_id = $details ['history_id']; |
307 | - if (isset ( $this->from ) && $this->from != '' && isset ( $this->to ) && $this->to != '' && ! $mass_mail) { |
|
308 | - if (! $this->smtp) { |
|
309 | - $this->get_smtp_details (); |
|
307 | + if (isset ($this->from) && $this->from != '' && isset ($this->to) && $this->to != '' && ! $mass_mail) { |
|
308 | + if ( ! $this->smtp) { |
|
309 | + $this->get_smtp_details(); |
|
310 | 310 | } |
311 | - $this->CI->email->from ( $this->from, $this->company_name ); |
|
312 | - $this->CI->email->to ( $this->to ); |
|
313 | - $this->CI->email->subject ( $this->subject ); |
|
314 | - eval ( "\$message = \"" . $this->message . "\";" ); |
|
315 | - $this->CI->email->message ( $this->message ); |
|
316 | - $this->CI->email->send (); |
|
317 | - $this->CI->email->clear ( true ); |
|
318 | - $this->update_mail_history ( $history_id ); |
|
311 | + $this->CI->email->from($this->from, $this->company_name); |
|
312 | + $this->CI->email->to($this->to); |
|
313 | + $this->CI->email->subject($this->subject); |
|
314 | + eval ("\$message = \"".$this->message."\";"); |
|
315 | + $this->CI->email->message($this->message); |
|
316 | + $this->CI->email->send(); |
|
317 | + $this->CI->email->clear(true); |
|
318 | + $this->update_mail_history($history_id); |
|
319 | 319 | } |
320 | 320 | } |
321 | 321 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
23 | +if (! defined ( 'BASEPATH' )) { |
|
24 | 24 | exit ( 'No direct script access allowed' ); |
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * Dynamically build forms for display |
@@ -116,9 +117,9 @@ discard block |
||
116 | 117 | return false; |
117 | 118 | } |
118 | 119 | function build_template($template_type, $detail, $detail_type = '') { |
119 | - if (! is_array ( $template_type )) |
|
120 | - $this->get_template ( $template_type ); |
|
121 | - else { |
|
120 | + if (! is_array ( $template_type )) { |
|
121 | + $this->get_template ( $template_type ); |
|
122 | + } else { |
|
122 | 123 | $this->message = $template_type ['message']; |
123 | 124 | $this->subject = $template_type ['subject']; |
124 | 125 | $template_type = ''; |
@@ -228,8 +229,9 @@ discard block |
||
228 | 229 | $this->account_id = $details ['accountid']; |
229 | 230 | } |
230 | 231 | function get_smtp_details() { |
231 | - if ($this->smtp_port == '' || $this->smtp_host == '' || $this->smtp_user == '' || $this->smtp_pass == '') |
|
232 | - exit (); |
|
232 | + if ($this->smtp_port == '' || $this->smtp_host == '' || $this->smtp_user == '' || $this->smtp_pass == '') { |
|
233 | + exit (); |
|
234 | + } |
|
233 | 235 | $config ['protocol'] = "smtp"; |
234 | 236 | $config ['smtp_host'] = $this->smtp_host; |
235 | 237 | $config ['smtp_port'] = $this->smtp_port; |
@@ -249,10 +251,11 @@ discard block |
||
249 | 251 | $this->set_email_paramenters ( $details ); |
250 | 252 | } |
251 | 253 | |
252 | - if (! $brodcast) |
|
253 | - $history_id = $this->mail_history ( $attachment ); |
|
254 | - else |
|
255 | - $history_id = $details ['history_id']; |
|
254 | + if (! $brodcast) { |
|
255 | + $history_id = $this->mail_history ( $attachment ); |
|
256 | + } else { |
|
257 | + $history_id = $details ['history_id']; |
|
258 | + } |
|
256 | 259 | if (isset ( $this->from ) && $this->from != '' && isset ( $this->to ) && $this->to != '' && ! $mass_mail) { |
257 | 260 | if (! $this->smtp) { |
258 | 261 | $this->get_smtp_details (); |
@@ -300,10 +303,11 @@ discard block |
||
300 | 303 | $this->set_email_paramenters ( $details ); |
301 | 304 | } |
302 | 305 | |
303 | - if (! $brodcast) |
|
304 | - $history_id = $this->mail_history ( $attachment ); |
|
305 | - else |
|
306 | - $history_id = $details ['history_id']; |
|
306 | + if (! $brodcast) { |
|
307 | + $history_id = $this->mail_history ( $attachment ); |
|
308 | + } else { |
|
309 | + $history_id = $details ['history_id']; |
|
310 | + } |
|
307 | 311 | if (isset ( $this->from ) && $this->from != '' && isset ( $this->to ) && $this->to != '' && ! $mass_mail) { |
308 | 312 | if (! $this->smtp) { |
309 | 313 | $this->get_smtp_details (); |
@@ -20,44 +20,44 @@ |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | class Permission { |
26 | 26 | function __construct($library_name = '') { |
27 | - $this->CI = & get_instance (); |
|
28 | - $this->CI->load->model ( "db_model" ); |
|
29 | - $this->CI->load->library ( 'session' ); |
|
27 | + $this->CI = & get_instance(); |
|
28 | + $this->CI->load->model("db_model"); |
|
29 | + $this->CI->load->library('session'); |
|
30 | 30 | } |
31 | 31 | function get_module_access($user_type) { |
32 | - $where = array ( |
|
32 | + $where = array( |
|
33 | 33 | "userlevelid" => $user_type |
34 | 34 | ); |
35 | - $modules_arr = $this->CI->db_model->getSelect ( "module_permissions", "userlevels", $where ); |
|
35 | + $modules_arr = $this->CI->db_model->getSelect("module_permissions", "userlevels", $where); |
|
36 | 36 | if ($modules_arr->num_rows > 0) { |
37 | - $modules_arr = $modules_arr->result_array (); |
|
37 | + $modules_arr = $modules_arr->result_array(); |
|
38 | 38 | $modules_arr = $modules_arr [0] ['module_permissions']; |
39 | 39 | |
40 | - $menu_arr = $this->CI->db_model->select ( "*", "menu_modules", "id IN ($modules_arr)", "priority", "asc", "", "", "" ); |
|
41 | - $menu_list = array (); |
|
42 | - $permited_modules = array (); |
|
43 | - $modules_seq_arr = array (); |
|
44 | - $modules_seq_arr = explode ( ",", $modules_arr ); |
|
45 | - $label_arr = array (); |
|
46 | - foreach ( $menu_arr->result_array () as $menu_key => $menu_value ) { |
|
47 | - if (! isset ( $label_arr [$menu_value ['menu_label']] ) && $menu_value ['menu_label'] != 'Configuration') { |
|
40 | + $menu_arr = $this->CI->db_model->select("*", "menu_modules", "id IN ($modules_arr)", "priority", "asc", "", "", ""); |
|
41 | + $menu_list = array(); |
|
42 | + $permited_modules = array(); |
|
43 | + $modules_seq_arr = array(); |
|
44 | + $modules_seq_arr = explode(",", $modules_arr); |
|
45 | + $label_arr = array(); |
|
46 | + foreach ($menu_arr->result_array() as $menu_key => $menu_value) { |
|
47 | + if ( ! isset ($label_arr [$menu_value ['menu_label']]) && $menu_value ['menu_label'] != 'Configuration') { |
|
48 | 48 | $label_arr [$menu_value ['menu_label']] = $menu_value ['menu_label']; |
49 | 49 | $menu_value ["menu_image"] = ($menu_value ["menu_image"] == "") ? "Home.png" : $menu_value ["menu_image"]; |
50 | - $menu_list [$menu_value ["menu_title"]] [$menu_value ["menu_subtitle"]] [] = array ( |
|
51 | - "menu_label" => trim ( $menu_value ["menu_label"] ), |
|
52 | - "module_url" => trim ( $menu_value ["module_url"] ), |
|
53 | - "module" => trim ( $menu_value ["module_name"] ), |
|
54 | - "menu_image" => trim ( $menu_value ["menu_image"] ) |
|
50 | + $menu_list [$menu_value ["menu_title"]] [$menu_value ["menu_subtitle"]] [] = array( |
|
51 | + "menu_label" => trim($menu_value ["menu_label"]), |
|
52 | + "module_url" => trim($menu_value ["module_url"]), |
|
53 | + "module" => trim($menu_value ["module_name"]), |
|
54 | + "menu_image" => trim($menu_value ["menu_image"]) |
|
55 | 55 | ); |
56 | 56 | } |
57 | - $permited_modules [] = trim ( $menu_value ["module_name"] ); |
|
57 | + $permited_modules [] = trim($menu_value ["module_name"]); |
|
58 | 58 | } |
59 | - $this->CI->session->set_userdata ( 'permited_modules', serialize ( $permited_modules ) ); |
|
60 | - $this->CI->session->set_userdata ( 'menuinfo', serialize ( $menu_list ) ); |
|
59 | + $this->CI->session->set_userdata('permited_modules', serialize($permited_modules)); |
|
60 | + $this->CI->session->set_userdata('menuinfo', serialize($menu_list)); |
|
61 | 61 | return true; |
62 | 62 | } |
63 | 63 | } |
@@ -20,8 +20,9 @@ |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
23 | +if (! defined ( 'BASEPATH' )) { |
|
24 | 24 | exit ( 'No direct script access allowed' ); |
25 | +} |
|
25 | 26 | class Permission { |
26 | 27 | function __construct($library_name = '') { |
27 | 28 | $this->CI = & get_instance (); |
@@ -20,30 +20,30 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Dynamically build forms for display |
28 | 28 | */ |
29 | 29 | class Form { |
30 | 30 | protected $CI; // codeigniter |
31 | - protected $fields = array (); // array of fields |
|
31 | + protected $fields = array(); // array of fields |
|
32 | 32 | protected $form_title = 'Form'; |
33 | 33 | protected $form_id = 'form'; |
34 | 34 | protected $form_action = ''; |
35 | 35 | protected $form_class = ''; |
36 | - protected $hidden = array (); |
|
36 | + protected $hidden = array(); |
|
37 | 37 | protected $multipart = FALSE; // default to standard form |
38 | 38 | protected $submit_button = 'Submit'; |
39 | 39 | protected $after_button = ''; |
40 | - protected $rules = array (); // storage for validation rules |
|
40 | + protected $rules = array(); // storage for validation rules |
|
41 | 41 | function __construct() { |
42 | - $this->CI = & get_instance (); |
|
43 | - $this->CI->load->library ( 'form_validation' ); |
|
44 | - $this->CI->load->library ( 'astpp/common' ); |
|
45 | - $this->CI->load->model ( 'db_model' ); |
|
46 | - $this->check_permissions (); |
|
42 | + $this->CI = & get_instance(); |
|
43 | + $this->CI->load->library('form_validation'); |
|
44 | + $this->CI->load->library('astpp/common'); |
|
45 | + $this->CI->load->model('db_model'); |
|
46 | + $this->check_permissions(); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | // __construct |
@@ -51,67 +51,67 @@ discard block |
||
51 | 51 | * adds raw html to the field array |
52 | 52 | */ |
53 | 53 | function check_permissions() { |
54 | - if ($this->CI->session->userdata ( 'user_login' ) == TRUE) { |
|
55 | - $module_info = unserialize ( $this->CI->session->userdata ( "permited_modules" ) ); |
|
56 | - if ($this->CI->session->userdata ( 'userlevel_logintype' ) != 0 && $this->CI->session->userdata ( 'userlevel_logintype' ) != 3) { |
|
54 | + if ($this->CI->session->userdata('user_login') == TRUE) { |
|
55 | + $module_info = unserialize($this->CI->session->userdata("permited_modules")); |
|
56 | + if ($this->CI->session->userdata('userlevel_logintype') != 0 && $this->CI->session->userdata('userlevel_logintype') != 3) { |
|
57 | 57 | $module_info [] = 'dashboard'; |
58 | 58 | } |
59 | 59 | $url = $this->CI->uri->uri_string; |
60 | - $file_name = explode ( "/", $url ); |
|
61 | - if (isset ( $file_name ['1'] )) { |
|
62 | - $module = explode ( '_', $file_name ['1'] ); |
|
60 | + $file_name = explode("/", $url); |
|
61 | + if (isset ($file_name ['1'])) { |
|
62 | + $module = explode('_', $file_name ['1']); |
|
63 | 63 | } else { |
64 | 64 | $module = $file_name; |
65 | 65 | } |
66 | - if ($this->CI->session->userdata ( 'userlevel_logintype' ) != -1) { |
|
66 | + if ($this->CI->session->userdata('userlevel_logintype') != -1) { |
|
67 | 67 | $module_info [] = 'user'; |
68 | 68 | } |
69 | - if (in_array ( $module [0], $module_info )) { |
|
70 | - if ($this->CI->session->userdata ( 'userlevel_logintype' ) == 0 && $module [0] == 'customer' && isset ( $file_name [1] ) && $file_name [1] != 'customer_transfer') { |
|
71 | - redirect ( base_url () . 'user/user/' ); |
|
69 | + if (in_array($module [0], $module_info)) { |
|
70 | + if ($this->CI->session->userdata('userlevel_logintype') == 0 && $module [0] == 'customer' && isset ($file_name [1]) && $file_name [1] != 'customer_transfer') { |
|
71 | + redirect(base_url().'user/user/'); |
|
72 | 72 | } else { |
73 | 73 | return true; |
74 | 74 | } |
75 | 75 | } else { |
76 | - $this->CI->session->set_userdata ( 'astpp_errormsg', 'You do not have permission to access this module..!' ); |
|
77 | - if ($this->CI->session->userdata ( 'userlevel_logintype' ) == '-1' || $this->CI->session->userdata ( 'logintype' ) == '1' || $this->CI->session->userdata ( 'logintype' ) == '4') { |
|
78 | - redirect ( base_url () . 'dashboard/' ); |
|
76 | + $this->CI->session->set_userdata('astpp_errormsg', 'You do not have permission to access this module..!'); |
|
77 | + if ($this->CI->session->userdata('userlevel_logintype') == '-1' || $this->CI->session->userdata('logintype') == '1' || $this->CI->session->userdata('logintype') == '4') { |
|
78 | + redirect(base_url().'dashboard/'); |
|
79 | 79 | } else { |
80 | - redirect ( base_url () . 'user/user/' ); |
|
80 | + redirect(base_url().'user/user/'); |
|
81 | 81 | } |
82 | 82 | } |
83 | 83 | } else { |
84 | - redirect ( base_url () ); |
|
84 | + redirect(base_url()); |
|
85 | 85 | } |
86 | 86 | } |
87 | 87 | function build_form($fields_array, $values) { |
88 | 88 | $form_contents = ''; |
89 | 89 | $form_contents .= '<div class="pop_md col-md-12 margin-t-10 padding-x-8">'; |
90 | - if (isset ( $fields_array ['breadcrumb'] )) { |
|
91 | - $form_contents .= form_breadcrumb ( $fields_array ['breadcrumb'] ); |
|
92 | - unset ( $fields_array ['breadcrumb'] ); |
|
90 | + if (isset ($fields_array ['breadcrumb'])) { |
|
91 | + $form_contents .= form_breadcrumb($fields_array ['breadcrumb']); |
|
92 | + unset ($fields_array ['breadcrumb']); |
|
93 | 93 | } |
94 | - $form_contents .= form_open ( $fields_array ['forms'] [0], $fields_array ['forms'] [1] ); |
|
95 | - unset ( $fields_array ['forms'] ); |
|
96 | - $button_array = array (); |
|
97 | - if (isset ( $fields_array ['button_save'] ) || isset ( $fields_array ['button_cancel'] ) || isset ( $fields_array ['additional_button'] )) { |
|
94 | + $form_contents .= form_open($fields_array ['forms'] [0], $fields_array ['forms'] [1]); |
|
95 | + unset ($fields_array ['forms']); |
|
96 | + $button_array = array(); |
|
97 | + if (isset ($fields_array ['button_save']) || isset ($fields_array ['button_cancel']) || isset ($fields_array ['additional_button'])) { |
|
98 | 98 | $save = $fields_array ['button_save']; |
99 | - unset ( $fields_array ['button_save'] ); |
|
100 | - if (isset ( $fields_array ['button_cancel'] )) { |
|
99 | + unset ($fields_array ['button_save']); |
|
100 | + if (isset ($fields_array ['button_cancel'])) { |
|
101 | 101 | $cancel = $fields_array ['button_cancel']; |
102 | - unset ( $fields_array ['button_cancel'] ); |
|
102 | + unset ($fields_array ['button_cancel']); |
|
103 | 103 | } |
104 | - if (isset ( $fields_array ['additional_button'] )) { |
|
104 | + if (isset ($fields_array ['additional_button'])) { |
|
105 | 105 | $additiopnal_button = $fields_array ['additional_button']; |
106 | - unset ( $fields_array ['additional_button'] ); |
|
106 | + unset ($fields_array ['additional_button']); |
|
107 | 107 | } |
108 | 108 | } |
109 | - if (isset ( $additiopnal_button )) { |
|
110 | - $form_contents .= form_button ( gettext ( $additiopnal_button ) ); |
|
109 | + if (isset ($additiopnal_button)) { |
|
110 | + $form_contents .= form_button(gettext($additiopnal_button)); |
|
111 | 111 | } |
112 | 112 | $i = 0; |
113 | - foreach ( $fields_array as $fieldset_key => $form_fileds ) { |
|
114 | - if (count ( $fields_array ) > 1) { |
|
113 | + foreach ($fields_array as $fieldset_key => $form_fileds) { |
|
114 | + if (count($fields_array) > 1) { |
|
115 | 115 | if ($i == 1 || $i == 3) { |
116 | 116 | $form_contents .= '<div class="col-md-6 no-padding pull-right">'; |
117 | 117 | $form_contents .= '<div class="col-md-12 padding-x-4">'; |
@@ -126,235 +126,235 @@ discard block |
||
126 | 126 | $form_contents .= '<ul class="no-padding">'; |
127 | 127 | $form_contents .= '<div class="col-md-12 no-padding">'; |
128 | 128 | if ($i == 1 || $i == 3) { |
129 | - $form_contents .= form_fieldset ( gettext ( $fieldset_key ) ); |
|
129 | + $form_contents .= form_fieldset(gettext($fieldset_key)); |
|
130 | 130 | } else { |
131 | - $form_contents .= form_fieldset ( gettext ( $fieldset_key ) ); |
|
131 | + $form_contents .= form_fieldset(gettext($fieldset_key)); |
|
132 | 132 | } |
133 | - foreach ( $form_fileds as $fieldkey => $fieldvalue ) { |
|
134 | - if (isset ( $fieldvalue ) && $fieldvalue != '') { |
|
133 | + foreach ($form_fileds as $fieldkey => $fieldvalue) { |
|
134 | + if (isset ($fieldvalue) && $fieldvalue != '') { |
|
135 | 135 | $form_contents .= '<li class="col-md-12">'; |
136 | 136 | if ($fieldvalue [1] == 'HIDDEN') { |
137 | - if (isset ( $this->CI->input->post )) |
|
138 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
137 | + if (isset ($this->CI->input->post)) |
|
138 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? @$fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
139 | 139 | else |
140 | - $fieldvalue [2] ['value'] = ($values) ? (isset ( $values [$fieldvalue [2] ['name']] ) ? $values [$fieldvalue [2] ['name']] : '') : (isset ( $fieldvalue [2] ['value'] ) ? $fieldvalue [2] ['value'] : ''); |
|
141 | - $form_contents .= form_hidden ( $fieldvalue [2] ['name'], $fieldvalue [2] ['value'] ); |
|
140 | + $fieldvalue [2] ['value'] = ($values) ? (isset ($values [$fieldvalue [2] ['name']]) ? $values [$fieldvalue [2] ['name']] : '') : (isset ($fieldvalue [2] ['value']) ? $fieldvalue [2] ['value'] : ''); |
|
141 | + $form_contents .= form_hidden($fieldvalue [2] ['name'], $fieldvalue [2] ['value']); |
|
142 | 142 | } else { |
143 | - $validation_arr = array (); |
|
143 | + $validation_arr = array(); |
|
144 | 144 | if ($fieldvalue [1] == 'INPUT') { |
145 | - if (! empty ( $fieldvalue [3] )) { |
|
146 | - $validation_arr = explode ( "|", $fieldvalue [3] ); |
|
145 | + if ( ! empty ($fieldvalue [3])) { |
|
146 | + $validation_arr = explode("|", $fieldvalue [3]); |
|
147 | 147 | } |
148 | 148 | } elseif ($fieldvalue [2] == 'SELECT') { |
149 | 149 | |
150 | - if (is_array ( $fieldvalue [4] )) { |
|
151 | - $validation_arr = explode ( "|", $fieldvalue [4] ['rules'] ); |
|
150 | + if (is_array($fieldvalue [4])) { |
|
151 | + $validation_arr = explode("|", $fieldvalue [4] ['rules']); |
|
152 | 152 | } else { |
153 | - $validation_arr = explode ( "|", $fieldvalue [4] ); |
|
153 | + $validation_arr = explode("|", $fieldvalue [4]); |
|
154 | 154 | } |
155 | 155 | } |
156 | - if (! empty ( $validation_arr )) { |
|
157 | - $fieldvalue [0] = in_array ( 'required', $validation_arr ) ? $fieldvalue [0] . "<span style='color:black;'> *</span>" : $fieldvalue [0]; |
|
158 | - $fieldvalue [0] = in_array ( 'dropdown', $validation_arr ) ? $fieldvalue [0] . "<span style='color:black;'> *</span>" : $fieldvalue [0]; |
|
156 | + if ( ! empty ($validation_arr)) { |
|
157 | + $fieldvalue [0] = in_array('required', $validation_arr) ? $fieldvalue [0]."<span style='color:black;'> *</span>" : $fieldvalue [0]; |
|
158 | + $fieldvalue [0] = in_array('dropdown', $validation_arr) ? $fieldvalue [0]."<span style='color:black;'> *</span>" : $fieldvalue [0]; |
|
159 | 159 | } |
160 | 160 | |
161 | - if (is_array ( $fieldvalue [1] ) || (is_array ( $fieldvalue [2] ) && isset ( $fieldvalue [2] ['hidden'] ))) { |
|
162 | - $form_contents .= form_label ( gettext ( $fieldvalue [0] ), $fieldvalue [0], array ( |
|
161 | + if (is_array($fieldvalue [1]) || (is_array($fieldvalue [2]) && isset ($fieldvalue [2] ['hidden']))) { |
|
162 | + $form_contents .= form_label(gettext($fieldvalue [0]), $fieldvalue [0], array( |
|
163 | 163 | 'class' => 'col-md-3 no-padding add_settings' |
164 | - ) ); |
|
164 | + )); |
|
165 | 165 | } else { |
166 | - $form_contents .= form_label ( gettext ( $fieldvalue [0] ), "", array ( |
|
166 | + $form_contents .= form_label(gettext($fieldvalue [0]), "", array( |
|
167 | 167 | "class" => "col-md-3 no-padding" |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | } |
171 | - if ($fieldvalue [2] == 'SELECT' && ! isset ( $fieldvalue [13] )) { |
|
171 | + if ($fieldvalue [2] == 'SELECT' && ! isset ($fieldvalue [13])) { |
|
172 | 172 | |
173 | 173 | /* |
174 | 174 | * To make Drop down enabled disabled |
175 | 175 | */ |
176 | - $extra = isset ( $fieldvalue [1] ['extra'] ) ? $fieldvalue [1] ['extra'] : ''; |
|
176 | + $extra = isset ($fieldvalue [1] ['extra']) ? $fieldvalue [1] ['extra'] : ''; |
|
177 | 177 | /** |
178 | 178 | * ************************ |
179 | 179 | */ |
180 | 180 | if ($fieldvalue [7] != '' && $fieldvalue [8] != '') { |
181 | - $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
|
181 | + $str = $fieldvalue [7].",".$fieldvalue [8]; |
|
182 | 182 | |
183 | - if (isset ( $this->CI->input->post )) { |
|
184 | - $fieldvalue ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [1] : $this->CI->input->post ( $fieldvalue [1] ); |
|
183 | + if (isset ($this->CI->input->post)) { |
|
184 | + $fieldvalue ['value'] = ( ! $this->CI->input->post($fieldvalue [1])) ? @$fieldvalue [1] : $this->CI->input->post($fieldvalue [1]); |
|
185 | 185 | } else { |
186 | - if (is_array ( $fieldvalue [1] )) { |
|
186 | + if (is_array($fieldvalue [1])) { |
|
187 | 187 | $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1] ['name']] : @$fieldvalue [1]; |
188 | 188 | } else { |
189 | 189 | $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1]] : @$fieldvalue [1]; |
190 | 190 | } |
191 | 191 | } |
192 | - $drp_array = call_user_func_array ( array ( |
|
192 | + $drp_array = call_user_func_array(array( |
|
193 | 193 | $this->CI->db_model, |
194 | 194 | $fieldvalue [10] |
195 | - ), array ( |
|
195 | + ), array( |
|
196 | 196 | $str, |
197 | 197 | $fieldvalue [9], |
198 | 198 | $fieldvalue [11], |
199 | 199 | $fieldvalue [12] |
200 | - ) ); |
|
200 | + )); |
|
201 | 201 | |
202 | - if ($fieldset_key == gettext ( 'System Configuration Information' ) || ($fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue [0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue [0] == 'Rate Group' || ($fieldset_key == 'Origination Rate Add/Edit' && $fieldvalue [0] == 'Trunks') || $fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Rate Group' || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Failover GW Name #1') || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Failover GW Name #2') || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Rate Group') || ($fieldset_key == 'Sip Devices' && $fieldvalue [0] == 'Sip Profile') || ($fieldset_key == 'Sip Devices' && $fieldvalue [0] == 'Account')) { |
|
203 | - $form_contents .= form_dropdown_all ( $fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra ); |
|
202 | + if ($fieldset_key == gettext('System Configuration Information') || ($fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Force Trunk') || ($fieldset_key == 'Card Information' && $fieldvalue [0] == 'Rate Group') || ($fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Account') || $fieldset_key == 'Freeswitch Devices' && $fieldvalue [0] == 'Rate Group' || ($fieldset_key == 'Origination Rate Add/Edit' && $fieldvalue [0] == 'Trunks') || $fieldset_key == 'Billing Information' && $fieldvalue [0] == 'Rate Group' || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Failover GW Name #1') || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Failover GW Name #2') || ($fieldset_key == 'Information' && $fieldvalue [0] == 'Rate Group') || ($fieldset_key == 'Sip Devices' && $fieldvalue [0] == 'Sip Profile') || ($fieldset_key == 'Sip Devices' && $fieldvalue [0] == 'Account')) { |
|
203 | + $form_contents .= form_dropdown_all($fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra); |
|
204 | 204 | } else { |
205 | - $form_contents .= form_dropdown ( $fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra ); |
|
205 | + $form_contents .= form_dropdown($fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra); |
|
206 | 206 | } |
207 | - if (isset ( $fieldvalue [4] ) && $fieldvalue [4] != '') { |
|
208 | - if (is_array ( $fieldvalue [4] )) { |
|
207 | + if (isset ($fieldvalue [4]) && $fieldvalue [4] != '') { |
|
208 | + if (is_array($fieldvalue [4])) { |
|
209 | 209 | |
210 | - if (isset ( $fieldvalue [1] ['name'] )) { |
|
210 | + if (isset ($fieldvalue [1] ['name'])) { |
|
211 | 211 | $fieldvalue_pass = $fieldvalue [1] ['name']; |
212 | 212 | } else { |
213 | 213 | $fieldvalue_pass = $fieldvalue [1]; |
214 | 214 | } |
215 | 215 | |
216 | - $this->CI->form_validation->set_rules ( $fieldvalue_pass, $fieldvalue [0], $fieldvalue [4] ['rules'] ); |
|
216 | + $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue [0], $fieldvalue [4] ['rules']); |
|
217 | 217 | } else { |
218 | 218 | |
219 | - if (isset ( $fieldvalue [1] ['name'] )) { |
|
219 | + if (isset ($fieldvalue [1] ['name'])) { |
|
220 | 220 | $fieldvalue_pass = $fieldvalue [1] ['name']; |
221 | 221 | } else { |
222 | 222 | $fieldvalue_pass = $fieldvalue [1]; |
223 | 223 | } |
224 | 224 | |
225 | - $this->CI->form_validation->set_rules ( $fieldvalue_pass, $fieldvalue [0], $fieldvalue [4] ); |
|
225 | + $this->CI->form_validation->set_rules($fieldvalue_pass, $fieldvalue [0], $fieldvalue [4]); |
|
226 | 226 | } |
227 | 227 | } |
228 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . (is_array ( $fieldvalue [1] ) ? $fieldvalue [1] ['name'] : $fieldvalue [1]) . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
229 | - $form_contents .= '<span class="popup_error error no-padding" id="' . (gettext ( is_array ( $fieldvalue [1] ) ? $fieldvalue [1] ['name'] : $fieldvalue [1] )) . '_error"> |
|
228 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue [1]) ? $fieldvalue [1] ['name'] : $fieldvalue [1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
229 | + $form_contents .= '<span class="popup_error error no-padding" id="'.(gettext(is_array($fieldvalue [1]) ? $fieldvalue [1] ['name'] : $fieldvalue [1])).'_error"> |
|
230 | 230 | </span></div>'; |
231 | 231 | } else { |
232 | - if (isset ( $this->CI->input->post )) { |
|
233 | - $fieldvalue ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [1] : $this->CI->input->post ( $fieldvalue [1] ); |
|
232 | + if (isset ($this->CI->input->post)) { |
|
233 | + $fieldvalue ['value'] = ( ! $this->CI->input->post($fieldvalue [1])) ? @$fieldvalue [1] : $this->CI->input->post($fieldvalue [1]); |
|
234 | 234 | } else { |
235 | - if (is_array ( $fieldvalue [1] )) { |
|
235 | + if (is_array($fieldvalue [1])) { |
|
236 | 236 | $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1] ['name']] : @$fieldvalue [1]; |
237 | 237 | } else { |
238 | 238 | $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1]] : @$fieldvalue [1]; |
239 | 239 | } |
240 | 240 | } |
241 | 241 | |
242 | - $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
|
243 | - $drp_array = call_user_func_array ( array ( |
|
242 | + $str = $fieldvalue [7].",".$fieldvalue [8]; |
|
243 | + $drp_array = call_user_func_array(array( |
|
244 | 244 | $this->CI->common, |
245 | 245 | $fieldvalue [10] |
246 | - ), array ( |
|
246 | + ), array( |
|
247 | 247 | $fieldvalue [9] |
248 | - ) ); |
|
249 | - $form_contents .= form_dropdown ( $fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra ); |
|
250 | - if (isset ( $fieldvalue [4] ) && $fieldvalue [4] != '') { |
|
251 | - $this->CI->form_validation->set_rules ( $fieldvalue [1], $fieldvalue [0], $fieldvalue [4] ); |
|
248 | + )); |
|
249 | + $form_contents .= form_dropdown($fieldvalue [1], $drp_array, $fieldvalue ['value'], $extra); |
|
250 | + if (isset ($fieldvalue [4]) && $fieldvalue [4] != '') { |
|
251 | + $this->CI->form_validation->set_rules($fieldvalue [1], $fieldvalue [0], $fieldvalue [4]); |
|
252 | 252 | } |
253 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . (is_array ( $fieldvalue [1] ) ? $fieldvalue [1] ['name'] : $fieldvalue [1]) . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
254 | - $form_contents .= '<span class="popup_error error no-padding" id="' . (is_array ( $fieldvalue [1] ) ? $fieldvalue [1] ['name'] : $fieldvalue [1]) . '_error"> |
|
253 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.(is_array($fieldvalue [1]) ? $fieldvalue [1] ['name'] : $fieldvalue [1]).'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
254 | + $form_contents .= '<span class="popup_error error no-padding" id="'.(is_array($fieldvalue [1]) ? $fieldvalue [1] ['name'] : $fieldvalue [1]).'_error"> |
|
255 | 255 | </span></div>'; |
256 | 256 | } |
257 | - } else if (isset ( $fieldvalue [13] ) && $fieldvalue [13] != '') { |
|
257 | + } else if (isset ($fieldvalue [13]) && $fieldvalue [13] != '') { |
|
258 | 258 | |
259 | 259 | /* For multi select code */ |
260 | - $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
|
260 | + $str = $fieldvalue [7].",".$fieldvalue [8]; |
|
261 | 261 | |
262 | - if (isset ( $this->CI->input->post )) |
|
263 | - $fieldvalue ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [1] : $this->CI->input->post ( $fieldvalue [1] ); |
|
262 | + if (isset ($this->CI->input->post)) |
|
263 | + $fieldvalue ['value'] = ( ! $this->CI->input->post($fieldvalue [1])) ? @$fieldvalue [1] : $this->CI->input->post($fieldvalue [1]); |
|
264 | 264 | else |
265 | 265 | $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1]] : @$fieldvalue [1]; |
266 | 266 | |
267 | - $drp_array = call_user_func_array ( array ( |
|
267 | + $drp_array = call_user_func_array(array( |
|
268 | 268 | $this->CI->db_model, |
269 | 269 | $fieldvalue [10] |
270 | - ), array ( |
|
270 | + ), array( |
|
271 | 271 | $str, |
272 | 272 | $fieldvalue [9], |
273 | 273 | $fieldvalue [11], |
274 | 274 | $fieldvalue [12] |
275 | - ) ); |
|
275 | + )); |
|
276 | 276 | if ($fieldset_key === 'System Configuration Information') { |
277 | - $form_contents .= form_dropdown_multiselect ( $fieldvalue [1], $drp_array, '' ); |
|
277 | + $form_contents .= form_dropdown_multiselect($fieldvalue [1], $drp_array, ''); |
|
278 | 278 | } else { |
279 | - $form_contents .= form_dropdown_multiselect ( $fieldvalue [1] . "[]", $drp_array, $fieldvalue ['value'] ); |
|
279 | + $form_contents .= form_dropdown_multiselect($fieldvalue [1]."[]", $drp_array, $fieldvalue ['value']); |
|
280 | 280 | } |
281 | - if (isset ( $fieldvalue [4] ) && $fieldvalue [4] != '') { |
|
282 | - $this->CI->form_validation->set_rules ( $fieldvalue [1], $fieldvalue [0], $fieldvalue [4] ); |
|
281 | + if (isset ($fieldvalue [4]) && $fieldvalue [4] != '') { |
|
282 | + $this->CI->form_validation->set_rules($fieldvalue [1], $fieldvalue [0], $fieldvalue [4]); |
|
283 | 283 | } |
284 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [1] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
285 | - $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [1] . '_error"></span></div>'; |
|
284 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue [1].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
285 | + $form_contents .= '<span class="popup_error error no-padding" id="'.$fieldvalue [1].'_error"></span></div>'; |
|
286 | 286 | /* End--------------------- For multi select code */ |
287 | 287 | } else if ($fieldvalue [1] == 'INPUT') { |
288 | 288 | |
289 | - if (isset ( $this->CI->input->post )) |
|
290 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? $fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
289 | + if (isset ($this->CI->input->post)) |
|
290 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? $fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
291 | 291 | else { |
292 | - $fieldvalue [2] ['value'] = ($values) ? (isset ( $values [$fieldvalue [2] ['name']] ) ? $values [$fieldvalue [2] ['name']] : '') : (isset ( $fieldvalue [2] ['value'] ) ? $fieldvalue [2] ['value'] : ''); |
|
292 | + $fieldvalue [2] ['value'] = ($values) ? (isset ($values [$fieldvalue [2] ['name']]) ? $values [$fieldvalue [2] ['name']] : '') : (isset ($fieldvalue [2] ['value']) ? $fieldvalue [2] ['value'] : ''); |
|
293 | 293 | } |
294 | - $form_contents .= form_input ( $fieldvalue [2], 'readonly' ); |
|
295 | - if (isset ( $fieldvalue [6] ) && ! empty ( $fieldvalue [6] )) { |
|
294 | + $form_contents .= form_input($fieldvalue [2], 'readonly'); |
|
295 | + if (isset ($fieldvalue [6]) && ! empty ($fieldvalue [6])) { |
|
296 | 296 | $form_contents .= $fieldvalue [6]; |
297 | 297 | } |
298 | - $this->CI->form_validation->set_rules ( $fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3] ); |
|
299 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [2] ['name'] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
300 | - $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [2] ['name'] . '_error"> |
|
298 | + $this->CI->form_validation->set_rules($fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3]); |
|
299 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue [2] ['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
300 | + $form_contents .= '<span class="popup_error error no-padding" id="'.$fieldvalue [2] ['name'].'_error"> |
|
301 | 301 | </span></div>'; |
302 | 302 | } /* |
303 | 303 | * Image upload from invoice configuration code. |
304 | 304 | */ |
305 | 305 | else if ($fieldvalue [1] == 'IMAGE') { |
306 | - if (isset ( $this->CI->input->post )) |
|
307 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
306 | + if (isset ($this->CI->input->post)) |
|
307 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? @$fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
308 | 308 | |
309 | 309 | else |
310 | 310 | $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
311 | - $fieldvalue [2] ['style'] = isset ( $fieldvalue [2] ['style'] ) ? $fieldvalue [2] ['style'] : ""; |
|
312 | - $form_contents .= form_image ( $fieldvalue [2], 'readonly', $fieldvalue [2] ['style'] ); |
|
311 | + $fieldvalue [2] ['style'] = isset ($fieldvalue [2] ['style']) ? $fieldvalue [2] ['style'] : ""; |
|
312 | + $form_contents .= form_image($fieldvalue [2], 'readonly', $fieldvalue [2] ['style']); |
|
313 | 313 | $form_contents .= @$fieldvalue [6]; |
314 | - $this->CI->form_validation->set_rules ( $fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3] ); |
|
315 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [2] ['name'] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
316 | - $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [2] ['name'] . '_error"> |
|
314 | + $this->CI->form_validation->set_rules($fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3]); |
|
315 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue [2] ['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
316 | + $form_contents .= '<span class="popup_error error no-padding" id="'.$fieldvalue [2] ['name'].'_error"> |
|
317 | 317 | </span></div>'; |
318 | 318 | } else if ($fieldvalue [1] == 'DEL_BUTTON') { |
319 | - if (isset ( $this->CI->input->post )) |
|
320 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
319 | + if (isset ($this->CI->input->post)) |
|
320 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? @$fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
321 | 321 | |
322 | 322 | else |
323 | 323 | $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
324 | - $fieldvalue [2] ['style'] = isset ( $fieldvalue [2] ['style'] ) ? $fieldvalue [2] ['style'] : ""; |
|
325 | - $form_contents .= form_img_delete ( $fieldvalue [2], 'readonly', $fieldvalue [2] ['style'] ); |
|
324 | + $fieldvalue [2] ['style'] = isset ($fieldvalue [2] ['style']) ? $fieldvalue [2] ['style'] : ""; |
|
325 | + $form_contents .= form_img_delete($fieldvalue [2], 'readonly', $fieldvalue [2] ['style']); |
|
326 | 326 | $form_contents .= @$fieldvalue [6]; |
327 | - $this->CI->form_validation->set_rules ( $fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3] ); |
|
328 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [2] ['name'] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
329 | - $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [2] ['name'] . '_error"> |
|
327 | + $this->CI->form_validation->set_rules($fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3]); |
|
328 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue [2] ['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
329 | + $form_contents .= '<span class="popup_error error no-padding" id="'.$fieldvalue [2] ['name'].'_error"> |
|
330 | 330 | </span></div>'; |
331 | 331 | } /** |
332 | 332 | * ******************************************************************************* |
333 | 333 | */ |
334 | 334 | else if ($fieldvalue [1] == 'PASSWORD') { |
335 | - if (isset ( $this->CI->input->post )) |
|
336 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
335 | + if (isset ($this->CI->input->post)) |
|
336 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? @$fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
337 | 337 | else |
338 | 338 | $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
339 | - $form_contents .= form_password ( $fieldvalue [2] ); |
|
340 | - $this->CI->form_validation->set_rules ( $fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3] ); |
|
341 | - $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [2] ['name'] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
342 | - $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [2] ['name'] . '_error"> |
|
339 | + $form_contents .= form_password($fieldvalue [2]); |
|
340 | + $this->CI->form_validation->set_rules($fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3]); |
|
341 | + $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="'.$fieldvalue [2] ['name'].'_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
|
342 | + $form_contents .= '<span class="popup_error error no-padding" id="'.$fieldvalue [2] ['name'].'_error"> |
|
343 | 343 | </span></div>'; |
344 | 344 | } else if ($fieldvalue [2] == 'CHECKBOX') { |
345 | - $OptionArray = array (); |
|
345 | + $OptionArray = array(); |
|
346 | 346 | |
347 | - if (isset ( $fieldvalue [7] ) && $fieldvalue [7] != '') |
|
348 | - $OptionArray = call_user_func_array ( array ( |
|
347 | + if (isset ($fieldvalue [7]) && $fieldvalue [7] != '') |
|
348 | + $OptionArray = call_user_func_array(array( |
|
349 | 349 | $this->CI->common, |
350 | 350 | $fieldvalue [7] |
351 | - ), array ( |
|
351 | + ), array( |
|
352 | 352 | $fieldvalue [6] |
353 | - ) ); |
|
354 | - if (isset ( $this->CI->input->post )) { |
|
355 | - $fieldvalue [3] ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [3] ['value'] : $this->CI->input->post ( $fieldvalue [1] ); |
|
353 | + )); |
|
354 | + if (isset ($this->CI->input->post)) { |
|
355 | + $fieldvalue [3] ['value'] = ( ! $this->CI->input->post($fieldvalue [1])) ? @$fieldvalue [3] ['value'] : $this->CI->input->post($fieldvalue [1]); |
|
356 | 356 | } else { |
357 | - $fieldvalue [3] ['value'] = ($values) ? (isset ( $values [$fieldvalue [1]] ) && $values [$fieldvalue [1]] ? 1 : 0) : @$fieldvalue [3] ['value']; |
|
357 | + $fieldvalue [3] ['value'] = ($values) ? (isset ($values [$fieldvalue [1]]) && $values [$fieldvalue [1]] ? 1 : 0) : @$fieldvalue [3] ['value']; |
|
358 | 358 | } |
359 | 359 | if ($fieldvalue [3] ['value'] == "1") { |
360 | 360 | $checked = true; |
@@ -362,22 +362,22 @@ discard block |
||
362 | 362 | $checked = false; |
363 | 363 | } |
364 | 364 | ; |
365 | - if (isset ( $fieldvalue [3] ['table_name'] ) && $fieldvalue [3] ['table_name'] != "") { |
|
365 | + if (isset ($fieldvalue [3] ['table_name']) && $fieldvalue [3] ['table_name'] != "") { |
|
366 | 366 | |
367 | - $form_contents .= form_checkbox ( $fieldvalue [1], $fieldvalue [3] ['value'], $checked, $OptionArray ); |
|
367 | + $form_contents .= form_checkbox($fieldvalue [1], $fieldvalue [3] ['value'], $checked, $OptionArray); |
|
368 | 368 | } else { |
369 | - $form_contents .= form_checkbox ( $fieldvalue [1], $fieldvalue [3] ['value'], $checked, $OptionArray ); |
|
369 | + $form_contents .= form_checkbox($fieldvalue [1], $fieldvalue [3] ['value'], $checked, $OptionArray); |
|
370 | 370 | } |
371 | 371 | } else if ($fieldvalue [1] == 'TEXTAREA') { |
372 | 372 | |
373 | - if (isset ( $this->CI->input->post )) |
|
374 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
373 | + if (isset ($this->CI->input->post)) |
|
374 | + $fieldvalue [2] ['value'] = ( ! $this->CI->input->post($fieldvalue [2] ['name'])) ? @$fieldvalue [2] ['value'] : $this->CI->input->post($fieldvalue [2] ['name']); |
|
375 | 375 | else |
376 | 376 | $fieldvalue [2] ['value'] = ($values) ? $values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
377 | - $form_contents .= form_textarea ( $fieldvalue [2] ); |
|
377 | + $form_contents .= form_textarea($fieldvalue [2]); |
|
378 | 378 | } else if ($fieldvalue [2] == 'RADIO') { |
379 | 379 | |
380 | - $form_contents .= form_radio ( $fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked'] ); |
|
380 | + $form_contents .= form_radio($fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked']); |
|
381 | 381 | } |
382 | 382 | $form_contents .= '</li>'; |
383 | 383 | } |
@@ -385,19 +385,19 @@ discard block |
||
385 | 385 | $form_contents .= '</ul>'; |
386 | 386 | $form_contents .= '</div>'; |
387 | 387 | $form_contents .= '</div>'; |
388 | - $i ++; |
|
388 | + $i++; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | $form_contents .= '<center><div class="col-md-12 margin-t-20 margin-b-20">'; |
392 | 392 | |
393 | - $form_contents .= form_button ( $save ); |
|
393 | + $form_contents .= form_button($save); |
|
394 | 394 | |
395 | - if (isset ( $cancel )) { |
|
396 | - $form_contents .= form_button ( $cancel ); |
|
395 | + if (isset ($cancel)) { |
|
396 | + $form_contents .= form_button($cancel); |
|
397 | 397 | } |
398 | 398 | $form_contents .= '</center></div>'; |
399 | - $form_contents .= form_fieldset_close (); |
|
400 | - $form_contents .= form_close (); |
|
399 | + $form_contents .= form_fieldset_close(); |
|
400 | + $form_contents .= form_close(); |
|
401 | 401 | $form_contents .= '</div>'; |
402 | 402 | |
403 | 403 | return $form_contents; |
@@ -405,128 +405,128 @@ discard block |
||
405 | 405 | function build_serach_form($fields_array) { |
406 | 406 | $form_contents = ''; |
407 | 407 | $form_contents .= '<div>'; |
408 | - $form_contents .= form_open ( $fields_array ['forms'] [0], $fields_array ['forms'] [1] ); |
|
409 | - unset ( $fields_array ['forms'] ); |
|
410 | - $button_array = array (); |
|
408 | + $form_contents .= form_open($fields_array ['forms'] [0], $fields_array ['forms'] [1]); |
|
409 | + unset ($fields_array ['forms']); |
|
410 | + $button_array = array(); |
|
411 | 411 | /** |
412 | 412 | * ***** |
413 | 413 | * Batch Delete |
414 | 414 | * ***** |
415 | 415 | */ |
416 | - if (isset ( $fields_array ['button_search'] ) || isset ( $fields_array ['button_reset'] ) || isset ( $fields_array ['button_search_delete'] ) || isset ( $fields_array ['display_in'] )) { |
|
416 | + if (isset ($fields_array ['button_search']) || isset ($fields_array ['button_reset']) || isset ($fields_array ['button_search_delete']) || isset ($fields_array ['display_in'])) { |
|
417 | 417 | $save = $fields_array ['button_search']; |
418 | - unset ( $fields_array ['button_search'] ); |
|
418 | + unset ($fields_array ['button_search']); |
|
419 | 419 | if ($fields_array ['button_reset']) { |
420 | 420 | $cancel = $fields_array ['button_reset']; |
421 | - unset ( $fields_array ['button_reset'] ); |
|
421 | + unset ($fields_array ['button_reset']); |
|
422 | 422 | } |
423 | 423 | $button_search_delete = ''; |
424 | - if (isset ( $fields_array ['button_search_delete'] )) { |
|
424 | + if (isset ($fields_array ['button_search_delete'])) { |
|
425 | 425 | $button_search_delete = $fields_array ['button_search_delete']; |
426 | - unset ( $fields_array ['button_search_delete'] ); |
|
426 | + unset ($fields_array ['button_search_delete']); |
|
427 | 427 | } |
428 | - if (isset ( $fields_array ['display_in'] )) { |
|
428 | + if (isset ($fields_array ['display_in'])) { |
|
429 | 429 | $display_in = $fields_array ['display_in']; |
430 | - unset ( $fields_array ['display_in'] ); |
|
430 | + unset ($fields_array ['display_in']); |
|
431 | 431 | } |
432 | 432 | } |
433 | 433 | /** |
434 | 434 | * *********************** |
435 | 435 | */ |
436 | 436 | $i = 1; |
437 | - foreach ( $fields_array as $fieldset_key => $form_fileds ) { |
|
437 | + foreach ($fields_array as $fieldset_key => $form_fileds) { |
|
438 | 438 | |
439 | 439 | $form_contents .= '<ul class="padding-15">'; |
440 | - $form_contents .= form_fieldset ( gettext ( $fieldset_key ), array ( |
|
440 | + $form_contents .= form_fieldset(gettext($fieldset_key), array( |
|
441 | 441 | 'style' => 'font-weight:bold;' |
442 | - ), "search" ); |
|
442 | + ), "search"); |
|
443 | 443 | |
444 | - foreach ( $form_fileds as $fieldkey => $fieldvalue ) { |
|
444 | + foreach ($form_fileds as $fieldkey => $fieldvalue) { |
|
445 | 445 | if ($i == 0) { |
446 | 446 | $form_contents .= '<li class="col-md-12">'; |
447 | 447 | } |
448 | 448 | $form_contents .= '<div class="col-md-3 no-padding">'; |
449 | 449 | if ($fieldvalue [1] == 'HIDDEN') { |
450 | - $form_contents .= form_hidden ( $fieldvalue [2], $fieldvalue [3] ); |
|
450 | + $form_contents .= form_hidden($fieldvalue [2], $fieldvalue [3]); |
|
451 | 451 | } else { |
452 | - $form_contents .= form_label ( gettext ( $fieldvalue [0] ), "", array ( |
|
452 | + $form_contents .= form_label(gettext($fieldvalue [0]), "", array( |
|
453 | 453 | "class" => "search_label col-md-12 no-padding" |
454 | - ) ); |
|
454 | + )); |
|
455 | 455 | } |
456 | 456 | if ($fieldvalue [1] == 'INPUT') { |
457 | - $form_contents .= form_input ( $fieldvalue [2] ); |
|
457 | + $form_contents .= form_input($fieldvalue [2]); |
|
458 | 458 | } |
459 | 459 | |
460 | 460 | if ($fieldvalue [2] == 'SELECT' || $fieldvalue [5] == '1') { |
461 | 461 | |
462 | 462 | if ($fieldvalue [7] != '' && $fieldvalue [8] != '') { |
463 | - $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
|
463 | + $str = $fieldvalue [7].",".$fieldvalue [8]; |
|
464 | 464 | |
465 | - $drp_array = call_user_func_array ( array ( |
|
465 | + $drp_array = call_user_func_array(array( |
|
466 | 466 | $this->CI->db_model, |
467 | 467 | $fieldvalue [10] |
468 | - ), array ( |
|
468 | + ), array( |
|
469 | 469 | $str, |
470 | 470 | $fieldvalue [9], |
471 | 471 | $fieldvalue [11], |
472 | 472 | $fieldvalue [12] |
473 | - ) ); |
|
474 | - $form_contents .= form_dropdown_all ( $fieldvalue [1], $drp_array, '' ); |
|
473 | + )); |
|
474 | + $form_contents .= form_dropdown_all($fieldvalue [1], $drp_array, ''); |
|
475 | 475 | } else { |
476 | 476 | |
477 | 477 | if ($fieldvalue [1] == 'INPUT') { |
478 | 478 | $fieldvalue [1] = $fieldvalue [6]; |
479 | 479 | } |
480 | 480 | |
481 | - $drp_array = call_user_func_array ( array ( |
|
481 | + $drp_array = call_user_func_array(array( |
|
482 | 482 | $this->CI->common, |
483 | 483 | $fieldvalue [10] |
484 | - ), array ( |
|
484 | + ), array( |
|
485 | 485 | $fieldvalue [9] |
486 | - ) ); |
|
487 | - $form_contents .= form_dropdown_all_search ( $fieldvalue [1], $drp_array, '' ); |
|
486 | + )); |
|
487 | + $form_contents .= form_dropdown_all_search($fieldvalue [1], $drp_array, ''); |
|
488 | 488 | } |
489 | 489 | } else if ($fieldvalue [1] == 'PASSWORD') { |
490 | - $form_contents .= form_password ( $fieldvalue [2] ); |
|
490 | + $form_contents .= form_password($fieldvalue [2]); |
|
491 | 491 | } else if ($fieldvalue [2] == 'CHECKBOX') { |
492 | - $form_contents .= form_checkbox ( $fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked'] ); |
|
492 | + $form_contents .= form_checkbox($fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked']); |
|
493 | 493 | } |
494 | 494 | $form_contents .= '</div>'; |
495 | 495 | if ($i % 5 == 0) { |
496 | 496 | $form_contents .= '</li>'; |
497 | 497 | $i = 0; |
498 | 498 | } |
499 | - $i ++; |
|
499 | + $i++; |
|
500 | 500 | } |
501 | 501 | } |
502 | 502 | $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">'; |
503 | - $form_contents .= form_button ( $cancel ); |
|
504 | - $form_contents .= form_button ( $save ); |
|
505 | - if (! empty ( $display_in )) { |
|
503 | + $form_contents .= form_button($cancel); |
|
504 | + $form_contents .= form_button($save); |
|
505 | + if ( ! empty ($display_in)) { |
|
506 | 506 | $form_contents .= "<div class='col-md-5 pull-right'>"; |
507 | 507 | $form_contents .= "<div class='col-md-3'></div>"; |
508 | 508 | $extra_parameters ['class'] = $display_in ['label_class']; |
509 | 509 | $extra_parameters ['style'] = $display_in ['label_style']; |
510 | - $form_contents .= form_label ( $display_in ['content'], "", $extra_parameters ); |
|
511 | - $drp_array = call_user_func_array ( array ( |
|
510 | + $form_contents .= form_label($display_in ['content'], "", $extra_parameters); |
|
511 | + $drp_array = call_user_func_array(array( |
|
512 | 512 | $this->CI->common, |
513 | 513 | $display_in ['function'] |
514 | - ), array () ); |
|
514 | + ), array()); |
|
515 | 515 | $extra_parameters ['class'] = $display_in ['dropdown_class']; |
516 | 516 | $extra_parameters ['style'] = $display_in ['dropdown_style']; |
517 | - $form_contents .= form_dropdown_all_search ( $display_in, $drp_array, '', $extra_parameters ); |
|
517 | + $form_contents .= form_dropdown_all_search($display_in, $drp_array, '', $extra_parameters); |
|
518 | 518 | $form_contents .= "</div>"; |
519 | 519 | } |
520 | - if (isset ( $button_search_delete ) && $button_search_delete != '') { |
|
521 | - $form_contents .= form_button ( $button_search_delete ); |
|
520 | + if (isset ($button_search_delete) && $button_search_delete != '') { |
|
521 | + $form_contents .= form_button($button_search_delete); |
|
522 | 522 | } |
523 | 523 | $form_contents .= '<div class="col-md-12 no-padding margin-t-15" style=""> |
524 | - <div class="pull-right btn-close" id="global_clearsearch_filter">' . gettext ( 'Close' ) . '</div> |
|
524 | + <div class="pull-right btn-close" id="global_clearsearch_filter">' . gettext('Close').'</div> |
|
525 | 525 | </div>'; |
526 | 526 | $form_contents .= '</ul>'; |
527 | 527 | $form_contents .= '</div>'; |
528 | - $form_contents .= form_fieldset_close (); |
|
529 | - $form_contents .= form_close (); |
|
528 | + $form_contents .= form_fieldset_close(); |
|
529 | + $form_contents .= form_close(); |
|
530 | 530 | $form_contents .= '</div>'; |
531 | 531 | |
532 | 532 | return $form_contents; |
@@ -534,56 +534,56 @@ discard block |
||
534 | 534 | function build_batchupdate_form($fields_array) { |
535 | 535 | $form_contents = ''; |
536 | 536 | $form_contents .= '<div >'; |
537 | - $form_contents .= form_open ( $fields_array ['forms'] [0], $fields_array ['forms'] [1] ); |
|
538 | - unset ( $fields_array ['forms'] ); |
|
539 | - $button_array = array (); |
|
540 | - if (isset ( $fields_array ['button_search'] ) || isset ( $fields_array ['button_reset'] )) { |
|
537 | + $form_contents .= form_open($fields_array ['forms'] [0], $fields_array ['forms'] [1]); |
|
538 | + unset ($fields_array ['forms']); |
|
539 | + $button_array = array(); |
|
540 | + if (isset ($fields_array ['button_search']) || isset ($fields_array ['button_reset'])) { |
|
541 | 541 | $save = $fields_array ['button_search']; |
542 | - unset ( $fields_array ['button_search'] ); |
|
542 | + unset ($fields_array ['button_search']); |
|
543 | 543 | if ($fields_array ['button_reset']) { |
544 | 544 | $cancel = $fields_array ['button_reset']; |
545 | - unset ( $fields_array ['button_reset'] ); |
|
545 | + unset ($fields_array ['button_reset']); |
|
546 | 546 | } |
547 | 547 | } |
548 | 548 | $i = 1; |
549 | - foreach ( $fields_array as $fieldset_key => $form_fileds ) { |
|
549 | + foreach ($fields_array as $fieldset_key => $form_fileds) { |
|
550 | 550 | $form_contents .= '<div class="col-md-12 no-padding margin-t-12" style="margin-bottom:10px; !important"> |
551 | 551 | <div class="pull-right close" id="global_clearbatchupdate_filter">×</div></div>'; |
552 | 552 | |
553 | 553 | $form_contents .= '<ul>'; |
554 | - $form_contents .= form_fieldset ( gettext ( $fieldset_key ), array ( |
|
554 | + $form_contents .= form_fieldset(gettext($fieldset_key), array( |
|
555 | 555 | 'style' => 'margin-left:-22px;font-weight:bold;' |
556 | - ) ); |
|
557 | - foreach ( $form_fileds as $fieldkey => $fieldvalue ) { |
|
556 | + )); |
|
557 | + foreach ($form_fileds as $fieldkey => $fieldvalue) { |
|
558 | 558 | if ($i == 0) { |
559 | 559 | $form_contents .= '<li>'; |
560 | 560 | } |
561 | 561 | $form_contents .= '<div class="col-md-4 no-padding">'; |
562 | 562 | if ($fieldvalue [1] == 'HIDDEN') { |
563 | - $form_contents .= form_hidden ( $fieldvalue [2], $fieldvalue [3] ); |
|
563 | + $form_contents .= form_hidden($fieldvalue [2], $fieldvalue [3]); |
|
564 | 564 | } else { |
565 | - $form_contents .= form_label ( gettext ( $fieldvalue [0] ), "", array ( |
|
565 | + $form_contents .= form_label(gettext($fieldvalue [0]), "", array( |
|
566 | 566 | "class" => "search_label col-md-12 no-padding" |
567 | - ) ); |
|
567 | + )); |
|
568 | 568 | } |
569 | 569 | if ($fieldvalue [2] == 'SELECT' || $fieldvalue [5] == '1') { |
570 | 570 | if ($fieldvalue [7] != '' && $fieldvalue [8] != '') { |
571 | - $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
|
572 | - if (is_array ( $fieldvalue [13] )) { |
|
573 | - $drp_array = call_user_func_array ( array ( |
|
571 | + $str = $fieldvalue [7].",".$fieldvalue [8]; |
|
572 | + if (is_array($fieldvalue [13])) { |
|
573 | + $drp_array = call_user_func_array(array( |
|
574 | 574 | $this->CI->common, |
575 | 575 | $fieldvalue [14] |
576 | - ), array ( |
|
576 | + ), array( |
|
577 | 577 | $fieldvalue [13] |
578 | - ) ); |
|
579 | - $form_contents .= form_dropdown ( $fieldvalue [13], $drp_array, '' ); |
|
578 | + )); |
|
579 | + $form_contents .= form_dropdown($fieldvalue [13], $drp_array, ''); |
|
580 | 580 | } |
581 | 581 | /** |
582 | 582 | * ASTPP 3.0 |
583 | 583 | * Reseller Batch Update |
584 | 584 | */ |
585 | 585 | if ($fieldvalue [10] == 'set_status') { |
586 | - $drp_array = array ( |
|
586 | + $drp_array = array( |
|
587 | 587 | '0' => 'Active', |
588 | 588 | '1' => 'Inactive' |
589 | 589 | ); |
@@ -591,59 +591,59 @@ discard block |
||
591 | 591 | * ********************************************************* |
592 | 592 | */ |
593 | 593 | else { |
594 | - $drp_array = call_user_func_array ( array ( |
|
594 | + $drp_array = call_user_func_array(array( |
|
595 | 595 | $this->CI->db_model, |
596 | 596 | $fieldvalue [10] |
597 | - ), array ( |
|
597 | + ), array( |
|
598 | 598 | $str, |
599 | 599 | $fieldvalue [9], |
600 | 600 | $fieldvalue [11], |
601 | 601 | $fieldvalue [12] |
602 | - ) ); |
|
602 | + )); |
|
603 | 603 | } |
604 | - $form_contents .= form_dropdown_all ( $fieldvalue [1], $drp_array, '' ); |
|
604 | + $form_contents .= form_dropdown_all($fieldvalue [1], $drp_array, ''); |
|
605 | 605 | } else { |
606 | 606 | if ($fieldvalue [1] == 'INPUT') { |
607 | 607 | $drp_name = $fieldvalue [6]; |
608 | 608 | } |
609 | - $drp_array = call_user_func_array ( array ( |
|
609 | + $drp_array = call_user_func_array(array( |
|
610 | 610 | $this->CI->common, |
611 | 611 | $fieldvalue [10] |
612 | - ), array ( |
|
612 | + ), array( |
|
613 | 613 | $fieldvalue [9] |
614 | - ) ); |
|
615 | - $form_contents .= form_dropdown ( $drp_name, $drp_array, '' ); |
|
614 | + )); |
|
615 | + $form_contents .= form_dropdown($drp_name, $drp_array, ''); |
|
616 | 616 | } |
617 | 617 | } |
618 | 618 | if ($fieldvalue [1] == 'INPUT') { |
619 | - $form_contents .= form_input ( $fieldvalue [2] ); |
|
619 | + $form_contents .= form_input($fieldvalue [2]); |
|
620 | 620 | } else if ($fieldvalue [2] == 'CHECKBOX') { |
621 | - $form_contents .= form_checkbox ( $fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked'] ); |
|
621 | + $form_contents .= form_checkbox($fieldvalue [1], $fieldvalue [3] ['value'], $fieldvalue [3] ['checked']); |
|
622 | 622 | } |
623 | 623 | $form_contents .= '</div>'; |
624 | 624 | if ($i % 5 == 0) { |
625 | 625 | $form_contents .= '</li>'; |
626 | 626 | $i = 0; |
627 | 627 | } |
628 | - $i ++; |
|
628 | + $i++; |
|
629 | 629 | } |
630 | 630 | } |
631 | 631 | |
632 | 632 | $form_contents .= '</ul>'; |
633 | 633 | $form_contents .= '<div class="col-md-12 margin-t-20 margin-b-20">'; |
634 | 634 | |
635 | - $form_contents .= form_button ( $cancel ); |
|
636 | - $form_contents .= form_button ( $save ); |
|
635 | + $form_contents .= form_button($cancel); |
|
636 | + $form_contents .= form_button($save); |
|
637 | 637 | |
638 | - $form_contents .= form_fieldset_close (); |
|
639 | - $form_contents .= form_close (); |
|
638 | + $form_contents .= form_fieldset_close(); |
|
639 | + $form_contents .= form_close(); |
|
640 | 640 | $form_contents .= '</div>'; |
641 | 641 | $form_contents .= '</div>'; |
642 | 642 | |
643 | 643 | return $form_contents; |
644 | 644 | } |
645 | 645 | function load_grid_config($count_all, $rp, $page) { |
646 | - $json_data = array (); |
|
646 | + $json_data = array(); |
|
647 | 647 | $config ['total_rows'] = $count_all; |
648 | 648 | $config ['per_page'] = $rp; |
649 | 649 | |
@@ -660,30 +660,30 @@ discard block |
||
660 | 660 | return $json_data; |
661 | 661 | } |
662 | 662 | function build_grid($query, $grid_fields) { |
663 | - $jsn_tmp = array (); |
|
664 | - $json_data = array (); |
|
663 | + $jsn_tmp = array(); |
|
664 | + $json_data = array(); |
|
665 | 665 | if ($query->num_rows > 0) { |
666 | - foreach ( $query->result_array () as $row ) { |
|
666 | + foreach ($query->result_array() as $row) { |
|
667 | 667 | /* |
668 | 668 | * ASTPP 3.0 |
669 | 669 | * For Edit on Account number or name |
670 | 670 | */ |
671 | - $row_id = isset ( $row ['id'] ) ? $row ["id"] : ''; |
|
671 | + $row_id = isset ($row ['id']) ? $row ["id"] : ''; |
|
672 | 672 | /** |
673 | 673 | * ************************** |
674 | 674 | */ |
675 | - foreach ( $grid_fields as $field_key => $field_arr ) { |
|
675 | + foreach ($grid_fields as $field_key => $field_arr) { |
|
676 | 676 | /** |
677 | 677 | * ASTPP 3.0 |
678 | 678 | * For Edit on Account number or name |
679 | 679 | * * |
680 | 680 | */ |
681 | - $Actionkey = array_search ( 'Action', $this->CI->common->array_column ( $grid_fields, 0 ) ); |
|
681 | + $Actionkey = array_search('Action', $this->CI->common->array_column($grid_fields, 0)); |
|
682 | 682 | if ($Actionkey == '') { |
683 | - $Actionkey = array_search ( 'action', $this->CI->common->array_column ( $grid_fields, 0 ) ); |
|
683 | + $Actionkey = array_search('action', $this->CI->common->array_column($grid_fields, 0)); |
|
684 | 684 | } |
685 | 685 | if ($Actionkey == '') { |
686 | - $Actionkey = array_search ( 'Acción', $this->CI->common->array_column ( $grid_fields, 0 ) ); |
|
686 | + $Actionkey = array_search('Acción', $this->CI->common->array_column($grid_fields, 0)); |
|
687 | 687 | } |
688 | 688 | /** |
689 | 689 | * ****************************** |
@@ -692,23 +692,23 @@ discard block |
||
692 | 692 | if ($field_arr [3] != "") { |
693 | 693 | if ($field_arr [2] == "status") { |
694 | 694 | $row ['id'] = $row_id; |
695 | - $jsn_tmp [$field_key] = call_user_func_array ( array ( |
|
695 | + $jsn_tmp [$field_key] = call_user_func_array(array( |
|
696 | 696 | $this->CI->common, |
697 | 697 | $field_arr [5] |
698 | - ), array ( |
|
698 | + ), array( |
|
699 | 699 | $field_arr [3], |
700 | 700 | $field_arr [4], |
701 | 701 | $row |
702 | - ) ); |
|
702 | + )); |
|
703 | 703 | } else { |
704 | - $jsn_tmp [$field_key] = call_user_func_array ( array ( |
|
704 | + $jsn_tmp [$field_key] = call_user_func_array(array( |
|
705 | 705 | $this->CI->common, |
706 | 706 | $field_arr [5] |
707 | - ), array ( |
|
707 | + ), array( |
|
708 | 708 | $field_arr [3], |
709 | 709 | $field_arr [4], |
710 | 710 | $row [$field_arr [2]] |
711 | - ) ); |
|
711 | + )); |
|
712 | 712 | } |
713 | 713 | |
714 | 714 | /** |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | */ |
719 | 719 | $row [$field_arr [2]] = $jsn_tmp [$field_key]; |
720 | 720 | } |
721 | - if (array_search ( "EDITABLE", $field_arr )) { |
|
721 | + if (array_search("EDITABLE", $field_arr)) { |
|
722 | 722 | $ActionArr = $grid_fields [$Actionkey]; |
723 | 723 | if ($ActionArr [5]->EDIT->url == "accounts/customer_edit/" || $ActionArr [5]->EDIT->url == "accounts/provider_edit/") { |
724 | 724 | $ActionArr [5]->EDIT->url = $row ['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/"; |
@@ -727,13 +727,13 @@ discard block |
||
727 | 727 | $ActionArr [5]->EDIT->url = $row ['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/"; |
728 | 728 | } |
729 | 729 | $acctype = ""; |
730 | - if (isset ( $row ["type"] ) && ($row ["type"] == '0' || $row ["type"] == '1' || $row ["type"] == '3')) { |
|
731 | - $acctype = (isset ( $row ["posttoexternal"] ) && $row ["posttoexternal"] != '') ? "<span class='label label-default pull-right'>" . $this->CI->common->get_account_type ( "", "", $row ["posttoexternal"] ) . "</span>" : ""; |
|
730 | + if (isset ($row ["type"]) && ($row ["type"] == '0' || $row ["type"] == '1' || $row ["type"] == '3')) { |
|
731 | + $acctype = (isset ($row ["posttoexternal"]) && $row ["posttoexternal"] != '') ? "<span class='label label-default pull-right'>".$this->CI->common->get_account_type("", "", $row ["posttoexternal"])."</span>" : ""; |
|
732 | 732 | } |
733 | 733 | |
734 | - $fieldstr = $this->CI->common->build_custome_edit_button ( $ActionArr [5]->EDIT, $row [$field_arr [2]], $row ["id"] ); |
|
734 | + $fieldstr = $this->CI->common->build_custome_edit_button($ActionArr [5]->EDIT, $row [$field_arr [2]], $row ["id"]); |
|
735 | 735 | if ($acctype != '') { |
736 | - $jsn_tmp [$field_key] = $fieldstr . "<br/>" . $acctype; |
|
736 | + $jsn_tmp [$field_key] = $fieldstr."<br/>".$acctype; |
|
737 | 737 | } else { |
738 | 738 | $jsn_tmp [$field_key] = $fieldstr; |
739 | 739 | } |
@@ -745,25 +745,25 @@ discard block |
||
745 | 745 | $jsn_tmp [$field_key] = $row [$field_arr [2]]; |
746 | 746 | } |
747 | 747 | } else { |
748 | - if ($field_arr [0] == gettext ( "Action" )) { |
|
749 | - if (isset ( $field_arr [5] ) && isset ( $field_arr [5]->EDIT ) && isset ( $field_arr [5]->DELETE )) { |
|
748 | + if ($field_arr [0] == gettext("Action")) { |
|
749 | + if (isset ($field_arr [5]) && isset ($field_arr [5]->EDIT) && isset ($field_arr [5]->DELETE)) { |
|
750 | 750 | |
751 | 751 | if ($field_arr [5]->EDIT->url == 'accounts/customer_edit/' || $field_arr [5]->EDIT->url == 'accounts/provider_edit/' || $field_arr [5]->DELETE->url == 'accounts/provider_delete/' || $field_arr [5]->DELETE->url == 'accounts/customer_delete/') { |
752 | - if ($row ['type'] == '0' || strtolower ( $row ['type'] ) == 'customer') { |
|
752 | + if ($row ['type'] == '0' || strtolower($row ['type']) == 'customer') { |
|
753 | 753 | $field_arr [5]->EDIT->url = 'accounts/customer_edit/'; |
754 | 754 | $field_arr [5]->DELETE->url = 'accounts/customer_delete/'; |
755 | 755 | } |
756 | - if ($row ['type'] == 3 || strtolower ( $row ['type'] ) == 'provider') { |
|
756 | + if ($row ['type'] == 3 || strtolower($row ['type']) == 'provider') { |
|
757 | 757 | $field_arr [5]->EDIT->url = 'accounts/provider_edit/'; |
758 | 758 | $field_arr [5]->DELETE->url = 'accounts/provider_delete/'; |
759 | 759 | } |
760 | 760 | } |
761 | 761 | if ($field_arr [5]->EDIT->url == 'accounts/admin_edit/' || $field_arr [5]->EDIT->url == 'accounts/subadmin_edit/' || $field_arr [5]->DELETE->url == 'accounts/admin_delete/' || $field_arr [5]->DELETE->url == 'accounts/subadmin_delete/') { |
762 | - if ($row ['type'] == 2 || strtolower ( $row ['type'] ) == 'administrator') { |
|
762 | + if ($row ['type'] == 2 || strtolower($row ['type']) == 'administrator') { |
|
763 | 763 | $field_arr [5]->EDIT->url = 'accounts/admin_edit/'; |
764 | 764 | $field_arr [5]->DELETE->url = 'accounts/admin_delete/'; |
765 | 765 | } |
766 | - if ($row ['type'] == 4 || strtolower ( $row ['type'] ) == 'sub admin') { |
|
766 | + if ($row ['type'] == 4 || strtolower($row ['type']) == 'sub admin') { |
|
767 | 767 | $field_arr [5]->EDIT->url = 'accounts/subadmin_edit/'; |
768 | 768 | $field_arr [5]->DELETE->url = 'accounts/subadmin_delete/'; |
769 | 769 | } |
@@ -773,22 +773,22 @@ discard block |
||
773 | 773 | * ASTPP 3.0 |
774 | 774 | * For edit on account number or name |
775 | 775 | */ |
776 | - $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons ( $field_arr [5], $row_id ); |
|
776 | + $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons($field_arr [5], $row_id); |
|
777 | 777 | /** |
778 | 778 | * ************************************************************************* |
779 | 779 | */ |
780 | - } elseif ($field_arr [0] == gettext ( "Profile Action" )) { |
|
781 | - if (isset ( $field_arr [5] ) && isset ( $field_arr [5]->START ) && isset ( $field_arr [5]->STOP ) && isset ( $field_arr [5]->RELOAD ) && isset ( $field_arr [5]->RESCAN )) { |
|
780 | + } elseif ($field_arr [0] == gettext("Profile Action")) { |
|
781 | + if (isset ($field_arr [5]) && isset ($field_arr [5]->START) && isset ($field_arr [5]->STOP) && isset ($field_arr [5]->RELOAD) && isset ($field_arr [5]->RESCAN)) { |
|
782 | 782 | } |
783 | - $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons ( $field_arr [5], $row ["id"] ); |
|
783 | + $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons($field_arr [5], $row ["id"]); |
|
784 | 784 | } else { |
785 | - $className = (isset ( $field_arr ['9'] ) && $field_arr ['9'] != '') ? $field_arr ['9'] : "chkRefNos"; |
|
785 | + $className = (isset ($field_arr ['9']) && $field_arr ['9'] != '') ? $field_arr ['9'] : "chkRefNos"; |
|
786 | 786 | |
787 | - $jsn_tmp [$field_key] = '<input type="checkbox" name="chkAll" id=' . $row ['id'] . ' class="ace ' . $className . '" onclick="clickchkbox(' . $row ['id'] . ')" value=' . $row ['id'] . '><lable class="lbl"></lable>'; |
|
787 | + $jsn_tmp [$field_key] = '<input type="checkbox" name="chkAll" id='.$row ['id'].' class="ace '.$className.'" onclick="clickchkbox('.$row ['id'].')" value='.$row ['id'].'><lable class="lbl"></lable>'; |
|
788 | 788 | } |
789 | 789 | } |
790 | 790 | } |
791 | - $json_data [] = array ( |
|
791 | + $json_data [] = array( |
|
792 | 792 | 'cell' => $jsn_tmp |
793 | 793 | ); |
794 | 794 | } |
@@ -796,17 +796,17 @@ discard block |
||
796 | 796 | return $json_data; |
797 | 797 | } |
798 | 798 | function build_json_grid($query, $grid_fields) { |
799 | - $jsn_tmp = array (); |
|
800 | - $json_data = array (); |
|
801 | - foreach ( $query as $row ) { |
|
802 | - foreach ( $grid_fields as $field_key => $field_arr ) { |
|
803 | - $row_id = isset ( $row ['id'] ) ? $row ["id"] : ''; |
|
799 | + $jsn_tmp = array(); |
|
800 | + $json_data = array(); |
|
801 | + foreach ($query as $row) { |
|
802 | + foreach ($grid_fields as $field_key => $field_arr) { |
|
803 | + $row_id = isset ($row ['id']) ? $row ["id"] : ''; |
|
804 | 804 | /** |
805 | 805 | * ASTPP 3.0 |
806 | 806 | * For Edit on Account number or name |
807 | 807 | * * |
808 | 808 | */ |
809 | - $Actionkey = array_search ( 'Action', $this->CI->common->array_column ( $grid_fields, 0 ) ); |
|
809 | + $Actionkey = array_search('Action', $this->CI->common->array_column($grid_fields, 0)); |
|
810 | 810 | /** |
811 | 811 | * **************************** |
812 | 812 | */ |
@@ -815,23 +815,23 @@ discard block |
||
815 | 815 | if ($field_arr [3] != "") { |
816 | 816 | if ($field_arr [2] == "status") { |
817 | 817 | $row ['id'] = $row_id; |
818 | - $jsn_tmp [$field_key] = call_user_func_array ( array ( |
|
818 | + $jsn_tmp [$field_key] = call_user_func_array(array( |
|
819 | 819 | $this->CI->common, |
820 | 820 | $field_arr [5] |
821 | - ), array ( |
|
821 | + ), array( |
|
822 | 822 | $field_arr [3], |
823 | 823 | $field_arr [4], |
824 | 824 | $row |
825 | - ) ); |
|
825 | + )); |
|
826 | 826 | } else { |
827 | - $jsn_tmp [$field_key] = call_user_func_array ( array ( |
|
827 | + $jsn_tmp [$field_key] = call_user_func_array(array( |
|
828 | 828 | $this->CI->common, |
829 | 829 | $field_arr [5] |
830 | - ), array ( |
|
830 | + ), array( |
|
831 | 831 | $field_arr [3], |
832 | 832 | $field_arr [4], |
833 | 833 | $row [$field_arr [2]] |
834 | - ) ); |
|
834 | + )); |
|
835 | 835 | } |
836 | 836 | /** |
837 | 837 | * ASTPP 3.0 |
@@ -840,7 +840,7 @@ discard block |
||
840 | 840 | */ |
841 | 841 | $row [$field_arr [2]] = $jsn_tmp [$field_key]; |
842 | 842 | } |
843 | - if (array_search ( "EDITABLE", $field_arr )) { |
|
843 | + if (array_search("EDITABLE", $field_arr)) { |
|
844 | 844 | $ActionArr = $grid_fields [$Actionkey]; |
845 | 845 | if ($ActionArr [5]->EDIT->url == "accounts/customer_edit/" || $ActionArr [5]->EDIT->url == "accounts/provider_edit/") { |
846 | 846 | $ActionArr [5]->EDIT->url = $row ['type'] == 0 ? "accounts/customer_edit/" : "accounts/provider_edit/"; |
@@ -848,22 +848,22 @@ discard block |
||
848 | 848 | if ($ActionArr [5]->EDIT->url == "accounts/admin_edit/" || $ActionArr [5]->EDIT->url == "accounts/subadmin_edit/") { |
849 | 849 | $ActionArr [5]->EDIT->url = $row ['type'] == 4 ? "accounts/subadmin_edit/" : "accounts/admin_edit/"; |
850 | 850 | } |
851 | - $jsn_tmp [$field_key] = $this->CI->common->build_custome_edit_button ( $ActionArr [5]->EDIT, $row [$field_arr [2]], $row ["id"] ); |
|
851 | + $jsn_tmp [$field_key] = $this->CI->common->build_custome_edit_button($ActionArr [5]->EDIT, $row [$field_arr [2]], $row ["id"]); |
|
852 | 852 | /** |
853 | 853 | * **************************** |
854 | 854 | */ |
855 | 855 | } else { |
856 | - $jsn_tmp [$field_key] = isset ( $row [$field_arr [2]] ) ? $row [$field_arr [2]] : ""; |
|
856 | + $jsn_tmp [$field_key] = isset ($row [$field_arr [2]]) ? $row [$field_arr [2]] : ""; |
|
857 | 857 | } |
858 | 858 | } else { |
859 | 859 | if ($field_arr [0] == "Action") { |
860 | - $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons ( $field_arr [5], $row ["id"] ); |
|
860 | + $jsn_tmp [$field_key] = $this->CI->common->get_action_buttons($field_arr [5], $row ["id"]); |
|
861 | 861 | } else { |
862 | - $jsn_tmp [$field_key] = '<input type="checkbox" name="chkAll" id=' . $row ['id'] . ' class="ace chkRefNos" onclick="clickchkbox(' . $row ['id'] . ')" value=' . $row ['id'] . '><lable class="lbl"></lable>'; |
|
862 | + $jsn_tmp [$field_key] = '<input type="checkbox" name="chkAll" id='.$row ['id'].' class="ace chkRefNos" onclick="clickchkbox('.$row ['id'].')" value='.$row ['id'].'><lable class="lbl"></lable>'; |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | } |
866 | - $json_data [] = array ( |
|
866 | + $json_data [] = array( |
|
867 | 867 | 'cell' => $jsn_tmp |
868 | 868 | ); |
869 | 869 | } |
@@ -20,8 +20,9 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
23 | +if (! defined ( 'BASEPATH' )) { |
|
24 | 24 | exit ( 'No direct script access allowed' ); |
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * Dynamically build forms for display |
@@ -134,10 +135,11 @@ discard block |
||
134 | 135 | if (isset ( $fieldvalue ) && $fieldvalue != '') { |
135 | 136 | $form_contents .= '<li class="col-md-12">'; |
136 | 137 | if ($fieldvalue [1] == 'HIDDEN') { |
137 | - if (isset ( $this->CI->input->post )) |
|
138 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
139 | - else |
|
140 | - $fieldvalue [2] ['value'] = ($values) ? (isset ( $values [$fieldvalue [2] ['name']] ) ? $values [$fieldvalue [2] ['name']] : '') : (isset ( $fieldvalue [2] ['value'] ) ? $fieldvalue [2] ['value'] : ''); |
|
138 | + if (isset ( $this->CI->input->post )) { |
|
139 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
140 | + } else { |
|
141 | + $fieldvalue [2] ['value'] = ($values) ? (isset ( $values [$fieldvalue [2] ['name']] ) ? $values [$fieldvalue [2] ['name']] : '') : (isset ( $fieldvalue [2] ['value'] ) ? $fieldvalue [2] ['value'] : ''); |
|
142 | + } |
|
141 | 143 | $form_contents .= form_hidden ( $fieldvalue [2] ['name'], $fieldvalue [2] ['value'] ); |
142 | 144 | } else { |
143 | 145 | $validation_arr = array (); |
@@ -259,10 +261,11 @@ discard block |
||
259 | 261 | /* For multi select code */ |
260 | 262 | $str = $fieldvalue [7] . "," . $fieldvalue [8]; |
261 | 263 | |
262 | - if (isset ( $this->CI->input->post )) |
|
263 | - $fieldvalue ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [1] : $this->CI->input->post ( $fieldvalue [1] ); |
|
264 | - else |
|
265 | - $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1]] : @$fieldvalue [1]; |
|
264 | + if (isset ( $this->CI->input->post )) { |
|
265 | + $fieldvalue ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [1] : $this->CI->input->post ( $fieldvalue [1] ); |
|
266 | + } else { |
|
267 | + $fieldvalue ['value'] = ($values) ? @$values [$fieldvalue [1]] : @$fieldvalue [1]; |
|
268 | + } |
|
266 | 269 | |
267 | 270 | $drp_array = call_user_func_array ( array ( |
268 | 271 | $this->CI->db_model, |
@@ -286,9 +289,9 @@ discard block |
||
286 | 289 | /* End--------------------- For multi select code */ |
287 | 290 | } else if ($fieldvalue [1] == 'INPUT') { |
288 | 291 | |
289 | - if (isset ( $this->CI->input->post )) |
|
290 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? $fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
291 | - else { |
|
292 | + if (isset ( $this->CI->input->post )) { |
|
293 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? $fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
294 | + } else { |
|
292 | 295 | $fieldvalue [2] ['value'] = ($values) ? (isset ( $values [$fieldvalue [2] ['name']] ) ? $values [$fieldvalue [2] ['name']] : '') : (isset ( $fieldvalue [2] ['value'] ) ? $fieldvalue [2] ['value'] : ''); |
293 | 296 | } |
294 | 297 | $form_contents .= form_input ( $fieldvalue [2], 'readonly' ); |
@@ -303,11 +306,11 @@ discard block |
||
303 | 306 | * Image upload from invoice configuration code. |
304 | 307 | */ |
305 | 308 | else if ($fieldvalue [1] == 'IMAGE') { |
306 | - if (isset ( $this->CI->input->post )) |
|
307 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
308 | - |
|
309 | - else |
|
310 | - $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
309 | + if (isset ( $this->CI->input->post )) { |
|
310 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
311 | + } else { |
|
312 | + $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
313 | + } |
|
311 | 314 | $fieldvalue [2] ['style'] = isset ( $fieldvalue [2] ['style'] ) ? $fieldvalue [2] ['style'] : ""; |
312 | 315 | $form_contents .= form_image ( $fieldvalue [2], 'readonly', $fieldvalue [2] ['style'] ); |
313 | 316 | $form_contents .= @$fieldvalue [6]; |
@@ -316,11 +319,11 @@ discard block |
||
316 | 319 | $form_contents .= '<span class="popup_error error no-padding" id="' . $fieldvalue [2] ['name'] . '_error"> |
317 | 320 | </span></div>'; |
318 | 321 | } else if ($fieldvalue [1] == 'DEL_BUTTON') { |
319 | - if (isset ( $this->CI->input->post )) |
|
320 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
321 | - |
|
322 | - else |
|
323 | - $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
322 | + if (isset ( $this->CI->input->post )) { |
|
323 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
324 | + } else { |
|
325 | + $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
326 | + } |
|
324 | 327 | $fieldvalue [2] ['style'] = isset ( $fieldvalue [2] ['style'] ) ? $fieldvalue [2] ['style'] : ""; |
325 | 328 | $form_contents .= form_img_delete ( $fieldvalue [2], 'readonly', $fieldvalue [2] ['style'] ); |
326 | 329 | $form_contents .= @$fieldvalue [6]; |
@@ -332,10 +335,11 @@ discard block |
||
332 | 335 | * ******************************************************************************* |
333 | 336 | */ |
334 | 337 | else if ($fieldvalue [1] == 'PASSWORD') { |
335 | - if (isset ( $this->CI->input->post )) |
|
336 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
337 | - else |
|
338 | - $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
338 | + if (isset ( $this->CI->input->post )) { |
|
339 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
340 | + } else { |
|
341 | + $fieldvalue [2] ['value'] = ($values) ? @$values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
342 | + } |
|
339 | 343 | $form_contents .= form_password ( $fieldvalue [2] ); |
340 | 344 | $this->CI->form_validation->set_rules ( $fieldvalue [2] ['name'], $fieldvalue [0], $fieldvalue [3] ); |
341 | 345 | $form_contents .= '<div class="tooltips error_div pull-left no-padding" id="' . $fieldvalue [2] ['name'] . '_error_div" ><i style="color:#D95C5C; padding-left: 3px; padding-top: 10px;" class="fa fa-exclamation-triangle"></i>'; |
@@ -344,13 +348,14 @@ discard block |
||
344 | 348 | } else if ($fieldvalue [2] == 'CHECKBOX') { |
345 | 349 | $OptionArray = array (); |
346 | 350 | |
347 | - if (isset ( $fieldvalue [7] ) && $fieldvalue [7] != '') |
|
348 | - $OptionArray = call_user_func_array ( array ( |
|
351 | + if (isset ( $fieldvalue [7] ) && $fieldvalue [7] != '') { |
|
352 | + $OptionArray = call_user_func_array ( array ( |
|
349 | 353 | $this->CI->common, |
350 | 354 | $fieldvalue [7] |
351 | 355 | ), array ( |
352 | 356 | $fieldvalue [6] |
353 | 357 | ) ); |
358 | + } |
|
354 | 359 | if (isset ( $this->CI->input->post )) { |
355 | 360 | $fieldvalue [3] ['value'] = (! $this->CI->input->post ( $fieldvalue [1] )) ? @$fieldvalue [3] ['value'] : $this->CI->input->post ( $fieldvalue [1] ); |
356 | 361 | } else { |
@@ -370,10 +375,11 @@ discard block |
||
370 | 375 | } |
371 | 376 | } else if ($fieldvalue [1] == 'TEXTAREA') { |
372 | 377 | |
373 | - if (isset ( $this->CI->input->post )) |
|
374 | - $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
375 | - else |
|
376 | - $fieldvalue [2] ['value'] = ($values) ? $values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
378 | + if (isset ( $this->CI->input->post )) { |
|
379 | + $fieldvalue [2] ['value'] = (! $this->CI->input->post ( $fieldvalue [2] ['name'] )) ? @$fieldvalue [2] ['value'] : $this->CI->input->post ( $fieldvalue [2] ['name'] ); |
|
380 | + } else { |
|
381 | + $fieldvalue [2] ['value'] = ($values) ? $values [$fieldvalue [2] ['name']] : @$fieldvalue [2] ['value']; |
|
382 | + } |
|
377 | 383 | $form_contents .= form_textarea ( $fieldvalue [2] ); |
378 | 384 | } else if ($fieldvalue [2] == 'RADIO') { |
379 | 385 | |
@@ -653,8 +659,9 @@ discard block |
||
653 | 659 | $json_data ["json_paging"] ['total'] = $config ['total_rows']; |
654 | 660 | $perpage = $config ['per_page']; |
655 | 661 | $start = ($page_no - 1) * $perpage; |
656 | - if ($start < 0) |
|
657 | - $start = 0; |
|
662 | + if ($start < 0) { |
|
663 | + $start = 0; |
|
664 | + } |
|
658 | 665 | $json_data ["paging"] ['start'] = $start; |
659 | 666 | $json_data ["paging"] ['page_no'] = $perpage; |
660 | 667 | return $json_data; |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -defined ( 'BASEPATH' ) or exit ( 'No direct script access allowed' ); |
|
3 | +defined('BASEPATH') or exit ('No direct script access allowed'); |
|
4 | 4 | abstract class API_Controller extends CI_Controller { |
5 | 5 | |
6 | 6 | /** |
@@ -17,14 +17,14 @@ discard block |
||
17 | 17 | * |
18 | 18 | * @var array |
19 | 19 | */ |
20 | - protected $methods = array (); |
|
20 | + protected $methods = array(); |
|
21 | 21 | |
22 | 22 | /** |
23 | 23 | * List of allowed HTTP methods |
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $allowed_http_methods = array ( |
|
27 | + protected $allowed_http_methods = array( |
|
28 | 28 | 'get', |
29 | 29 | 'delete', |
30 | 30 | 'post', |
@@ -58,35 +58,35 @@ discard block |
||
58 | 58 | * |
59 | 59 | * @var array |
60 | 60 | */ |
61 | - protected $_get_args = array (); |
|
61 | + protected $_get_args = array(); |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * The arguments for the POST request method |
65 | 65 | * |
66 | 66 | * @var array |
67 | 67 | */ |
68 | - protected $_post_args = array (); |
|
68 | + protected $_post_args = array(); |
|
69 | 69 | |
70 | 70 | /** |
71 | 71 | * The arguments for the PUT request method |
72 | 72 | * |
73 | 73 | * @var array |
74 | 74 | */ |
75 | - protected $_put_args = array (); |
|
75 | + protected $_put_args = array(); |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * The arguments for the DELETE request method |
79 | 79 | * |
80 | 80 | * @var array |
81 | 81 | */ |
82 | - protected $_delete_args = array (); |
|
82 | + protected $_delete_args = array(); |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * The arguments from GET, POST, PUT, DELETE request methods combined. |
86 | 86 | * |
87 | 87 | * @var array |
88 | 88 | */ |
89 | - protected $_args = array (); |
|
89 | + protected $_args = array(); |
|
90 | 90 | |
91 | 91 | /** |
92 | 92 | * If the request is allowed based on the API key provided. |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | * |
108 | 108 | * @var array |
109 | 109 | */ |
110 | - protected $_supported_formats = array ( |
|
110 | + protected $_supported_formats = array( |
|
111 | 111 | 'xml' => 'application/xml', |
112 | 112 | 'json' => 'application/json', |
113 | 113 | 'jsonp' => 'application/javascript', |
@@ -123,72 +123,72 @@ discard block |
||
123 | 123 | * @todo Document more please. |
124 | 124 | */ |
125 | 125 | public function __construct() { |
126 | - parent::__construct (); |
|
126 | + parent::__construct(); |
|
127 | 127 | |
128 | 128 | // Loading my custom log class |
129 | - $this->load->library ( 'Api_log' ); |
|
129 | + $this->load->library('Api_log'); |
|
130 | 130 | |
131 | 131 | // Loading language file |
132 | - $this->lang->load ( 'api/api', config_item ( 'api_default_language' ) ); |
|
132 | + $this->lang->load('api/api', config_item('api_default_language')); |
|
133 | 133 | |
134 | 134 | // Lets grab the config and get ready to party |
135 | - $this->load->config ( 'api' ); |
|
135 | + $this->load->config('api'); |
|
136 | 136 | |
137 | 137 | // How is this request being made? POST, DELETE, GET, PUT? |
138 | - $this->request = new stdClass (); |
|
139 | - $this->request->method = $this->_detect_method (); |
|
138 | + $this->request = new stdClass(); |
|
139 | + $this->request->method = $this->_detect_method(); |
|
140 | 140 | |
141 | 141 | // Create argument container, if nonexistent |
142 | - if (! isset ( $this->{'_' . $this->request->method . '_args'} )) { |
|
143 | - $this->{'_' . $this->request->method . '_args'} = array (); |
|
142 | + if ( ! isset ($this->{'_'.$this->request->method.'_args'} )) { |
|
143 | + $this->{'_'.$this->request->method.'_args'} = array(); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | // Set up our GET variables |
147 | - $this->_get_args = array_merge ( $this->_get_args, $this->uri->ruri_to_assoc () ); |
|
147 | + $this->_get_args = array_merge($this->_get_args, $this->uri->ruri_to_assoc()); |
|
148 | 148 | |
149 | 149 | // $this->load->library('security'); |
150 | 150 | |
151 | 151 | // This library is bundled with api_Controller 2.5+, but will eventually be part of CodeIgniter itself |
152 | - $this->load->library ( 'format' ); |
|
152 | + $this->load->library('format'); |
|
153 | 153 | |
154 | 154 | // Try to find a format for the request (means we have a request body) |
155 | - $this->request->format = $this->_detect_input_format (); |
|
155 | + $this->request->format = $this->_detect_input_format(); |
|
156 | 156 | |
157 | 157 | // Some Methods cant have a body |
158 | 158 | $this->request->body = NULL; |
159 | 159 | |
160 | - $this->{'_parse_' . $this->request->method} (); |
|
160 | + $this->{'_parse_'.$this->request->method} (); |
|
161 | 161 | |
162 | 162 | // Now we know all about our request, let's try and parse the body if it exists |
163 | 163 | if ($this->request->format and $this->request->body) { |
164 | - $this->request->body = $this->format->factory ( $this->request->body, $this->request->format )->to_array (); |
|
164 | + $this->request->body = $this->format->factory($this->request->body, $this->request->format)->to_array(); |
|
165 | 165 | // Assign payload arguments to proper method container |
166 | - $this->{'_' . $this->request->method . '_args'} = $this->request->body; |
|
166 | + $this->{'_'.$this->request->method.'_args'} = $this->request->body; |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | // Merge both for one mega-args variable |
170 | - $this->_args = array_merge ( $this->_get_args, $this->_put_args, $this->_post_args, $this->_delete_args, $this->{'_' . $this->request->method . '_args'} ); |
|
170 | + $this->_args = array_merge($this->_get_args, $this->_put_args, $this->_post_args, $this->_delete_args, $this->{'_'.$this->request->method.'_args'} ); |
|
171 | 171 | |
172 | 172 | // Which format should the data be returned in? |
173 | - $this->response = new stdClass (); |
|
174 | - $this->response->format = $this->_detect_output_format (); |
|
173 | + $this->response = new stdClass(); |
|
174 | + $this->response->format = $this->_detect_output_format(); |
|
175 | 175 | |
176 | 176 | // Which format should the data be returned in? |
177 | - $this->response->lang = $this->_detect_lang (); |
|
177 | + $this->response->lang = $this->_detect_lang(); |
|
178 | 178 | |
179 | 179 | // Developers can extend this class and add a check in here |
180 | - $this->early_checks (); |
|
180 | + $this->early_checks(); |
|
181 | 181 | |
182 | - $this->api = new StdClass (); |
|
182 | + $this->api = new StdClass(); |
|
183 | 183 | // Load DB if its enabled |
184 | 184 | $this->api->db = $this->db; |
185 | 185 | |
186 | 186 | // only allow ajax requests |
187 | - if (! $this->input->is_ajax_request () and config_item ( 'api_ajax_only' )) { |
|
188 | - $this->response ( array ( |
|
187 | + if ( ! $this->input->is_ajax_request() and config_item('api_ajax_only')) { |
|
188 | + $this->response(array( |
|
189 | 189 | 'status' => false, |
190 | 190 | 'error' => 'Only AJAX requests are accepted.' |
191 | - ), 505 ); |
|
191 | + ), 505); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | |
@@ -204,8 +204,8 @@ discard block |
||
204 | 204 | * The arguments passed to the controller method. |
205 | 205 | */ |
206 | 206 | public function _remap($object_called, $arguments) { |
207 | - $pattern = '/^(.*)\.(' . implode ( '|', array_keys ( $this->_supported_formats ) ) . ')$/'; |
|
208 | - if (preg_match ( $pattern, $object_called, $matches )) { |
|
207 | + $pattern = '/^(.*)\.('.implode('|', array_keys($this->_supported_formats)).')$/'; |
|
208 | + if (preg_match($pattern, $object_called, $matches)) { |
|
209 | 209 | $object_called = $matches [1]; |
210 | 210 | } |
211 | 211 | |
@@ -215,45 +215,45 @@ discard block |
||
215 | 215 | // Samir : Ends |
216 | 216 | |
217 | 217 | // Do we want to log this method (if allowed by config)? |
218 | - $log_method = ! (isset ( $this->methods [$controller_method] ['log'] ) and $this->methods [$controller_method] ['log'] == FALSE); |
|
218 | + $log_method = ! (isset ($this->methods [$controller_method] ['log']) and $this->methods [$controller_method] ['log'] == FALSE); |
|
219 | 219 | |
220 | 220 | // Use keys for this method? |
221 | - $use_key = ! (isset ( $this->methods [$controller_method] ['key'] ) and $this->methods [$controller_method] ['key'] == FALSE); |
|
221 | + $use_key = ! (isset ($this->methods [$controller_method] ['key']) and $this->methods [$controller_method] ['key'] == FALSE); |
|
222 | 222 | |
223 | 223 | // Sure it exists, but can they do anything with it? |
224 | - if (! method_exists ( $this, $controller_method )) { |
|
225 | - $this->response ( array ( |
|
224 | + if ( ! method_exists($this, $controller_method)) { |
|
225 | + $this->response(array( |
|
226 | 226 | 'status' => false, |
227 | - 'error' => $this->lang->line ( 'unknown_method' ) |
|
228 | - ), 404 ); |
|
227 | + 'error' => $this->lang->line('unknown_method') |
|
228 | + ), 404); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | // Doing key related stuff? Can only do it if they have a key right? |
232 | - if (config_item ( 'api_enable_keys' ) and ! empty ( $this->api->key )) { |
|
232 | + if (config_item('api_enable_keys') and ! empty ($this->api->key)) { |
|
233 | 233 | // Check the limit |
234 | - if (config_item ( 'api_enable_limits' ) and ! $this->_check_limit ( $controller_method )) { |
|
235 | - $this->response ( array ( |
|
234 | + if (config_item('api_enable_limits') and ! $this->_check_limit($controller_method)) { |
|
235 | + $this->response(array( |
|
236 | 236 | 'status' => false, |
237 | 237 | 'error' => 'This API key has reached the hourly limit for this method.' |
238 | - ), 401 ); |
|
238 | + ), 401); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | // If no level is set use 0, they probably aren't using permissions |
242 | - $level = isset ( $this->methods [$controller_method] ['level'] ) ? $this->methods [$controller_method] ['level'] : 0; |
|
242 | + $level = isset ($this->methods [$controller_method] ['level']) ? $this->methods [$controller_method] ['level'] : 0; |
|
243 | 243 | |
244 | 244 | // If no level is set, or it is lower than/equal to the key's level |
245 | 245 | $authorized = $level <= $this->api->level; |
246 | 246 | |
247 | 247 | // IM TELLIN! |
248 | - if (config_item ( 'api_enable_logging' ) and $log_method) { |
|
249 | - $this->_log_request ( $authorized ); |
|
248 | + if (config_item('api_enable_logging') and $log_method) { |
|
249 | + $this->_log_request($authorized); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | // They don't have good enough perms |
253 | - $authorized or $this->response ( array ( |
|
253 | + $authorized or $this->response(array( |
|
254 | 254 | 'status' => false, |
255 | 255 | 'error' => 'This API key does not have enough permissions.' |
256 | - ), 401 ); |
|
256 | + ), 401); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // No key stuff, but record that stuff is happening |
@@ -265,10 +265,10 @@ discard block |
||
265 | 265 | */ |
266 | 266 | |
267 | 267 | // And...... GO! |
268 | - $this->_fire_method ( array ( |
|
268 | + $this->_fire_method(array( |
|
269 | 269 | $this, |
270 | 270 | $controller_method |
271 | - ), $arguments ); |
|
271 | + ), $arguments); |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * The arguments to pass to the controller method |
283 | 283 | */ |
284 | 284 | protected function _fire_method($method, $args) { |
285 | - call_user_func_array ( $method, $args ); |
|
285 | + call_user_func_array($method, $args); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | global $CFG; |
298 | 298 | |
299 | 299 | // If data is empty and not code provide, error and bail |
300 | - if (empty ( $data ) && $http_code === null) { |
|
300 | + if (empty ($data) && $http_code === null) { |
|
301 | 301 | $http_code = 404; |
302 | 302 | |
303 | 303 | // create the output variable here in the case of $this->response(array()); |
@@ -310,30 +310,30 @@ discard block |
||
310 | 310 | $data ['response_code'] = $http_code; |
311 | 311 | |
312 | 312 | // Is compression requested? |
313 | - if ($CFG->item ( 'compress_output' ) === TRUE && $this->_zlib_oc == FALSE) { |
|
314 | - if (extension_loaded ( 'zlib' )) { |
|
315 | - if (isset ( $_SERVER ['HTTP_ACCEPT_ENCODING'] ) and strpos ( $_SERVER ['HTTP_ACCEPT_ENCODING'], 'gzip' ) !== FALSE) { |
|
316 | - ob_start ( 'ob_gzhandler' ); |
|
313 | + if ($CFG->item('compress_output') === TRUE && $this->_zlib_oc == FALSE) { |
|
314 | + if (extension_loaded('zlib')) { |
|
315 | + if (isset ($_SERVER ['HTTP_ACCEPT_ENCODING']) and strpos($_SERVER ['HTTP_ACCEPT_ENCODING'], 'gzip') !== FALSE) { |
|
316 | + ob_start('ob_gzhandler'); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | } |
320 | 320 | |
321 | - is_numeric ( $http_code ) or $http_code = 200; |
|
321 | + is_numeric($http_code) or $http_code = 200; |
|
322 | 322 | |
323 | 323 | // If the format method exists, call and return the output in that format |
324 | - if (method_exists ( $this, '_format_' . $this->response->format )) { |
|
324 | + if (method_exists($this, '_format_'.$this->response->format)) { |
|
325 | 325 | // Set the correct format header |
326 | - header ( 'Content-Type: ' . $this->_supported_formats [$this->response->format] ); |
|
326 | + header('Content-Type: '.$this->_supported_formats [$this->response->format]); |
|
327 | 327 | |
328 | - $output = $this->{'_format_' . $this->response->format} ( $data ); |
|
328 | + $output = $this->{'_format_'.$this->response->format} ($data); |
|
329 | 329 | } |
330 | 330 | |
331 | 331 | // If the format method exists, call and return the output in that format |
332 | - elseif (method_exists ( $this->format, 'to_' . $this->response->format )) { |
|
332 | + elseif (method_exists($this->format, 'to_'.$this->response->format)) { |
|
333 | 333 | // Set the correct format header |
334 | - header ( 'Content-Type: ' . $this->_supported_formats [$this->response->format] ); |
|
334 | + header('Content-Type: '.$this->_supported_formats [$this->response->format]); |
|
335 | 335 | |
336 | - $output = $this->format->factory ( $data )->{'to_' . $this->response->format} (); |
|
336 | + $output = $this->format->factory($data)->{'to_'.$this->response->format} (); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | // Format not supported, output directly |
@@ -342,20 +342,20 @@ discard block |
||
342 | 342 | } |
343 | 343 | } |
344 | 344 | |
345 | - header ( 'HTTP/1.1: ' . $http_code ); |
|
346 | - header ( 'Status: ' . $http_code ); |
|
345 | + header('HTTP/1.1: '.$http_code); |
|
346 | + header('Status: '.$http_code); |
|
347 | 347 | |
348 | 348 | // If zlib.output_compression is enabled it will compress the output, |
349 | 349 | // but it will not modify the content-length header to compensate for |
350 | 350 | // the reduction, causing the browser to hang waiting for more data. |
351 | 351 | // We'll just skip content-length in those cases. |
352 | - if (! $this->_zlib_oc && ! $CFG->item ( 'compress_output' )) { |
|
352 | + if ( ! $this->_zlib_oc && ! $CFG->item('compress_output')) { |
|
353 | 353 | // header('Content-Length: ' . strlen($output)); |
354 | 354 | } |
355 | 355 | |
356 | - $loglevel = (isset ( $data ['error'] )) ? "error" : "info"; |
|
357 | - $this->api_log->write_log ( $loglevel, "[" . $http_code . "] " . $output ); |
|
358 | - exit ( $output ); |
|
356 | + $loglevel = (isset ($data ['error'])) ? "error" : "info"; |
|
357 | + $this->api_log->write_log($loglevel, "[".$http_code."] ".$output); |
|
358 | + exit ($output); |
|
359 | 359 | } |
360 | 360 | |
361 | 361 | /* |
@@ -364,11 +364,11 @@ discard block |
||
364 | 364 | * Detect which format the HTTP Body is provided in |
365 | 365 | */ |
366 | 366 | protected function _detect_input_format() { |
367 | - if ($this->input->server ( 'CONTENT_TYPE' )) { |
|
367 | + if ($this->input->server('CONTENT_TYPE')) { |
|
368 | 368 | // Check all formats against the HTTP_ACCEPT header |
369 | - foreach ( $this->_supported_formats as $format => $mime ) { |
|
370 | - if (strpos ( $match = $this->input->server ( 'CONTENT_TYPE' ), ';' )) { |
|
371 | - $match = current ( explode ( ';', $match ) ); |
|
369 | + foreach ($this->_supported_formats as $format => $mime) { |
|
370 | + if (strpos($match = $this->input->server('CONTENT_TYPE'), ';')) { |
|
371 | + $match = current(explode(';', $match)); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | if ($match == $mime) { |
@@ -388,36 +388,36 @@ discard block |
||
388 | 388 | * @return string The output format. |
389 | 389 | */ |
390 | 390 | protected function _detect_output_format() { |
391 | - $pattern = '/\.(' . implode ( '|', array_keys ( $this->_supported_formats ) ) . ')$/'; |
|
391 | + $pattern = '/\.('.implode('|', array_keys($this->_supported_formats)).')$/'; |
|
392 | 392 | |
393 | 393 | // Check if a file extension is used |
394 | - if (preg_match ( $pattern, $this->uri->uri_string (), $matches )) { |
|
394 | + if (preg_match($pattern, $this->uri->uri_string(), $matches)) { |
|
395 | 395 | return $matches [1]; |
396 | 396 | } |
397 | 397 | |
398 | 398 | // Check if a file extension is used |
399 | - elseif ($this->_get_args and ! is_array ( end ( $this->_get_args ) ) and preg_match ( $pattern, end ( $this->_get_args ), $matches )) { |
|
399 | + elseif ($this->_get_args and ! is_array(end($this->_get_args)) and preg_match($pattern, end($this->_get_args), $matches)) { |
|
400 | 400 | // The key of the last argument |
401 | - $last_key = end ( array_keys ( $this->_get_args ) ); |
|
401 | + $last_key = end(array_keys($this->_get_args)); |
|
402 | 402 | |
403 | 403 | // Remove the extension from arguments too |
404 | - $this->_get_args [$last_key] = preg_replace ( $pattern, '', $this->_get_args [$last_key] ); |
|
405 | - $this->_args [$last_key] = preg_replace ( $pattern, '', $this->_args [$last_key] ); |
|
404 | + $this->_get_args [$last_key] = preg_replace($pattern, '', $this->_get_args [$last_key]); |
|
405 | + $this->_args [$last_key] = preg_replace($pattern, '', $this->_args [$last_key]); |
|
406 | 406 | |
407 | 407 | return $matches [1]; |
408 | 408 | } |
409 | 409 | |
410 | 410 | // A format has been passed as an argument in the URL and it is supported |
411 | - if (isset ( $this->_get_args ['format'] ) and array_key_exists ( $this->_get_args ['format'], $this->_supported_formats )) { |
|
411 | + if (isset ($this->_get_args ['format']) and array_key_exists($this->_get_args ['format'], $this->_supported_formats)) { |
|
412 | 412 | return $this->_get_args ['format']; |
413 | 413 | } |
414 | 414 | |
415 | 415 | // Otherwise, check the HTTP_ACCEPT (if it exists and we are allowed) |
416 | - if ($this->config->item ( 'api_ignore_http_accept' ) === FALSE and $this->input->server ( 'HTTP_ACCEPT' )) { |
|
416 | + if ($this->config->item('api_ignore_http_accept') === FALSE and $this->input->server('HTTP_ACCEPT')) { |
|
417 | 417 | // Check all formats against the HTTP_ACCEPT header |
418 | - foreach ( array_keys ( $this->_supported_formats ) as $format ) { |
|
418 | + foreach (array_keys($this->_supported_formats) as $format) { |
|
419 | 419 | // Has this format been requested? |
420 | - if (strpos ( $this->input->server ( 'HTTP_ACCEPT' ), $format ) !== FALSE) { |
|
420 | + if (strpos($this->input->server('HTTP_ACCEPT'), $format) !== FALSE) { |
|
421 | 421 | // If not HTML or XML assume its right and send it on its way |
422 | 422 | if ($format != 'html' and $format != 'xml') { |
423 | 423 | |
@@ -427,12 +427,12 @@ discard block |
||
427 | 427 | // HTML or XML have shown up as a match |
428 | 428 | else { |
429 | 429 | // If it is truly HTML, it wont want any XML |
430 | - if ($format == 'html' and strpos ( $this->input->server ( 'HTTP_ACCEPT' ), 'xml' ) === FALSE) { |
|
430 | + if ($format == 'html' and strpos($this->input->server('HTTP_ACCEPT'), 'xml') === FALSE) { |
|
431 | 431 | return $format; |
432 | 432 | } |
433 | 433 | |
434 | 434 | // If it is truly XML, it wont want any HTML |
435 | - elseif ($format == 'xml' and strpos ( $this->input->server ( 'HTTP_ACCEPT' ), 'html' ) === FALSE) { |
|
435 | + elseif ($format == 'xml' and strpos($this->input->server('HTTP_ACCEPT'), 'html') === FALSE) { |
|
436 | 436 | return $format; |
437 | 437 | } |
438 | 438 | } |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | } // End HTTP_ACCEPT checking |
442 | 442 | |
443 | 443 | // Well, none of that has worked! Let's see if the controller has a default |
444 | - if (! empty ( $this->api_format )) { |
|
444 | + if ( ! empty ($this->api_format)) { |
|
445 | 445 | return $this->api_format; |
446 | 446 | } |
447 | 447 | |
448 | 448 | // Just use the default format |
449 | - return config_item ( 'api_default_format' ); |
|
449 | + return config_item('api_default_format'); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
@@ -457,17 +457,17 @@ discard block |
||
457 | 457 | * @return string |
458 | 458 | */ |
459 | 459 | protected function _detect_method() { |
460 | - $method = strtolower ( $this->input->server ( 'REQUEST_METHOD' ) ); |
|
460 | + $method = strtolower($this->input->server('REQUEST_METHOD')); |
|
461 | 461 | |
462 | - if ($this->config->item ( 'enable_emulate_request' )) { |
|
463 | - if ($this->input->post ( '_method' )) { |
|
464 | - $method = strtolower ( $this->input->post ( '_method' ) ); |
|
465 | - } elseif ($this->input->server ( 'HTTP_X_HTTP_METHOD_OVERRIDE' )) { |
|
466 | - $method = strtolower ( $this->input->server ( 'HTTP_X_HTTP_METHOD_OVERRIDE' ) ); |
|
462 | + if ($this->config->item('enable_emulate_request')) { |
|
463 | + if ($this->input->post('_method')) { |
|
464 | + $method = strtolower($this->input->post('_method')); |
|
465 | + } elseif ($this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE')) { |
|
466 | + $method = strtolower($this->input->server('HTTP_X_HTTP_METHOD_OVERRIDE')); |
|
467 | 467 | } |
468 | 468 | } |
469 | 469 | |
470 | - if (in_array ( $method, $this->allowed_http_methods ) && method_exists ( $this, '_parse_' . $method )) { |
|
470 | + if (in_array($method, $this->allowed_http_methods) && method_exists($this, '_parse_'.$method)) { |
|
471 | 471 | return $method; |
472 | 472 | } |
473 | 473 | |
@@ -482,20 +482,20 @@ discard block |
||
482 | 482 | * @return null|string The language code. |
483 | 483 | */ |
484 | 484 | protected function _detect_lang() { |
485 | - if (! $lang = $this->input->server ( 'HTTP_ACCEPT_LANGUAGE' )) { |
|
485 | + if ( ! $lang = $this->input->server('HTTP_ACCEPT_LANGUAGE')) { |
|
486 | 486 | return NULL; |
487 | 487 | } |
488 | 488 | |
489 | 489 | // They might have sent a few, make it an array |
490 | - if (strpos ( $lang, ',' ) !== FALSE) { |
|
491 | - $langs = explode ( ',', $lang ); |
|
490 | + if (strpos($lang, ',') !== FALSE) { |
|
491 | + $langs = explode(',', $lang); |
|
492 | 492 | |
493 | - $return_langs = array (); |
|
493 | + $return_langs = array(); |
|
494 | 494 | $i = 1; |
495 | - foreach ( $langs as $lang ) { |
|
495 | + foreach ($langs as $lang) { |
|
496 | 496 | // Remove weight and strip space |
497 | - list ( $lang ) = explode ( ';', $lang ); |
|
498 | - $return_langs [] = trim ( $lang ); |
|
497 | + list ($lang) = explode(';', $lang); |
|
498 | + $return_langs [] = trim($lang); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | return $return_langs; |
@@ -516,7 +516,7 @@ discard block |
||
516 | 516 | */ |
517 | 517 | protected function _check_limit($controller_method) { |
518 | 518 | // They are special, or it might not even have a limit |
519 | - if (! empty ( $this->api->ignore_limits ) or ! isset ( $this->methods [$controller_method] ['limit'] )) { |
|
519 | + if ( ! empty ($this->api->ignore_limits) or ! isset ($this->methods [$controller_method] ['limit'])) { |
|
520 | 520 | // On your way sonny-jim. |
521 | 521 | return TRUE; |
522 | 522 | } |
@@ -525,17 +525,17 @@ discard block |
||
525 | 525 | $limit = $this->methods [$controller_method] ['limit']; |
526 | 526 | |
527 | 527 | // Get data on a keys usage |
528 | - $result = $this->api->db->where ( 'uri', $this->uri->uri_string () )->where ( 'api_key', $this->api->key )->get ( config_item ( 'api_limits_table' ) )->row (); |
|
528 | + $result = $this->api->db->where('uri', $this->uri->uri_string())->where('api_key', $this->api->key)->get(config_item('api_limits_table'))->row(); |
|
529 | 529 | |
530 | 530 | // No calls yet, or been an hour since they called |
531 | - if (! $result or $result->hour_started < time () - (60 * 60)) { |
|
531 | + if ( ! $result or $result->hour_started < time() - (60 * 60)) { |
|
532 | 532 | // Right, set one up from scratch |
533 | - $this->api->db->insert ( config_item ( 'api_limits_table' ), array ( |
|
534 | - 'uri' => $this->uri->uri_string (), |
|
535 | - 'api_key' => isset ( $this->api->key ) ? $this->api->key : '', |
|
533 | + $this->api->db->insert(config_item('api_limits_table'), array( |
|
534 | + 'uri' => $this->uri->uri_string(), |
|
535 | + 'api_key' => isset ($this->api->key) ? $this->api->key : '', |
|
536 | 536 | 'count' => 1, |
537 | - 'hour_started' => time () |
|
538 | - ) ); |
|
537 | + 'hour_started' => time() |
|
538 | + )); |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | // They have called within the hour, so lets update |
@@ -545,7 +545,7 @@ discard block |
||
545 | 545 | return FALSE; |
546 | 546 | } |
547 | 547 | |
548 | - $this->api->db->where ( 'uri', $this->uri->uri_string () )->where ( 'api_key', $this->api->key )->set ( 'count', 'count + 1', FALSE )->update ( config_item ( 'api_limits_table' ) ); |
|
548 | + $this->api->db->where('uri', $this->uri->uri_string())->where('api_key', $this->api->key)->set('count', 'count + 1', FALSE)->update(config_item('api_limits_table')); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | return TRUE; |
@@ -556,10 +556,10 @@ discard block |
||
556 | 556 | */ |
557 | 557 | protected function _parse_get() { |
558 | 558 | // Grab proper GET variables |
559 | - parse_str ( parse_url ( $_SERVER ['REQUEST_URI'], PHP_URL_QUERY ), $get ); |
|
559 | + parse_str(parse_url($_SERVER ['REQUEST_URI'], PHP_URL_QUERY), $get); |
|
560 | 560 | |
561 | 561 | // Merge both the URI segments and GET params |
562 | - $this->_get_args = array_merge ( $this->_get_args, $get ); |
|
562 | + $this->_get_args = array_merge($this->_get_args, $get); |
|
563 | 563 | } |
564 | 564 | |
565 | 565 | /** |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | protected function _parse_post() { |
569 | 569 | $this->_post_args = $_POST; |
570 | 570 | |
571 | - $this->request->format and $this->request->body = file_get_contents ( 'php://input' ); |
|
571 | + $this->request->format and $this->request->body = file_get_contents('php://input'); |
|
572 | 572 | } |
573 | 573 | |
574 | 574 | // INPUT FUNCTION -------------------------------------------------------------- |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | return $this->_get_args; |
588 | 588 | } |
589 | 589 | |
590 | - return array_key_exists ( $key, $this->_get_args ) ? $this->_xss_clean ( $this->_get_args [$key], $xss_clean ) : FALSE; |
|
590 | + return array_key_exists($key, $this->_get_args) ? $this->_xss_clean($this->_get_args [$key], $xss_clean) : FALSE; |
|
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
@@ -604,7 +604,7 @@ discard block |
||
604 | 604 | return $this->_post_args; |
605 | 605 | } |
606 | 606 | |
607 | - return array_key_exists ( $key, $this->_post_args ) ? $this->_xss_clean ( $this->_post_args [$key], $xss_clean ) : FALSE; |
|
607 | + return array_key_exists($key, $this->_post_args) ? $this->_xss_clean($this->_post_args [$key], $xss_clean) : FALSE; |
|
608 | 608 | } |
609 | 609 | |
610 | 610 | /** |
@@ -618,10 +618,10 @@ discard block |
||
618 | 618 | */ |
619 | 619 | protected function _xss_clean($val, $process) { |
620 | 620 | if (CI_VERSION < 2) { |
621 | - return $process ? $this->input->xss_clean ( $val ) : $val; |
|
621 | + return $process ? $this->input->xss_clean($val) : $val; |
|
622 | 622 | } |
623 | 623 | |
624 | - return $process ? $this->security->xss_clean ( $val ) : $val; |
|
624 | + return $process ? $this->security->xss_clean($val) : $val; |
|
625 | 625 | } |
626 | 626 | |
627 | 627 | // SECURITY FUNCTIONS --------------------------------------------------------- |
@@ -630,19 +630,19 @@ discard block |
||
630 | 630 | * Check if the client's ip is in the 'api_ip_whitelist' config |
631 | 631 | */ |
632 | 632 | protected function _check_whitelist_auth() { |
633 | - $whitelist = explode ( ',', config_item ( 'api_ip_whitelist' ) ); |
|
633 | + $whitelist = explode(',', config_item('api_ip_whitelist')); |
|
634 | 634 | |
635 | - array_push ( $whitelist, '127.0.0.1', '0.0.0.0' ); |
|
635 | + array_push($whitelist, '127.0.0.1', '0.0.0.0'); |
|
636 | 636 | |
637 | - foreach ( $whitelist as &$ip ) { |
|
638 | - $ip = trim ( $ip ); |
|
637 | + foreach ($whitelist as &$ip) { |
|
638 | + $ip = trim($ip); |
|
639 | 639 | } |
640 | 640 | |
641 | - if (! in_array ( $this->input->ip_address (), $whitelist )) { |
|
642 | - $this->response ( array ( |
|
641 | + if ( ! in_array($this->input->ip_address(), $whitelist)) { |
|
642 | + $this->response(array( |
|
643 | 643 | 'status' => false, |
644 | 644 | 'error' => 'Not authorized' |
645 | - ), 401 ); |
|
645 | + ), 401); |
|
646 | 646 | } |
647 | 647 | } |
648 | 648 | |
@@ -654,8 +654,8 @@ discard block |
||
654 | 654 | */ |
655 | 655 | protected function _force_loopable($data) { |
656 | 656 | // Force it to be something useful |
657 | - if (! is_array ( $data ) and ! is_object ( $data )) { |
|
658 | - $data = ( array ) $data; |
|
657 | + if ( ! is_array($data) and ! is_object($data)) { |
|
658 | + $data = (array)$data; |
|
659 | 659 | } |
660 | 660 | |
661 | 661 | return $data; |
@@ -672,7 +672,7 @@ discard block |
||
672 | 672 | * @return string The JSONP data string (loadable from Javascript). |
673 | 673 | */ |
674 | 674 | protected function _format_jsonp($data = array()) { |
675 | - return $this->get ( 'callback' ) . '(' . json_encode ( $data ) . ')'; |
|
675 | + return $this->get('callback').'('.json_encode($data).')'; |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /* |
@@ -685,15 +685,15 @@ discard block |
||
685 | 685 | */ |
686 | 686 | |
687 | 687 | // Added patch to validate request from freeswitch to send push notification for callkit to ios |
688 | - if ($_SERVER ['HTTP_USER_AGENT'] == 'freeswitch-curl/1.0' && isset ( $_POST ['uuid'] )) { |
|
689 | - $_SERVER ['HTTP_X_AUTH_TOKEN'] = $this->post ( 'fs_key' ); |
|
688 | + if ($_SERVER ['HTTP_USER_AGENT'] == 'freeswitch-curl/1.0' && isset ($_POST ['uuid'])) { |
|
689 | + $_SERVER ['HTTP_X_AUTH_TOKEN'] = $this->post('fs_key'); |
|
690 | 690 | } |
691 | 691 | |
692 | - if (! isset ( $_SERVER ['HTTP_X_AUTH_TOKEN'] ) || config_item ( 'api_x_auth_token' ) != $_SERVER ['HTTP_X_AUTH_TOKEN']) { |
|
693 | - $this->response ( array ( |
|
692 | + if ( ! isset ($_SERVER ['HTTP_X_AUTH_TOKEN']) || config_item('api_x_auth_token') != $_SERVER ['HTTP_X_AUTH_TOKEN']) { |
|
693 | + $this->response(array( |
|
694 | 694 | 'status' => false, |
695 | - 'error' => $this->lang->line ( 'error_authentication_invalid_token' ) |
|
696 | - ), 403 ); |
|
695 | + 'error' => $this->lang->line('error_authentication_invalid_token') |
|
696 | + ), 403); |
|
697 | 697 | } |
698 | 698 | } |
699 | 699 | } |
@@ -20,40 +20,40 @@ |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
24 | - exit ( 'No direct script access allowed' ); |
|
23 | +if ( ! defined('BASEPATH')) |
|
24 | + exit ('No direct script access allowed'); |
|
25 | 25 | |
26 | 26 | /** |
27 | 27 | * Dynamically build forms for display |
28 | 28 | */ |
29 | 29 | class Locale { |
30 | 30 | function __construct($library_name = '') { |
31 | - $this->CI = & get_instance (); |
|
32 | - $this->CI->load->model ( 'db_model' ); |
|
33 | - $this->CI->load->library ( 'email' ); |
|
34 | - $this->CI->load->library ( 'session' ); |
|
35 | - $this->CI->load->driver ( 'cache' ); |
|
36 | - $this->set_lang (); |
|
31 | + $this->CI = & get_instance(); |
|
32 | + $this->CI->load->model('db_model'); |
|
33 | + $this->CI->load->library('email'); |
|
34 | + $this->CI->load->library('session'); |
|
35 | + $this->CI->load->driver('cache'); |
|
36 | + $this->set_lang(); |
|
37 | 37 | } |
38 | 38 | function set_lang($lang = FALSE) { |
39 | - $current_locale = $this->CI->session->userdata ( 'user_language' ); |
|
40 | - if (empty ( $current_locale )) { |
|
39 | + $current_locale = $this->CI->session->userdata('user_language'); |
|
40 | + if (empty ($current_locale)) { |
|
41 | 41 | $current_locale = 'en_US'; |
42 | 42 | } |
43 | - putenv ( "LANG=$current_locale" ); |
|
44 | - setlocale ( LC_ALL, $current_locale . ".UTF-8" ); |
|
45 | - setlocale ( LC_MESSAGES, $current_locale ); |
|
46 | - setlocale ( LC_TIME, $current_locale ); |
|
47 | - setlocale ( LC_CTYPE, $current_locale ); |
|
43 | + putenv("LANG=$current_locale"); |
|
44 | + setlocale(LC_ALL, $current_locale.".UTF-8"); |
|
45 | + setlocale(LC_MESSAGES, $current_locale); |
|
46 | + setlocale(LC_TIME, $current_locale); |
|
47 | + setlocale(LC_CTYPE, $current_locale); |
|
48 | 48 | $domain = 'messages'; |
49 | 49 | $uri_segment = ''; |
50 | 50 | $uri_segment = $this->CI->uri->segments; |
51 | - if (isset ( $uri_segment [1] )) { |
|
52 | - $filename = getcwd () . '/application/modules/user/language/' . $lang . '/LC_MESSAGES/messages.mo'; |
|
53 | - bindtextdomain ( WEBSITE_DOMAIN, getcwd () . '/application/modules/' . $uri_segment [1] . '/language/' ); |
|
51 | + if (isset ($uri_segment [1])) { |
|
52 | + $filename = getcwd().'/application/modules/user/language/'.$lang.'/LC_MESSAGES/messages.mo'; |
|
53 | + bindtextdomain(WEBSITE_DOMAIN, getcwd().'/application/modules/'.$uri_segment [1].'/language/'); |
|
54 | 54 | } |
55 | - bind_textdomain_codeset ( WEBSITE_DOMAIN, 'UTF-8' ); |
|
56 | - textdomain ( WEBSITE_DOMAIN ); |
|
55 | + bind_textdomain_codeset(WEBSITE_DOMAIN, 'UTF-8'); |
|
56 | + textdomain(WEBSITE_DOMAIN); |
|
57 | 57 | return true; |
58 | 58 | } |
59 | 59 | } |
@@ -20,8 +20,9 @@ |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -if (! defined ( 'BASEPATH' )) |
|
23 | +if (! defined ( 'BASEPATH' )) { |
|
24 | 24 | exit ( 'No direct script access allowed' ); |
25 | +} |
|
25 | 26 | |
26 | 27 | /** |
27 | 28 | * Dynamically build forms for display |