function updateProject() { global $url, $auth, $db; $pNameEnd = strrpos($url, "/"); $oldName = substr($url, 0, $pNameEnd); $prj = new EcProject(); $prj->name = $oldName; $prj->fetch(); $role = intVal($prj->checkPermission($auth->getEcUserId())); if ($role != 3) { header("Cache-Control: no-cache; must-revalidate;"); flash("You do not have permission to manage this project", "err"); $url = str_replace("update", "", $url); header("location: {$SITE_ROOT}/{$url}"); } else { header("Cache-Control: no-cache; must-revalidate;"); if ($_SERVER["REQUEST_METHOD"] == "POST") { $xml = getValIfExists($_POST, "xml"); $managers = getValIfExists($_POST, "managers"); $curators = getValIfExists($_POST, "curators"); $public = getValIfExists($_POST, "public"); $listed = getValIfExists($_POST, "listed"); $drty = false; if ($xml && $xml != "") { $prj->parse($xml); if ($prj->name != oldName) { header("HTTP/1.1 400 CANNOT CHANGE NAME", 400); return false; } $drty = true; } echo 'description ' . $prj->description . ' ' . getValIfExists($_POST, "description"); if ($prj->description != getValIfExists($_POST, "description")) { $prj->description = getValIfExists($_POST, "description"); $drty = true; } if ($prj->image != getValIfExists($_POST, "projectImage")) { $prj->image = getValIfExists($_POST, "projectImage"); $drty = true; } if ($public !== false) { $prj->isPublic = $public === "true"; $drty = true; } if ($listed !== false) { $prj->isListed = $listed === "true"; $drty = true; } if ($drty) { $prj->publicSubmission = true; $prj->put($oldName); } if ($curators) { $prj->setCurators($curators); } if ($managers) { $prj->setManagers($managers); } } else { $managers = $prj->getManagers(); if (is_array($managers)) { $managers = '"' . implode(",", $managers) . '"'; } else { $curators = '""'; } $curators = $prj->getCurators(); if (is_array($curators)) { $curators = '"' . implode(",", $curators) . '"'; } else { $curators = '""'; } $img = $prj->image; $img = substr($img, strpos($img, '~') + 1); echo applyTemplate("./base.html", "./updateProject.html", array("projectName" => $prj->name, "description" => $prj->description, "image" => $img, "managers" => $managers, "curators" => $curators, "public" => $prj->isPublic, "listed" => $prj->isListed)); return; } } }