All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 95c3c21f authored by Leigh B. Stoller's avatar Leigh B. Stoller

Do not allow the root template to be "hidden"

parent c227a8f7
......@@ -74,6 +74,26 @@ function TBIsExperimentTemplateHidden($guid, $version)
return $row[hidden];
}
#
# Check if a template is the root template (cannot be hidden)
#
# usage TBIsRootTemplate($guid, $version)
# returns 1 if hidden
# returns 0 if visible
#
function TBIsRootTemplate($guid, $version)
{
$guid = addslashes($guid);
$version = addslashes($version);
$query_result =
DBQueryFatal("select parent_guid from experiment_templates ".
"where guid='$guid' and vers='$version' and ".
" parent_guid is null");
return mysql_num_rows($query_result);
}
#
# Experiment Template permission checks; using the experiment access checks.
#
......
......@@ -197,13 +197,19 @@ WRITESUBMENUBUTTON("Show NS File &nbsp &nbsp",
WRITESUBMENUBUTTON("Modify Template",
"template_modify.php?guid=$guid&version=$version");
if (TBIsExperimentTemplateHidden($guid, $version)) {
WRITESUBMENUBUTTON("Show Template",
"template_show.php?guid=$guid&version=$version&action=show");
}
else {
WRITESUBMENUBUTTON("Hide Template",
"template_show.php?guid=$guid&version=$version&action=hide");
if (! TBIsRootTemplate($guid, $version)) {
$hidden = TBIsExperimentTemplateHidden($guid, $version);
if ($hidden) {
WRITESUBMENUBUTTON("Show Template",
"template_show.php?guid=$guid".
"&version=$version&action=show");
}
else {
WRITESUBMENUBUTTON("Hide Template",
"template_show.php?guid=$guid".
"&version=$version&action=hide");
}
}
WRITESUBMENUBUTTON("Instantiate Template",
......
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