Beispiel #1
0
function getProjectInfo()
{
    $query = "SELECT p.id, p.duedate, p.title, p.notes, p.hash, p.moveto, p.sdurl FROM projects p WHERE p.id = " . sqlSafe($_SESSION['project']);
    $result = readQuery($query);
    $return = array();
    while ($row = $result->fetch_assoc()) {
        $return = $row;
    }
    return $return;
}
Beispiel #2
0
function getProjects($account)
{
    $query = "SELECT p.id, p.duedate, p.title, p.notes, (select count(o.id) from objectProject o where p.id = o.project_id group by o.project_id) as nObjects  FROM projects p WHERE account_id = " . sqlSafe($account);
    $result = readQuery($query);
    $return = array();
    while ($row = $result->fetch_assoc()) {
        array_push($return, $row);
    }
    return $return;
}
Beispiel #3
0
function authorize($email)
{
    $query = "SELECT * FROM accounts WHERE email = " . sqlSafe($email);
    $result = readQuery($query);
    while ($row = $result->fetch_assoc()) {
        $_SESSION["auth_account_id"] = $row["id"];
        $_SESSION["auth_active_time"] = date("Y-m-d H:i:s");
        $_SESSION["auth_valid"] = TRUE;
        return true;
    }
    $_SESSION["auth_invalid_reason"] = "That is not an account, please register first";
    return false;
}
Beispiel #4
0
function getFollowers($id, $timestamp)
{
    $day = 24 * 60 * 60;
    $sdate = sqlSafe(date('Y-m-d H:i:s', $timestamp - $day / 2));
    $edate = sqlSafe(date('Y-m-d H:i:s', $timestamp + $day / 2));
    $id = sqlSafe($id);
    $query = "SELECT followers FROM account_stats WHERE user_id = {$id} AND (record_date BETWEEN {$sdate} AND {$edate})";
    //print $query;
    $result = readQuery($query);
    if ($result) {
        if ($row = $result->fetch_row()) {
            return $row[0];
        }
    }
    return null;
}
Beispiel #5
0
function getItems()
{
    $project = $_SESSION['project'];
    $query = "SELECT o.irn, o.image_url,  o.accession_no, o.title FROM objectProject op\n\t LEFT JOIN objects o ON (op.object_irn = o.irn AND op.object_holder = o.holder)\n\t WHERE op.project_id = " . sqlSafe($project);
    $res = readQuery($query);
    $return = array("objects" => array());
    while ($row = $res->fetch_row()) {
        $jr = array();
        $jr['irn'] = $row[0];
        $jr['image_url'] = $row[1];
        $jr['accession_no'] = $row[2];
        $jr['title'] = $row[3];
        array_push($return['objects'], $jr);
    }
    print json_encode($return);
}
Beispiel #6
0
function getChildren($irn)
{
    $irn = sqlSafe($irn);
    $query = "SELECT c.irn, c.title, c.accession_no, c.location_barcode, c.location_name, c.barcode FROM children c LEFT JOIN objects o ON (o.irn = c.parent_irn) WHERE c.parent_irn = {$irn} AND (c.location_name != o.location_name OR o.location_name is null) order by c.accession_no";
    $result = readQuery($query);
    //var_dump($query);
    $child = array();
    while ($row = $result->fetch_assoc()) {
        array_push($child, $row);
    }
    return $child;
}
Beispiel #7
0
function checkInProject()
{
    $irn = $_GET['irn'];
    $project = $_SESSION['project'];
    $query = "SELECT * FROM objectProject WHERE object_irn = " . sqlSafe($irn) . " AND project_id = " . sqlSafe($project);
    if (hasSQLerrors()) {
        throwError(getSQLerrors());
    }
    $result = readQuery($query);
    if ($result->num_rows > 0) {
        $result = array("in_project" => true);
    } else {
        $result = array("in_project" => false);
    }
    print json_encode($result);
    exit(0);
}