Projet

Général

Profil

Paste
Statistiques
| Branche: | Révision:

ryxeo-glpi-git / front / ldap.group.import.php @ b67d8923

Historique | Voir | Annoter | Télécharger (4,42 ko)

1
<?php
2

    
3
/*
4
 * @version $Id: ldap.group.import.php 7763 2009-01-06 18:44:50Z moyo $
5
 -------------------------------------------------------------------------
6
 GLPI - Gestionnaire Libre de Parc Informatique
7
 Copyright (C) 2003-2009 by the INDEPNET Development Team.
8

9
 http://indepnet.net/   http://glpi-project.org
10
 -------------------------------------------------------------------------
11

12
 LICENSE
13

14
 This file is part of GLPI.
15

16
 GLPI is free software; you can redistribute it and/or modify
17
 it under the terms of the GNU General Public License as published by
18
 the Free Software Foundation; either version 2 of the License, or
19
 (at your option) any later version.
20

21
 GLPI is distributed in the hope that it will be useful,
22
 but WITHOUT ANY WARRANTY; without even the implied warranty of
23
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
 GNU General Public License for more details.
25

26
 You should have received a copy of the GNU General Public License
27
 along with GLPI; if not, write to the Free Software
28
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
 --------------------------------------------------------------------------
30
 */
31

    
32
// ----------------------------------------------------------------------
33
// Original Author of file:
34
// Purpose of file:
35
// ----------------------------------------------------------------------
36

    
37
$NEEDED_ITEMS = array ("ldap","user","profile","group","entity","rulesengine","rule.right");
38

    
39
define('GLPI_ROOT', '..');
40
include (GLPI_ROOT . "/inc/includes.php");
41

    
42
checkSeveralRightsAnd(array (
43
        "group" => "w",
44
        "user_auth_method" => "w"
45
));
46

    
47
commonHeader($LANG["setup"][3], $_SERVER['PHP_SELF'], "admin", "group", "ldap");
48

    
49
if (isset ($_GET['next'])) {
50
        ldapChooseDirectory($_SERVER['PHP_SELF']);
51
} else {
52
        if (isset ($_SESSION["ldap_import"])) {
53
                if ($count = count($_SESSION["ldap_import"])) {
54
                        $percent = min(100, round(100 * ($_SESSION["ldap_import_count"] - $count) / $_SESSION["ldap_import_count"], 0));
55

    
56
                        displayProgressBar(400, $percent);
57

    
58
                        $key = array_pop($_SESSION["ldap_import"]);
59

    
60
                        if (isset ($_SESSION["ldap_import_entities"][$key]))
61
                                $entity = $_SESSION["ldap_import_entities"][$key];
62
                        else
63
                                $entity = $_SESSION["glpiactive_entity"];
64

    
65
                        ldapImportGroup($key, $_SESSION["ldap_server"], $entity, $_SESSION["ldap_import_type"][$key]);
66
                        glpi_header($_SERVER['PHP_SELF']);
67

    
68
                } else {
69
                        unset ($_SESSION["ldap_import"]);
70

    
71
                        displayProgressBar(400, 100);
72

    
73
                        echo "<div align='center'><strong>" . $LANG["ocsng"][8] . "<br>";
74
                        echo "<a href='" . $_SERVER['PHP_SELF'] . "'>" . $LANG["buttons"][13] . "</a>";
75
                        echo "</strong></div>";
76
                }
77
        }
78
        if (isset ($_POST["change_ldap_filter"])) {
79
                if (isset ($_POST["ldap_filter"]))
80
                        $_SESSION["ldap_group_filter"] = $_POST["ldap_filter"];
81

    
82
                if (isset ($_POST["ldap_filter2"]))
83
                        $_SESSION["ldap_group_filter2"] = $_POST["ldap_filter2"];
84

    
85
                glpi_header($_SERVER['PHP_SELF']);
86
        }
87
        elseif (!isset ($_POST["import_ok"])) {
88
                if (!isset ($_GET['check']))
89
                        $_GET['check'] = 'all';
90
                if (!isset ($_GET['start']))
91
                        $_GET['start'] = 0;
92

    
93
                if (isset ($_SESSION["ldap_import"]))
94
                        unset ($_SESSION["ldap_import"]);
95
                if (!isset ($_SESSION["ldap_server"])) {
96
                        if (isset ($_POST["ldap_server"])) {
97
                                $_SESSION["ldap_server"] = $_POST["ldap_server"];
98
                        } else {
99
                                glpi_header($CFG_GLPI["root_doc"] . "/front/ldap.php");
100
                        }
101
                }
102

    
103
                if (!testLDAPConnection($_SESSION["ldap_server"])) {
104
                        unset ($_SESSION["ldap_server"]);
105
                        echo "<div align='center'><strong>" . $LANG["ldap"][6] . "<br>";
106
                        echo "<a href='" . $_SERVER['PHP_SELF'] . "?next=listservers'>" . $LANG["buttons"][13] . "</a>";
107
                        echo "</strong></div>";
108
                } else {
109
                        if (!isset ($_SESSION["ldap_group_filter"])) {
110
                                $_SESSION["ldap_group_filter"] = '';
111
                        }
112
                        if (!isset ($_SESSION["ldap_group_filter2"])) {
113
                                $_SESSION["ldap_group_filter2"] = '';
114
                        }
115

    
116
                        showLdapGroups($_SERVER['PHP_SELF'], $_GET['check'], $_GET['start'], 0, $_SESSION["ldap_group_filter"], $_SESSION["ldap_group_filter2"], $_SESSION["glpiactive_entity"]);
117
                }
118
        } else {
119

    
120
                if (count($_POST['toimport']) > 0) {
121
                        $_SESSION["ldap_import_count"] = 0;
122

    
123
                        foreach ($_POST['toimport'] as $key => $val) {
124
                                if ($val == "on") {
125
                                        $_SESSION["ldap_import"][] = $key;
126
                                        $_SESSION["ldap_import_count"]++;
127
                                        $_SESSION["ldap_import_entities"][$key] = $_POST["toimport_entities"][$key];
128
                                        $_SESSION["ldap_import_type"][$key] = $_POST["toimport_type"][$key];
129
                                }
130
                        }
131
                }
132

    
133
                glpi_header($_SERVER['PHP_SELF']);
134
        }
135
}
136

    
137
commonFooter();
138
?>
Redmine Appliance - Powered by TurnKey Linux