root/devel/mod/commentwall/do_action.php

Revision 1613, 1.7 kB (checked in by misja, 4 months ago)

Applied attachment:ticket:383:commentwall.diff, fixes #383

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     @require_once("../../includes.php");
4
5     global $messages, $CFG;
6
7     /**
8      * Handle comment post.
9      */
10
11     $ident = optional_param('ident','');
12     $action = optional_param('action','');
13     $owner = optional_param('owner','');
14     $wallowner = optional_param('wallowner','');
15     $comment_owner = $_SESSION['userid'];
16     $reply = optional_param('reply','');
17     $displaymode = optional_param('displaymode','noxml');
18     $text = optional_param('text','');
19     $returnurl = urldecode(optional_param('return_url',''));
20     
21     $page = "";
22
23     /**
24      * Post comments etc.
25      */
26     if ($action == "commentwall::post")
27     {
28         // Store the comment if successful
29     // Check the form key here
30     $success = ((empty($text)) || !elggform_key_check(optional_param('form_key'), "commentwall_{$wallowner}_post")) ? false : commentwall_addcomment($wallowner, $comment_owner, $text);
31
32         // Message
33         if ($success)
34         {
35             $messages[] = __gettext("Comment posted."); 
36             if ($displaymode=="xml")
37                 $messages[] = __gettext(" Click here to see.");
38         }
39         else
40         {
41             $messages[] = __gettext("Comment could not be posted.");
42         }
43         
44         // Are we outputing XML or text
45         if ($displaymode=="xml")
46         {
47             $message = implode(" \n", $messages);
48             if ($success)
49                 $err = "0";
50             else
51                 $err = "1";   
52     
53             $page = "<ajax>\n<message>$message</message>\n<error>$err</error>\n</ajax>\n";
54         }
55         else
56         {
57             header("Location: $returnurl");
58             exit;
59         }
60     }
61     else if($action == "commentwall::delete")
62     {
63         if (commentwall_deletecomment($ident))
64         {
65             // Success
66         }
67         else
68         {
69             // Fail
70         }
71         
72         // Redirect
73         header("Location: $returnurl");
74         exit;
75     }
76     
77     // Output the page
78     if ($displaymode=="xml") {
79         header("Content-type: text/xml");
80         
81         echo $page;
82     }
83     
84     
85 ?>
86
Note: See TracBrowser for help on using the browser.