Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions public_html/api/1.1/get/project/object-idnos/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
include("../../../../../header.php");

ini_set('memory_limit',-1);
set_time_limit(0);

// we don't need engine's display handling here.
$engine->obCallback = FALSE;

try {
if (!projects::validID($engine->cleanGet['MYSQL']['id'])) throw new Exception("Invalid Project ID.");
if (!projects::get($engine->cleanGet['MYSQL']['id'])) throw new Exception("Project doesn't exist.");
if (($project_idnos = projects::get_project_idnos($engine->cleanGet['MYSQL']['id'])) === false) {
throw new Exception("Unable to retrieve IDNOs");
}

$json = json_encode($project_idnos);
print (isset($engine->cleanGet['HTML']['prettyPrint']))?json_format($json):$json;

exit;
}
catch(Exception $e) {
print json_encode(array("error" => "true", "message" => $e->getMessage()));
}

exit;
?>
30 changes: 22 additions & 8 deletions public_html/includes/classes/projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@
class projects {

public static function validID($id) {

if (!validate::integer($id)) {
return FALSE;
}

if (!validate::integer($id)) return FALSE;
return TRUE;

}

/**
Expand Down Expand Up @@ -180,18 +175,37 @@ public static function title($projectID) {

$sql = sprintf("SELECT `projectName` from `projects` WHERE `ID`='%s' LIMIT 1",mfcs::$engine->openDB->escape($projectID));
$sqlResult = mfcs::$engine->openDB->query($sql);

if (!$sqlResult['result']) {
errorHandle::newError(__METHOD__."() - : ".$sqlResult['error'], errorHandle::DEBUG);
return FALSE;
}

$row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC);

return (isset($row['projectName']))?$row['projectName']:"Project Not Found";

}

public static function get_project_idnos($projectID) {

$sql = sprintf("select `objects`.`idno` from `objectProjects` left join `objects` on `objects`.`ID`=`objectProjects`.`objectId` WHERE `objects`.`metadata`='0' AND `objectProjects`.`projectId`='%s'",
mfcs::$engine->openDB->escape($projectID)
);
$sqlResult = mfcs::$engine->openDB->query($sql);

if (!$sqlResult['result']) {
errorHandle::newError(__METHOD__."() - getting all object IDNOs for project: ".$projectID, errorHandle::DEBUG);
return FALSE;
}

$idnos = array();
while($row = mysql_fetch_array($sqlResult['result'], MYSQL_ASSOC)) {
$idnos[] = $row['idno'];
}
return ($idnos);
}

}

?>