Revize c1bdc1c4
Přidáno uživatelem Michal Kliment před více než 9 roky(ů)
application/models/acl.php | ||
---|---|---|
* @author Michal Kliment
|
||
* @return integer
|
||
*/
|
||
public function count_all_rules()
|
||
public function count_all_rules($filter_sql = '')
|
||
{
|
||
return $this->count_all();
|
||
return $this
|
||
->get_all_rules(NULL, NULL, NULL, NULL, $filter_sql)
|
||
->count();
|
||
}
|
||
|
||
/**
|
||
... | ... | |
SELECT cm.value
|
||
FROM aco_map cm
|
||
WHERE acl_id = ?
|
||
ORDER BY cm.value
|
||
", $acl_id);
|
||
}
|
||
|
||
... | ... | |
* @param string $order_by_direction
|
||
* @return MySQL Result
|
||
*/
|
||
public function get_all_rules ($limit_from = 0, $limit_results = 50, $order_by = 'id',
|
||
$order_by_direction = 'asc')
|
||
public function get_all_rules ($limit_from = NULL, $limit_results = NULL, $order_by = NULL,
|
||
$order_by_direction = 'asc', $filter_sql = '')
|
||
{
|
||
// order by direction check
|
||
if (strtolower($order_by_direction) != 'desc')
|
||
... | ... | |
$order_by_direction = 'asc';
|
||
}
|
||
|
||
$where = '';
|
||
|
||
if ($filter_sql != '')
|
||
{
|
||
$where = 'WHERE '.$filter_sql;
|
||
}
|
||
|
||
$order = '';
|
||
|
||
if ($order_by)
|
||
{
|
||
$order = "ORDER BY ".$this->db->escape_column($order_by)." ".$order_by_direction;
|
||
}
|
||
|
||
$limit = '';
|
||
|
||
if (!is_null($limit_from) && !is_null($limit_results))
|
||
{
|
||
$limit = "LIMIT ".intval($limit_from).", ".intval($limit_results);
|
||
}
|
||
|
||
return $this->db->query("
|
||
SELECT
|
||
acl.id, acl.note AS description,
|
||
IFNULL(cm.count,0) AS aco_count, cm.value AS aco_value,
|
||
IFNULL(rgm.count,0) AS aro_groups_count, rgm.value AS aro_groups_value,
|
||
IFNULL(xm.count,0) AS axo_count, xm.value AS axo_value
|
||
FROM acl
|
||
LEFT JOIN
|
||
(
|
||
SELECT
|
||
acl_id, COUNT(*) AS count,
|
||
GROUP_CONCAT(value ORDER BY value SEPARATOR ', \n') AS value
|
||
FROM
|
||
(
|
||
SELECT acl_id,
|
||
IF(value = ?, ?, IF(value = ?, ?, IF(value = ?, ?,
|
||
IF(value = ?, ?, IF(value = ?, ?, IF(value = ?, ?,
|
||
IF(value = ?, ?, IF(value = ?, ?, NULL)))))))) AS value
|
||
FROM aco_map cm
|
||
) cm
|
||
GROUP BY acl_id
|
||
) cm ON cm.acl_id = acl.id
|
||
LEFT JOIN
|
||
(
|
||
SELECT
|
||
acl_id, COUNT(*) AS count,
|
||
GROUP_CONCAT(name ORDER BY name SEPARATOR ', \n') AS value
|
||
FROM aro_groups_map rgm
|
||
LEFT JOIN aro_groups rg ON rg.id = rgm.group_id
|
||
GROUP BY acl_id
|
||
) rgm ON rgm.acl_id = acl.id
|
||
LEFT JOIN
|
||
SELECT a.*,
|
||
COUNT(DISTINCT aco_id) AS aco_count,
|
||
COUNT(DISTINCT aro_group_id) AS aro_groups_count,
|
||
COUNT(DISTINCT axo_id) AS axo_count,
|
||
GROUP_CONCAT(DISTINCT aco_name SEPARATOR ',\n') AS aco_names,
|
||
GROUP_CONCAT(DISTINCT aro_group_name) AS aro_groups_names,
|
||
GROUP_CONCAT(DISTINCT CONCAT(axo_name,' (',axo_section_value,' - ',axo_value,')')ORDER BY axo_name SEPARATOR ',\n') AS axo_names
|
||
FROM
|
||
(
|
||
SELECT
|
||
xm.acl_id, COUNT(*) AS count,
|
||
GROUP_CONCAT(x.name ORDER BY x.name SEPARATOR ', \n') AS value
|
||
FROM axo_map xm
|
||
SELECT a.*,
|
||
c.id AS aco_id, c.value AS aco_value, IFNULL(ct.translated_term, c.name) AS aco_name,
|
||
rg.id AS aro_group_id, rg.value AS aro_group_value, rg.name AS aro_group_name,
|
||
x.id AS axo_id, x.section_value AS axo_section_value, x.value AS axo_value, x.name AS axo_name
|
||
FROM acl a
|
||
JOIN aco_map cm ON cm.acl_id = a.id
|
||
JOIN aco c ON cm.value = c.value
|
||
LEFT JOIN translations ct ON ct.original_term LIKE c.name AND ct.lang = ?
|
||
JOIN aro_groups_map rgm ON rgm.acl_id = a.id
|
||
JOIN aro_groups rg ON rgm.group_id = rg.id
|
||
JOIN axo_map xm ON xm.acl_id = a.id
|
||
JOIN axo x ON xm.section_value = x.section_value AND xm.value = x.value
|
||
GROUP BY xm.acl_id
|
||
) xm ON xm.acl_id = acl.id
|
||
ORDER BY ".$this->db->escape_column($order_by)." ".$order_by_direction."
|
||
LIMIT ".intval($limit_from).", ".intval($limit_results),
|
||
array
|
||
(
|
||
Aco_Model::VIEW_OWN, Aco_Model::get_action(Aco_Model::VIEW_OWN),
|
||
Aco_Model::VIEW_ALL, Aco_Model::get_action(Aco_Model::VIEW_ALL),
|
||
Aco_Model::NEW_OWN, Aco_Model::get_action(Aco_Model::NEW_OWN),
|
||
Aco_Model::NEW_ALL, Aco_Model::get_action(Aco_Model::NEW_ALL),
|
||
Aco_Model::EDIT_OWN, Aco_Model::get_action(Aco_Model::EDIT_OWN),
|
||
Aco_Model::EDIT_ALL, Aco_Model::get_action(Aco_Model::EDIT_ALL),
|
||
Aco_Model::DELETE_OWN, Aco_Model::get_action(Aco_Model::DELETE_OWN),
|
||
Aco_Model::DELETE_ALL, Aco_Model::get_action(Aco_Model::DELETE_ALL),
|
||
));
|
||
) a
|
||
$where
|
||
GROUP BY a.id
|
||
$order
|
||
$limit
|
||
", Config::get('lang'));
|
||
}
|
||
|
||
/**
|
||
... | ... | |
FROM aro_groups rg
|
||
LEFT JOIN aro_groups_map rgm ON rgm.group_id = rg.id
|
||
WHERE acl_id = ?
|
||
ORDER BY rg.name
|
||
", $acl_id);
|
||
}
|
||
|
||
... | ... | |
x.section_value = xm.section_value AND x.value = xm.value
|
||
LEFT JOIN translations t ON t.original_term LIKE x.name AND t.lang = 'cs'
|
||
WHERE acl_id = ?
|
||
ORDER BY x.section_value, x.value
|
||
", $acl_id);
|
||
}
|
||
|
Také k dispozici: Unified diff
Release 1.1.0