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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<?php
/**
* Elgg Message board
* This plugin allows users and groups to attach a message board to their profile for other users
* to post comments.
*
* @package ElggMessageBoard
*/
/**
* MessageBoard initialisation
*/
function messageboard_init() {
// Extend system CSS with our own styles, which are defined in the messageboard/css view
elgg_extend_view('css', 'messageboard/css');
// Register a page handler, so we can have nice URLs
register_page_handler('messageboard', 'messageboard_page_handler');
// add a messageboard widget - only for profile
add_widget_type('messageboard', elgg_echo("messageboard:board"), elgg_echo("messageboard:desc"), "profile");
}
/**
* Messageboard page handler
*
* @param array $page Array of page elements, forwarded by the page handling mechanism
*/
function messageboard_page_handler($page) {
global $CONFIG;
// The username should be the first array entry
if (isset($page[0])) {
set_input('username', $page[0]);
}
// Include the standard messageboard index
include($CONFIG->pluginspath . "messageboard/index.php");
}
/**
* Add messageboard post
*
* @param ElggUser $poster User posting the message
* @param ElggUser $owner User who owns the message board
* @param string $message The posted message
* @param int $access_id Access level (see defines in elgglib.php)
* @return bool
*/
function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC) {
global $CONFIG;
$result = $owner->annotate('messageboard', $message, $access_id, $poster->guid);
if (!$result) {
return FALSE;
}
add_to_river('river/object/messageboard/create',
'messageboard',
$poster->guid,
$owner->guid,
$access_id,
0,
$result);
// only send notification if not self
if ($poster->guid != $owner->guid) {
$subject = elgg_echo('messageboard:email:subject');
$body = elgg_echo('messageboard:email:body', array(
$poster->name,
$message,
elgg_get_site_url() . "pg/messageboard/" . $owner->username,
$poster->name,
$poster->getURL()
));
notify_user($owner->guid, $poster->guid, $subject, $body);
}
return TRUE;
}
// Register initialisation callback
register_elgg_event_handler('init', 'system', 'messageboard_init');
// Register actions
register_action("messageboard/add", FALSE, $CONFIG->pluginspath . "messageboard/actions/add.php");
register_action("messageboard/delete", FALSE, $CONFIG->pluginspath . "messageboard/actions/delete.php");
|