-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathreport.php
100 lines (87 loc) · 3.24 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?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 Ansel
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$title = _("Do you really want to report this gallery?");
$gallery_id = (int)Horde_Util::getFormData('gallery');
try {
$gallery = $injector->getInstance('Ansel_Storage')->getGallery($gallery_id);
} catch (Ansel_Exception $e) {
$notification->push($e->getMessage());
Horde::url('view.php?view=List', true)->redirect();
exit;
}
if (($image_id = Horde_Util::getFormData('image')) !== null) {
$title = _("Do you really want to report this photo?");
$return_url = Ansel::getUrlFor(
'view',
array('view' => 'Image',
'image' => $image_id,
'gallery' => $gallery_id),
true
);
} else {
$return_url = Ansel::getUrlFor(
'view',
array('gallery' => $gallery_id,
'view' => 'Gallery'),
true
);
}
$vars = Horde_Variables::getDefaultVariables();
$form = new Horde_Form($vars, $title);
$form->setButtons(array(
array('class' => 'horde-default', 'value' => _("Report")),
array('class' => 'horde-cancel', 'value' => _("Cancel")))
);
$enum = array('advertisement' => _("Advertisement content"),
'terms' => _("Terms and conditions infringement"),
'offensive' => _("Offensive content"),
'copyright' => _("Copyright infringement"));
$form->addVariable($gallery->get('name'), 'name', 'description', false);
$form->addVariable($gallery->get('desc'), 'desc', 'description', false);
$form->addHidden('', 'gallery', 'text', true, true);
$vars->set('gallery', $gallery_id);
$form->addVariable(_("Report type"), 'type', 'radio', true, false, null, array($enum));
$form->addVariable(_("Report reason"), 'reason', 'longtext', true);
$gallery_id = Horde_Util::getFormData('id');
if ($vars->get('submitbutton') == _("Cancel")) {
Horde::url('', true)->redirect();
}
if ($form->validate()) {
if (Horde_Util::getFormData('submitbutton') == _("Report")) {
$report = Ansel_Report::factory();
$body = _("Gallery Name") . ': ' . $gallery->get('name') . "\n"
. _("Gallery Description") . ': ' . $gallery->get('desc') . "\n"
. _("Gallery Id") . ': ' . $gallery->id . "\n"
. _("Report type") . ': ' . $enum[$vars->get('type')] . "\n"
. _("Report reason") . ': ' . $vars->get('reason') . "\n"
. $return_url;
try {
$result = $report->report($body);
$notification->push(_("Gallery was reported."), 'horde.success');
} catch (Horde_Exception $e) {
$notification->push(_("Gallery was not reported.") . ' ' . $result->getMessage(), 'horde.error');
}
} else {
$notification->push(_("Gallery was not reported."), 'horde.warning');
}
$return_url->redirect();
exit;
}
$page_output->header(array(
'title' => $title
));
$notification->notify(array('listeners' => 'status'));
$form->renderActive(null, null, null, 'post');
$page_output->footer();