Skip to content

Commit b209ed1

Browse files
committed
Merge remote-tracking branch 'alexandre@gh/master'
2 parents 8797168 + 1486506 commit b209ed1

File tree

3 files changed

+221
-2
lines changed

3 files changed

+221
-2
lines changed
+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
3+
/*
4+
------------------------------------------------------------------------
5+
FusionInventory
6+
Copyright (C) 2010-2013 by the FusionInventory Development Team.
7+
8+
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
9+
------------------------------------------------------------------------
10+
11+
LICENSE
12+
13+
This file is part of FusionInventory project.
14+
15+
FusionInventory is free software: you can redistribute it and/or modify
16+
it under the terms of the GNU Affero General Public License as published by
17+
the Free Software Foundation, either version 3 of the License, or
18+
(at your option) any later version.
19+
20+
FusionInventory 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 Affero General Public License for more details.
24+
25+
You should have received a copy of the GNU Affero General Public License
26+
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
27+
28+
------------------------------------------------------------------------
29+
30+
@package FusionInventory
31+
@author Alexandre Delaunay
32+
@co-author
33+
@copyright Copyright (c) 2010-2013 FusionInventory team
34+
@license AGPL License 3.0 or (at your option) any later version
35+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
36+
@link http://www.fusioninventory.org/
37+
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
38+
@since 2010
39+
40+
------------------------------------------------------------------------
41+
*/
42+
43+
include ("../../../inc/includes.php");
44+
header("Content-Type: text/html; charset=UTF-8");
45+
Html::header_nocache();
46+
Session::checkCentralAccess();
47+
48+
PluginFusioninventoryDeployFile::showServerFileTree($_REQUEST);
49+
50+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
3+
/*
4+
------------------------------------------------------------------------
5+
FusionInventory
6+
Copyright (C) 2010-2013 by the FusionInventory Development Team.
7+
8+
http://www.fusioninventory.org/ http://forge.fusioninventory.org/
9+
------------------------------------------------------------------------
10+
11+
LICENSE
12+
13+
This file is part of FusionInventory project.
14+
15+
FusionInventory is free software: you can redistribute it and/or modify
16+
it under the terms of the GNU Affero General Public License as published by
17+
the Free Software Foundation, either version 3 of the License, or
18+
(at your option) any later version.
19+
20+
FusionInventory 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 Affero General Public License for more details.
24+
25+
You should have received a copy of the GNU Affero General Public License
26+
along with FusionInventory. If not, see <http://www.gnu.org/licenses/>.
27+
28+
------------------------------------------------------------------------
29+
30+
@package FusionInventory
31+
@author Alexandre Delaunay
32+
@co-author
33+
@copyright Copyright (c) 2010-2013 FusionInventory team
34+
@license AGPL License 3.0 or (at your option) any later version
35+
http://www.gnu.org/licenses/agpl-3.0-standalone.html
36+
@link http://www.fusioninventory.org/
37+
@link http://forge.fusioninventory.org/projects/fusioninventory-for-glpi/
38+
@since 2010
39+
40+
------------------------------------------------------------------------
41+
*/
42+
43+
$AJAX_INCLUDE = 1;
44+
45+
include ("../../../inc/includes.php");
46+
47+
header("Content-Type: text/html; charset=UTF-8");
48+
Html::header_nocache();
49+
50+
Session::checkLoginUser();
51+
52+
PluginFusioninventoryDeployFile::getServerFileTree($_REQUEST);
53+
54+
?>

fusioninventory/inc/deployfile.class.php

