ryxeo-glpi-git / front / rule.common.php @ b67d8923
Historique | Voir | Annoter | Télécharger (4,84 ko)
1 | b67d8923 | Eric Seigne | <?php
|
---|---|---|---|
2 | /*
|
||
3 | * @version $Id: rule.common.php 7763 2009-01-06 18:44:50Z moyo $
|
||
4 | -------------------------------------------------------------------------
|
||
5 | GLPI - Gestionnaire Libre de Parc Informatique
|
||
6 | Copyright (C) 2003-2009 by the INDEPNET Development Team.
|
||
7 | |||
8 | http://indepnet.net/ http://glpi-project.org
|
||
9 | -------------------------------------------------------------------------
|
||
10 | |||
11 | LICENSE
|
||
12 | |||
13 | This file is part of GLPI.
|
||
14 | |||
15 | GLPI is free software; you can redistribute it and/or modify
|
||
16 | it under the terms of the GNU General Public License as published by
|
||
17 | the Free Software Foundation; either version 2 of the License, or
|
||
18 | (at your option) any later version.
|
||
19 | |||
20 | GLPI 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 General Public License for more details.
|
||
24 | |||
25 | You should have received a copy of the GNU General Public License
|
||
26 | along with GLPI; if not, write to the Free Software
|
||
27 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||
28 | --------------------------------------------------------------------------
|
||
29 | */
|
||
30 | |||
31 | // ----------------------------------------------------------------------
|
||
32 | // Original Author of file: Walid Nouh
|
||
33 | // Purpose of file:
|
||
34 | // ----------------------------------------------------------------------
|
||
35 | |||
36 | if (!defined('GLPI_ROOT')){ |
||
37 | die("Sorry. You can't access directly to this file"); |
||
38 | } |
||
39 | |||
40 | $rule = $rulecollection->getRuleClass();; |
||
41 | |||
42 | if(!isset($_GET["ID"])) $_GET["ID"] = ""; |
||
43 | |||
44 | checkRight($rulecollection->right,"r"); |
||
45 | |||
46 | if (isset($_GET["action"])){ |
||
47 | checkRight($rulecollection->right,"w"); |
||
48 | $rulecollection->changeRuleOrder($_GET["ID"],$_GET["action"]); |
||
49 | glpi_header($_SERVER['HTTP_REFERER']); |
||
50 | }elseif (isset($_POST["action"])){ |
||
51 | checkRight($rulecollection->right,"w"); |
||
52 | |||
53 | // Use massive action system
|
||
54 | switch ($_POST["action"]){ |
||
55 | case "delete": |
||
56 | if (isset($_POST["item"])&&count($_POST["item"])){ |
||
57 | foreach ($_POST["item"] as $key => $val){ |
||
58 | $rule->getFromDB($key); |
||
59 | $input["ID"]=$key; |
||
60 | $rulecollection->deleteRuleOrder($rule->fields["ranking"]); |
||
61 | $rule->delete(array('ID'=>$key)); |
||
62 | } |
||
63 | logEvent(0, "rules", 4, "setup", $_SESSION["glpiname"]." ".$LANG["log"][22]); |
||
64 | glpi_header($_SERVER['HTTP_REFERER']); |
||
65 | } |
||
66 | break;
|
||
67 | case "move_rule": |
||
68 | if (isset($_POST["item"])&&count($_POST["item"])){ |
||
69 | foreach ($_POST["item"] as $key => $val){ |
||
70 | $rule->getFromDB($key); |
||
71 | $rulecollection->moveRule($key,$_POST['ranking'],$_POST['move_type']); |
||
72 | } |
||
73 | } |
||
74 | break;
|
||
75 | case "activate_rule": |
||
76 | if (isset($_POST["item"])){ |
||
77 | $rule = new Rule(); |
||
78 | foreach ($_POST["item"] as $key => $val){ |
||
79 | if ($val==1) { |
||
80 | $input['ID']=$key; |
||
81 | $input['active']=$_POST["activate_rule"]; |
||
82 | $rule->update($input); |
||
83 | } |
||
84 | } |
||
85 | } |
||
86 | break;
|
||
87 | } |
||
88 | } else if (isset($_POST["replay_rule"]) || isset($_GET["replay_rule"])){ |
||
89 | |||
90 | checkRight($rulecollection->right,"w"); |
||
91 | |||
92 | // Current time
|
||
93 | $start = explode(" ",microtime()); |
||
94 | $start = $start[0]+$start[1]; |
||
95 | |||
96 | // Limit computed from current time
|
||
97 | $max = get_cfg_var("max_execution_time"); |
||
98 | $max = $start + ($max>0 ? $max/2.0 : 30.0); |
||
99 | |||
100 | commonHeader($LANG["rulesengine"][17],$_SERVER['PHP_SELF'],"admin",getCategoryNameToDisplay($rulecollection->rule_type),$rulecollection->rule_type); |
||
101 | |||
102 | if (!(isset($_POST['replay_confirm']) || isset($_GET['offset'])) && $rulecollection->warningBeforeReplayRulesOnExistingDB($_SERVER['PHP_SELF'])){ |
||
103 | commonFooter(); |
||
104 | exit();
|
||
105 | } |
||
106 | |||
107 | echo "<div class='center'>"; |
||
108 | echo "<table class='tab_cadrehov'>"; |
||
109 | |||
110 | echo "<tr><th><div class='relative'><span><strong>" .$rulecollection->getTitle(). "</strong></span>"; |
||
111 | echo " - " .$LANG["rulesengine"][76]. "</th></tr>\n"; |
||
112 | echo "<tr><td align='center'>"; |
||
113 | createProgressBar($LANG["rulesengine"][90]); |
||
114 | echo "</td></tr>\n"; |
||
115 | echo "</table>"; |
||
116 | echo "</div>"; |
||
117 | |||
118 | if (!isset($_GET['offset'])) { |
||
119 | // First run
|
||
120 | $offset = $rulecollection->replayRulesOnExistingDB(0,$max,array(),$_POST); |
||
121 | $manufacturer = (isset($_POST["manufacturer"]) ? $_POST["manufacturer"] : 0); |
||
122 | } else {
|
||
123 | // Next run
|
||
124 | $offset = $rulecollection->replayRulesOnExistingDB($_GET['offset'],$max,array(),$_GET); |
||
125 | $manufacturer = $_GET["manufacturer"]; |
||
126 | |||
127 | // global start for stat
|
||
128 | $start = $_GET["start"]; |
||
129 | } |
||
130 | |||
131 | if ($offset < 0) { |
||
132 | // Work ended
|
||
133 | $end=explode(" ",microtime()); |
||
134 | $duree=round($end[0]+$end[1]-$start); |
||
135 | |||
136 | changeProgressBarMessage($LANG["rulesengine"][91]." (".timestampToString($duree). |
||
137 | ")<br /><a href='".$_SERVER['PHP_SELF']."'>".$LANG["buttons"][13]."</a>"); |
||
138 | } else {
|
||
139 | // Need more work
|
||
140 | glpi_header($_SERVER['PHP_SELF']."?start=$start&replay_rule=1&offset=$offset&manufacturer=$manufacturer"); |
||
141 | } |
||
142 | |||
143 | commonFooter(true);
|
||
144 | exit();
|
||
145 | } |
||
146 | |||
147 | commonHeader($LANG["rulesengine"][17],$_SERVER['PHP_SELF'],"admin",getCategoryNameToDisplay($rulecollection->rule_type),$rulecollection->rule_type); |
||
148 | |||
149 | $rulecollection->showForm($_SERVER['PHP_SELF']); |
||
150 | commonFooter(); |
||
151 | ?> |