diff --git a/doc/en/administration_guide/parameters.rst b/doc/en/administration_guide/parameters.rst index 1db2942734f..947739e458e 100644 --- a/doc/en/administration_guide/parameters.rst +++ b/doc/en/administration_guide/parameters.rst @@ -126,7 +126,7 @@ To add a new directory: * **Configuration name** and **Description** fields define the name and the description of the LDAP server * **Enable LDAP authentication** field serves to enable authentication via the LDAP server * **Store LDAP password** field can be used to store user passwords in the database, useful to authenticate users in the event of loss of connection with the LDAP -* **Auto import users** field serves to import the users of the LDAP directory automatically into Centreon. By clicking on **Import users manually**, you can chose the users that you want to import +* **Auto import users** field used to import the users of the LDAP directory automatically into Centreon. By clicking on **Import users manually**, you can chose the users that you want to import .. note:: If the **Auto import users** option is checked, the LDAP settings of any new user who logs into the Centreon interface will automatically be imported into Centreon (name, first name, e-mail address, etc.). ACL profiles will be applied on access (link to :ref:`ACL `). However, if this option is not checked, only the users imported manually will be able to authenticate. @@ -134,6 +134,7 @@ To add a new directory: * **LDAP search size limit** field can be used to limit the size of user searches * **LDAP search timeout** field can be used define the maximum time for the LDAP search * **Contact template** field defines the contact template that will be linked to all the users imported from this LDAP directory +* **Default contactgroup** optional field, which is used to add a new user to a default contactgroup. * **Use service DNS** field indicates if it is necessary to use the DNS server to solve the IP address of the LDAP directory * **LDAP servers** field can be used to add one or more LDAP directories to which Centreon will connect diff --git a/doc/en/images/guide_exploitation/eldap.png b/doc/en/images/guide_exploitation/eldap.png index e19bba87657..12601f9eec5 100644 Binary files a/doc/en/images/guide_exploitation/eldap.png and b/doc/en/images/guide_exploitation/eldap.png differ diff --git a/doc/en/release_notes/centreon-18.10/centreon-18.10.4.rst b/doc/en/release_notes/centreon-18.10/centreon-18.10.4.rst index cd7465e2298..0a53c6ec650 100644 --- a/doc/en/release_notes/centreon-18.10/centreon-18.10.4.rst +++ b/doc/en/release_notes/centreon-18.10/centreon-18.10.4.rst @@ -39,3 +39,4 @@ Security * Fix rce vulnerability when using command's testing feature (PR/#7245) * Fix SQL injection for GET parameter (PR/#7229) * Fix unauthorized file upload (PR/#7171) + diff --git a/doc/fr/administration_guide/parameters.rst b/doc/fr/administration_guide/parameters.rst index ef23e52fc75..82e35b3b8c6 100644 --- a/doc/fr/administration_guide/parameters.rst +++ b/doc/fr/administration_guide/parameters.rst @@ -140,6 +140,7 @@ Pour ajouter un nouvel annuaire : * Le champ **Taille limite de la recherche LDAP** permet de limiter la taille de la recherche des utilisateurs * Le champ **Temps maximum d'exécution de la recherche LDAP** permet de définir le temps maximum de la recherche LDAP * Le champ **Modèle de contact** définit le modèle de contact qui sera lié pour tous les utilisateurs importés depuis cet annuaire LDAP +* Le champ optionnel **Groupe de contacts par défaut** permet d'ajouter à un groupe de contact les contacts importés * Le champ **Utiliser le service DNS** indique s'il faut utiliser le serveur DNS pour résoudre l'adresse IP de l'annuaire LDAP * Le champ **LDAP servers** permet d'ajouter un ou plusieurs annuaires LDAP vers lequel Centreon va se connecter. diff --git a/doc/fr/images/guide_exploitation/eldap.png b/doc/fr/images/guide_exploitation/eldap.png index e34a3081b8e..12601f9eec5 100644 Binary files a/doc/fr/images/guide_exploitation/eldap.png and b/doc/fr/images/guide_exploitation/eldap.png differ diff --git a/lang/es_ES.UTF-8/LC_MESSAGES/help.po b/lang/es_ES.UTF-8/LC_MESSAGES/help.po index 8c6662dbdf0..e3d38113448 100644 --- a/lang/es_ES.UTF-8/LC_MESSAGES/help.po +++ b/lang/es_ES.UTF-8/LC_MESSAGES/help.po @@ -273,8 +273,10 @@ msgstr "" "La configuración del servidor LDAP debe ser válida y el usuario debe coincidir con los criterios de búsqueda definidos." #: centreon-web/www/include/Administration/parameters/ldap/help.php:14 -msgid "The contact template for auto imported user.
This template is applied for Monitoring Engine contact configuration and ACLs" -msgstr "La plantilla de contacto para usuarios automáticos importados.
Esta plantilla se aplica para configurar los contactos del programador y para las ACL." +msgid "The contact template for auto imported user.
This template is applied for " +"Monitoring Engine contact configuration and ACLs." +msgstr "La plantilla de contacto para usuarios automáticos importados.
" +"Esta plantilla se aplica para configurar los contactos del programador y para las ACL." #: centreon-web/www/include/Administration/parameters/ldap/help.php:17 msgid "Use the DNS service for get LDAP host" diff --git a/lang/fr_FR.UTF-8/LC_MESSAGES/help.po b/lang/fr_FR.UTF-8/LC_MESSAGES/help.po index 210f011326b..4514997cbb5 100644 --- a/lang/fr_FR.UTF-8/LC_MESSAGES/help.po +++ b/lang/fr_FR.UTF-8/LC_MESSAGES/help.po @@ -414,11 +414,19 @@ msgstr "" #: centreon-web/www/include/Administration/parameters/ldap/help.php:14 msgid "" "The contact template for auto imported user.
This template is applied for " -"Monitoring Engine contact configuration and ACLs" +"Monitoring Engine contact configuration and ACLs." msgstr "" "Le modèle de contact pour les utilisateurs auto importés.
Ce modèle est " "appliqué pour la configuration des contacts de l'ordonnanceur et pour les ACLs." +#: centreon-web/www/include/Administration/parameters/ldap/help.php:14 +msgid "" +"Default contact group applied to new users.
All imported users will join " +"this contactgroup." +msgstr "" +"Groupe de contact par défaut.
Tous les nouveaux utilisateurs rejoindront " +"ce groupe de contact." + #: centreon-web/www/include/Administration/parameters/ldap/help.php:17 msgid "Use the DNS service for get LDAP host" msgstr "Utilise le service DNS pour obtenir les hôtes LDAP" diff --git a/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po b/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po index 2c585dcd665..ac764ab7f2e 100644 --- a/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po +++ b/lang/fr_FR.UTF-8/LC_MESSAGES/messages.po @@ -2116,10 +2116,15 @@ msgid "Contact" msgstr "Contact" #: centreon-web/www/install/smarty_translate.php:624 -#: centreon-web/www/include/Administration/parameters/ldap/form.php:117 +#: centreon-web/www/include/Administration/parameters/ldap/form.php:111 msgid "Contact template" msgstr "Modèle de contact" +#: centreon-web/www/install/smarty_translate.php:672 +#: centreon-web/www/include/Administration/parameters/ldap/form.php:125 +msgid "Default contact group" +msgstr "Groupe de contacts par défaut" + #: centreon-web/www/install/smarty_translate.php:633 msgid "Escalation" msgstr "Escalade de notification" diff --git a/lang/pt_BR.UTF-8/LC_MESSAGES/help.po b/lang/pt_BR.UTF-8/LC_MESSAGES/help.po index 99e37aff989..81bf6abcff6 100644 --- a/lang/pt_BR.UTF-8/LC_MESSAGES/help.po +++ b/lang/pt_BR.UTF-8/LC_MESSAGES/help.po @@ -838,7 +838,7 @@ msgstr "" #: /home/lgcosta/devel/centreon/centreon/www/include/Administration/parameters/ldap/help.php:14 msgid "" "The contact template for auto imported user.
This template is applied " -"for Monitoring Engine contact configuration and ACLs" +"for Monitoring Engine contact configuration and ACLs." msgstr "" "O modelo de contato para usuários automáticos importados.
Este modelo " "é aplicado para configurar os contatos do agendador e para as ACLs." diff --git a/lang/pt_PT.UTF-8/LC_MESSAGES/help.po b/lang/pt_PT.UTF-8/LC_MESSAGES/help.po index 34c306f51fc..8cde8e36514 100644 --- a/lang/pt_PT.UTF-8/LC_MESSAGES/help.po +++ b/lang/pt_PT.UTF-8/LC_MESSAGES/help.po @@ -276,8 +276,10 @@ msgstr "" "A configuração do servidor LDAP deve ser válida e o utilizador deve corresponder aos critérios de pesquisa definidos." #: centreon-web/www/include/Administration/parameters/ldap/help.php:14 -msgid "The contact template for auto imported user.
This template is applied for Monitoring Engine contact configuration and ACLs" -msgstr "O modelo de contacto para utilizadors automáticos importados.
Este modelo é aplicado para configurar os contactos do agendador e para as ACLs." +msgid "The contact template for auto imported user.
This template is applied for " +"Monitoring Engine contact configuration and ACLs." +msgstr "O modelo de contacto para utilizadors automáticos importados.
" +"Este modelo é aplicado para configurar os contactos do agendador e para as ACLs." #: centreon-web/www/include/Administration/parameters/ldap/help.php:17 msgid "Use the DNS service for get LDAP host" diff --git a/www/class/centreonAuth.LDAP.class.php b/www/class/centreonAuth.LDAP.class.php index 06db6ce8b6f..c8db08ea39a 100644 --- a/www/class/centreonAuth.LDAP.class.php +++ b/www/class/centreonAuth.LDAP.class.php @@ -1,7 +1,7 @@ pearDB->query("SELECT value FROM options WHERE `key` = 'debug_ldap_import'"); - $data = $res->fetchRow(); + $data = $res->fetch(); if (isset($data["value"])) { return $data["value"]; } @@ -209,32 +209,24 @@ public function updateUserDn() return false; } - /* - * Get ldap user informations - */ + // Get ldap user informations $userInfos = $this->ldap->getEntry($userDn); $userDisplay = $userInfos[$this->ldap->getAttrName('user', 'name')]; - /* - * Get the first if there are multiple entries - */ + + // Get the first if there are multiple entries if (is_array($userDisplay)) { $userDisplay = $userDisplay[0]; } - /* - * Replace space by underscore - */ + // Replace space by underscore $userDisplay = str_replace(array(' ', ','), '_', $userDisplay); - /* - * Delete parenthesis - */ + + // Delete parenthesis $userDisplay = str_replace(array('(', ')'), '', $userDisplay); $userEmail = "'".$this->contactInfos['contact_email']."'"; if (isset($userInfos[$this->ldap->getAttrName('user', 'email')]) && trim($userInfos[$this->ldap->getAttrName('user', 'email')]) != '') { if (is_array($userInfos[$this->ldap->getAttrName('user', 'email')])) { - /* - * Get the first if there are multiple entries - */ + // Get the first if there are multiple entries if ($userInfos[$this->ldap->getAttrName('user', 'email')][0]) { $userEmail = "'" . $userInfos[$this->ldap->getAttrName('user', 'email')][0] . "'"; } @@ -246,9 +238,7 @@ public function updateUserDn() if (isset($userInfos[$this->ldap->getAttrName('user', 'pager')]) && trim($userInfos[$this->ldap->getAttrName('user', 'pager')]) != '') { if (is_array($userInfos[$this->ldap->getAttrName('user', 'pager')])) { - /* - * Get the first if there are multiple entries - */ + // Get the first if there are multiple entries if ($userInfos[$this->ldap->getAttrName('user', 'pager')][0]) { $userPager = "'" . $userInfos[$this->ldap->getAttrName('user', 'pager')][0] . "'"; } @@ -257,9 +247,7 @@ public function updateUserDn() } } if (isset($this->contactInfos['contact_id'])) { - /* - * Update the user dn and extended informations for user - */ + // Update the user dn and extended informations for user $this->CentreonLog->insertLog(3, "LDAP AUTH : Update user DN for user " . html_entity_decode($this->contactInfos['contact_alias'], ENT_QUOTES, 'UTF-8')); $queryUpdateExtInfos = "UPDATE contact SET @@ -279,9 +267,7 @@ public function updateUserDn() } $this->contactInfos['contact_ldap_dn'] = $userDn; - /* - * try to update user groups from AD - */ + // try to update user groups from AD try { include_once(realpath(dirname(__FILE__) . '/centreonContactgroup.class.php')); $cgs = new CentreonContactgroup($this->pearDB); @@ -292,24 +278,21 @@ public function updateUserDn() return true; } else { - /* - * Find the template ID - */ + // Find the template ID $query = "SELECT ari_value FROM `auth_ressource_info` a, `contact` c WHERE a.`ari_name` = 'ldap_contact_tmpl' AND a.ar_id = ".$this->pearDB->escape($this->arId)." AND a.ari_value = c.contact_id"; $res = $this->pearDB->query($query); - $row = $res->fetchRow(); + $row = $res->fetch(); if (!isset($row['ari_value']) || !$row['ari_value']) { $this->CentreonLog->insertLog(3, "LDAP AUTH : No contact template defined."); return false; } $tmplId = $row['ari_value']; - /* - * Insert user in database - */ + + // Insert user in database $query = "INSERT INTO contact (contact_template_id, contact_alias, contact_name, contact_auth_type, contact_ldap_dn, ar_id, contact_email, contact_pager, contact_oreon, contact_activate, contact_register, @@ -320,14 +303,13 @@ public function updateUserDn() ", " . $userEmail . ", " . $userPager . ", '1', '1', '1', '2')"; try { $this->pearDB->query($query); - /* - * Get the contact_id - */ + + // Get the contact_id $query = "SELECT contact_id FROM contact WHERE contact_ldap_dn = '" . $this->pearDB->escape($userDn) . "'"; $res = $this->pearDB->query($query); - $row = $res->fetchRow(); - $contact_id = $row['contact_id']; + $row = $res->fetch(); + $this->contactInfos['contact_id'] = $row['contact_id']; $listGroup = $this->ldap->listGroupsForUser($userDn); $listGroupStr = ""; foreach ($listGroup as $gName) { @@ -341,16 +323,22 @@ public function updateUserDn() } $query = "SELECT cg_id FROM contactgroup WHERE cg_name IN (" . $listGroupStr . ")"; $res = $this->pearDB->query($query); - /* - * Insert the relation between contact and contact group - */ - while ($row = $res->fetchRow()) { - $query = "INSERT INTO contactgroup_contact_relation - (contactgroup_cg_id, contact_contact_id) - VALUES (" . $row['cg_id'] . ", " . $contact_id . ")"; - $this->pearDB->query($query); + + // Insert the relation between contact and contactgroups + $query = "INSERT INTO contactgroup_contact_relation (contactgroup_cg_id, contact_contact_id) " . + "VALUES (:ldapCg, :contactId)"; + $stmt = $this->pearDB->prepare($query); + while ($row = $res->fetch()) { + $stmt->bindValue(':ldapCg', $row['cg_id'], PDO::PARAM_INT); + $stmt->bindValue(':contactId', $this->contactInfos['contact_id'], PDO::PARAM_INT); + $stmt->execute(); } - return true; + // Insert the relation between the LDAP's default contactgroup and the user + // returns true if everything goes well + return $this->ldap->addUserToLdapDefautCg( + $this->arId, + $this->contactInfos['contact_id'] + ); } catch (\PDOException $e) { // Nothing } diff --git a/www/class/centreonLDAP.class.php b/www/class/centreonLDAP.class.php index bb5af46f251..82fcbffeed3 100644 --- a/www/class/centreonLDAP.class.php +++ b/www/class/centreonLDAP.class.php @@ -1,7 +1,7 @@ db->escape($arId) ); - $row = $dbresult->fetchRow(); + $row = $dbresult->fetch(); $dbresult->closeCursor(); if (isset($row['ari_value'])) { $use_dns_srv = $row['ari_value']; @@ -97,7 +97,7 @@ public function __construct($pearDB, $CentreonLog = null, $arId = null) WHERE `key` IN ('debug_ldap_import', 'debug_path')" ); - while ($row = $dbresult->fetchRow()) { + while ($row = $dbresult->fetch()) { if ($row['key'] == 'debug_ldap_import') { if ($row['value'] == 1) { $this->debugImport = true; @@ -130,7 +130,7 @@ public function __construct($pearDB, $CentreonLog = null, $arId = null) WHERE `ari_name` = 'ldap_dns_use_domain' AND ar_id = " . $this->db->escape($arId) ); - $row = $dbresult->fetchRow(); + $row = $dbresult->fetch(); $dbresult->closeCursor(); if ($row && trim($row['ari_value']) != '') { $dns_query .= "." . $row['ari_value']; @@ -153,7 +153,7 @@ public function __construct($pearDB, $CentreonLog = null, $arId = null) WHERE auth_ressource_id = " . $this->db->escape($arId) . " ORDER BY host_order" ); - while ($row = $dbresult->fetchRow()) { + while ($row = $dbresult->fetch()) { $ldap = array(); $ldap['host'] = $row['host_address']; $ldap['id'] = $arId; @@ -185,7 +185,7 @@ public function getLdapHostParameters($arId, $filter = '') $finalLdapHostParameters = array(); - while ($rowLdapHostParameters = $resLdapHostParameters->fetchRow()) { + while ($rowLdapHostParameters = $resLdapHostParameters->fetch()) { $finalLdapHostParameters = $rowLdapHostParameters; } @@ -661,7 +661,7 @@ private function loadSearchInfo($ldapHostId = null) ); $user = array(); $group = array(); - while ($row = $dbresult->fetchRow()) { + while ($row = $dbresult->fetch()) { switch ($row['ari_name']) { case 'user_filter': $user['filter'] = $row['ari_value']; @@ -737,7 +737,7 @@ private function getInfoConnect($id) FROM auth_ressource_host WHERE ldap_host_id = " . CentreonDB::escape($id) ); - $row = $dbresult->fetchRow(); + $row = $dbresult->fetch(); return $row; } @@ -751,7 +751,7 @@ private function getInfoUseDnsConnect() $query = "SELECT `key`, `value` FROM `options` WHERE `key` IN ('ldap_dns_use_ssl', 'ldap_dns_use_tls')"; $dbresult = $this->db->query($query); $infos = array(); - while ($row = $dbresult->fetchRow()) { + while ($row = $dbresult->fetch()) { if ($row['key'] == 'ldap_dns_use_ssl') { $infos['use_ssl'] = $row['value']; } elseif ($row['key'] == 'ldap_dns_use_tls') { @@ -778,7 +778,7 @@ private function getBindInfo($id) AND ar_id = " . CentreonDB::escape($id); $dbresult = $this->db->query($query); $infos = array(); - while ($row = $dbresult->fetchRow()) { + while ($row = $dbresult->fetch()) { $infos[$row['ari_name']] = $row['ari_value']; } $dbresult->closeCursor(); @@ -819,6 +819,58 @@ private function getCnFromDn($dn) } return false; } + + /** + * Set a relation between the LDAP's default contactgroup and the user + * + * @param int $arId : The Id of the chosen LDAP, from which we'll find the default contactgroup + * @param int $contactId : The Id of the contact to be added + * + * @return bool : return true to the parent if everything goes well. Needed for the method calling it + */ + public function addUserToLdapDefautCg(int $arId = null, int $contactId = null) + { + $ldapCg = null; + try { + // searching the default contactgroup chosen in the ldap configuration + $resLdap = $this->db->prepare("SELECT ari_value FROM auth_ressource_info " . + "WHERE ari_name LIKE 'ldap_default_cg' AND ar_id = :arId"); + $resLdap->bindValue(':arId', $arId, PDO::PARAM_INT); + $resLdap->execute(); + while ($result = $resLdap->fetch()) { + $ldapCg = $result['ari_value']; + } + unset($resLdap); + if (null === $ldapCg) { + //no default contactgroup was set in the LDAP parameters + return true; + } + + // checking if the user isn't already linked to this contactgroup + $resCgExist = $this->db->prepare("SELECT COUNT(*) AS `exist` FROM contactgroup_contact_relation " . + "WHERE contact_contact_id = :contactId AND contactgroup_cg_id = :ldapCg"); + $resCgExist->bindValue(':contactId', $contactId, PDO::PARAM_INT); + $resCgExist->bindValue(':ldapCg', $ldapCg, PDO::PARAM_INT); + $resCgExist->execute(); + $row = $resCgExist->fetch(); + if ($row['exist'] != 0) { + //user already linked to this contactgroup + return true; + } + unset($resCgExist); + + // inserting the user to the chosen default contactgroup + $resCg = $this->db->prepare("INSERT INTO contactgroup_contact_relation " . + "(contactgroup_cg_id, contact_contact_id) VALUES (:ldapCg, :contactId)"); + $resCg->bindValue(':ldapCg', $ldapCg, PDO::PARAM_INT); + $resCg->bindValue(':contactId', $contactId, PDO::PARAM_INT); + $resCg->execute(); + unset($resCg); + } catch (\PDOException $e) { + return false; + } + return true; + } } /** @@ -852,6 +904,7 @@ public function getLdapParameters() 'ldap_search_limit', 'ldap_search_timeout', 'ldap_contact_tmpl', + 'ldap_default_cg', 'ldap_srv_dns', 'ldap_dns_use_ssl', 'ldap_dns_use_tls', @@ -940,7 +993,7 @@ public function setGeneralOptions($arId, $options) FROM auth_ressource WHERE ar_name = '" . $this->db->escape($options['ar_name']) . "'"; $res = $this->db->query($maxArIdSql); - $row = $res->fetchRow(); + $row = $res->fetch(); $arId = $row['last_id']; unset($res); } else { @@ -995,7 +1048,7 @@ public function getGeneralOptions($arId) FROM `auth_ressource_info` WHERE ar_id = " . $this->db->escape($arId); $res = $this->db->query($query); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $gopt[$row['ari_name']] = $row['ari_value']; } return $gopt; @@ -1064,7 +1117,7 @@ public function addTemplate($options = array()) } try { $dbresult = $this->db->query("SELECT MAX(ar_id) as id FROM auth_ressource WHERE ar_type = 'ldap_tmpl'"); - $row = $dbresult->fetchRow(); + $row = $dbresult->fetch(); } catch (\PDOException $e) { return false; } @@ -1123,6 +1176,7 @@ public function modifyTemplate($id, $options = array()) * Get the template information * * @param int $id The template id, if 0 get the template + * @return array $list */ public function getTemplate($id = 0) { @@ -1134,7 +1188,7 @@ public function getTemplate($id = 0) if ($res->rowCount() == 0) { return array(); } - $row = $res->fetchRow(); + $row = $res->fetch(); $id = $row['ar_id']; } $query = "SELECT ari_name, ari_value @@ -1142,7 +1196,7 @@ public function getTemplate($id = 0) WHERE ar_id = " . CentreonDB::escape($id); $res = $this->db->query($query); $list = array(); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $list[$row['ari_name']] = $row['ari_value']; } return $list; @@ -1221,14 +1275,14 @@ public function getLdapConfigurationList($search = "", $offset = null, $limit = } $res = $this->db->query($sql); $tab = array(); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $tab[] = $row; } return $tab; } /** - * Delete ldap configuraition + * Delete ldap configuration * * @param array $configList * @return void @@ -1278,7 +1332,7 @@ public function getServersFromResId($arId) ); $arr = array(); $i = 0; - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $arr[$i]['address_#index#'] = $row['host_address']; $arr[$i]['port_#index#'] = $row['host_port']; if ($row['use_ssl']) { @@ -1306,7 +1360,7 @@ private function manageContactPasswords($arId) 'WHERE ar_id = ' . $this->db->escape($arId) . ' ' . 'AND ari_name = "ldap_store_password" ' ); - if ($row = $result->fetchRow()) { + if ($row = $result->fetch()) { if ($row['ari_value'] == '0') { $this->db->query( "UPDATE contact " . diff --git a/www/include/Administration/parameters/ldap/form.ihtml b/www/include/Administration/parameters/ldap/form.ihtml index c451d867b09..0e1a12e992c 100644 --- a/www/include/Administration/parameters/ldap/form.ihtml +++ b/www/include/Administration/parameters/ldap/form.ihtml @@ -2,27 +2,15 @@ {$colorJS}
- - - - - - + + - - + + - - + + @@ -30,32 +18,24 @@  {/if} - + + + + + {if $hideDnsOptions != 1} - - + + {/if} - - - - + + {if $o != 'w'} - - + + {/if} - - - + diff --git a/www/include/Administration/parameters/ldap/form.php b/www/include/Administration/parameters/ldap/form.php index 726c5332632..e1dfe4f7528 100644 --- a/www/include/Administration/parameters/ldap/form.php +++ b/www/include/Administration/parameters/ldap/form.php @@ -1,8 +1,8 @@ addGroup($ldapUseDns, 'ldap_srv_dns', _("Use service DNS"), ' '); -$ldapDnsUseSsl[] = $form->createElement('radio', 'ldap_dns_use_ssl', null, _("Yes"), '1'); -$ldapDnsUseSsl[] = $form->createElement('radio', 'ldap_dns_use_ssl', null, _("No"), '0'); -$form->addGroup($ldapDnsUseSsl, 'ldap_dns_use_ssl', _("Use SSL connection"), ' '); -$ldapDnsUseTls[] = $form->createElement('radio', 'ldap_dns_use_tls', null, _("Yes"), '1'); -$ldapDnsUseTls[] = $form->createElement('radio', 'ldap_dns_use_tls', null, _("No"), '0'); -$form->addGroup($ldapDnsUseTls, 'ldap_dns_use_tls', _("Use TLS connection"), ' '); $form->addElement('text', 'ldap_dns_use_domain', _("Alternative domain for ldap"), $attrsText); $form->addElement('text', 'ldap_search_limit', _('LDAP search size limit'), $attrsText2); $form->addElement('text', 'ldap_search_timeout', _('LDAP search timeout'), $attrsText2); +// list of contact template available $query = "SELECT contact_id, contact_name FROM contact WHERE contact_register = '0'"; $res = $pearDB->query($query); -$tmplList = array(); -while ($row = $res->fetchRow()) { - $tmplList[$row['contact_id']] = $row['contact_name']; +$LdapContactTplList = array(); +while ($row = $res->fetch()) { + $LdapContactTplList[$row['contact_id']] = $row['contact_name']; } $res->closeCursor(); +$form->addElement( + 'select', + 'ldap_contact_tmpl', + _('Contact template'), + $LdapContactTplList, + array('id' => 'ldap_contact_tmpl') +); -$form->addElement('select', 'ldap_contact_tmpl', _('Contact template'), $tmplList, array('id' => 'ldap_contact_tmpl')); +// Default contactgroup for imported contact +$cgAvRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_contactgroup&action=list'; +$cgDeRoute = './include/common/webServices/rest/internal.php?object=centreon_configuration_contactgroup' + . '&action=defaultValues&target=contact&field=ldap_default_cg&id=' . $arId; +$attrContactGroup = array( + 'datasourceOrigin' => 'ajax', + 'availableDatasetRoute' => $cgAvRoute, + 'defaultDatasetRoute' => $cgDeRoute, + 'multiple' => false, + 'linkedObject' => 'centreonContactgroup' +); +$form->addElement('select2', 'ldap_default_cg', _('Default contactgroup'), array(), $attrContactGroup); $form->addElement('header', 'ldapinfo', _("LDAP Information")); @@ -169,6 +182,7 @@ 'ldap_dns_use_ssl' => '0', 'ldap_dns_use_tls' => '0', 'ldap_contact_tmpl' => '0', + 'ldap_default_cg' => '0', 'ldap_search_limit' => '60', 'ldap_search_timeout' => '60'); $gopt = array(); @@ -178,7 +192,7 @@ $res = $pearDB->query("SELECT `ar_name`, `ar_description`, `ar_enable` FROM `auth_ressource` WHERE ar_id = " . $pearDB->escape($arId)); - while ($row = $res->fetchRow()) { + while ($row = $res->fetch()) { $gopt['ar_name'] = $row['ar_name']; $gopt['ar_description'] = $row['ar_description']; $gopt['ldap_auth_enable'] = $row['ar_enable']; @@ -247,9 +261,9 @@ $nbOfInitialRows = 0; if ($arId) { - $query = "SELECT count(*) as nb FROM auth_ressource_host WHERE auth_ressource_id = " . $pearDB->escape($arId); + $query = "SELECT COUNT(*) as nb FROM auth_ressource_host WHERE auth_ressource_id = " . $pearDB->escape($arId); $res = $pearDB->query($query); - $row = $res->fetchRow(); + $row = $res->fetch(); $nbOfInitialRows = $row['nb']; } @@ -260,7 +274,7 @@ WHERE auth_ressource_id = " . $pearDB->escape($arId); $res = $pearDB->query($query); if ($res->rowCount()) { - $row = $res->fetchRow(); + $row = $res->fetch(); $maxHostId = $row['cnt']; } } @@ -274,9 +288,9 @@ $values = $form->getSubmitValues(); /* - * Test is filter string is validate + * Test if filter string is valid */ - if (false === CentreonLDAP::validateFilterPattern($values['user_filter'])) { + if (!CentreonLDAP::validateFilterPattern($values['user_filter'])) { $filterValid = false; } @@ -293,6 +307,10 @@ $values['ldap_contact_tmpl'] = ""; } + if (!isset($values['ldap_contact_tmpl'])) { + $values['ldap_default_cg'] = ""; + } + $arId = $ldapAdmin->setGeneralOptions($values['ar_id'], $values); $o = "w"; $valid = true; diff --git a/www/include/Administration/parameters/ldap/help.php b/www/include/Administration/parameters/ldap/help.php index f262d71a179..8def8989f09 100644 --- a/www/include/Administration/parameters/ldap/help.php +++ b/www/include/Administration/parameters/ldap/help.php @@ -12,7 +12,12 @@ $help['ldap_contact_tmpl'] = dgettext( 'help', 'The contact template for auto imported user.
' - . 'This template is applied for Monitoring Engine contact configuration and ACLs' + . 'This template is applied for Monitoring Engine contact configuration and ACLs.' +); +$help['ldap_default_cg'] = dgettext( + 'help', + 'Default contact group applied to new users.
' + . 'All imported users will join this contactgroup.' ); $help['ldap_srv_dns'] = dgettext('help', 'Use the DNS service for get LDAP host'); $help['ldap_srv_dns_ssl'] = dgettext('help', 'Enable SSL connection'); diff --git a/www/include/Administration/parameters/ldap/list.php b/www/include/Administration/parameters/ldap/list.php index dad31d8a1cb..e99e1c32d89 100644 --- a/www/include/Administration/parameters/ldap/list.php +++ b/www/include/Administration/parameters/ldap/list.php @@ -1,7 +1,7 @@ query("UPDATE options SET `value` = $enableLdap WHERE `key` = 'ldap_auth_enable'"); +$pearDB->query("UPDATE options SET `value` = " . $enableLdap . " WHERE `key` = 'ldap_auth_enable'"); include "./include/common/checkPagination.php"; $list = $ldapConf->getLdapConfigurationList($searchLdap, ($num * $limit), $limit); diff --git a/www/include/common/javascript/ContactAjaxLDAP/ajaxLdapSearch.js b/www/include/common/javascript/ContactAjaxLDAP/ajaxLdapSearch.js index 6a2fad2d774..1c6bb4303e6 100644 --- a/www/include/common/javascript/ContactAjaxLDAP/ajaxLdapSearch.js +++ b/www/include/common/javascript/ContactAjaxLDAP/ajaxLdapSearch.js @@ -1,6 +1,6 @@ /* - * Copyright 2005-2015 Centreon - * Centreon is developped by : Julien Mathis and Romain Le Merlus under + * Copyright 2005-2019 Centreon + * Centreon is developed by : Julien Mathis and Romain Le Merlus under * GPL Licence 2.0. * * This program is free software; you can redistribute it and/or modify it under @@ -32,10 +32,10 @@ * */ -var _addrSearchM = "include/configuration/configObject/contact/ldapsearch.php" //l'adresse interroger pour trouver les suggestions +var _addrSearchM = "include/configuration/configObject/contact/ldapsearch.php" function getXhrM() { - if (window.XMLHttpRequest) // Firefox et autres + if (window.XMLHttpRequest) // Firefox and others var xhrM = new XMLHttpRequest(); else if (window.ActiveXObject) { // Internet Explorer try { @@ -43,8 +43,8 @@ function getXhrM() { } catch (e) { var xhrM = new ActiveXObject("Microsoft.XMLHTTP"); } - } else { // XMLHttpRequest non supporté par le navigateur - alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest..."); + } else { // if XMLHttpRequest isn't supported by the browser + alert("Your browser doesn't support XMLHTTPRequest objects"); var xhrM = false; } return xhrM; @@ -79,17 +79,17 @@ function LdapSearch() { xhrM.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhrM.send("confList=" + confList + ldap_search_filters); - document.getElementById('ldap_search_result_output').innerHTML = ""; + document.getElementById('ldap_search_result_output'). + innerHTML = ""; - // On defini ce qu'on va faire quand on aura la reponse + // defining what we should do when we got a reply xhrM.onreadystatechange = function () { - // On ne fait quelque chose que si on a tout recu et que le serveur est ok + // doing nothing until we got everything and a status 200 document.getElementById('ldap_search_result_output').innerHTML = xhrM.responseText; if (xhrM && xhrM.readyState == 4 && xhrM.status == 200 && xhrM.responseXML) { - //alert(xhrM.responseText); document.getElementById('ldap_search_result_output').innerHTML = ''; - reponse = xhrM.responseXML.documentElement; + response = xhrM.responseXML.documentElement; var _tab = document.createElement('table'); @@ -158,7 +158,7 @@ function LdapSearch() { _tr.appendChild(_td7); _tbody.appendChild(_tr); - var infos = reponse.getElementsByTagName("user"); + var infos = response.getElementsByTagName("user"); var serverName = ''; for (var i = 0; i < infos.length; i++) { diff --git a/www/include/configuration/configObject/contact/DB-Func.php b/www/include/configuration/configObject/contact/DB-Func.php index df6d17b1799..3b3282dae63 100644 --- a/www/include/configuration/configObject/contact/DB-Func.php +++ b/www/include/configuration/configObject/contact/DB-Func.php @@ -55,7 +55,7 @@ function testContactExistence($name = null) $query = "SELECT contact_name, contact_id FROM contact WHERE contact_name = '" . htmlentities($centreon->checkIllegalChar($name), ENT_QUOTES, "UTF-8") . "'"; $DBRESULT = $pearDB->query($query); - $contact = $DBRESULT->fetchRow(); + $contact = $DBRESULT->fetch(); if ($DBRESULT->rowCount() >= 1 && $contact["contact_id"] == $id) { return true; @@ -80,7 +80,7 @@ function testAliasExistence($alias = null) $query = "SELECT contact_alias, contact_id FROM contact WHERE contact_alias = '" . htmlentities($alias, ENT_QUOTES, "UTF-8") . "'"; $DBRESULT = $pearDB->query($query); - $contact = $DBRESULT->fetchRow(); + $contact = $DBRESULT->fetch(); if ($DBRESULT->rowCount() >= 1 && $contact["contact_id"] == $id) { return true; @@ -127,7 +127,7 @@ function keepOneContactAtLeast($ct_id = null) WHERE contact_activate = '1' AND contact_oreon = '1' AND contact_id <> '" . $pearDB->escape($contact_id) . "'"); - $contacts = $DBRESULT->fetchRow(); + $contacts = $DBRESULT->fetch(); if ($contacts["nbr_valid"] == 0) { if ($cct_oreon == 0 || $cct_activate == 0) { @@ -159,7 +159,7 @@ function enableContactInDB($contact_id = null, $contact_arr = array()) $query = "SELECT contact_name FROM `contact` WHERE `contact_id` = '" . intval($key) . "' LIMIT 1"; $DBRESULT2 = $pearDB->query($query); - $row = $DBRESULT2->fetchRow(); + $row = $DBRESULT2->fetch(); $centreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "enable"); } @@ -187,7 +187,7 @@ function disableContactInDB($contact_id = null, $contact_arr = array()) $pearDB->query("UPDATE contact SET contact_activate = '0' WHERE contact_id = '" . intval($key) . "'"); $query = "SELECT contact_name FROM `contact` WHERE `contact_id` = '" . intval($key) . "' LIMIT 1"; $DBRESULT2 = $pearDB->query($query); - $row = $DBRESULT2->fetchRow(); + $row = $DBRESULT2->fetch(); $centreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "disable"); } @@ -206,7 +206,7 @@ function deleteContactInDB($contacts = array()) foreach ($contacts as $key => $value) { $query = "SELECT contact_name FROM `contact` WHERE `contact_id` = '" . intval($key) . "' LIMIT 1"; $DBRESULT2 = $pearDB->query($query); - $row = $DBRESULT2->fetchRow(); + $row = $DBRESULT2->fetch(); $pearDB->query("DELETE FROM contact WHERE contact_id = '" . intval($key) . "'"); $centreon->CentreonLogAction->insertLog("contact", $key, $row['contact_name'], "d"); @@ -225,7 +225,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) foreach ($contacts as $key => $value) { $DBRESULT = $pearDB->query("SELECT * FROM contact WHERE contact_id = '" . intval($key) . "' LIMIT 1"); - $row = $DBRESULT->fetchRow(); + $row = $DBRESULT->fetch(); $row["contact_id"] = ''; for ($i = 1; $i <= $nbrDup[$key]; $i++) { $val = null; @@ -253,7 +253,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) $val ? $rq = "INSERT INTO contact VALUES (" . $val . ")" : $rq = null; $DBRESULT = $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(contact_id) FROM contact"); - $maxId = $DBRESULT->fetchRow(); + $maxId = $DBRESULT->fetch(); if (isset($maxId["MAX(contact_id)"])) { /* @@ -263,7 +263,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) "WHERE contact_contact_id = " . (int)$key; $dbResult = $pearDB->query($query); $fields["contact_aclRelation"] = ""; - while ($aclRelation = $dbResult->fetchRow()) { + while ($aclRelation = $dbResult->fetch()) { $query = "INSERT INTO acl_group_contacts_relations VALUES ('', '" . $maxId["MAX(contact_id)"] . "', '" . $aclRelation["acl_group_id"] . "')"; $pearDB->query($query); @@ -278,7 +278,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) "WHERE contact_contact_id = '" . intval($key) . "'"; $DBRESULT = $pearDB->query($query); $fields["contact_hostNotifCmds"] = ""; - while ($hostCmd = $DBRESULT->fetchRow()) { + while ($hostCmd = $DBRESULT->fetch()) { $query = "INSERT INTO contact_hostcommands_relation VALUES ('', '" . $maxId["MAX(contact_id)"] . "', '" . $hostCmd["command_command_id"] . "')"; $pearDB->query($query); @@ -293,7 +293,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) "WHERE contact_contact_id = '" . intval($key) . "'"; $DBRESULT = $pearDB->query($query); $fields["contact_svNotifCmds"] = ""; - while ($serviceCmd = $DBRESULT->fetchRow()) { + while ($serviceCmd = $DBRESULT->fetch()) { $query = "INSERT INTO contact_servicecommands_relation VALUES ('', '" . $maxId["MAX(contact_id)"] . "', '" . $serviceCmd["command_command_id"] . "')"; $pearDB->query($query); @@ -308,7 +308,7 @@ function multipleContactInDB($contacts = array(), $nbrDup = array()) "WHERE contact_contact_id = '" . intval($key) . "'"; $DBRESULT = $pearDB->query($query); $fields["contact_cgNotif"] = ""; - while ($Cg = $DBRESULT->fetchRow()) { + while ($Cg = $DBRESULT->fetch()) { $query = "INSERT INTO contactgroup_contact_relation VALUES ('', '" . $maxId["MAX(contact_id)"] . "', '" . $Cg["contactgroup_cg_id"] . "')"; $pearDB->query($query); @@ -544,7 +544,7 @@ function insertContact($ret = array()) $pearDB->query($rq); $DBRESULT = $pearDB->query("SELECT MAX(contact_id) FROM contact"); - $contact_id = $DBRESULT->fetchRow(); + $contact_id = $DBRESULT->fetch(); if (isset($ret["contact_passwd"])) { if ($encryptType == 1) { @@ -861,7 +861,7 @@ function updateContact_MC($contact_id = null) $query = "SELECT contact_name FROM `contact` WHERE contact_id='" . intval($contact_id) . "' LIMIT 1"; $DBRESULT2 = $pearDB->query($query); - $row = $DBRESULT2->fetchRow(); + $row = $DBRESULT2->fetch(); /* Prepare value for changelog */ $fields = CentreonLogAction::prepareChanges($ret); @@ -921,7 +921,7 @@ function updateContactHostCommands_MC($contact_id = null, $ret = array()) $rq .= "WHERE contact_contact_id = '" . intval($contact_id) . "'"; $DBRESULT = $pearDB->query($rq); $cmds = array(); - while ($arr = $DBRESULT->fetchRow()) { + while ($arr = $DBRESULT->fetch()) { $cmds[$arr["command_command_id"]] = $arr["command_command_id"]; } $ret = $form->getSubmitValue("contact_hostNotifCmds"); @@ -987,7 +987,7 @@ function updateContactServiceCommands_MC($contact_id = null, $ret = array()) $rq .= "WHERE contact_contact_id = '" . intval($contact_id) . "'"; $DBRESULT = $pearDB->query($rq); $cmds = array(); - while ($arr = $DBRESULT->fetchRow()) { + while ($arr = $DBRESULT->fetch()) { $cmds[$arr["command_command_id"]] = $arr["command_command_id"]; } $ret = $form->getSubmitValue("contact_svNotifCmds"); @@ -1052,7 +1052,7 @@ function updateContactContactGroup_MC($contact_id = null, $ret = array()) $rq .= "WHERE contact_contact_id = '" . intval($contact_id) . "'"; $DBRESULT = $pearDB->query($rq); $cmds = array(); - while ($arr = $DBRESULT->fetchRow()) { + while ($arr = $DBRESULT->fetch()) { $cmds[$arr["contactgroup_cg_id"]] = $arr["contactgroup_cg_id"]; } $ret = $form->getSubmitValue("contact_cgNotif"); @@ -1121,13 +1121,12 @@ function insertLdapContactInDB($tmpContacts = array()) } catch (\PDOException $e) { return false; } - $row = $res->fetchRow(); + $row = $res->fetch(); $contact_id = $row['contact_id']; if (!isset($ldapInstances[$arId])) { - $ldapInstances[$arId] = new CentreonLDAP($pearDB, null, $arId); + $ldap = new CentreonLDAP($pearDB, null, $arId); $ldapAdmin = new CentreonLDAPAdmin($pearDB); - $ldap = $ldapInstances[$arId]; $opt = $ldapAdmin->getGeneralOptions($arId); if (isset($opt['ldap_contact_tmpl']) && $opt['ldap_contact_tmpl']) { $contactTemplates[$arId] = $opt['ldap_contact_tmpl']; @@ -1155,15 +1154,20 @@ function insertLdapContactInDB($tmpContacts = array()) } catch (\PDOException $e) { return false; } - /* - * Insert the relation between contact and contact group - */ - while ($row = $res->fetchRow()) { - $query = "INSERT INTO contactgroup_contact_relation (contactgroup_cg_id, contact_contact_id) - VALUES (" . $row['cg_id'] . ", " . intval($contact_id) . ")"; + + // Insert the relation between contact and contactgroups + while ($row = $res->fetch()) { + $query = "INSERT INTO contactgroup_contact_relation (contactgroup_cg_id, contact_contact_id) " . + "VALUES (" . $row['cg_id'] . ", " . (int) $contact_id . ")"; $pearDB->query($query); } } + + //Insert a relation between LDAP's default contactgroup and the contact + $ldap->addUserToLdapDefautCg( + $arId, + $contact_id + ); } return true; } @@ -1249,7 +1253,7 @@ function getContactIdByName($name) $id = 0; $res = $pearDB->query("SELECT contact_id FROM contact WHERE contact_name = '" . $pearDB->escape($name) . "'"); if ($res->rowCount()) { - $row = $res->fetchRow(); + $row = $res->fetch(); $id = $row['contact_id']; } return $id; diff --git a/www/include/configuration/configObject/contact/ldapImportContact.ihtml b/www/include/configuration/configObject/contact/ldapImportContact.ihtml index 9bc12bfb852..4e1eb49d9d5 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.ihtml +++ b/www/include/configuration/configObject/contact/ldapImportContact.ihtml @@ -12,13 +12,6 @@ -
-

| {$optGen_ldap_properties}

-
-

{$form.header.ldap}

-

| {$optGen_ldap_properties}

{$form.header.ldap}

{$form.ar_name.label}{$form.ar_name.html}
{$form.ar_description.label}{$form.ar_description.html}
{$form.ldap_auth_enable.label}{$form.ldap_auth_enable.html}
{$form.ar_description.label}{$form.ar_description.html}
{$form.ldap_auth_enable.label}{$form.ldap_auth_enable.html}
{$form.ldap_store_password.label}{$form.ldap_store_password.html}
- {$form.ldap_auto_import.label} - - {$form.ldap_auto_import.html}   - {$form.ldap_auto_import.label}{$form.ldap_auto_import.html}  
{$form.ldap_search_limit.label}{$form.ldap_search_limit.html}
{$form.ldap_search_timeout.label}{$form.ldap_search_timeout.html}
{$form.ldap_srv_dns.label}{$form.ldap_srv_dns.html}
{$form.ldap_default_cg.label}{$form.ldap_default_cg.html}
{$form.ldap_srv_dns.label}{$form.ldap_srv_dns.html}
{$form.ldap_dns_use_ssl.label}{$form.ldap_dns_use_ssl.html}
{$form.ldap_dns_use_tls.label}{$form.ldap_dns_use_tls.html}
{$form.ldap_dns_use_ssl.label}{$form.ldap_dns_use_ssl.html}
{$form.ldap_dns_use_tls.label}{$form.ldap_dns_use_tls.html}
{$form.ldap_dns_use_domain.label}{$form.ldap_dns_use_domain.html}
-

{$form.header.ldapserver}

-
{$form.ldap_dns_use_domain.label}{$form.ldap_dns_use_domain.html}

{$form.header.ldapserver}

-  {$addNewHostLabel} - - {include file="file:$centreon_path/www/include/common/templates/clone.ihtml" cloneId="ldapservers" cloneSet=$cloneSet} -  {$addNewHostLabel}{include file="file:$centreon_path/www/include/common/templates/clone.ihtml" cloneId="ldapservers" cloneSet=$cloneSet}
-

{$form.header.ldapinfo}

-

{$form.header.ldapinfo}

{$form.bind_dn.label}{$form.bind_dn.html}
{$form.bind_pass.label}{$form.bind_pass.html}
{$form.protocol_version.label}{$form.protocol_version.html}
{$ldapServers} {$ldapConfList}
{$form.ldap_search_button.html}
diff --git a/www/include/configuration/configObject/contact/ldapImportContact.php b/www/include/configuration/configObject/contact/ldapImportContact.php index b001c5039d0..341e0ea1de7 100644 --- a/www/include/configuration/configObject/contact/ldapImportContact.php +++ b/www/include/configuration/configObject/contact/ldapImportContact.php @@ -1,7 +1,7 @@ addElement('header', 'options', _("LDAP Servers")); -/* -$form->addElement('text', 'ldap_base_dn', _("LDAP Base DN"), $attrsText); -$form->addElement('text', 'ldap_search_timeout', _("LDAP search timeout"), $attrsText2); -$form->addElement('text', 'ldap_search_limit', _("LDAP Search Size Limit"), $attrsText2); -*/ + $form->addElement('text', 'ldap_search_filter', _("Search Filter"), $attrsText); $form->addElement('header', 'result', _("Search Result")); $form->addElement('header', 'ldap_search_result_output', _("Result")); @@ -67,12 +63,6 @@ $link = "LdapSearch()"; $form->addElement("button", "ldap_search_button", _("Search"), array("class" => "btc bt_success", "onClick" => $link)); -$tab = array(); -$tab[] = $form->createElement('radio', 'action', null, _("List"), '1'); -$tab[] = $form->createElement('radio', 'action', null, _("Form"), '0'); -$form->addGroup($tab, 'action', _("Post Validation"), ' '); -$form->setDefaults(array('action' => '1')); - $form->addElement('hidden', 'contact_id'); $redirect = $form->addElement('hidden', 'o'); $redirect->setValue($o); @@ -101,7 +91,7 @@ "ORDER BY ar_name"; $res = $pearDB->query($query); $ldapConfList = ""; -while ($row = $res->fetchRow()) { +while ($row = $res->fetch()) { if ($res->rowCount() == 1) { $ldapConfList .= " " . $row['ar_name']; @@ -116,7 +106,7 @@ /* - * Just watch a contact information + * List available contacts to choose which one we want to import */ if ($o == "li") { $subA = $form->addElement('submit', 'submitA', _("Import"), array("class" => "btc bt_success")); @@ -133,14 +123,13 @@ $valid = true; } -$action = $form->getSubmitValue("action"); -if ($valid && isset($action["action"]) && $action["action"]) { +if ($valid) { require_once($path . "listContact.php"); } else { /* - * Apply a template definition - */ + * Apply a template definition + */ $renderer = new HTML_QuickForm_Renderer_ArraySmarty($tpl); $form->accept($renderer); $tpl->assign('ldapServers', _('Import from LDAP servers')); diff --git a/www/install/smarty_translate.php b/www/install/smarty_translate.php index 11ad536ee7a..6241bd452b8 100644 --- a/www/install/smarty_translate.php +++ b/www/install/smarty_translate.php @@ -667,3 +667,6 @@ /* /tmp/centreon-2.7.x/www//include/common/templates/cloneMacro.ihtml */ _("Nothing here, use the \"Add\" button"); + +/* /www/include/common/Administration/parameters/ldap/form.ihtml*/ +_('Default contact group');