Skip to content

Commit

Permalink
Added 'delete labelset' function. Checks to make sure that no questio…
Browse files Browse the repository at this point in the history
…ns rely on label set then removes complete set (including all titles/answers)

git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@578 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Jul 26, 2003
1 parent 0c5fe03 commit 8105f07
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions admin/labels.php
Expand Up @@ -45,6 +45,7 @@
if ($action == "updateset") {updateset($lid);}
if ($action == "insertset") {insertset();}
if ($action == "modanswers") {modanswers($lid);}
if ($action == "delset") {if (delset($lid)) {unset($lid);}}

echo $htmlheader;
echo "<script type='text/javascript'>\n";
Expand Down Expand Up @@ -162,6 +163,7 @@
echo "\t\t\t\t\t<img src='./images/blank.gif' width='60' height='20' border='0' hspace='0' align='left'>\n";
echo "\t\t\t\t\t<img src='./images/seperator.gif' border='0' hspace='0' align='left'>\n";
echo "\t\t\t\t\t<input type='image' src='./images/edit.gif' title='"._L_EDIT_BT."' align='left' border='0' hspace='0' onclick=\"window.open('labels.php?action=editset&lid=$lid', '_top')\">";
echo "\t\t\t\t\t<input type='image' src='./images/delete.gif' title='"._L_DEL_BT."' align='left' border='0' hspace='0' onClick=\"window.open('labels.php?action=delset&lid=$lid', '_top')\">";
echo "\t\t\t\t\t</td>\n";
echo "\t\t\t\t</tr>\n";
echo "\t\t\t</table>\n";
Expand Down Expand Up @@ -277,6 +279,26 @@ function updateset($lid)
echo "<script type=\"text/javascript\">\n<!--\n alert(\""._LB_FAIL_UPDATESET." - ".$query." - ".mysql_error()."\")\n //-->\n</script>\n";
}
}
function delset($lid)
{
//CHECK THAT THERE ARE NO QUESTIONS THAT RELY ON THIS LID
$query = "SELECT qid FROM questions WHERE lid=$lid";
$result = mysql_query($query);
$count=mysql_num_rows($result);
if ($count > 0)
{
echo "<script type=\"text/javascript\">\n<!--\n alert(\""._LB_FAIL_DELSET." \")\n //-->\n</script>\n";
return false;
}
else //There are no dependencies. We can delete this safely
{
$query = "DELETE FROM labels WHERE lid=$lid";
$result = mysql_query($query);
$query = "DELETE FROM labelsets WHERE lid=$lid";
$result = mysql_query($query);
return true;
}
}
function insertset()
{
if (get_magic_quotes_gpc() == "0")
Expand Down

0 comments on commit 8105f07

Please sign in to comment.