+117-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ static function displayAjaxValue($datas) {
185185
echo "<input type='text' name='filename' id='server_filename$rand'".
186186
" style='width:120px;float:left' />";
187187
echo "<input type='button' class='submit' value='".__("Choose", 'fusioninventory').
188-
"' onclick='fileModal.show();' style='width:50px' />";
189-
Ajax::createModalWindow('fileModal',
188+
"' onclick='fileModal$rand.show();' style='width:50px' />";
189+
Ajax::createModalWindow("fileModal$rand",
190190
$CFG_GLPI['root_doc']."/plugins/fusioninventory/ajax/deployfilemodal.php",
191191
array('title' => __('Select the file on server', 'fusioninventory'),
192192
'extraparams' => array(
@@ -216,6 +216,121 @@ static function displayAjaxValue($datas) {
216216
echo "</tr></table>";
217217
}
218218

219+
static function showServerFileTree($params) {
220+
global $CFG_GLPI;
221+
222+
$rand = $params['rand'];
223+
224+
echo "<script type='javascript'>";
225+
echo "var Tree_Category_Loader$rand = new Ext.tree.TreeLoader({
226+
dataUrl:'".$CFG_GLPI["root_doc"]."/plugins/fusioninventory/ajax/serverfilestreesons.php'
227+
});";
228+
229+
echo "var Tree_Category$rand = new Ext.tree.TreePanel({
230+
collapsible : false,
231+
animCollapse : false,
232+
border : false,
233+
id : 'tree_projectcategory$rand',
234+
el : 'tree_projectcategory$rand',
235+
autoScroll : true,
236+
animate : false,
237+
enableDD : true,
238+
containerScroll : true,
239+
height : 320,
240+
width : 770,
241+
loader : Tree_Category_Loader$rand,
242+
rootVisible : false,
243+
listeners: {
244+
click: function(node, event){
245+
if (node.leaf == true) {
246+
console.log('server_filename$rand');
247+
Ext.get('server_filename$rand').dom.value = node.id;
248+
fileModal$rand.hide();
249+
}
250+
}
251+
}
252+
});";
253+
254+
// SET the root node.
255+
echo "var Tree_Category_Root$rand = new Ext.tree.AsyncTreeNode({
256+
text : '',
257+
draggable : false,
258+
id : '-1' // this IS the id of the startnode
259+
});
260+
Tree_Category$rand.setRootNode(Tree_Category_Root$rand);";
261+
262+
// Render the tree.
263+
echo "Tree_Category$rand.render();
264+
Tree_Category_Root$rand.expand();";
265+
266+
echo "</script>";
267+
268+
echo "<div id='tree_projectcategory$rand' ></div>";
269+
echo "</div>";
270+
}
271+
272+
static function getServerFileTree($params) {
273+
274+
$nodes = array();
275+
276+
if (isset($params['node'])) {
277+
278+
//root node
279+
$dir = "/var/www/glpi"; // TODO : add config option as 0.83 version
280+
281+
// leaf node
282+
if ($params['node'] != -1) {
283+
$dir = $params['node'];
284+
}
285+
286+
if ($handle = opendir($dir)) {
287+
$folders = $files = array();
288+
289+
//list files in dir selected
290+
//we store folders and files separately to sort them alphabeticaly separatly
291+
while (false !== ($entry = readdir($handle))) {
292+
if ($entry != "." && $entry != "..") {
293+
$filepath = $dir."/".$entry;
294+
if (is_dir($filepath)) {
295+
$folders[$filepath] = $entry;
296+
} else {
297+
$files[$filepath] = $entry;
298+
}
299+
}
300+
}
301+
302+
//sort folders and files (and maintain index association)
303+
asort($folders);
304+
asort($files);
305+
306+
//add folders in json
307+
foreach ($folders as $filepath => $entry) {
308+
$path['text'] = $entry;
309+
$path['id'] = $filepath;
310+
$path['draggable'] = false;
311+
$path['leaf'] = false;
312+
$path['cls'] = 'folder';
313+
314+
$nodes[] = $path;
315+
}
316+
317+
//add files in json
318+
foreach ($files as $filepath => $entry) {
319+
$path['text'] = $entry;
320+
$path['id'] = $filepath;
321+
$path['draggable'] = false;
322+
$path['leaf'] = true;
323+
$path['cls'] = 'file';
324+
325+
$nodes[] = $path;
326+
}
327+
328+
closedir($handle);
329+
}
330+
}
331+
332+
print json_encode($nodes);
333+
}
219334

220335

221336
static function getExtensionsWithAutoAction() {

0 commit comments

Comments
 (0)