Skip to content

Commit 144de67

Browse files
Merge pull request #626 from OCSInventory-NG/reworkExtensionEngine
Ready - Rework extension engine
2 parents 6706ff8 + 145cd17 commit 144de67

File tree

25 files changed

+1007
-803
lines changed

25 files changed

+1007
-803
lines changed

config/main_menu.xml

100755100644
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,13 @@
130130
</menu-elem>
131131
</submenu>
132132
</menu-elem>
133-
<menu-elem id="plugins">
133+
<menu-elem id="extension">
134134
<label>g(7000)</label>
135-
<url>ms_plugins</url>
135+
<url>ms_extension</url>
136136
<submenu>
137-
<menu-elem id="ms_pluginsmanager">
137+
<menu-elem id="ms_extensionmanager">
138138
<label>g(7001)</label>
139-
<url>ms_pluginsmanager</url>
139+
<url>ms_extensionmanager</url>
140140
</menu-elem>
141141
</submenu>
142142
</menu-elem>

config/profiles/sadmin.xml

100755100644
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,14 +98,14 @@
9898
<page>ms_add_key</page>
9999
<page>ms_export_ocs</page>
100100
<page>ms_qrcode</page>
101-
<page>ms_plugins</page>
101+
<page>ms_extension</page>
102102
<page>ms_stats_top</page>
103103
<page>ms_server_infos</page>
104104
<page>ms_wiki</page>
105105
<page>ms_irc</page>
106106
<page>ms_offers</page>
107107
<page>ms_ask</page>
108-
<page>ms_pluginsmanager</page>
108+
<page>ms_extensionmanager</page>
109109
<page>ms_soft_cat</page>
110110
<page>ms_asset_cat</page>
111111
<page>ms_asset_cat_list</page>

config/urls.xml

100755100644
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,13 +280,13 @@
280280
<value>qrcode</value>
281281
<directory>ms_computer</directory>
282282
</url>
283-
<url key="ms_plugins">
284-
<value>plugins</value>
285-
<directory>ms_plugins</directory>
283+
<url key="ms_extension">
284+
<value>extension</value>
285+
<directory>ms_extension</directory>
286286
</url>
287-
<url key="ms_pluginsmanager">
288-
<value>pluginsmanager</value>
289-
<directory>ms_plugins</directory>
287+
<url key="ms_extensionmanager">
288+
<value>extensionmanager</value>
289+
<directory>ms_extensionmanager</directory>
290290
</url>
291291
<url key="ms_stats_top">
292292
<value>stats_top</value>

download/README

Lines changed: 0 additions & 3 deletions
This file was deleted.

extensions/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add extensions in this folder

