Revision 0d761a49
[#1571] Ajout du champ Vigilo Template
Change-Id: Ib31d45245cbbbeb845df30f013bec479878ee627
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2321
Reviewed-by: Francois POIROTTE <francois.poirotte@c-s.fr>
Tested-by: Francois POIROTTE <francois.poirotte@c-s.fr>
hook.php | ||
---|---|---|
18 | 18 |
$confdir = implode(DIRECTORY_SEPARATOR, $dirs); |
19 | 19 |
$file = $confdir . DIRECTORY_SEPARATOR . "groups.xml"; |
20 | 20 |
|
21 |
if (!file_exists($confdir)) { |
|
22 |
mkdir($confdir, 0770, true); |
|
23 |
} |
|
24 |
|
|
21 |
mkdir($confdir, 0770, true); |
|
25 | 22 |
$acc = ""; |
26 | 23 |
foreach ($dirs as $dir) { |
27 | 24 |
$acc .= DIRECTORY_SEPARATOR . $dir; |
... | ... | |
38 | 35 |
public function add($computer) |
39 | 36 |
{ |
40 | 37 |
if ($computer->getField("is_template")==0) { |
38 |
global $DB; |
|
39 |
$template_id = PluginVigiloVigiloTemplate::getVigiloTemplateNameByID($computer->getField("vigilo_template")); |
|
40 |
|
|
41 |
if(!empty($template_id)) { |
|
42 |
$query = "UPDATE glpi_computers |
|
43 |
SET vigilo_template = '" . PluginVigiloVigiloTemplate::getVigiloTemplateNameByID($computer->getField("vigilo_template")) . |
|
44 |
"' WHERE id = " . $computer->getField("id") . ";"; |
|
45 |
$DB->queryOrDie($query, "update vigilo_template field"); |
|
46 |
} |
|
47 |
|
|
48 |
$query = "UPDATE glpi_computers |
|
49 |
SET is_dynamic = ' 1 |
|
50 |
' WHERE id = " . $computer->getField("id") . ";"; |
|
51 |
$DB->queryOrDie($query, "update vigilo_template field"); |
|
41 | 52 |
$host = new VigiloHost($computer); |
42 | 53 |
$dirs = array($this->confdir, "hosts", "managed"); |
43 | 54 |
$confdir = implode(DIRECTORY_SEPARATOR, $dirs); |
... | ... | |
67 | 78 |
|
68 | 79 |
public function update($computer) |
69 | 80 |
{ |
70 |
global $PLUGIN_HOOKS; |
|
81 |
global $PLUGIN_HOOKS, $DB;
|
|
71 | 82 |
if (isset($computer->oldvalues["name"])) { |
72 | 83 |
$this->unmonitor($computer->oldvalues["name"]); |
73 | 84 |
} |
74 |
|
|
75 | 85 |
$this->add($computer); |
76 | 86 |
} |
77 | 87 |
|
... | ... | |
86 | 96 |
global $DB; |
87 | 97 |
$computer=new Computer(); |
88 | 98 |
$computer->getFromDB($computer_software_version->getField("computers_id")); |
89 |
$this->update($computer); |
|
99 |
$this->update($computer);
|
|
90 | 100 |
} |
91 | 101 |
|
92 | 102 |
public function manageSoftwares($software) |
... | ... | |
136 | 146 |
$comp->getFromDB($id); |
137 | 147 |
$this->update($comp); |
138 | 148 |
} |
149 |
|
|
150 |
public function plugin_vigilo_getAddSearchOptions($itemtype) |
|
151 |
{ |
|
152 |
$options = array(); |
|
153 |
if ($itemtype == 'Computer' or $itemtype == 'PluginVigiloComputer') |
|
154 |
{ |
|
155 |
$options['7007']['table'] = 'glpi_computers'; |
|
156 |
$options['7007']['field'] = 'vigilo_template'; |
|
157 |
$options['7007']['name'] = 'vigilo_template'; |
|
158 |
$options['7007']['massiveaction'] = 'TRUE'; |
|
159 |
$options['7007']['datatype'] = 'dropdown'; |
|
160 |
return $options; |
|
161 |
} |
|
162 |
} |
|
139 | 163 |
} |
Also available in: Unified diff