2004-12-12 03:51:51 +00:00
< ? php
2006-07-06 18:37:34 +00:00
/**
* Adds a new comment .
*
* Mandatory parameters :
* - iVersionId , version identifier
*
* Optional parameters :
* - iThread , parent comment identifier
* - sBody , body of the comment
* - sSubject , title of the comment
*/
// application environment
2006-07-07 18:14:53 +00:00
require ( " path.php " );
2006-06-17 06:10:10 +00:00
require ( BASE . " include/incl.php " );
2006-07-07 18:14:53 +00:00
require_once ( BASE . " include/comment.php " );
2006-06-17 06:10:10 +00:00
2004-12-11 04:07:40 +00:00
// you must be logged in to submit comments
2005-01-30 23:12:48 +00:00
if ( ! $_SESSION [ 'current' ] -> isLoggedIn ())
2004-12-11 04:07:40 +00:00
{
apidb_header ( " Please login " );
2006-07-06 17:27:54 +00:00
echo " To submit a comment for an application you must be logged in. Please <a href= \" account.php?sCmd=login \" >login now</a> or create a <a href= \" account.php?sCmd=new \" >new account</a>. " , " \n " ;
2005-01-15 05:59:21 +00:00
exit ;
2004-03-15 16:22:00 +00:00
}
2006-07-06 18:37:34 +00:00
// the user submitted his comment
2006-07-06 17:27:54 +00:00
if ( ! empty ( $aClean [ 'sBody' ]))
2004-03-15 16:22:00 +00:00
{
2007-04-21 02:30:22 +00:00
// create a new comment
2005-02-02 03:01:29 +00:00
$oComment = new Comment ();
2007-04-21 02:30:22 +00:00
$oComment -> sSubject = $aClean [ 'sSubject' ];
$oComment -> sBody = $aClean [ 'sBody' ];
$oComment -> iParentId = $aClean [ 'iThread' ];
$oComment -> iVersionId = $aClean [ 'iVersionId' ];
$oComment -> create ();
2007-04-09 01:23:11 +00:00
$oVersion = new version ( $oComment -> iVersionId );
util_redirect_and_exit ( $oVersion -> objectMakeUrl ());
2006-07-06 18:37:34 +00:00
// let's show the comment form
} else
2004-12-11 04:07:40 +00:00
{
apidb_header ( " Add Comment " );
2004-03-15 16:22:00 +00:00
2004-12-11 04:07:40 +00:00
$mesTitle = " <b>Post New Comment</b> " ;
2004-03-15 16:22:00 +00:00
2006-07-06 17:27:54 +00:00
if ( $aClean [ 'iThread' ] > 0 )
2004-12-11 04:07:40 +00:00
{
2006-06-27 19:16:27 +00:00
$hResult = query_parameters ( " SELECT * FROM appComments WHERE commentId = '?' " ,
2006-07-06 17:27:54 +00:00
$aClean [ 'iThread' ]);
2006-06-21 01:04:12 +00:00
$oRow = mysql_fetch_object ( $hResult );
if ( $oRow )
2004-11-17 23:05:36 +00:00
{
2006-06-21 01:04:12 +00:00
$mesTitle = " <b>Replying To ...</b> $oRow->subject\n " ;
echo html_frame_start ( $oRow -> subject , 500 );
echo htmlify_urls ( $oRow -> body ), " <br /><br /> \n " ;
2004-12-11 04:07:40 +00:00
echo html_frame_end ();
2004-11-17 23:05:36 +00:00
}
2004-12-11 04:07:40 +00:00
}
2004-03-15 16:22:00 +00:00
2006-06-27 16:54:22 +00:00
echo " <form method= \" post \" action= \" addcomment.php \" > \n " ;
2004-03-15 16:22:00 +00:00
2004-12-11 04:07:40 +00:00
echo html_frame_start ( $mesTitle , 500 , " " , 0 );
echo '<table width="100%" border=0 cellpadding=0 cellspacing=1>' , " \n " ;
2004-12-29 20:21:31 +00:00
echo " <tr class= \" color0 \" ><td align=right><b>From:</b> </td> \n " ;
2005-02-02 00:14:01 +00:00
echo " <td> " . $_SESSION [ 'current' ] -> sRealname . " </td></tr> \n " ;
2004-12-29 20:21:31 +00:00
echo " <tr class= \" color0 \" ><td align=right><b>Subject:</b> </td> \n " ;
2006-07-06 17:27:54 +00:00
echo " <td> <input type= \" text \" size= \" 35 \" name= \" sSubject \" value= \" " . $aClean [ 'sSubject' ] . " \" /> </td></tr> \n " ;
2006-07-06 23:44:52 +00:00
echo " <tr class= \" color1 \" ><td colspan=2><textarea name= \" sBody \" cols= \" 70 \" rows= \" 15 \" wrap= \" virtual \" > " . $aClean [ 'sBody' ] . " </textarea></td></tr> \n " ;
2004-12-29 20:21:31 +00:00
echo " <tr class= \" color1 \" ><td colspan=2 align=center> \n " ;
2006-06-27 16:54:22 +00:00
echo " <input type= \" submit \" value= \" Post Comment \" class= \" button \" /> \n " ;
echo " <input type= \" reset \" value= \" Reset \" class= \" button \" /> \n " ;
2004-12-11 04:07:40 +00:00
echo " </td></tr> \n " ;
echo " </table> \n " ;
echo html_frame_end ();
2006-07-06 17:27:54 +00:00
echo " <input type= \" hidden \" name= \" iThread \" value= \" " . $aClean [ 'iThread' ] . " \" /> \n " ;
echo " <input type= \" hidden \" name= \" iAppId \" value= \" " . $aClean [ 'iAppId' ] . " \" /> \n " ;
echo " <input type= \" hidden \" name= \" iVersionId \" value= \" " . $aClean [ 'iVersionId' ] . " \" /> \n " ;
2004-12-11 04:07:40 +00:00
echo " </form> " ;
2004-03-15 16:22:00 +00:00
}
2004-12-11 04:07:40 +00:00
apidb_footer ();
2004-03-15 16:22:00 +00:00
?>