files/update/7021.sql

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
DROP TABLE `plugins`;
2+
3+
CREATE TABLE IF NOT EXISTS `extensions` (
4+
`id` varchar(255) COLLATE utf8_bin NOT NULL,
5+
`name` varchar(255) COLLATE utf8_bin NOT NULL,
6+
`description` varchar(255) COLLATE utf8_bin DEFAULT NULL,
7+
`version` double NOT NULL,
8+
`licence` varchar(255) COLLATE utf8_bin DEFAULT NULL,
9+
`author` varchar(255) COLLATE utf8_bin DEFAULT NULL,
10+
`contributor` varchar(255) COLLATE utf8_bin DEFAULT NULL,
11+
`install_date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
12+
) ENGINE=InnoDB DEFAULT CHARSET=UTF8;
13+
14+
ALTER TABLE `plugins` ADD PRIMARY KEY (`id`);

plugins/language/en_GB/en_GB.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,21 +1535,21 @@
15351535
6011 Click here to solve your problem
15361536
6012 Select All
15371537

1538-
7000 Plugins
1539-
7001 Plugins manager
1540-
7002 Plugin's name
1538+
7000 Extensions
1539+
7001 Extensions manager
1540+
7002 Extension's name
15411541
7003 Version
15421542
7004 License
15431543
7005 Author
15441544
7006 Last updated
15451545
7007 Are you sure you want to delete this plugin
1546-
7008 Plugin Install
1547-
7009 Installed Plugins
1548-
7010 This plugin has been already installed
1549-
7011 is an invalid plugin, check your sources.
1546+
7008 Extension Install
1547+
7009 Installed Extensions
1548+
7010 This extension has been already installed
1549+
7011 is an invalid extension, check your sources.
15501550
7012 Installation aborted !
15511551
7013 installed
1552-
7014 There is currently no plugin available for installation
1552+
7014 There is currently no extensions available for installation
15531553
7015 Select at least one computer !
15541554
7016 MTU
15551555

plugins/language/fr_FR/fr_FR.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,20 +1534,20 @@
15341534
6012 Tout afficher
15351535

15361536
7000 Plugins
1537-
7001 Gestionnaire de plugins
1538-
7002 Nom du plugin
1537+
7001 Gestionnaire d'extensions
1538+
7002 Nom de l'extension
15391539
7003 Version
15401540
7004 Licence
15411541
7005 Auteur
15421542
7006 Dernière mise à jour
15431543
7007 Etes-vous sûr de vouloir supprimer ce plugin
1544-
7008 Installer un plugin
1545-
7009 Plugins installés
1546-
7010 Ce plugin a déjà été installé
1547-
7011 est un plugin non valide, vérifiez vos sources.
1544+
7008 Installer une extension
1545+
7009 Extensions installés
1546+
7010 Cette extension a déjà été installé
1547+
7011 est une extension non valide, vérifiez vos sources.
15481548
7012 Installation annulée !
15491549
7013 installé
1550-
7014 Il n'y a aucun plugin disponible
1550+
7014 Il n'y a aucune extensions disponible
15511551
7015 Sélectionnez au minimum un ordinateur !
15521552

15531553
8000 Notifications

plugins/main_sections/ms_computer/ms_computer.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
}
2929
require('require/function_opt_param.php');
3030
require('require/function_graphic.php');
31+
require_once('require/extensions/ExtensionManager.php');
32+
require_once('require/extensions/ExtensionHook.php');
3133
require_once('require/function_machine.php');
3234
require_once('require/function_files.php');
3335
require_once('ms_computer_views.php');
@@ -85,6 +87,8 @@
8587

8688
$plugins_serializer = new XMLPluginsSerializer();
8789
$plugins = $plugins_serializer->unserialize(file_get_contents( CD_CONFIG_DIR .'plugins.xml'));
90+
$extMgr = new ExtensionManager();
91+
$extHooks = new ExtensionHook($extMgr->installedExtensionsList);
8892

8993
if (isset($protectedGet['cat']) && in_array($protectedGet['cat'], array('software', 'hardware', 'network', 'devices', 'admin', 'config', 'teledeploy', 'other'))) {
9094
// If category
@@ -103,6 +107,15 @@
103107
}
104108
}
105109
}
110+
// Load cd entries for extensions
111+
foreach ($extHooks->getCdEntryByCategory($protectedGet['cat']) as $extensionPlugins){
112+
$fileName = EXT_DL_DIR.$extensionPlugins[ExtensionHook::EXTENSION]."/".$extensionPlugins[ExtensionHook::IDENTIFIER]."/".$extensionPlugins[ExtensionHook::IDENTIFIER].".php";
113+
if(file_exists($fileName)){
114+
echo '<div class="plugin-name-' . $extensionPlugins[ExtensionHook::IDENTIFIER] . ' ">';
115+
require $fileName;
116+
echo '</div>';
117+
}
118+
}
106119
} else if (isset($protectedGet['option']) && isset($plugins[$protectedGet['option']])) {
107120
// If specific plugin
108121
$plugin = $plugins[$protectedGet['option']];
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
/*
3+
* Copyright 2005-2016 OCSInventory-NG/OCSInventory-ocsreports contributors.
4+
* See the Contributors file for more details about them.
5+
*
6+
* This file is part of OCSInventory-NG/OCSInventory-ocsreports.
7+
*
8+
* OCSInventory-NG/OCSInventory-ocsreports is free software: you can redistribute
9+
* it and/or modify it under the terms of the GNU General Public License as
10+
* published by the Free Software Foundation, either version 2 of the License,
11+
* or (at your option) any later version.
12+
*
13+
* OCSInventory-NG/OCSInventory-ocsreports is distributed in the hope that it
14+
* will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15+
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU General Public License
19+
* along with OCSInventory-NG/OCSInventory-ocsreports. if not, write to the
20+
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21+
* MA 02110-1301, USA.
22+
*/
23+
24+
if (AJAX) {
25+
parse_str($protectedPost['ocs']['0'], $params);
26+
$protectedPost += $params;
27+
28+
ob_start();
29+
}
30+
31+
require_once 'require/extensions/ExtensionManager.php';
32+
require_once 'require/extensions/ExtensionCommon.php';
33+
34+
printEnTete($l->g(7008));
35+
36+
?>
37+
<div class="container">
38+
<div class="col col-md-12">
39+
<?php
40+
41+
$extMgr = new ExtensionManager();
42+
if($extMgr->checkPrerequisites()){
43+
$extMgr->checkInstallableExtensions();
44+
45+
if(empty($extMgr->installableExtensionsList)){
46+
msg_warning($l->g(7014));
47+
}else{
48+
echo open_form("PluginInstall", '', '', 'form-horizontal');
49+
?>
50+
<div class="form-group">
51+
<div class="col col-sm-5 col-sm-offset-3">
52+
<select class="form-control" name="extensions">
53+
<?php
54+
foreach ($extMgr->installableExtensionsList as $key => $value) {
55+
echo "<option value=$value >$value</option>";
56+
}
57+
?>
58+
</select>
59+
</div>
60+
<div class="col col-sm-2">
61+
<input type="submit" class="form-control btn btn-success" value="Install">
62+
</div>
63+
</div>
64+
<?php
65+
echo close_form();
66+
}
67+
68+
}else{
69+
msg_warning($l->g(7014));
70+
}
71+
72+
?>
73+
</div>
74+
</div>
75+
<?php
76+
77+
if (!AJAX) {
78+
if(isset($protectedPost['extensions'])){
79+
$extMgr->installExtension($protectedPost['extensions']);
80+
}
81+
82+
if(isset($protectedPost['SUP_PROF'])){
83+
$extMgr->deleteExtension($protectedPost['SUP_PROF']);
84+
}
85+
}
86+
87+
// Plugins Tab
88+
printEnTete($l->g(7009));
89+
$form_name = "show_all_extensions";
90+
$table_name = $form_name;
91+
$tab_options = $protectedPost;
92+
$tab_options['form_name'] = $form_name;
93+
$tab_options['table_name'] = $table_name;
94+
echo open_form($form_name, '', '', 'form-horizontal');
95+
96+
$list_fields = array('ID' => 'id',
97+
$l->g(7002) => 'name',
98+
$l->g(53) => 'description',
99+
$l->g(7003) => 'version',
100+
$l->g(7005) => 'author',
101+
$l->g(7004) => 'licence'
102+
);
103+
104+
$tab_options['FILTRE'] = array_flip($list_fields);
105+
$tab_options['FILTRE']['NAME'] = $l->g(49);
106+
asort($tab_options['FILTRE']);
107+
$list_fields['SUP'] = 'ID';
108+
$list_col_cant_del = array('SUP' => 'SUP');
109+
$default_fields = array($l->g(7002) => $l->g(7002), $l->g(7003) => $l->g(7003), $l->g(7004) => $l->g(7005), $l->g(7006), $l->g(7006));
110+
$sql = prepare_sql_tab($list_fields, $list_col_cant_del);
111+
$tab_options['ARG_SQL'] = $sql['ARG'];
112+
$queryDetails = $sql['SQL'] . ",ID from extensions";
113+
$tab_options['LBL_POPUP']['SUP'] = $l->g(7007) . " ";
114+
$tab_options['LBL']['SUP'] = $l->g(122);
115+
$tab_options['LIEN_CHAMP']['NAME'] = 'ID';
116+
$tab_options['LBL']['NAME'] = $l->g(49);
117+
ajaxtab_entete_fixe($list_fields, $default_fields, $tab_options, $list_col_cant_del);
118+
echo close_form();
119+
120+
if (AJAX) {
121+
ob_end_clean();
122+
tab_req($list_fields, $default_fields, $list_col_cant_del, $queryDetails, $tab_options);
123+
}

0 commit comments

Comments
 (0)