diff --git a/app/gateways/resources/classes/gateways.php b/app/gateways/resources/classes/gateways.php index 32bc353349..0d125c0102 100644 --- a/app/gateways/resources/classes/gateways.php +++ b/app/gateways/resources/classes/gateways.php @@ -17,7 +17,7 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2019 + Portions created by the Initial Developer are Copyright (C) 2008-2022 the Initial Developer. All Rights Reserved. Contributor(s): @@ -98,9 +98,14 @@ if (!class_exists('gateways')) { //get necessary gateway details if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile, enabled from v_".$this->table." "; - $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; - $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + if (permission_exists('gateway_all')) { + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + } + else { + $sql .= "where (domain_uuid = :domain_uuid) "; + $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { @@ -172,9 +177,14 @@ if (!class_exists('gateways')) { //get necessary gateway details if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile, enabled from v_".$this->table." "; - $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; - $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + if (permission_exists('gateway_all')) { + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + } + else { + $sql .= "where (domain_uuid = :domain_uuid) "; + $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { @@ -246,9 +256,14 @@ if (!class_exists('gateways')) { //get necessary gateway details if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->uuid_prefix."uuid as uuid, gateway, profile from v_".$this->table." "; - $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; - $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + if (permission_exists('gateway_all')) { + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + } + else { + $sql .= "where (domain_uuid = :domain_uuid) "; + $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { @@ -379,7 +394,14 @@ if (!class_exists('gateways')) { } if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select ".$this->uuid_prefix."uuid as uuid, ".$this->toggle_field." as state, gateway, profile from v_".$this->table." "; - $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + if (permission_exists('gateway_all')) { + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + } + else { + $sql .= "where (domain_uuid = :domain_uuid) "; + $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) { @@ -505,9 +527,14 @@ if (!class_exists('gateways')) { //create insert array from existing data if (is_array($uuids) && @sizeof($uuids) != 0) { $sql = "select * from v_".$this->table." "; - $sql .= "where (domain_uuid = :domain_uuid ".(permission_exists('gateway_domain') ? " or domain_uuid is null " : null).") "; - $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + if (permission_exists('gateway_all')) { + $sql .= "where ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + } + else { + $sql .= "where (domain_uuid = :domain_uuid) "; + $sql .= "and ".$this->uuid_prefix."uuid in (".implode(', ', $uuids).") "; + $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + } $database = new database; $rows = $database->select($sql, $parameters, 'all'); if (is_array($rows) && @sizeof($rows) != 0) {