Subversion Repositories oidplus

Rev

Rev 1265 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1207 daniel-mar 1
 
2
Plugin-to-Plugin communication using "Features" (INTF_OID interfaces)
3
=====================================================================
4
 
5
System-to-Plugin and Plugin-to-System communication
6
---------------------------------------------------
7
 
8
PHP classes belonging to the OIDplus system (such as the class handling the tree menu structure,
9
the sitemap, the AJAX handling, etc) are communicating to plugins the "normal way", i.e.
10
the base classes define functions that are overridden by the plugins.
11
 
12
Plugin-to-Plugin communication
13
------------------------------
14
 
15
Plugins can offer interfaces/functionalities that can be used by other plugins. (Plugin-to-Plugin communication)
16
 
17
Example: The OOBE plugin queries other plugins if they want to be included
18
in the Out-Of-Box-Experience configuration. Therefore the plugins need to implement an
19
"oobeEntry" function.
20
 
21
For the plugin-to-plugin communication, the PHP interfaces offered by the plugin *MUST*
22
have the prefix "INTF_OID_" followed by an OID (dots replaced by underscores), e.g. "INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1".
23
The OIDplus autoloader will make sure that interfaces following this naming convention
24
are replaced with an empty "fake" interface if the plugin defining the interface is not installed.
25
Therefore, the interface is "optional" and there won't be a fatal error if a plugin implements (references)
1405 daniel-mar 26
a feature that is unknown.
1207 daniel-mar 27
 
28
Previously, the plugin-to-plugin-communication used a function called implementsFeature(), which
29
has been discontinued as of 26 March 2023, because types could not be easily checked.
30
 
31
### Usage example (new method):
32
 
1405 daniel-mar 33
Implement feature in a class:
34
 
1207 daniel-mar 35
    class OIDplusPageAdminNostalgia
36
          extends OIDplusPagePluginAdmin
37
          implements INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 /* getNotifications */
38
    {
39
        public function getNotifications(...) {
40
            /* Implements interface INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8 */
41
            ...
42
        }
43
    }
44
 
1405 daniel-mar 45
Call all plugins supporting the feature:
46
 
1207 daniel-mar 47
    foreach (OIDplus::getAllPlugins() as $plugin) {
48
        if ($plugin instanceof INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8) {
49
            $plugin->getNotifications(...);
50
        }
51
    }
52
 
53
### Old method (deprecated as of 26 March 2023):
54
 
1405 daniel-mar 55
Implement feature in a class:
56
 
1207 daniel-mar 57
    class OIDplusPageAdminNostalgia
58
          extends OIDplusPagePluginAdmin
59
    {
60
        public function implementsFeature(string $oid): bool {
1405 daniel-mar 61
            if ($oid == '1.3.6.1.4.1.37476.2.5.2.3.8') return true; /*getNotifications*/
1207 daniel-mar 62
            return false;
63
        }
64
        public function getNotifications(...) {
65
            /* Implements feature 1.3.6.1.4.1.37476.2.5.2.3.8 */
66
            ...
67
        }
68
    }
69
 
1405 daniel-mar 70
Call all plugins supporting the feature:
71
 
1207 daniel-mar 72
    foreach (OIDplus::getAllPlugins() as $plugin) {
73
        if ($plugin->implementsFeature('1.3.6.1.4.1.37476.2.5.2.3.8')) {
74
            $plugin->getNotifications(...);
75
        }
76
    }
77
 
78
List of defined features
79
------------------------
80
 
81
Currently, there are the following features defined in the standard plugins of OIDplus:
82
 
83
- plugins/viathinksoft/adminPages/050_oobe/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_1.class.php containing the functions:
84
    - oobeEntry
85
    - oobeRequested
86
 
87
- plugins/viathinksoft/publicPages/000_objects/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_2.class.php containing the functions:
88
    - modifyContent
89
 
90
- plugins/viathinksoft/publicPages/000_objects/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_3.class.php containing the functions:
91
    - beforeObjectDelete
92
    - afterObjectDelete
93
    - beforeObjectUpdateSuperior
94
    - afterObjectUpdateSuperior
95
    - beforeObjectUpdateSelf
96
    - afterObjectUpdateSelf
97
    - beforeObjectInsert
98
    - afterObjectInsert
99
 
100
- plugins/viathinksoft/publicPages/100_whois/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_4.class.php containing the functions:
101
    - whoisObjectAttributes
102
    - whoisRaAttributes
103
 
104
- plugins/viathinksoft/publicPages/090_login/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_5.class.php containing the functions:
105
    - alternativeLoginMethods
106
 
107
- plugins/viathinksoft/publicPages/000_objects/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_6.class.php containing the functions:
108
    - gridGeneratorLinks
109
 
110
- plugins/viathinksoft/publicPages/000_objects/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_7.class.php containing the functions:
111
    - getAlternativesForQuery
112
 
113
- plugins/viathinksoft/adminPages/010_notifications/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_8.class.php containing the functions:
114
    - getNotifications
1265 daniel-mar 115
 
116
- plugins/viathinksoft/publicPages/002_rest_api/INTF_OID_1_3_6_1_4_1_37476_2_5_2_3_9.class.php containing the functions:
117
    - restApiCall
118
    - restApiInfo