Commit b190c0fd authored by Leigh Stoller's avatar Leigh Stoller

Fix up /p/project/profile handling.

parent 4c5ef92a
......@@ -94,13 +94,20 @@ $am_array = array('Utah DDC' =>
if (isset($profile)) {
#
# Guest users must use the uuid, but logged in users may use the
# internal index.
# internal index. But, we have to support simple the URL too, which
# is /p/project/profilename, but only for public profiles. Need to
# deal with the version at some point.
#
if (! ($this_user || IsValidUUID($profile))) {
if (isset($project) && isset($profile)) {
$obj = Profile::LookupByName($project, $profile);
}
elseif ($this_user || IsValidUUID($profile)) {
$obj = Profile::Lookup($profile);
}
else {
SPITUSERERROR("Illegal profile for guest user: $profile");
exit();
}
$obj = Profile::Lookup($profile);
if (! $obj) {
SPITUSERERROR("No such profile: $profile");
exit();
......
......@@ -99,9 +99,22 @@ class Profile
return null;
}
# Lookup by name/version. If no version, then return highest
# numbered version.
function LookupByName() {}
function LookupByName($project, $profile) {
$pid = $project->pid();
$safe_profile = addslashes($profile);
$query_result =
DBQueryWarn("select idx from apt_profiles ".
"where pid='$pid' and ".
" (name='$safe_profile' or uuid='$safe_profile')");
if ($query_result && mysql_num_rows($query_result)) {
$row = mysql_fetch_row($query_result);
$idx = $row[0];
return Profile::Lookup($idx);
}
return null;
}
#
# Refresh an instance by reloading from the DB.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment