Revize 2238
Přidáno uživatelem Ondřej Fibich před asi 11 roky(ů)
freenetis/branches/1.1/application/controllers/search.php | ||
---|---|---|
$total_counts = array();
|
||
$values = array();
|
||
|
||
// no rules => empty result
|
||
if (!count($search_rules))
|
||
{
|
||
$this->results = array();
|
||
return;
|
||
}
|
||
|
||
// each rule should get oportunity to be searched (reserved limits)
|
||
$result_limit = !empty($limit) ? ceil($limit / count($search_rules)) : NULL;
|
||
|
freenetis/branches/1.1/application/models/search.php | ||
---|---|---|
* if property equals to searched keyword [optional, default FALSE]
|
||
* - variation_enabled: enable variations of keyword for searching this
|
||
* property, used because performance reasons [optional, default FALSE]
|
||
* - access: access array with AXO value and AXO section required for
|
||
* searching this property
|
||
*
|
||
* @var array
|
||
*/
|
||
... | ... | |
'method' => 'member_name',
|
||
'model' => 'member',
|
||
'weight' => 5,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_id',
|
||
'model' => 'member',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_variable_symbol',
|
||
'model' => 'member',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_comment',
|
||
'model' => 'member',
|
||
'weight' => 0.5,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
... | ... | |
'model' => 'member',
|
||
'weight' => 0.4,
|
||
'ignore_special_threatment' => TRUE,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_street',
|
||
'model' => 'member',
|
||
'weight' => 0.6,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_street_number',
|
||
'model' => 'member',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_organization_identifier',
|
||
'model' => 'member',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'member_vat_organization_identifier',
|
||
'model' => 'member',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'user_name',
|
||
'model' => 'user',
|
||
'weight' => 1,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Users_Controller', 'show')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'user_login',
|
||
'model' => 'user',
|
||
'weight' => 0.5
|
||
'weight' => 0.5,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'user_contact',
|
||
'model' => 'user',
|
||
'weight' => 0.1
|
||
'weight' => 0.1,
|
||
'access' => array('Members_Controller', 'members')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'town_name',
|
||
'model' => 'town',
|
||
'weight' => 1,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Address_points_Controller', 'town')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'device_name',
|
||
'model' => 'device',
|
||
'weight' => 1,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Devices_Controller', 'devices')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'device_mac',
|
||
'model' => 'device',
|
||
'weight' => 0.5
|
||
'weight' => 0.5,
|
||
'access' => array('Devices_Controller', 'devices')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'device_ip_address',
|
||
'model' => 'device',
|
||
'weight' => 0.5
|
||
'weight' => 0.5,
|
||
'access' => array('Devices_Controller', 'devices')
|
||
),
|
||
array(
|
||
'method' => 'device_ssid',
|
||
'model' => 'device',
|
||
'weight' => 0.5
|
||
'weight' => 0.5,
|
||
'access' => array('Devices_Controller', 'devices')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'subnet_name',
|
||
'model' => 'subnet',
|
||
'weight' => 1,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Subnets_Controller', 'subnet')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'subnet_address',
|
||
'model' => 'subnet',
|
||
'weight' => 1
|
||
'weight' => 1,
|
||
'access' => array('Subnets_Controller', 'subnet')
|
||
),
|
||
array
|
||
(
|
||
'method' => 'link_name',
|
||
'model' => 'link',
|
||
'weight' => 1,
|
||
'variation_enabled' => TRUE
|
||
'variation_enabled' => TRUE,
|
||
'access' => array('Links_Controller', 'link')
|
||
),
|
||
);
|
||
|
||
... | ... | |
*/
|
||
public static function get_rules_sorted_by_weight()
|
||
{
|
||
// get rules (clone)
|
||
$rules = self::$rules;
|
||
$rules_count = count($rules);
|
||
|
||
// remove items with restricted access
|
||
for ($i = 0; $i < $rules_count; $i++)
|
||
{
|
||
$axo = NULL;
|
||
|
||
if (isset($rules[$i]['access']) &&
|
||
is_array($rules[$i]['access']) &&
|
||
count($rules[$i]['access']) >= 2)
|
||
{
|
||
$axo = $rules[$i]['access'];
|
||
}
|
||
|
||
if ($axo && !Controller::instance()->acl_check_view($axo[0], $axo[1]))
|
||
{
|
||
unset($rules[$i]); // remove rule
|
||
}
|
||
}
|
||
|
||
// sort rules
|
||
usort($rules, 'Search_Model::cmp_rule_weight');
|
||
|
||
// return values
|
||
return $rules;
|
||
}
|
||
|
Také k dispozici: Unified diff
Novinky:
- fixes #812: Omezeni vyhledavani dle pristupovych prav uzivatele