Revize 1412
Přidáno uživatelem Ondřej Fibich před více než 12 roky(ů)
freenetis/branches/network/application/models/search.php | ||
---|---|---|
class Search_Model extends Model
|
||
{
|
||
/**
|
||
* Definitions of serach rules
|
||
* Definitions of search rules
|
||
*
|
||
* @var array
|
||
*/
|
||
... | ... | |
),
|
||
array
|
||
(
|
||
'method' => 'segment_name',
|
||
'model' => 'segment'
|
||
'method' => 'link_name',
|
||
'model' => 'link'
|
||
),
|
||
);
|
||
|
||
... | ... | |
{
|
||
return $this->db->query("
|
||
SELECT m.id, m.name AS value,
|
||
CONCAT('ID ',m.id,', ',s.street,' ',ap.street_number,', ',tw.town,IF(tw.quarter IS NOT NULL,CONCAT('-',tw.quarter),'')) AS `desc`,
|
||
CONCAT(IFNULL(t.translated_term,e.value),' ',m.name,IF(mf.id IS NOT NULL,?,'')) AS return_value,
|
||
'members/show/' AS link FROM members m
|
||
CONCAT('ID ',m.id,', ',s.street,' ',ap.street_number,', ',tw.town,IF(tw.quarter IS NOT NULL,CONCAT('-',tw.quarter),'')) AS `desc`,
|
||
CONCAT(IFNULL(t.translated_term,e.value),' ',m.name,IF(mf.id IS NOT NULL,?,'')) AS return_value,
|
||
'members/show/' AS link FROM members m
|
||
JOIN enum_types e ON m.type = e.id
|
||
LEFT JOIN translations t ON e.value LIKE t.original_term AND t.lang = 'cs'
|
||
JOIN address_points ap ON m.address_point_id = ap.id
|
||
... | ... | |
{
|
||
return $this->db->query("
|
||
SELECT m.id, vs.variable_symbol AS value,
|
||
CONCAT(?, vs.variable_symbol) AS `desc`,
|
||
CONCAT(IFNULL(t.translated_term,e.value),' ',m.name,IF(mf.id IS NOT NULL,?,'')) AS return_value,
|
||
'members/show/' AS link FROM members m
|
||
CONCAT(?, vs.variable_symbol) AS `desc`,
|
||
CONCAT(IFNULL(t.translated_term,e.value),' ',m.name,IF(mf.id IS NOT NULL,?,'')) AS return_value,
|
||
'members/show/' AS link FROM members m
|
||
JOIN enum_types e ON m.type = e.id
|
||
LEFT JOIN accounts a ON a.member_id = m.id
|
||
LEFT JOIN variable_symbols vs ON vs.account_id = a.id
|
||
... | ... | |
{
|
||
return $this->db->query("
|
||
SELECT u.id,
|
||
CONCAT(u.name,' ',u.surname) AS value,
|
||
CONCAT(?, u.login) AS `desc`,
|
||
CONCAT(?, u.name, ' ',u.surname) AS return_value, 'users/show/' AS link
|
||
FROM users u WHERE CONCAT(u.name,' ',u.surname) LIKE ? COLLATE utf8_general_ci
|
||
CONCAT(u.name,' ',u.surname) AS value,
|
||
CONCAT(?, u.login) AS `desc`,
|
||
CONCAT(?, u.name, ' ',u.surname) AS return_value, 'users/show/' AS link
|
||
FROM users u
|
||
WHERE CONCAT(u.name,' ',u.surname) LIKE ? COLLATE utf8_general_ci
|
||
", array
|
||
(
|
||
__('Username') . ": ",
|
||
... | ... | |
return $this->db->query("
|
||
SELECT d.id, ic.mac AS value,
|
||
CONCAT(?, ic.mac) AS `desc`,
|
||
CONCAT(?,d.name) AS return_value,
|
||
CONCAT(?, d.name) AS return_value,
|
||
'devices/show/' AS link
|
||
FROM devices d
|
||
JOIN ifaces ic ON ic.device_id = d.id
|
||
... | ... | |
public function device_ip_address($keyword)
|
||
{
|
||
return $this->db->query("
|
||
SELECT d.id, IFNULL(ip1.ip_address,ip2.ip_address) AS value,
|
||
CONCAT(?, IFNULL(ip1.ip_address,ip2.ip_address)) AS `desc`,
|
||
SELECT d.id, ip.ip_address AS value,
|
||
CONCAT(?, ip.ip_address) AS `desc`,
|
||
CONCAT(?, d.name) AS return_value,
|
||
'devices/show/' AS link
|
||
FROM devices d
|
||
JOIN ifaces ic ON ic.device_id = d.id
|
||
LEFT JOIN ip_addresses ip1 ON ip1.iface_id = ic.id
|
||
LEFT JOIN vlan_ifaces vi ON vi.iface_id = ic.id
|
||
LEFT JOIN ip_addresses ip2 ON ip2.vlan_iface_id = vi.id
|
||
WHERE ip1.ip_address LIKE ? COLLATE utf8_general_ci OR
|
||
ip2.ip_address LIKE ? COLLATE utf8_general_ci
|
||
LEFT JOIN ip_addresses ip ON ip.iface_id = ic.id
|
||
WHERE ip.ip_address LIKE ? COLLATE utf8_general_ci
|
||
", array
|
||
(
|
||
__('IP address') . ": ",
|
||
... | ... | |
public function device_ssid($keyword)
|
||
{
|
||
return $this->db->query("
|
||
SELECT d.id, ws.ssid AS value,
|
||
CONCAT(?, ws.ssid) AS `desc`,
|
||
SELECT d.id, s.wireless_ssid AS value,
|
||
CONCAT(?, s.wireless_ssid) AS `desc`,
|
||
CONCAT(?, d.name) AS return_value,
|
||
'devices/show/' AS link
|
||
FROM devices d
|
||
JOIN ifaces i ON i.device_id = d.id
|
||
JOIN wireless_ifaces wi ON wi.iface_id = i.id
|
||
JOIN segments s ON i.segment_id = s.id
|
||
JOIN wireless_segments ws ON ws.segment_id = s.id
|
||
WHERE wi.wmode = ? AND s.medium_id = ? AND
|
||
ws.ssid LIKE ? COLLATE utf8_general_ci
|
||
JOIN links s ON i.link_id = s.id
|
||
WHERE i.wireless_mode = ? AND s.medium = ? AND
|
||
s.wireless_ssid LIKE ? COLLATE utf8_general_ci
|
||
", array
|
||
(
|
||
__('SSID') . ": ",
|
||
__('Device') . " ",
|
||
Wireless_iface_Model::WIRELESS_MODE_AP,
|
||
Iface_Model::WIRELESS_MODE_AP,
|
||
Link_Model::AIR,
|
||
"%$keyword%"
|
||
));
|
||
... | ... | |
}
|
||
|
||
/**
|
||
* Searchs in segments by name
|
||
* Searchs in linkss by name
|
||
*
|
||
* @author Michal Kliment
|
||
* @param string $keyword
|
||
* @return MySQL_Result object
|
||
*/
|
||
public function segment_name($keyword)
|
||
public function link_name($keyword)
|
||
{
|
||
return $this->db->query("
|
||
SELECT s.id,
|
||
s.name AS value,
|
||
CONCAT('Segment ',s.name) AS return_value,
|
||
CONCAT(?,ROUND(s.bitrate / 1048576), ' Mbps') AS `desc`,
|
||
'segments/show' AS link
|
||
FROM segments s
|
||
SELECT s.id, s.name AS value,
|
||
CONCAT(?, s.name) AS return_value,
|
||
CONCAT(?, ROUND(s.bitrate / 1048576), ' Mbps') AS `desc`,
|
||
'links/show' AS link
|
||
FROM links s
|
||
WHERE s.name LIKE ? COLLATE utf8_general_ci
|
||
", __('Bitrate') . ": ", "%$keyword%");
|
||
", array
|
||
(
|
||
__('Link') . ' ',
|
||
__('Bitrate') . ': ',
|
||
"%$keyword%"
|
||
));
|
||
}
|
||
|
||
}
|
Také k dispozici: Unified diff
Upravy:
- uprava vyhledavani pro #185