\n";
}
}
return $persons;
}
// find person roles
$_person= $plc->person;
$_roles= $_person['role_ids'];
///////////////////////////////////////////////////////////////////////
// Initially, we need a search form, and blank information after that.
// Based on the fields of the search form, we should be able to populate a lot
// of information, related to user, site, keys,
//
// from a simple domain name search, it would display the site,
// nodes -> pcu
// users grouped by role,
// from a user search, it would find,
// user info link, site, roles, etc.
//
// userquery will be one of these types:
// part of a user name, email, user_id
// part of a site name, site alias, site_id
// part of a node name, domain, node_id
//
// we should be able to return results based on these guesses. If they're
// good, we'll get hits, if nothing comes back, we won't display anything.
echo "
\n
\n
\n
\n";
// if userquery then search based on string
if( $_POST['userquery'] or $_GET['userquery']) {
if ( $_POST['userquery'] ) {
$query = $_POST['userquery'];
} else {
$query = $_GET['userquery'];
}
echo "
Search Results:
\n";
$f_commas = explode(",", $query);
// PHASE 1: query contains email, user_id, or part of a user name
foreach($f_commas as $tok) {
$tok = trim($tok); // strip white space.
$e = false;
//find user by email
if ( is_valid_email_addr($tok) ){
$u = get_and_print_user(array("email"=>$tok));
$e = true;
if( count( $u ) == 0 ) $none = 1;
}
$n = false;
// find user by user_id
if ( is_numeric($tok) ){
$u = get_and_print_user(array("person_id"=>intval($tok)));
$n = true;
if( count( $u ) == 0 ) $none = 1;
}
// neither of the above,
if (!$n && !$e) {
// split on spaces, and search each part.
// TODO: search upper and lower-case
$f_spaces = explode(" ", $tok);
foreach($f_spaces as $stok) {
// assume $tok is part of a name
// get_user
$a = get_and_print_user(array("first_name"=>$stok));
$b = get_and_print_user(array("last_name"=>$stok));
// c = intersect_users(a, b)
// if c
// print_user(c),
// else
// print_user(a,b)
}
if( count( $a ) == 0 && count( $b ) == 0 ) $none = 1;
}
// PHASE 2: query contains login_base, site_id, or part of a site name
// find site by login_base
$lb = false;
$s = get_and_print_site(array("login_base"=>strtolower($tok)));
if( count( $s ) == 0 ) $none = 1;
else $lb = true;
$n = false;
// find site by site_id
if ( is_numeric($tok) ){
$s = get_and_print_site(array("site_id"=>intval($tok)));
$n = true;
if( count( $s ) == 0 ) $none = 1;
}
if( !$lb && !$n ) {
$f_spaces = explode(" ", $tok);
foreach($f_spaces as $stok) {
$a = get_and_print_site(array("name"=>$stok));
}
if( count($a) == 0 ) $none = 1;
}
// PHASE 3: query contains part of a node name, domain, node_id
//if( $none == 1 ) echo "