Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vdeville committed Jun 6, 2016
0 parents commit f369582
Show file tree
Hide file tree
Showing 9 changed files with 470 additions and 0 deletions.
1 change: 1 addition & 0 deletions APACHE/Listprinters.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
PerlModule Apache::Ocsinventory::Plugins::Listprinters::Map
22 changes: 22 additions & 0 deletions APACHE/Map.pm
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@


package Apache::Ocsinventory::Plugins::Listprinters::Map;

use strict;

use Apache::Ocsinventory::Map;

$DATA_MAP{listprinters} = {
mask => 0,
multi => 1,
auto => 1,
delOnReplace => 1,
sortBy => 'NAME',
writeDiff => 0,
cache => 0,
fields => {
NAME => {},
ADDRESS => {}
}
};
1;
339 changes: 339 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# List printers
Retrieve connected printers
13 changes: 13 additions & 0 deletions agent/listprinters.vbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'Author: Valentin DEVILLE


Set WshNetwork = WScript.CreateObject("WScript.Network")
Set oPrinters = WshNetwork.EnumPrinterConnections


For i = 0 to oPrinters.Count - 1 Step 2
Wscript.Echo "<LISTPRINTERS>"
Wscript.Echo "<NAME>" & oPrinters.Item(i+1) & "</NAME>"
Wscript.Echo "<ADDRESS>" & oPrinters.Item(i) & "</ADDRESS>"
Wscript.Echo "</LISTPRINTERS>"
Next
51 changes: 51 additions & 0 deletions cd_listprinters/cd_listprinters.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/*
====================================================================================
OCS INVENTORY
Copyleft Valentin DEVILLE 2016
Web: http://www.ocsinventory-ng.org
This code is open source and may be copied and modified as long as the source code is always made freely available.
Please refer to the General Public Licence http://www.gnu.org/ or LiCENSE.MD
====================================================================================
*/

if(AJAX){
parse_str($protectedPost['ocs']['0'], $params);
$protectedPost+=$params;
ob_start();
$ajax = true;
}
else{
$ajax=false;
}
print_item_header("Printers list");

if (!isset($protectedPost['SHOW'])){
$protectedPost['SHOW'] = 'NOSHOW';
}
$form_name="listprinters";
$table_name=$form_name;
$tab_options=$protectedPost;
$tab_options['form_name']=$form_name;
$tab_options['table_name']=$table_name;
echo open_form($form_name);
$list_fields = array(
'Name' => 'NAME',
'Address' => 'ADDRESS'
);
$list_col_cant_del=$list_fields;
$default_fields= $list_fields;
$sql=prepare_sql_tab($list_fields);

$sql['SQL'] .= "FROM $table_name WHERE (hardware_id = $systemid)";
array_push($sql['ARG'],$systemid);
$tab_options['ARG_SQL']=$sql['ARG'];
$tab_options['ARG_SQL_COUNT']=$systemid;
ajaxtab_entete_fixe($list_fields,$default_fields,$tab_options,$list_col_cant_del);
echo close_form();
if ($ajax){
ob_end_clean();
tab_req($list_fields,$default_fields,$list_col_cant_del,$sql['SQL'],$tab_options);
ob_start();
}
10 changes: 10 additions & 0 deletions infos.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"displayName" : "List printers",
"author" : ["Valentin DEVILLE"],
"contributor" : [],
"supportedAgent" : ["Windows"],
"description" : {
"fr" : "Remonte les imprimantes connectés",
"en" : "Retrieve connected printers"
}
}
32 changes: 32 additions & 0 deletions install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
function plugin_version_listprinters()
{
return array('name' => 'List printers',
'version' => '1.0',
'author'=> 'Valentin DEVILLE',
'license' => 'GPLv2',
'verMinOcs' => '2.2');
}

function plugin_init_listprinters()
{
$object = new plugins;
$object -> add_cd_entry("listprinters","other");

$object -> sql_query("CREATE TABLE IF NOT EXISTS `listprinters` (
`ID` INT(11) NOT NULL AUTO_INCREMENT,
`HARDWARE_ID` INT(11) NOT NULL,
`NAME` VARCHAR(255) DEFAULT NULL,
`ADDRESS` VARCHAR(255) DEFAULT NULL,
PRIMARY KEY (`ID`,`HARDWARE_ID`)
) ENGINE=INNODB;");

}

function plugin_delete_listprinters()
{
$object = new plugins;
$object -> del_cd_entry("listprinters");
$object -> sql_query("DROP TABLE `listprinters`");

}
Binary file added preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f369582

Please sign in to comment.