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
|
<?php /** * Overrides of the <i>publish</i> save handling use such that only * a User with <var>ADMIN_RIGHTS</var> or <var>MANAGE_ALL_<i>object</i></var> rights may * mark an object published. * * @author Stephen Billard (sbillard) * @package plugins * @subpackage admin */
$plugin_is_filter = 9|ADMIN_PLUGIN; $plugin_description = gettext('Allows only users with Admin or Manage All rights to change the publish state of objects.'); $plugin_author = "Stephen Billard (sbillard)";
zp_register_filter('save_album_utilities_data', 'admin_approval::publishZenphoto'); zp_register_filter('save_image_utilities_data', 'admin_approval::publishZenphoto'); zp_register_filter('new_page','admin_approval::Zenpage'); zp_register_filter('update_page','admin_approval::Zenpage'); zp_register_filter('new_article','admin_approval::Zenpage'); zp_register_filter('update_article','admin_approval::Zenpage'); zp_register_filter('new_article','admin_approval::Zenpage'); zp_register_filter('update_article','admin_approval::Zenpage');
class admin_approval {
static function publish_object($object) { $msg = ''; if (!zp_loggedin($object->manage_rights)) { // not allowed to change the published status $data = $object->getData(); if (isset($data['show'])) { $show = $data['show']; } else { $show = 0; } $newshow = $object->getShow(); $object->setShow($show); if ($newshow != $show) { $msg = gettext('You do not have rights to change the <em>publish</em> state.'); } } return $msg; } static function publishZenphoto($object, $i) { global $_admin_approval_error; $msg = admin_approval::publish_object($object); if ($msg) { $_admin_approval_error = $msg; zp_register_filter('edit_error', 'admin_approval::post_error'); } return $object; } static function Zenpage($report, $object) { $msg = admin_approval::publish_object($object); if ($msg) { $msg = '<p class="errorbox fade-message">'.$msg.'</p>'; } return $report.$msg; } static function post_error() { global $_admin_approval_error; return $_admin_approval_error; }
} ?>
|