-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathreport.php
70 lines (57 loc) · 2.3 KB
/
report.php
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
<?php
/**
* Report offensive content
*
* Copyright 2007-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file LICENSE for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Duck <[email protected]>
* @package Folks
*/
require_once __DIR__ . '/lib/base.php';
$user = Horde_Util::getFormData('user');
if (empty($user)) {
$notification->push(_("User is not selected"), 'horde.warning');
Folks::getUrlFor('list', 'list')->redirect();
}
$title = _("Do you really want to report this user?");
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->setButtons(array(_("Report"), _("Cancel")));
$enum = array('advertisement' => _("Advertisement content"),
'terms' => _("Terms and conditions infringement"),
'offensive' => _("Offensive content"),
'copyright' => _("Copyright infringement"));
$form->addVariable($user, 'name', 'description', false);
$form->addHidden('', 'user', 'text', true, true);
$form->addVariable(_("Report type"), 'type', 'radio', true, false, null, array($enum));
$form->addVariable(_("Report reason"), 'reason', 'longtext', true);
$user_id = Horde_Util::getFormData('id');
if ($form->validate()) {
if (Horde_Util::getFormData('submitbutton') == _("Report")) {
$body = _("User") . ': ' . $user . "\n"
. _("Report type") . ': ' . $enum[$vars->get('type')] . "\n"
. _("Report reason") . ': ' . $vars->get('reason') . "\n"
. Folks::getUrlFor('user', $user);
require FOLKS_BASE . '/lib/Notification.php';
$rn = new Folks_Notification();
$result = $rn->notifyAdmins($title, $body);
if ($result instanceof PEAR_Error) {
$notification->push(_("User was not reported.") . ' ' .
$result->getMessage(), 'horde.error');
} else {
$notification->push(_("User was reported."), 'horde.success');
}
} else {
$notification->push(_("User was not reported."), 'horde.warning');
}
Folks::getUrlFor('user', $user)->redirect();
}
$page_output->header(array(
'title' => $title
));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, null, null, 'post');
$page_output->footer();