コード例 #1
0
 /** Form to choose a ldap server
  *
  * @param   $target target page for the form
  *
  * @return  nothing
  **/
 static function ldapChooseDirectory($target)
 {
     global $DB;
     $query = "SELECT *\n                FROM `glpi_authldaps`\n                WHERE `is_active` = '1'\n                ORDER BY `name` ASC";
     $result = $DB->query($query);
     if ($DB->numrows($result) == 1) {
         //If only one server, do not show the choose ldap server window
         $ldap = $DB->fetch_assoc($result);
         $_SESSION["ldap_server"] = $ldap["id"];
         Html::redirect($_SERVER['PHP_SELF']);
     }
     echo "<div class='center'>";
     echo "<form action='{$target}' method=\"post\">";
     echo "<p>" . __('Please choose LDAP directory to import users from') . "</p>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_2'><th colspan='2'>" . __('LDAP directory choice') . "</th></tr>";
     //If more than one ldap server
     if ($DB->numrows($result) > 1) {
         echo "<tr class='tab_bg_2'><td class='center'>" . __('Name') . "</td>";
         echo "<td class='center'>";
         AuthLDAP::Dropdown(array('name' => 'ldap_server', 'display_emptychoice' => false, 'comment' => true, 'condition' => "`is_active`='1'"));
         echo "</td></tr>";
         echo "<tr class='tab_bg_2'><td class='center' colspan='2'>";
         echo "<input class='submit' type='submit' name='ldap_showusers' value=\"" . _sx('button', 'Post') . "\"></td></tr>";
     } else {
         //No ldap server
         echo "<tr class='tab_bg_2'>" . "<td class='center' colspan='2'>" . __('No LDAP directory defined in GLPI') . "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }