PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.4.2
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.4.2
2.45.0 2.44.0 trunk 1.10 1.10.1 1.4.1 1.4.10 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5 1.5.1 1.5.10 1.5.11 1.5.2 1.5.3 1.5.4 1.5.5 1.5.7 1.5.8 1.5.9 1.6 1.6.1 1.7 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 1.8.1 1.9 1.9.10 1.9.12 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.9 2.0 2.0.2 2.0.3 2.1 2.1.1 2.10.0 2.10.1 2.10.2 2.10.3 2.11.1 2.12.1 2.12.2 2.13.0 2.14.0 2.15.0 2.16.0 2.17.0 2.18.0 2.18.2 2.19.0 2.19.1 2.19.2 2.2 2.2.1 2.20.0 2.21.0 2.22.0 2.23.0 2.3 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.30.0 2.31.0 2.32.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.40.0 2.41.0 2.42.0 2.43.0 2.5.0 2.5.1 2.5.2 2.6.0 2.6.1 2.7.0 2.7.1 2.8.0 2.8.1 2.9.0 2.9.1
capability-manager-enhanced / framework / lib / objects.php
capability-manager-enhanced / framework / lib Last commit date
filesystem.php 13 years ago formating.php 13 years ago modules.php 13 years ago objects.php 13 years ago plugins.php 13 years ago system.php 13 years ago themes.php 13 years ago users.php 13 years ago
objects.php
111 lines
1 <?php
2 /**
3 * Functions for objects management.
4 *
5 * @version $Rev: 198515 $
6 * @author Jordi Canals
7 * @copyright Copyright (C) 2008, 2009, 2010 Jordi Canals
8 * @license GNU General Public License version 2
9 * @link http://alkivia.org
10 * @package Alkivia
11 * @subpackage Framework
12 *
13
14 Copyright 2008, 2009, 2010 Jordi Canals <devel@jcanals.cat>
15
16 This program is free software; you can redistribute it and/or
17 modify it under the terms of the GNU General Public License
18 version 2 as published by the Free Software Foundation.
19
20 This program is distributed in the hope that it will be useful,
21 but WITHOUT ANY WARRANTY; without even the implied warranty of
22 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 GNU General Public License for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with this program. If not, see <http://www.gnu.org/licenses/>.
27 */
28
29 if ( ! isset($GLOBALS['_akv']) )
30 {
31 // Create the global $_akv. This holds all objects and settings.
32 $GLOBALS['_akv'] = array();
33 }
34
35 /**
36 * Creates and stores an object in the $_akv global.
37 * Can be called at the same time we create the object: ak_store_object( 'obj_name', new objectName() );
38 *
39 * @param string $name Internal object name.
40 * @param object $object The object reference to store in the global.
41 * @return object The newly stored object reference.
42 */
43 function & ak_create_object ( $name, $object )
44 {
45 $GLOBALS['_akv'][$name] =& $object;
46 return $object;
47 }
48
49 /**
50 * Gets an object stored in the $_akv global.
51 *
52 * @param string $name Object name.
53 * @return object|false Returns the requested object reference. If not found, or not an object, returns false.
54 */
55 function & ak_get_object ( $name )
56 {
57 if ( is_object($GLOBALS['_akv'][$name]) ) {
58 return $GLOBALS['_akv'][$name];
59 } else {
60 return false;
61 }
62 }
63
64 /**
65 * Checks if an object exists in the $_akv global.
66 *
67 * @param string $name Object name to check.
68 * @return boolean If the object exists or not.
69 */
70 function ak_object_exists ( $name )
71 {
72 global $_akv;
73
74 if ( isset($_akv[$name]) && is_object($_akv[$name]) ) {
75 return true;
76 } else {
77 return false;
78 }
79 }
80
81 /**
82 * Returns the 'settings' object reference.
83 *
84 * @return object|false Returns the object reference, or false if not found.
85 */
86 function & ak_settings_object ()
87 {
88 if ( ak_object_exists('settings') ) {
89 return ak_get_object('settings');
90 } else {
91 return ak_create_object('settings', new akSettings());
92 }
93 }
94
95 /**
96 * Returns an object option/setting.
97 *
98 * @param string $object Object name to get options from.
99 * @param string $option Option name to return.
100 * @param mixed $default Default value if option not found.
101 * @return mixed The option value.
102 */
103 function ak_get_option ( $object, $option = '', $default = false )
104 {
105 if ( is_object($GLOBALS['_akv'][$object]) && method_exists($GLOBALS['_akv'][$object], 'getOption') ) {
106 return $GLOBALS['_akv'][$object]->getOption($option, $default);
107 } else {
108 return $default;
109 }
110 }
111