Example #1
0
#And finally, discover more authentication credentials
$s3ql = array('user_id' => '1', 'db' => $db);
#to be changed once any user can query this collections, his own items
$s3ql['from'] = 'authentication';
$s3ql['where']['user_id'] = $id;
list($valid, $authentications) = apiQuery($s3ql);
#Discover also all authorities
$s3ql = array('user_id' => '1', 'db' => $db);
#TO BE CHANGED ONCE ALL USERS CAN SEE AUTHORITIES
$s3ql['from'] = 'authority';
list($valid, $authorities) = apiQuery($s3ql);
$json_auth = 'authorities=' . json_encode($authorities) . '';
#And the protocols because authroties don't have a protocol value, only an id
$s3ql = array('user_id' => '1', 'db' => $db);
$s3ql['from'] = 'protocol';
list($valid, $protocols) = apiQuery($s3ql);
$json_prot = 'protocols=' . json_encode($protocols) . '';
$newProt = array();
if (is_array($protocols)) {
    foreach ($protocols as $prot) {
        $newProt[$prot['item_id']] = $prot['label'];
    }
}
if (!$key) {
    $key = get_user_key($user_id, $db);
}
#now encode the authorities for the javascript that is coming
//
//if(is_array($authorities)){
//foreach ($authorities as $authority) {
//	$json_auth_label[] = $authority['DisplayLabel'];
Example #2
0
function checkValidAuthority($authority, $db)
{
    $user_proj = create_authentication_proj($db, '1');
    #still dbating whether this should be a public project.
    if (!empty($user_proj)) {
        #find the authority in the list of authority labels
        $s3ql = array('user_id' => '1', 'db' => $db);
        #to be changes once user is given permission on project
        $s3ql['from'] = 'authority';
        $s3ql['where']['DisplayLabel'] = $authority;
        list($valid, $data) = apiQuery($s3ql, $user_proj);
        if (is_array($data[0])) {
            $reqAuth = $data[0];
        }
    }
    if (!is_array($reqAuth)) {
        return array(false);
    } else {
        return array(true, $reqAuth, $user_proj);
    }
}
Example #3
0
}
#if a key has been provided, validate the key
$key = $_REQUEST['key'];
include_once 'core.header.php';
include_once S3DB_SERVER_ROOT . '/s3dbcore/api.php';
#$user_proj = $GLOBALS['users_project'];
if (!$_REQUEST['query']) {
    $s3ql = compact('user_id', 'db');
    $s3ql['from'] = 'authority';
}
#now, if query is not empyt, read it, parse it, interpret it.
if ($_REQUEST['query']) {
    $query = $_REQUEST['query'];
    $q = compact('query', 'format', 'key', 'user_proj', 'user_id', 'db');
    $s3ql = parse_xml_query($q);
    ##now interpret the query
    $s3ql['db'] = $db;
    $s3ql['user_id'] = $user_id;
    $s3ql['format'] = $format;
}
list($valid, $data, $cols) = apiQuery($s3ql);
if ($valid) {
    #now display the data
    if (!$cols) {
        $cols = array('user_id', 'authentication_id', 'created_on');
    }
    $z = compact('data', 'cols', 'format');
    echo outputFormat($z);
} else {
    echo $data;
}