added $attributes argument to pre/postModifyActions
This commit is contained in:
parent
13472acf8d
commit
0d986e228d
|
@ -1012,9 +1012,10 @@ abstract class baseModule {
|
|||
* An error message should be printed if the function returns false.
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
* @return boolean true, if no problems occured
|
||||
*/
|
||||
public function preModifyActions($newAccount) {
|
||||
public function preModifyActions($newAccount, $attributes) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1024,8 +1025,9 @@ abstract class baseModule {
|
|||
* Calling this method requires the existence of an enclosing {@link accountContainer}.
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
public function postModifyActions($newAccount) {
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1684,7 +1684,33 @@ class accountContainer {
|
|||
$attributes[$this->dn_orig] = $attributes[$this->finalDN];
|
||||
unset ($attributes[$this->finalDN]);
|
||||
$this->finalDN = $this->dn_orig;
|
||||
}
|
||||
// pre modify actions
|
||||
$currentAccountAttributes = array();
|
||||
if (isset($attributes[$this->finalDN]) && is_array($attributes[$this->finalDN])) {
|
||||
if (isset($attributes[$this->finalDN]['modify'])) {
|
||||
$currentAccountAttributes = array_merge($currentAccountAttributes, $attributes[$this->finalDN]['modify']);
|
||||
}
|
||||
if (isset($attributes[$this->finalDN]['add'])) {
|
||||
$currentAccountAttributes = array_merge($currentAccountAttributes, $attributes[$this->finalDN]['add']);
|
||||
}
|
||||
if (isset($attributes[$this->finalDN]['notchanged'])) {
|
||||
$currentAccountAttributes = array_merge($currentAccountAttributes, $attributes[$this->finalDN]['notchanged']);
|
||||
}
|
||||
}
|
||||
$currentAccountAttributes['dn'] = $this->finalDN;
|
||||
$preModifyOk = true;
|
||||
foreach ($module as $singlemodule) {
|
||||
$result = $this->module[$singlemodule]->preModifyActions($this->isNewAccount, $currentAccountAttributes);
|
||||
if (!$result) {
|
||||
$preModifyOk = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$preModifyOk) {
|
||||
$errors[] = array('ERROR', _('The operation was stopped because of the above errors.'));
|
||||
return $errors;
|
||||
}
|
||||
// Set to true if an real error has happened
|
||||
$stopprocessing = false;
|
||||
if (strtolower($this->finalDN) != strtolower($this->dn_orig)) {
|
||||
|
@ -1763,7 +1789,7 @@ class accountContainer {
|
|||
if (!$stopprocessing) {
|
||||
// post modify actions
|
||||
foreach ($module as $singlemodule) {
|
||||
$this->module[$singlemodule]->postModifyActions($this->isNewAccount);
|
||||
$this->module[$singlemodule]->postModifyActions($this->isNewAccount, $currentAccountAttributes);
|
||||
}
|
||||
}
|
||||
$_SESSION['cache']->refresh_cache(true);
|
||||
|
|
|
@ -437,11 +437,15 @@ class fixed_ip extends baseModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* This function will be overwrite, because this function
|
||||
* creates the fixed ips after ldap_add command.
|
||||
**/
|
||||
public function postModifyActions($newAccount) {
|
||||
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
|
||||
* This function is overwritten because the fixed IPs are set after the ldap_add command.
|
||||
*
|
||||
* @see baseModule::postModifyActions()
|
||||
*
|
||||
* @param boolean $newAccount
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
|
||||
$add = array();
|
||||
$delete = array();
|
||||
// Which dns are to delete and to add
|
||||
|
|
|
@ -170,22 +170,21 @@ class phpGroupwareGroup extends baseModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Allows the module to run commands after the LDAP entry is changed or created.
|
||||
*
|
||||
* Calling this method requires the existence of an enclosing {@link accountContainer}.
|
||||
* @see baseModule::postModifyActions()
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param boolean $newAccount
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
public function postModifyActions($newAccount) {
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
// check if extension was removed
|
||||
if (!$newAccount &&
|
||||
(in_array('phpgwGroup', $this->orig['objectClass']) && !in_array('phpgwGroup', $this->attributes['objectClass']))) {
|
||||
$dn = $this->getAccountContainer()->finalDN;
|
||||
$attributes = array(
|
||||
$myattributes = array(
|
||||
'objectClass' => array('phpgwGroup'),
|
||||
'phpgwGroupID' => $this->attributes['phpgwGroupID']
|
||||
);
|
||||
$success = @ldap_mod_del($_SESSION['ldap']->server(), $dn, $attributes);
|
||||
$success = @ldap_mod_del($_SESSION['ldap']->server(), $dn, $myattributes);
|
||||
if (!$success) {
|
||||
StatusMessage('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server()));
|
||||
}
|
||||
|
|
|
@ -316,19 +316,18 @@ class phpGroupwareUser extends baseModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Allows the module to run commands after the LDAP entry is changed or created.
|
||||
*
|
||||
* Calling this method requires the existence of an enclosing {@link accountContainer}.
|
||||
* @see baseModule::postModifyActions()
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param boolean $newAccount
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
public function postModifyActions($newAccount) {
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
// check if extension was removed
|
||||
if (!$newAccount &&
|
||||
(in_array('phpgwAccount', $this->orig['objectClass']) && !in_array('phpgwAccount', $this->attributes['objectClass']))) {
|
||||
$dn = $this->getAccountContainer()->finalDN;
|
||||
$attributes = array_merge(array('objectClass'), $this->meta['attributes']);
|
||||
$sr = @ldap_read($_SESSION['ldap']->server(), $dn, 'objectClass=*', $attributes);
|
||||
$myattributes = array_merge(array('objectClass'), $this->meta['attributes']);
|
||||
$sr = @ldap_read($_SESSION['ldap']->server(), $dn, 'objectClass=*', $myattributes);
|
||||
if (!$sr) {
|
||||
StatusMessage('ERROR', sprintf(_('Was unable to remove attribtues from DN: %s.'), $dn), ldap_error($_SESSION['ldap']->server()));
|
||||
return;
|
||||
|
|
|
@ -550,11 +550,12 @@ class posixAccount extends baseModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Allows the module to run commands after the LDAP entry was changed or created.
|
||||
* @see baseModule::postModifyActions()
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param boolean $newAccount
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
function postModifyActions($newAccount) {
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
// create home directory if needed
|
||||
if ($this->createhomedir) {
|
||||
$server = null;
|
||||
|
|
|
@ -223,11 +223,12 @@ class quota extends baseModule {
|
|||
}
|
||||
|
||||
/**
|
||||
* Allows the module to run commands after the LDAP entry is changed or created.
|
||||
* @see baseModule::postModifyActions()
|
||||
*
|
||||
* @param boolean $newAccount new account
|
||||
* @param boolean $newAccount
|
||||
* @param array $attributes LDAP attributes of this entry
|
||||
*/
|
||||
function postModifyActions($newAccount) {
|
||||
public function postModifyActions($newAccount, $attributes) {
|
||||
if (!isset($this->quota) || !is_array($this->quota)) return;
|
||||
// determine if this is a user or group account
|
||||
if ($this->get_scope()=='user') {
|
||||
|
|
Loading…
Reference in New Issue