|
1 |
<?php
|
|
2 |
/*
|
|
3 |
* recherche les groupes qui sont affectes a plusieurs entites, ca pose pb
|
|
4 |
* pour les tickets
|
|
5 |
*/
|
|
6 |
|
|
7 |
if(!defined('GLPI_ROOT')){
|
|
8 |
define('GLPI_ROOT', '../../..');
|
|
9 |
}
|
|
10 |
include_once (GLPI_ROOT . "/inc/includes.php");
|
|
11 |
|
|
12 |
checkRight("config","w");
|
|
13 |
global $DB;
|
|
14 |
|
|
15 |
commonHeader("anet_epacks",$_SERVER['PHP_SELF'],"config","plugins");
|
|
16 |
|
|
17 |
print "<h3>Détection des multigroupes</h3>\n";
|
|
18 |
|
|
19 |
$query = "SELECT name FROM glpi_groups GROUP BY name HAVING COUNT(name) > 1";
|
|
20 |
$result = $DB->query($query);
|
|
21 |
while($data=$DB->fetch_array($result)) {
|
|
22 |
$lenom=$data[0];
|
|
23 |
|
|
24 |
$query2 = "SELECT * FROM glpi_groups WHERE name='" . $lenom . "'";
|
|
25 |
$result2 = $DB->query($query2);
|
|
26 |
|
|
27 |
$query3 = "select * from glpi_plugin_anet_epacks WHERE code='" . $lenom . "'";
|
|
28 |
$result3 = $DB->query($query3);
|
|
29 |
$data3=$DB->fetch_array($result3);
|
|
30 |
|
|
31 |
$query4 = "SELECT FK_entities FROM glpi_computers WHERE ID='" . $data3['FK_serveur'] . "'";
|
|
32 |
$result4 = $DB->query($query4);
|
|
33 |
$data4=$DB->fetch_array($result4);
|
|
34 |
/*
|
|
35 |
* plusieurs cas de figure
|
|
36 |
* - FK_entities correspond a une entite de la table glpi_plugin_anet_epacks: c'est bon
|
|
37 |
* - FK_entities est un enfant de celui qui est dans glpi_plugin_anet_epacks: c'est bon
|
|
38 |
* -> le reste c'est pas bon
|
|
39 |
*/
|
|
40 |
while($data2=$DB->fetch_array($result2)) {
|
|
41 |
$lid = $data2['FK_entities'];
|
|
42 |
if(
|
|
43 |
$lid == $data3['FK_clientderyxeo'] ||
|
|
44 |
$lid == $data3['FK_activation'] ||
|
|
45 |
$lid == $data3['FK_client'] ||
|
|
46 |
$lid == $data3['FK_enduser'] ||
|
|
47 |
//Peut-etre que le le FK_serveur est a une entite qui fait partie du groupe ...
|
|
48 |
$lid == $data4['FK_entities']
|
|
49 |
) {
|
|
50 |
//print "<p>Ok pour: $lenom : $lid</p>";
|
|
51 |
}
|
|
52 |
else {
|
|
53 |
print "<p>PAS Ok pour: $lenom : $lid";
|
|
54 |
$query5 = "DELETE FROM glpi_groups WHERE name='" . $lenom . "' AND FK_entities='" . $lid . "'";
|
|
55 |
$result5 = $DB->query($query5);
|
|
56 |
//print $query5;
|
|
57 |
print " ... corrigé</p>";
|
|
58 |
}
|
|
59 |
}
|
|
60 |
}
|
|
61 |
|
|
62 |
//$query = "UPDATE `glpi_users` SET FK_entities='1' WHERE `FK_entities` = 0 AND email NOT LIKE '%ryxeo.com'";
|
|
63 |
//$result = $DB->query($query);
|
|
64 |
|
|
65 |
commonFooter();
|
|
66 |
?>
|