-
Notifications
You must be signed in to change notification settings - Fork 40
/
module_lock.inc.php
87 lines (67 loc) · 1.52 KB
/
module_lock.inc.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
<?php
/**
* module_lock.inc.php
* Module for locking objects
*
* Copyright Gottfried Haider, Danja Vasiliev 2010.
* This source code is licensed under the GNU General Public License.
* See the file COPYING for more details.
*/
@require_once('config.inc.php');
require_once('html.inc.php');
require_once('html_parse.inc.php');
require_once('modules.inc.php');
// module glue gets loaded on demand
// module_image.inc.php has more information on what's going on inside modules
// (they can be easier than that one though)
function lock_alter_render_early($args)
{
$elem = &$args['elem'];
$obj = $args['obj'];
if (!elem_has_class($elem, 'object')) {
return false;
}
if (!empty($obj['object-lock'])) {
elem_add_class($elem, 'locked');
}
return true;
}
function lock_alter_save($args)
{
$elem = $args['elem'];
$obj = &$args['obj'];
if (!elem_has_class($elem, 'object')) {
return false;
}
if (elem_has_class($elem, 'locked')) {
$obj['object-lock'] = 'locked';
} else {
unset($obj['object-lock']);
}
return true;
}
function lock_render_object($args)
{
$elem = &$args['elem'];
$obj = &$args['obj'];
if (!elem_has_class($elem, 'object')) {
return false;
}
if (!empty($obj['object-lock'])) {
elem_css($elem, 'object-lock', $obj['object-lock']);
}
}
function lock_render_page_early($args)
{
if ($args['edit']) {
if (USE_MIN_FILES) {
html_add_js(base_url().'modules/lock/lock.min.js');
} else {
html_add_js(base_url().'modules/lock/lock.js');
}
return true;
} else {
return false;
}
}
?>