first commit
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
<?php if (!defined('BASEPATH')) {
|
||||
exit('No direct script access allowed');
|
||||
}
|
||||
|
||||
class Acl_Whitelist_model extends CI_Model {
|
||||
|
||||
private $read_replica;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->read_replica = $this->load->database('savvy_replica', TRUE);
|
||||
}
|
||||
|
||||
public function getControllerAndMethod() {
|
||||
$this->read_replica->select('acl_wl.id AS bko_acl_whitelist_id, CONCAT(acl.class_name, \' - \', acl.method_name) AS class_method');
|
||||
$this->read_replica->from('bko_acl_whitelist acl_wl');
|
||||
$this->read_replica->join('bko_acl acl', 'acl.id = acl_wl.bko_acl_id');
|
||||
|
||||
$query = $this->read_replica->get();
|
||||
|
||||
return array_column($query->result_array(), 'class_method', 'bko_acl_whitelist_id');
|
||||
}
|
||||
|
||||
// Fetch records
|
||||
public function getData($rowno,$rowperpage, $filters = []) {
|
||||
|
||||
$this->read_replica->select( 'acl.id AS acl_id,
|
||||
acl_wl_ext.id AS acl_wl_ext_id,
|
||||
acl_wl.id AS acl_wl_id,
|
||||
acl.method_name AS method_name,
|
||||
acl.class_name AS class_name,
|
||||
pl.name AS name,
|
||||
acl_wl_ext.parameter_name AS parameter_name,
|
||||
acl_wl_ext.parameter_value AS parameter_value');
|
||||
$this->read_replica->from('bko_acl acl');
|
||||
$this->read_replica->join('bko_acl_permission_level', 'acl.id = bko_acl_permission_level.bko_acl_id ');
|
||||
$this->read_replica->join('bko_permission_level pl', 'bko_acl_permission_level.plevel = pl.plevel ');
|
||||
$this->read_replica->join('bko_acl_whitelist acl_wl', 'acl_wl.bko_acl_id = acl.id ');
|
||||
$this->read_replica->join('bko_acl_whitelist_extra acl_wl_ext', 'acl_wl_ext.bko_acl_whitelist_id = acl_wl.id ');
|
||||
|
||||
foreach($filters as $key => $value) {
|
||||
if ($key === 'card_class_filter') {
|
||||
|
||||
$this->read_replica->where('lower(acl.class_name)', strtolower($value));
|
||||
|
||||
} else if ($key === 'method_filter') {
|
||||
|
||||
$this->read_replica->like('acl.method_name', strtolower($value));
|
||||
|
||||
} else {
|
||||
|
||||
$this->read_replica->where('pl.plevel', $value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$this->read_replica->order_by('acl_id');
|
||||
$this->read_replica->limit($rowperpage, $rowno);
|
||||
$query = $this->read_replica->get();
|
||||
|
||||
return $query->result_array();
|
||||
}
|
||||
|
||||
// Select total records
|
||||
public function getrecordCount($filters = []) {
|
||||
|
||||
$this->read_replica->select('count(*) as allcount');
|
||||
$this->read_replica->from('bko_acl acl');
|
||||
$this->read_replica->join('bko_acl_permission_level', 'acl.id = bko_acl_permission_level.bko_acl_id ');
|
||||
$this->read_replica->join('bko_permission_level pl', 'bko_acl_permission_level.plevel = pl.plevel ');
|
||||
$this->read_replica->join('bko_acl_whitelist acl_wl', 'acl_wl.bko_acl_id = acl.id ');
|
||||
$this->read_replica->join('bko_acl_whitelist_extra acl_wl_ext', 'acl_wl_ext.bko_acl_whitelist_id = acl_wl.id ');
|
||||
|
||||
foreach($filters as $key => $value) {
|
||||
if ($key === 'card_class_filter') {
|
||||
|
||||
$this->read_replica->where('lower(acl.class_name)', strtolower($value));
|
||||
|
||||
} else if ($key === 'method_filter') {
|
||||
|
||||
$this->read_replica->like('acl.method_name', strtolower($value));
|
||||
|
||||
} else {
|
||||
|
||||
$this->read_replica->where('pl.plevel', $value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$query = $this->read_replica->get();
|
||||
$result = $query->result_array();
|
||||
|
||||
return $result[0]['allcount'];
|
||||
}
|
||||
|
||||
public function getRecordAclWhitelistById($data) {
|
||||
$this->read_replica->get_where('bko_acl_whitelist', $data);
|
||||
return $this->read_replica->affected_rows();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user