public static function convertImage($result, $format = 'xml') { return VMCaster::convertImage($result, $format); }
public function vappimageAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(); $format = $this->getRequest()->getParam("format"); $strict = isset($_GET["strict"]) ? true : false; $guid = trim($this->getRequest()->getParam("guid")); if ($format === null || $format === "json") { header('Content-type: application/json'); } else { if ($format === "xml") { header('Content-type: application/xml'); } } if ($guid !== "") { $imageid = null; if (strpos($guid, ":") !== false) { $tmp = explode(":", $guid); if (count($tmp) > 1) { $guid = $tmp[0]; $imageid = $tmp[1]; } } if ($imageid !== null) { $result = VMCaster::getImageInfoById($imageid, $guid, $strict); } else { $result = VMCaster::getImageInfoByIdentifier($guid); } $canaccessvadata = false; $privs = null; $user = null; if ($result !== null) { $result["isprivateimage"] = false; $result["canaccessprivate"] = true; $vapp = $result["va"]; if ($vapp->imglstprivate) { $result["isprivateimage"] = true; $result["canaccessprivate"] = false; $vapp = $result["va"]; $app = $vapp->getApplication(); $privs = null; $users = new Default_Model_Researchers(); $users->filter->id->equals($this->session->userid); if (count($users->items) > 0) { $user = $users->items[0]; $privs = $user->getPrivs(); } if ($privs !== null) { $canaccessvadata = $privs->canAccessVAPrivateData($app->guid); } $result["canaccessprivate"] = $canaccessvadata; } } if ($result !== null) { $result['sites'] = VMCaster::getSitesByVMI($guid, $imageid); } if ($result !== null && $format == null) { //UI call $result["result"] = "success"; $va = $result["va"]; $app = $va->getApplication(); $version = $result["version"]; $image = $result["image"]; $result["app"] = array("id" => $app->id, "name" => $app->name, "cname" => $app->cname); $result["va"] = array("id" => $va->id); $result["version"] = array("id" => $version->id, "version" => $version->version, "published" => $version->published, "archived" => $version->archived, "enabled" => $version->enabled); $result["image"] = array("id" => $image->id, "identifier" => $image->guid); echo json_encode($result, JSON_HEX_TAG | JSON_NUMERIC_CHECK); return; } else { if ($format !== null) { if ($result !== null) { $result = VMCaster::convertImage($result, $format); } if ($result !== null) { echo $result; } else { header('HTTP/1.0 404 Not Found'); header("Status: 404 Not Found"); } return; } } } echo json_encode(array("result" => "error", "message" => "Image not found")); }