コード例 #1
0
$sqlbase = "lsf2";
if (isset($_REQUEST['str'])) {
    $str = $_REQUEST['str'];
} else {
    $str = "";
}
if (isset($_REQUEST['labgroup'])) {
    $group = $_REQUEST['labgroup'];
} else {
    $group = "";
}
date_default_timezone_set('America/New_York');
if ($group == "") {
    $qstr = 'select user_name from user';
    if ($str != "") {
        $qstr .= " where user_name like '%{$str}%'";
    }
    $qstr .= " order by user_name limit 200";
} else {
    $qstr = 'select user_name from user, labgroup, user_group where ';
    if ($str != "") {
        $qstr .= " user_name like '%{$str}%' and";
    }
    $qstr .= " user.user_internal_id = user_group.user_internal_id and user_group.labgroup_internal_id = labgroup.labgroup_internal_id and labgroup.labgroup_name = '{$group}' ";
    $qstr .= " order by user_name limit 200";
}
error_log($qstr . "\n", 3, "/tmp/log");
$rawdata = mysql_magic($qstr);
foreach ($rawdata as $data) {
    print $data['user_name'] . "\n";
}
コード例 #2
0
function get_users_by_labgroup($group)
{
    $qstr = "select user_internal_id from labgroup,user_group where labgroup.labgroup_name = '{$group}' and labgroup.labgroup_internal_id = user_group.labgroup_internal_id";
    $rows = mysql_magic($qstr);
    $groups = array();
    foreach ($rows as $row) {
        $groups[] = $row['user_internal_id'];
    }
    return $groups;
}