diff --git a/addcomment.php b/addcomment.php
index 30bf5a0..7c78f17 100644
--- a/addcomment.php
+++ b/addcomment.php
@@ -10,6 +10,7 @@ include("path.php");
require(BASE."include/incl.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
+require(BASE."include/comment.php");
// you must be logged in to submit comments
if(!$_SESSION['current']->isLoggedIn())
@@ -19,17 +20,12 @@ if(!$_SESSION['current']->isLoggedIn())
exit;
}
-if(!is_numeric($_REQUEST['appId']))
+if(!is_numeric($_REQUEST['versionId']))
{
errorpage('Internal Database Access Error');
exit;
}
-if(!is_numeric($_REQUEST['versionId']))
-{
- $_REQUEST['versionId'] = 0;
-}
-
if(!is_numeric($_REQUEST['thread']))
{
$_REQUEST['thread'] = 0;
@@ -40,47 +36,9 @@ if(!is_numeric($_REQUEST['thread']))
############################
if(isset($_REQUEST['body']))
{
- $hostname = get_remote();
-
- // get current userid
- $userId = $_SESSION['current']->userid;
-
- $aInsert = compile_insert_string(array( 'parentId' => $_REQUEST['thread'],
- 'appId' => $_REQUEST['appId'],
- 'versionId' => $_REQUEST['versionId'],
- 'userId' => $userId,
- 'hostname' => $hostname,
- 'subject' => $_REQUEST['subject'],
- 'body' => $_REQUEST['body']));
-
- $result = query_appdb("INSERT INTO appComments (`time`, {$aInsert['FIELDS']}) VALUES (NOW(), {$aInsert['VALUES']})");
-
- if ($result)
- {
- $sEmail = $oOriginator->sEmail;
- $sFullAppName = "Comment added to ".lookupAppName($_REQUEST['appId'])." ".lookupVersionName($_REQUEST['appId'], $_REQUEST['versionId']);
- $sMsg = APPDB_ROOT."appview.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId'].".\n";
- $sMsg .= "\n";
- $sMsg .= $_SESSION['current']->sRealname." added comment to ".$sFullAppName."\n";
- $sMsg .= "\n";
- $sMsg .= "Subject: ".$_REQUEST['subject']."\n";
- $sMsg .= $_REQUEST['body']."\n";
-
- $oOriginator = new User($_REQUEST['originator']);
- if ($oOriginator->wantsEmail())
- {
- mail_appdb($sEmail, $sFullAppName ,$sMsg);
- addmsg("Comment message sent to original poster", "green");
- }
-
- $sEmail = get_notify_email_address_list($_REQUEST['appId'], $_REQUEST['versionId']);
- if($sEmail)
- {
- mail_appdb($sEmail, $sFullAppName ,$sMsg);
- }
- addmsg("New comment posted.", "green");
- }
- redirect(apidb_fullurl("appview.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
+ $oComment = new Comment();
+ $oComment->create($_REQUEST['subject'], $_REQUEST['body'], $_REQUEST['thread'], $_REQUEST['versionId']);
+ redirect(apidb_fullurl("appview.php?versionId=".$oComment->iVersionId));
}
################################
@@ -133,10 +91,6 @@ else
}
echo "";
}
-?>
-
\n";
echo " \n";
echo " \n";
@@ -237,7 +228,7 @@ if($appId && !$versionId)
echo " URL ".$appLinkURL." \n";
// optional links
- $result = query_appdb("SELECT * FROM appData WHERE appId = $appId AND versionID = 0 AND type = 'url'");
+ $result = query_appdb("SELECT * FROM appData WHERE appId = ".$_REQUEST['appId']." AND versionID = 0 AND type = 'url'");
if($result && mysql_num_rows($result) > 0)
{
echo " Links \n";
@@ -249,7 +240,7 @@ if($appId && !$versionId)
}
// image
- $img = get_screenshot_img($appId);
+ $img = get_screenshot_img($_REQUEST['appId']);
echo " $img \n";
echo "
\n"; /* close of name/vendor/bugs/url table */
@@ -260,7 +251,7 @@ if($appId && !$versionId)
// Display all supermaintainers maintainers of this application
echo " \n";
echo " Super maintainers: \n";
- $other_maintainers = getSuperMaintainersUserIdsFromAppId($appId);
+ $other_maintainers = getSuperMaintainersUserIdsFromAppId($_REQUEST['appId']);
if($other_maintainers)
{
while(list($index, list($userIdValue)) = each($other_maintainers))
@@ -279,7 +270,7 @@ if($appId && !$versionId)
if($_SESSION['current']->isLoggedIn())
{
/* are we already a maintainer? */
- if($_SESSION['current']->isSuperMaintainer($appId)) /* yep */
+ if($_SESSION['current']->isSuperMaintainer($_REQUEST['appId'])) /* yep */
{
echo ' ";
- if($_SESSION['current']->isSuperMaintainer($appId) || $_SESSION['current']->hasPriv("admin"))
+ if($_SESSION['current']->isSuperMaintainer($_REQUEST['appId']) || $_SESSION['current']->hasPriv("admin"))
{
- echo ' ';
+ echo ' ';
echo '';
@@ -303,7 +293,7 @@ if($appId && !$versionId)
{
$url = BASE."admin/deleteAny.php?what=appFamily&appId=".$_REQUEST['appId']."&confirmed=yes";
echo " ";
- echo ' ';
+ echo ' ';
}
} else
{
@@ -320,29 +310,33 @@ if($appId && !$versionId)
// description
echo " \n";
- echo " Description \n";
- echo add_br(stripslashes($data->description));
-
+ echo " Description \n";
+ echo $data->description;
echo "
\n";
-
echo html_frame_end("For more details and user comments, view the versions of this application.");
// display versions
- display_versions($appId,$app->getAppVersionList());
+ display_versions($_REQUEST['appId'],$app->getAppVersionList());
// display bundle
- display_bundle($appId);
+ display_bundle($_REQUEST['appId']);
// disabled for now
- //log_application_visit($appId);
+ //log_application_visit($_REQUEST['appId']);
}
#######################################
# We want to see a particular version #
#######################################
-else if($appId && $versionId)
+else if($_REQUEST['versionId'])
{
- $app = new Application($appId);
+ //FIXME: get rid of appId references everywhere, as version is enough.
+ $sQuery = "SELECT appId FROM appVersion WHERE versionId = '".$_REQUEST['versionId']."'";
+ $hResult = query_appdb($sQuery);
+ $oRow = mysql_fetch_object($hResult);
+ $appId = $oRow->appId;
+
+ $app = new Application($oRow->appId);
$data = $app->data;
if(!$data)
{
@@ -351,7 +345,7 @@ else if($appId && $versionId)
exit;
}
- $ver = $app->getAppVersion($versionId);
+ $ver = $app->getAppVersion($_REQUEST['versionId']);
if(!$ver)
{
// Oops! Version not found or other error. do something
@@ -360,24 +354,24 @@ else if($appId && $versionId)
}
// header
- apidb_header("Viewing App Version - ".$data->appName);
+ apidb_header("Viewing App Version - ".$data->appName);
// cat
- display_catpath($app->data->catId, $appId, $versionId);
+ display_catpath($app->data->catId, $appId, $_REQUEST['versionId']);
// set URL
$appLinkURL = ($ver->webPage) ? "".substr(stripslashes($ver->webPage),0,30)." ": " ";
// start version display
echo html_frame_start("","98%","",0);
-
+ echo " ";
echo '',"\n";
echo '',"\n";
echo " Name ".stripslashes($data->appName)." \n";
echo " Version ".stripslashes($ver->versionName)." \n";
// links
- $result = query_appdb("SELECT * FROM appData WHERE appId = $appId AND versionID = $versionId AND type = 'url'");
+ $result = query_appdb("SELECT * FROM appData WHERE appId = $appId AND versionID = ".$_REQUEST['versionId']." AND type = 'url'");
if($result && mysql_num_rows($result) > 0)
{
echo " Links \n";
@@ -393,13 +387,13 @@ else if($appId && $versionId)
echo " Maintainers Version ".stripslashes($ver->maintainer_release)." \n";
// image
- $img = get_screenshot_img($appId, $versionId);
+ $img = get_screenshot_img($appId, $_REQUEST['versionId']);
echo "$img \n";
// display all maintainers of this application
echo "Maintainers of this application: \n";
echo "";
- $other_maintainers = getMaintainersUserIdsFromAppIdVersionId($appId, $versionId);
+ $other_maintainers = getMaintainersUserIdsFromAppIdVersionId($appId, $_REQUEST['versionId']);
if($other_maintainers)
{
while(list($index, list($userIdValue)) = each($other_maintainers))
@@ -428,7 +422,7 @@ else if($appId && $versionId)
} else
{
/* are we already a maintainer? */
- if($_SESSION['current']->isMaintainer($appId, $versionId)) /* yep */
+ if($_SESSION['current']->isMaintainer($appId, $_REQUEST['versionId'])) /* yep */
{
echo '";
} else
{
@@ -450,26 +444,26 @@ else if($appId && $versionId)
echo "";
- if ($_SESSION['current']->isLoggedIn() && ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($appId, $versionId)))
+ if ($_SESSION['current']->isLoggedIn() && ($_SESSION['current']->hasPriv("admin") || $_SESSION['current']->isMaintainer($appId, $_REQUEST['versionId'])))
{
echo "";
- echo '';
$url = BASE."admin/deleteAny.php?what=appVersion&appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']."&confirmed=yes";
echo "';
- echo '';
echo '';
- echo '';
echo '';
- echo '';
@@ -478,9 +472,9 @@ else if($appId && $versionId)
echo "
\n";
- //Desc Image
+ // description
echo " Description \n";
- echo add_br(stripslashes($ver->description));
+ echo $ver->description;
echo " ";
/* close the table */
@@ -488,21 +482,15 @@ else if($appId && $versionId)
echo html_frame_end();
- $rNotes = query_appdb("SELECT * FROM appNotes WHERE appId = $appId and versionId = $versionId");
+ $rNotes = query_appdb("SELECT * FROM appNotes WHERE versionId = ".$_REQUEST['versionId']);
while( $oNote = mysql_fetch_object($rNotes) )
{
echo show_note($oNote->noteTitle,$oNote);
}
- //TODO: code to view/add user experience record
- // if(!$versionId)
- // {
- // $versionId = 0;
- // }
-
// Comments Section
- view_app_comments($appId, $versionId);
+ view_app_comments($_REQUEST['versionId']);
} else
{
@@ -510,10 +498,6 @@ else if($appId && $versionId)
errorpage('Page Called with No Params!');
exit;
}
-?>
-
-
-
diff --git a/bugs.php b/bugs.php
index a4a1939..7a5afbb 100644
--- a/bugs.php
+++ b/bugs.php
@@ -9,7 +9,7 @@
include("path.php");
require(BASE."include/incl.php");
require(BASE."include/application.php");
-require(BASE."include/comments.php");
+require(BASE."include/comment.php");
require(BASE."include/appdb.php");
require(BASE."include/screenshot.php");
require(BASE."include/category.php");
diff --git a/commentview.php b/commentview.php
index 5b1cf47..2ccd186 100644
--- a/commentview.php
+++ b/commentview.php
@@ -9,8 +9,8 @@
* application environment
*/
include("path.php");
-include(BASE."include/"."incl.php");
-require(BASE."include/"."comments.php");
+include(BASE."include/incl.php");
+require(BASE."include/comment.php");
apidb_header("Comments");
diff --git a/deletecomment.php b/deletecomment.php
index 94c1441..5d04f50 100644
--- a/deletecomment.php
+++ b/deletecomment.php
@@ -10,6 +10,7 @@ include("path.php");
require(BASE."include/incl.php");
require(BASE."include/application.php");
require(BASE."include/mail.php");
+require(BASE."include/comment.php");
$_REQUEST['appId'] = strip_tags($_REQUEST['appId']);
@@ -26,42 +27,24 @@ if(!$_SESSION['current']->isLoggedIn())
/* if we aren't an admin or the maintainer of this app we shouldn't be */
/* allowed to delete any comments */
if(!$_SESSION['current']->hasPriv("admin") &&
- !$_SESSION['current']->isMaintainer($_REQUEST['appId'],
- $_REQUEST['versionId']))
+ !$_SESSION['current']->isMaintainer($_REQUEST['appId'], $_REQUEST['versionId']))
{
- errorpage('You don\'t have admin privileges');
+ errorpage('You don\'t have sufficient privileges to delete this comment.');
exit;
}
-/* retrieve the parentID of the comment we are deleting */
-/* so we can fix up the parentIds of this comments children */
-$result = query_appdb("SELECT parentId FROM appComments WHERE commentId = '".$_REQUEST['commentId']."'");
-if (!$result)
-{
- errorpage('Internal error retrieving parent of commentId');
- exit;
-}
+$oComment = new Comment($_REQUEST['commentId']);
-$ob = mysql_fetch_object($result);
-$deletedParentId = $ob->parentId;
-/* get the subject and body from the comment */
-$result = query_appdb("select * FROM appComments WHERE commentId = '".$_REQUEST['commentId']."'");
-if (!$result) redirect(apidb_fullurl("appview.php?appId=".$_REQUEST['appId']."&versionId=".$_REQUEST['versionId']));
-$ob = mysql_fetch_object($result);
-$body = $ob->body;
-$subject = $ob->subject;
-
-if($_SESSION['current']->getpref("confirm_comment_deletion") != "no" &&
- !isset($_REQUEST['int_delete_it']))
+if($_SESSION['current']->getPref("confirm_comment_deletion") != "no" && !isset($_REQUEST['int_delete_it']))
{
apidb_header("Delete Comment");
$mesTitle = "Please state why you are deleting the following comment ";
echo "