зеркало из https://github.com/mozilla/phonebook.git
Fixed random breakage to existing code; refactoring
git-svn-id: http://svn.mozilla.org/projects/phonebook/trunk@57212 4eb1ac78-321c-0410-a911-ec516a8615a5
This commit is contained in:
Родитель
355735c5b3
Коммит
fb0c80db9c
|
@ -127,6 +127,14 @@ class MozillaSearchAdapter extends SearchAdapter {
|
|||
);
|
||||
|
||||
public function search_users($search) {
|
||||
if ($search != "random") {
|
||||
return $this->_search_users($search);
|
||||
}
|
||||
$entries = $this->_search_users('*');
|
||||
return array($entries[mt_rand(0, count($entries) - 1)]);
|
||||
}
|
||||
|
||||
public function _search_users($search) {
|
||||
$filter = ($search == '*') ? 'objectClass=mozComPerson' : "(&(|(cn=*$search*)(mail=*$search*)(im=*$search*))(objectClass=mozComPerson))";
|
||||
return $this->query_users($filter, 'dc=mozilla', $this->fields);
|
||||
}
|
||||
|
|
10
search.php
10
search.php
|
@ -6,17 +6,7 @@ require_once("preprocessors-attr.inc");
|
|||
$auth = new MozillaAuthAdapter();
|
||||
$search = new MozillaSearchAdapter($ldapconn);
|
||||
$keyword = isset($_GET["query"]) ? $_GET["query"] : '*';
|
||||
|
||||
if ($keyword == 'random') {
|
||||
$keyword = '*';
|
||||
$random = true;
|
||||
}
|
||||
|
||||
$entries = normalize($search->search_users($keyword));
|
||||
$entries = array(
|
||||
0 => $entries[mt_rand(0, count($entries)-1)]
|
||||
);
|
||||
|
||||
$attr_preps = get_attr_preprocessors();
|
||||
|
||||
$preprocess_attr_functions = array();
|
||||
|
|
Загрузка…
Ссылка в новой задаче