[phpwebapp-commits] CVS: top10/templates/proj_details/comments comments.php,1.2,1.3 comments.js,1.1,
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2003-12-29 15:01:05
|
Update of /cvsroot/phpwebapp/top10/templates/proj_details/comments In directory sc8-pr-cvs1:/tmp/cvs-serv28405/templates/proj_details/comments Modified Files: comments.php comments.js comments.html comments.db Log Message: Deletting a comment. Index: comments.php =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comments.php 25 Sep 2003 15:50:26 -0000 1.2 --- comments.php 29 Dec 2003 14:14:17 -0000 1.3 *************** *** 12,15 **** --- 12,78 ---- WebApp::execDBCmd("insert_comment", $params); } + + function on_del_comment($event_args) + { + if (ADMIN=='true') + { + WebApp::execDBCmd("delete_comment", $event_args); + return; + } + + //if not admin, then send a confirmation request + //to the author of the comment + + //get the comment details + $comment_id = $event_args["comment_id"]; + $rs = WebApp::openRS("get_comment", compact("comment_id")); + $username = $rs->Field("username"); + $proj_id = $rs->Field("proj_id"); + $title = $rs->Field("title"); + $comment = $rs->Field("comment"); + $date = $rs->Field("date"); + + //get a unique id + $request_id = md5(uniqid(rand())); + + //insert in DB a request with the same id as above + $time = time(); + $ip = $_SERVER["REMOTE_ADDR"]; + $params = compact("request_id", "time", "ip", "username", "comment_id"); + WebApp::execDBCmd("insert_request", $params); + + //send a notification e-mail to the user + $to = "dasho"; + //$to = $username."@users.sourceforge.net"; + $subject = "Top10: Delete Comment"; + $top10_site = "http://" . $_SERVER["HTTP_HOST"] . APP_URL; + $confirmation_uri = $top10_site."confirm.php?".$request_id; + $message = " + The site $top10_site received a request from [$ip] + for deleting the following comment that you have made for the + project '$proj_id': + + Title: $title + Comment: $comment + + In order to delete this comment you should confirm this request by opening + the following URL in 24 hours: + + $confirmation_uri + + If you changed your mind and you don't want to delete the comment, + just ignore and delete this message. + + "; + //mail the message + mail($to, $subject, $message); + + //display a confirmation message + $msg = "A confirmation e-mail has been sent \n" + . "to $use...@us... .\n" + . "If you don't confirm the delete request in 24 hours, \n" + . "it will be discarded."; + WebApp::message($msg); + } } ?> Index: comments.js =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.js,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** comments.js 25 Sep 2003 15:50:26 -0000 1.1 --- comments.js 29 Dec 2003 14:14:17 -0000 1.2 *************** *** 30,31 **** --- 30,36 ---- SendEvent("comments", "add_comment", event_args); } + + function del_comment(comment_id) + { + SendEvent("comments", "del_comment", "comment_id="+comment_id); + } Index: comments.html =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.html,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comments.html 25 Sep 2003 15:50:26 -0000 1.2 --- comments.html 29 Dec 2003 14:14:17 -0000 1.3 *************** *** 18,22 **** <td><b>{{subject}}</b></td> <td align="right"> ! <a class="button" href="del_comment('{{comment_id}}')">X</a> </td> </tr> --- 18,22 ---- <td><b>{{subject}}</b></td> <td align="right"> ! <a class="button" href="javascript:del_comment('{{comment_id}}')">X</a> </td> </tr> Index: comments.db =================================================================== RCS file: /cvsroot/phpwebapp/top10/templates/proj_details/comments/comments.db,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** comments.db 25 Sep 2003 15:50:26 -0000 1.2 --- comments.db 29 Dec 2003 14:14:17 -0000 1.3 *************** *** 21,22 **** --- 21,50 ---- </dbCommand> <!--# ToDo: add the field 'subject' #--> + + <dbCommand ID="delete_comment"> + <Query> + DELETE FROM comments + WHERE comment_id = '{{comment_id}}' + </Query> + </dbCommand> + + <Recordset ID="get_comment"> + <Query> + SELECT * FROM comments + WHERE comment_id = '{{comment_id}}' + </Query> + </Recordset> + + <dbCommand ID="insert_request"> + <Query> + INSERT INTO requests + SET + request_id = '{{request_id}}', + time = '{{time}}', + username = '{{username}}', + ip = '{{ip}}', + type = 'delete_comment', + data = '{{proj_id}}/{{comment_id}}', + status = 'pending' + </Query> + </dbCommand> |