NEW: Add hook addAdminLdapOptions and doAction in ldap admin page

NEW: complete_head_from_modules() in ldap_prepare_head()
This commit is contained in:
Regis Houssin 2017-09-15 10:57:22 +02:00
parent f5d2283093
commit b9e0879847
3 changed files with 64 additions and 39 deletions

View File

@ -5,6 +5,10 @@ English Dolibarr ChangeLog
***** ChangeLog for 7.0.0 compared to 6.0.* ***** ***** ChangeLog for 7.0.0 compared to 6.0.* *****
For developers:
NEW: Add hook addAdminLdapOptions and doAction in ldap admin page
NEW: complete_head_from_modules() in ldap_prepare_head()
WARNING: WARNING:
Following changes may create regression for some external modules, but were necessary to make Dolibarr better: Following changes may create regression for some external modules, but were necessary to make Dolibarr better:

View File

@ -2,7 +2,7 @@
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005 Regis Houssin <regis.houssin@capnetworks.com> * Copyright (C) 2005-2017 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es> * Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
* *
@ -36,14 +36,23 @@ $langs->load("admin");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = GETPOST('action','aZ09'); $action = GETPOST('action','aZ09');
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
$hookmanager->initHooks(array('adminldap','globaladmin'));
/* /*
* Actions * Actions
*/ */
if ($action == 'setvalue' && $user->admin) $parameters=array();
$reshook=$hookmanager->executeHooks('doActions',$parameters,'',$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook))
{ {
if ($action == 'setvalue' && $user->admin)
{
$error=0; $error=0;
$db->begin(); $db->begin();
@ -70,10 +79,9 @@ if ($action == 'setvalue' && $user->admin)
$db->rollback(); $db->rollback();
dol_print_error($db); dol_print_error($db);
} }
}
} }
/* /*
* View * View
*/ */
@ -149,6 +157,11 @@ if (! empty($conf->adherent->enabled))
print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>'; print '</td><td>'.$langs->trans("LDAPDnMemberActiveExample").'</td></tr>';
} }
// Fields from hook
$parameters=array();
$reshook=$hookmanager->executeHooks('addAdminLdapOptions',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td>'.$langs->trans("Parameter").'</td>'; print '<td>'.$langs->trans("Parameter").'</td>';
print '<td>'.$langs->trans("Value").'</td>'; print '<td>'.$langs->trans("Value").'</td>';

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2006 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2006-2017 Regis Houssin <regis.houssin@capnetworks.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -30,6 +31,7 @@
function ldap_prepare_head() function ldap_prepare_head()
{ {
global $langs, $conf, $user; global $langs, $conf, $user;
$langs->load("ldap"); $langs->load("ldap");
// Onglets // Onglets
@ -73,6 +75,12 @@ function ldap_prepare_head()
$h++; $h++;
} }
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,'',$head,$h,'ldap');
return $head; return $head;
} }