aboutsummaryrefslogtreecommitdiff
path: root/mod/blog/actions/comments/add.php
blob: 8a54cde139517f41c4398fbfd38a188f65ca1102 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

	/**
	 * Elgg blog: add comment action
	 * 
	 * @package ElggBlog
	 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
	 * @author Ben Werdmuller <ben@curverider.co.uk>
	 * @copyright Curverider Ltd 2008
	 * @link http://elgg.org/
	 */

	// Make sure we're logged in; forward to the front page if not
		if (!isloggedin()) forward();
		
	// Get input
		$blogpost_guid = (int) get_input('blogpost_guid');
		$comment = get_input('comment');
		
	// Let's see if we can get an entity with the specified GUID, and that it's a blog post
		if ($blogpost = get_entity($blogpost_guid)) {
			if ($blogpost->getSubtype() == "blog") {
				
	// If posting the comment was successful, say so
				if ($blogpost->annotate('comment',$comment,$blogpost->access_id, $_SESSION['guid'])) {
					
					system_message(elgg_echo("comment:success"));
					
				} else {
					system_message(elgg_echo("comment:failure"));
				}
			
			}
				
		} else {
		
			system_message(elgg_echo("blog:notfound"));
			
		}
		
	// Forward to the 
		forward("mod/blog/read.php?blogpost=" . $blogpost_guid);

?>