- Let Maintainers add, edit and delete Notes.
- Display out front, special class notes ( WARNING & HOWTO )
This commit is contained in:
committed by
Jeremy Newman
parent
27af6a8f7e
commit
1f9dda0c38
@@ -7,45 +7,104 @@
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
require(BASE."include/"."application.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
if(!loggedin() || (!havepriv("admin") && !isMaintainer($appId,$versionId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Add Application Note");
|
||||
|
||||
$t = new TableVE("create");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
//set link for version
|
||||
if ($versionId != 0)
|
||||
{
|
||||
$t->update($HTTP_POST_VARS);
|
||||
$versionLink = "&versionId=$versionId";
|
||||
}
|
||||
|
||||
if($sub == "Submit")
|
||||
{
|
||||
|
||||
$query = "INSERT into appNotes VALUES (null, '".
|
||||
addslashes($noteTitle)."', '".
|
||||
addslashes($noteDesc)."', ".
|
||||
"$appId , $versionId);";
|
||||
if (mysql_query($query))
|
||||
{
|
||||
//successful
|
||||
$email = getNotifyEmailAddressList($appId, $versionId);
|
||||
if($email)
|
||||
{
|
||||
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
|
||||
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= ($current->username ? $current->username : "Anonymous")." added note to ".$fullAppName."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= "title: ".$noteTitle."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= $noteDesc."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= STANDARD_NOTIFY_FOOTER;
|
||||
|
||||
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
|
||||
|
||||
} else
|
||||
{
|
||||
$email = "no one";
|
||||
}
|
||||
addmsg("mesage sent to: ".$email, green);
|
||||
|
||||
$statusMessage = "<p>Note added into the database</p>\n";
|
||||
addmsg($statusMessage,Green);
|
||||
}
|
||||
else
|
||||
{
|
||||
//error
|
||||
addmsg($query,red);
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
addmsg($statusMessage,red);
|
||||
}
|
||||
redirect(apidb_fullurl("appview.php?appId=".$appId.$versionLink));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
$table = "appNotes";
|
||||
apidb_header("Add Application Note");
|
||||
|
||||
if (!$versionId) { $versionId = 0; }
|
||||
echo "<form method=post action='addAppNote.php'>\n";
|
||||
echo html_frame_start("Add Application Note $appId", "90%","",0);
|
||||
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
|
||||
|
||||
//delete old NONAMES
|
||||
mysql_query("DELETE FROM $table WHERE noteTitle = 'NONAME'");
|
||||
echo '<input type=hidden name="appId" value='.$appId.'>';
|
||||
echo '<input type=hidden name="versionId" value='.$versionId.'>';
|
||||
echo '<tr><td colspan=2 class=color4>';
|
||||
echo '<center><b>You can use html to make your Warning, Howto or Note look better.</b></center>';
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
//show edit form
|
||||
$query = "INSERT INTO $table VALUES(0, 'NONAME', '', $appId, $versionId)";
|
||||
echo add_br($noteDesc);
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
if ($noteTitle == "HOWTO" || $noteTitle == "WARNING")
|
||||
{
|
||||
echo '<input type=hidden name="noteTitle" value='.$noteTitle.'>';
|
||||
echo '<tr><td class=color1>Type</td><td class=color0>'.$noteTitle.'</td></tr>',"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<tr><td class=color1>Title</td><td class=color0><input size=80% type="text" name="noteTitle" type="text" value="'.$noteTitle.'"></td></tr>',"\n";
|
||||
}
|
||||
echo '<tr><td class=color4>Description</td><td class=color0>', "\n";
|
||||
echo '<textarea cols=$50 rows=10 name="noteDesc">'.stripslashes($noteDesc).'</textarea></td></tr>',"\n";
|
||||
|
||||
$t->create($query, $table, "noteId");
|
||||
echo '<tr><td colspan=2 align=center class=color3>',"\n";
|
||||
echo '<input type="submit" name=preview value="Preview"> ',"\n";
|
||||
echo '<input type="submit" name=sub value="Submit"></td></tr>',"\n";
|
||||
echo html_table_end();
|
||||
echo html_frame_end();
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId&versionId=$versionId");
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId".$versionLink);
|
||||
apidb_footer();
|
||||
}
|
||||
|
||||
apidb_footer();
|
||||
|
||||
?>
|
||||
|
||||
@@ -6,38 +6,166 @@
|
||||
|
||||
include("path.php");
|
||||
include(BASE."include/"."incl.php");
|
||||
include(BASE."include/"."tableve.php");
|
||||
include(BASE."include/"."qclass.php");
|
||||
require(BASE."include/"."application.php");
|
||||
|
||||
global $apidb_root;
|
||||
|
||||
|
||||
//check for admin privs
|
||||
if(!loggedin() || (!havepriv("admin") && !$current->ownsApp($appId)) )
|
||||
if(!loggedin() || (!havepriv("admin") && !isMaintainer($appId,$versionId)) )
|
||||
{
|
||||
errorpage("Insufficient Privileges!");
|
||||
exit;
|
||||
}
|
||||
|
||||
apidb_header("Edit Application Note");
|
||||
|
||||
$t = new TableVE("edit");
|
||||
|
||||
if($HTTP_POST_VARS)
|
||||
//set link for version
|
||||
if ($versionId != 0)
|
||||
{
|
||||
// commit changes of form to database
|
||||
$t->update($HTTP_POST_VARS);
|
||||
$versionLink = "&versionId=$versionId";
|
||||
}
|
||||
|
||||
if($sub)
|
||||
{
|
||||
$query = "SELECT * from appNotes where noteId = $noteId;";
|
||||
$result = mysql_query($query);
|
||||
if(!$result)
|
||||
{
|
||||
$ob = mysql_fetch_object($result);
|
||||
|
||||
$oldNoteTitle = $ob->noteTitle;
|
||||
$oldNoteDesc = $ob->noteDesc;
|
||||
}
|
||||
if ($sub == 'Delete')
|
||||
{
|
||||
//delete Note
|
||||
$query = "DELETE from appNotes where noteId = $noteId;";
|
||||
$result = mysql_query($query);
|
||||
if(!$result)
|
||||
{
|
||||
//error
|
||||
addmsg("Internal Error: unable to delete selected note!", "red");
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = getNotifyEmailAddressList($appId, $versionId);
|
||||
if($email)
|
||||
{
|
||||
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
|
||||
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= ($current->username ? $current->username : "Anonymous")." deleted note from ".$fullAppName."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= "title: ".$oldNoteTitle."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= $oldNoteDesc."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= STANDARD_NOTIFY_FOOTER;
|
||||
|
||||
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
|
||||
|
||||
} else
|
||||
{
|
||||
$email = "no one";
|
||||
}
|
||||
addmsg("mesage sent to: ".$email, green);
|
||||
//success
|
||||
addmsg("Note Deleted.", "green");
|
||||
}
|
||||
}
|
||||
if ($sub == 'Update')
|
||||
{
|
||||
//Update Note
|
||||
$NewNoteTitle = addslashes($noteTitle);
|
||||
$NewNoteDesc = addslashes($noteDesc);
|
||||
if (!mysql_query("UPDATE appNotes SET noteTitle = '".$NewNoteTitle."', ".
|
||||
"noteDesc = '".$NewNoteDesc."'".
|
||||
" WHERE noteId = $noteId"))
|
||||
{
|
||||
$statusMessage = "<p><b>Database Error!<br>".mysql_error()."</b></p>\n";
|
||||
addmsg($statusMessage, "red");
|
||||
}
|
||||
else
|
||||
{
|
||||
$email = getNotifyEmailAddressList($appId, $versionId);
|
||||
if($email)
|
||||
{
|
||||
$fullAppName = "Application: ".lookupAppName($appId)." Version: ".lookupVersionName($appId, $versionId);
|
||||
$ms = APPDB_ROOT."appview.php?appId=$appId&versionId=$versionId"."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= ($current->username ? $current->username : "Anonymous")." changed note for ".$fullAppName."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= "From --------------------------\n";
|
||||
$ms .= "title: ".$oldNoteTitle."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= $oldNoteDesc."\n";
|
||||
$ms .= "To --------------------------\n";
|
||||
$ms .= "title: ".$noteTitle."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= $noteDesc."\n";
|
||||
$ms .= "\n";
|
||||
$ms .= STANDARD_NOTIFY_FOOTER;
|
||||
|
||||
mail(stripslashes($email), "[AppDB] ".$fullAppName ,$ms);
|
||||
|
||||
} else
|
||||
{
|
||||
$email = "no one";
|
||||
}
|
||||
addmsg("mesage sent to: ".$email, green);
|
||||
|
||||
addmsg("Note Updated", "green");
|
||||
}
|
||||
}
|
||||
redirect(apidb_fullurl("appview.php?appId=".$appId.$versionLink));
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!$preview)
|
||||
{
|
||||
$table = "appNotes";
|
||||
$query = "SELECT * FROM $table WHERE noteId = $noteId";
|
||||
$result = mysql_query($query);
|
||||
$ob = mysql_fetch_object($result);
|
||||
$noteTitle = $ob->noteTitle;
|
||||
$noteDesc = $ob->noteDesc;
|
||||
$appId = $ob->appId;
|
||||
$versionId = $ob->versionId;
|
||||
}
|
||||
// show form
|
||||
$table = "appNotes";
|
||||
$query = "SELECT * FROM $table WHERE noteId = $noteId";
|
||||
apidb_header("Edit Application Note");
|
||||
|
||||
if(debugging()) { echo "<p align=center><b>query:</b> $query </p>"; }
|
||||
echo "<form method=post action='editAppNote.php'>\n";
|
||||
echo html_frame_start("Edit Application Note $ob->noteId", "90%","",0);
|
||||
echo html_table_begin("width='100%' border=0 align=left cellpadding=6 cellspacing=0 class='box-body'");
|
||||
echo '<tr><td colspan=2 class=color4>';
|
||||
echo '<center><b>You can use html to make your Warning, Howto or Note look better.</b></center>';
|
||||
echo '</td></tr>',"\n";
|
||||
|
||||
$t->edit($query);
|
||||
echo add_br($noteDesc);
|
||||
echo '<input type=hidden name="noteId" value='.$noteId.'>';
|
||||
echo '<input type=hidden name="appId" value='.$appId.'>';
|
||||
echo '<input type=hidden name="versionId" value='.$versionId.'>';
|
||||
if ($noteTitle == "HOWTO" || $noteTitle == "WARNING")
|
||||
{
|
||||
echo '<tr><td class=color1>Title (Do not change)</td>';
|
||||
echo '<td class=color0><input size=80% type="text" name="noteTitle" type="text" value="'.$noteTitle.'"></td></tr>',"\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<tr><td class=color1>Title</td><td class=color0><input size=80% type="text" name="noteTitle" type="text" value="'.$noteTitle.'"></td></tr>',"\n";
|
||||
}
|
||||
echo '<tr><td class=color4>Description</td><td class=color0>', "\n";
|
||||
echo '<textarea cols=$50 rows=10 name="noteDesc">'.stripslashes($noteDesc).'</textarea></td></tr>',"\n";
|
||||
echo '<tr><td colspan=2 align=center class=color3>',"\n";
|
||||
echo '<input type="submit" name=preview value="Preview"> ',"\n";
|
||||
echo '<input type="submit" name=sub value="Update"> ',"\n";
|
||||
echo '<input type="submit" name=sub value="Delete"></td></tr>',"\n";
|
||||
|
||||
echo html_back_link(1,$apidb_root."noteview.php?noteId=$noteId");
|
||||
echo html_table_end();
|
||||
echo html_frame_end();
|
||||
|
||||
echo html_back_link(1,$apidb_root."appview.php?appId=$appId".$versionLink);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user