allow to remove the extension

This commit is contained in:
Roland Gruber 2009-12-20 14:35:42 +00:00
parent f4c653d0ac
commit 39fabb357e
5 changed files with 146 additions and 23 deletions

View File

@ -122,7 +122,18 @@ class eduPerson extends baseModule {
'orgUnitDNUpload' => array( 'orgUnitDNUpload' => array(
"Headline" => _("Organizational units"), "Headline" => _("Organizational units"),
"Text" => _("The DNs of the directory entries representing the person's organizational units.") . ' ' . _('Multiple values are separated by comma.') "Text" => _("The DNs of the directory entries representing the person's organizational units.") . ' ' . _('Multiple values are separated by comma.')
),
'autoAdd' => array(
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
)); ));
// profile options
$return['profile_options'] = array(
array(
array('kind' => 'text', 'text' => _('Automatically add this extension') . ":"),
array('kind' => 'input', 'name' => 'eduPerson_addExt', 'type' => 'checkbox'),
array('kind' => 'help', 'value' => 'autoAdd')),
);
// upload fields // upload fields
$return['upload_columns'] = array( $return['upload_columns'] = array(
array( array(
@ -215,9 +226,6 @@ class eduPerson extends baseModule {
* @return array HTML meta data * @return array HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
if (isset($_POST['form_subpage_eduPerson_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
}
$return = array(); $return = array();
if (in_array('eduPerson', $this->attributes['objectClass'])) { if (in_array('eduPerson', $this->attributes['objectClass'])) {
// principal name // principal name
@ -380,6 +388,13 @@ class eduPerson extends baseModule {
))), ))),
array('kind' => 'text', 'text' => ' ') array('kind' => 'text', 'text' => ' ')
); );
$return[] = array(
array('kind' => 'text', 'text' => ' ')
);
$return[] = array(
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_eduPerson_attributes_remObjectClass',
'value' => _('Remove EDU person extension'), 'td' => array('colspan' => '3'))
);
} }
else { else {
$return[] = array( $return[] = array(
@ -397,6 +412,19 @@ class eduPerson extends baseModule {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_attributes() { function process_attributes() {
if (isset($_POST['form_subpage_eduPerson_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
return array();
}
elseif (isset($_POST['form_subpage_eduPerson_attributes_remObjectClass'])) {
$this->attributes['objectClass'] = array_delete(array('eduPerson'), $this->attributes['objectClass']);
for ($i = 0; $i < sizeof($this->meta['attributes']); $i++) {
if (isset($this->attributes[$this->meta['attributes'][$i]])) {
unset($this->attributes[$this->meta['attributes'][$i]]);
}
}
return array();
}
$errors = array(); $errors = array();
// primary affiliation // primary affiliation
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation']; $this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];
@ -493,6 +521,21 @@ class eduPerson extends baseModule {
return $errors; return $errors;
} }
/**
* Loads the values of an account profile into internal variables.
*
* @param array $profile hash array with profile values (identifier => value)
*/
function load_profile($profile) {
parent::load_profile($profile);
// add extension
if ($profile['eduPerson_addExt'][0] == "true") {
if (!in_array('eduPerson', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
}
}
}
/** /**
* In this function the LDAP account is built up. * In this function the LDAP account is built up.
* *

View File

@ -81,8 +81,19 @@ class phpGroupwareUser extends baseModule implements passwordService {
'phpgwAccountExpires' => array( 'phpgwAccountExpires' => array(
"Headline" => _("Account expiration date"), "Headline" => _("Account expiration date"),
"Text" => _("This is the date when the account will expire. Format: DD-MM-YYYY") "Text" => _("This is the date when the account will expire. Format: DD-MM-YYYY")
),
'autoAdd' => array(
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
) )
); );
// profile options
$return['profile_options'] = array(
array(
array('kind' => 'text', 'text' => _('Automatically add this extension') . ":"),
array('kind' => 'input', 'name' => 'phpGroupwareUser_addExt', 'type' => 'checkbox'),
array('kind' => 'help', 'value' => 'autoAdd')),
);
// available PDF fields // available PDF fields
$return['PDF_fields'] = array( $return['PDF_fields'] = array(
'phpgwAccountStatus', 'phpgwAccountExpires', 'phpgwAccountStatus', 'phpgwAccountExpires',
@ -341,6 +352,21 @@ class phpGroupwareUser extends baseModule implements passwordService {
return $return; return $return;
} }
/**
* Loads the values of an account profile into internal variables.
*
* @param array $profile hash array with profile values (identifier => value)
*/
function load_profile($profile) {
parent::load_profile($profile);
// add extension
if ($profile['phpGroupwareUser_addExt'][0] == "true") {
if (!in_array('phpgwAccount', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'phpgwAccount';
}
}
}
/** /**
* In this function the LDAP account is built up. * In this function the LDAP account is built up.
* *

View File

@ -276,7 +276,7 @@ class sambaGroupMapping extends baseModule {
else { else {
$return[] = array( $return[] = array(
array('kind' => 'text', 'text' => '&nbsp;'), array('kind' => 'text', 'text' => '&nbsp;'),
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaGroupMapping_attributes_addObjectClass', 'value' => _('Add Samba 3 account')) array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaGroupMapping_attributes_addObjectClass', 'value' => _('Add Samba 3 extension'))
); );
} }
return $return; return $return;

View File

@ -139,6 +139,13 @@ class sambaSamAccount extends baseModule implements passwordService {
'sambaUserWorkstations', 'sambaPrimaryGroupSID', 'sambaDomainName', 'sambaLogonHours', 'sambaMungedDial'); 'sambaUserWorkstations', 'sambaPrimaryGroupSID', 'sambaDomainName', 'sambaLogonHours', 'sambaMungedDial');
// PHP extensions // PHP extensions
$return['extensions'] = array('hash', 'iconv'); $return['extensions'] = array('hash', 'iconv');
// profile options
$return['profile_options'] = array(
array(
array('kind' => 'text', 'text' => _('Automatically add this extension') . ":"),
array('kind' => 'input', 'name' => 'sambaSamAccount_addExt', 'type' => 'checkbox'),
array('kind' => 'help', 'value' => 'autoAdd')),
);
// profile checks // profile checks
$return['profile_checks']['sambaSamAccount_smbhome'] = array( $return['profile_checks']['sambaSamAccount_smbhome'] = array(
'type' => 'ext_preg', 'type' => 'ext_preg',
@ -376,7 +383,10 @@ class sambaSamAccount extends baseModule implements passwordService {
"Text" => _("Windows password hashes are saved by default as NT and LM hashes. LM hashes are insecure and only needed for old versions of Windows. You should disable them unless you really need them.")), "Text" => _("Windows password hashes are saved by default as NT and LM hashes. LM hashes are insecure and only needed for old versions of Windows. You should disable them unless you really need them.")),
'hiddenOptions' => array( 'hiddenOptions' => array(
"Headline" => _("Hidden options"), "Headline" => _("Hidden options"),
"Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.")) "Text" => _("The selected options will not be managed inside LAM. You can use this to reduce the number of displayed input fields.")),
'autoAdd' => array(
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded."))
); );
// upload dependencies // upload dependencies
$return['upload_preDepends'] = array('posixAccount', 'inetOrgPerson'); $return['upload_preDepends'] = array('posixAccount', 'inetOrgPerson');
@ -703,17 +713,19 @@ class sambaSamAccount extends baseModule implements passwordService {
* <br>"modify" are attributes which have to been modified in LDAP entry * <br>"modify" are attributes which have to been modified in LDAP entry
*/ */
function save_attributes() { function save_attributes() {
if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) { if (!in_array('sambaSamAccount', $this->attributes['objectClass']) && !in_array('sambaSamAccount', $this->orig['objectClass'])) {
// skip saving if the extension was not added/modified
return array(); return array();
} }
if (in_array('sambaSamAccount', $this->attributes['objectClass'])) {
if ($this->expirePassword === true) { if ($this->expirePassword === true) {
$this->attributes['sambaPwdLastSet'][0] = '0'; $this->attributes['sambaPwdLastSet'][0] = '0';
} }
elseif ((isset($this->attributes['sambaPwdLastSet'][0])) && ($this->attributes['sambaPwdLastSet'][0] == '0')) { elseif ((isset($this->attributes['sambaPwdLastSet'][0])) && ($this->attributes['sambaPwdLastSet'][0] == '0')) {
$this->attributes['sambaPwdLastSet'][0] = time(); $this->attributes['sambaPwdLastSet'][0] = time();
} }
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig); }
return $return; return parent::save_attributes();
} }
/** /**
@ -723,6 +735,26 @@ class sambaSamAccount extends baseModule implements passwordService {
* @return array list of info/error messages * @return array list of info/error messages
*/ */
function process_attributes() { function process_attributes() {
// add extension
if (isset($_POST['form_subpage_sambaSamAccount_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'sambaSamAccount';
return array();
}
// remove extension
elseif (isset($_POST['form_subpage_sambaSamAccount_attributes_remObjectClass'])) {
$this->attributes['objectClass'] = array_delete(array('sambaSamAccount'), $this->attributes['objectClass']);
$attrKeys = array_keys($this->attributes);
for ($k = 0; $k < sizeof($attrKeys); $k++) {
if (strpos($attrKeys[$k], 'samba') > -1) {
unset($this->attributes[$attrKeys[$k]]);
}
}
if (isset($this->attributes['displayName'])) {
unset($this->attributes['displayName']);
}
return array();
}
// skip processing if extension is not active
if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) { if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) {
return array(); return array();
} }
@ -1044,9 +1076,6 @@ class sambaSamAccount extends baseModule implements passwordService {
* @return array HTML meta data * @return array HTML meta data
*/ */
function display_html_attributes() { function display_html_attributes() {
if (isset($_POST['form_subpage_sambaSamAccount_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'sambaSamAccount';
}
$return = array(); $return = array();
if (in_array('sambaSamAccount', $this->attributes['objectClass'])) { if (in_array('sambaSamAccount', $this->attributes['objectClass'])) {
if ($this->get_scope() == "host") { if ($this->get_scope() == "host") {
@ -1281,11 +1310,18 @@ class sambaSamAccount extends baseModule implements passwordService {
array('kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword', 'value' => _('Reset')), array('kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword', 'value' => _('Reset')),
array('kind' => 'help', 'value' => 'resetPassword' )); array('kind' => 'help', 'value' => 'resetPassword' ));
} }
$return[] = array(
array('kind' => 'text', 'text' => '&nbsp;')
);
$return[] = array(
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaSamAccount_attributes_remObjectClass',
'value' => _('Remove Samba 3 extension'), 'td' => array('colspan' => '3'))
);
} }
else { else {
$return[] = array( $return[] = array(
array('kind' => 'text', 'text' => '&nbsp;'), array('kind' => 'text', 'text' => '&nbsp;'),
array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaSamAccount_attributes_addObjectClass', 'value' => _('Add Samba 3 account')) array('kind' => 'input', 'type' => 'submit', 'name' => 'form_subpage_sambaSamAccount_attributes_addObjectClass', 'value' => _('Add Samba 3 extension'))
); );
} }
return $return; return $return;
@ -1565,7 +1601,7 @@ class sambaSamAccount extends baseModule implements passwordService {
* @return profile elements * @return profile elements
*/ */
function get_profileOptions() { function get_profileOptions() {
$return = array(); $return = parent::get_profileOptions();
if ($this->get_scope() == 'user') { if ($this->get_scope() == 'user') {
// lists for expiration date // lists for expiration date
$day = array(); $mon = array(); $year = array(); $day = array(); $mon = array(); $year = array();
@ -1708,7 +1744,12 @@ class sambaSamAccount extends baseModule implements passwordService {
function load_profile($profile) { function load_profile($profile) {
// profile mappings in meta data // profile mappings in meta data
parent::load_profile($profile); parent::load_profile($profile);
// special profile options // add extension
if ($profile['sambaSamAccount_addExt'][0] == "true") {
if (!in_array('sambaSamAccount', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'sambaSamAccount';
}
}
// use no password // use no password
if ($profile['sambaSamAccount_sambaAcctFlagsN'][0] == "true") { if ($profile['sambaSamAccount_sambaAcctFlagsN'][0] == "true") {
$this->nopwd = true; $this->nopwd = true;

View File

@ -95,6 +95,10 @@ class shadowAccount extends baseModule implements passwordService {
for ( $i=1; $i<=12; $i++ ) $mon[] = $i; for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
for ( $i=2003; $i<=2030; $i++ ) $year[] = $i; for ( $i=2003; $i<=2030; $i++ ) $year[] = $i;
$return['profile_options'] = array( $return['profile_options'] = array(
array(
array('kind' => 'text', 'text' => _('Automatically add this extension') . ":"),
array('kind' => 'input', 'name' => 'shadowAccount_addExt', 'type' => 'checkbox'),
array('kind' => 'help', 'value' => 'autoAdd')),
// password warning // password warning
array( array(
array('kind' => 'text', 'text' => _('Password warning')), array('kind' => 'text', 'text' => _('Password warning')),
@ -125,7 +129,7 @@ class shadowAccount extends baseModule implements passwordService {
array('kind' => 'select', 'name' => 'shadowAccount_shadowExpire_yea', 'options' => $year, 'options_selected' => array('2030')) array('kind' => 'select', 'name' => 'shadowAccount_shadowExpire_yea', 'options' => $year, 'options_selected' => array('2030'))
) )
)), )),
array('kind' => 'help', 'value' => 'shadowExpire')) array('kind' => 'help', 'value' => 'shadowExpire')),
); );
// profile checks // profile checks
$return['profile_checks']['shadowAccount_shadowMin'] = array( $return['profile_checks']['shadowAccount_shadowMin'] = array(
@ -184,6 +188,10 @@ class shadowAccount extends baseModule implements passwordService {
'shadowExpire' => array ( 'shadowExpire' => array (
"Headline" => _("Account expiration date"), "Headline" => _("Account expiration date"),
"Text" => _("This is the date when the account will expire. Format: DD-MM-YYYY") "Text" => _("This is the date when the account will expire. Format: DD-MM-YYYY")
),
'autoAdd' => array(
"Headline" => _("Automatically add this extension"),
"Text" => _("This will enable the extension automatically if this profile is loaded.")
) )
); );
// upload fields // upload fields
@ -502,7 +510,12 @@ class shadowAccount extends baseModule implements passwordService {
function load_profile($profile) { function load_profile($profile) {
// profile mappings in meta data // profile mappings in meta data
parent::load_profile($profile); parent::load_profile($profile);
// special profile options // add extension
if ($profile['shadowAccount_addExt'][0] == "true") {
if (!in_array('shadowAccount', $this->attributes['objectClass'])) {
$this->attributes['objectClass'][] = 'shadowAccount';
}
}
// expiration date // expiration date
if (isset($profile['shadowAccount_shadowExpire_day'][0]) && ($profile['shadowAccount_shadowExpire_day'][0] != "")) { if (isset($profile['shadowAccount_shadowExpire_day'][0]) && ($profile['shadowAccount_shadowExpire_day'][0] != "")) {
$date = intval(mktime(0, 0, 0, intval($profile['shadowAccount_shadowExpire_mon'][0]), $date = intval(mktime(0, 0, 0, intval($profile['shadowAccount_shadowExpire_mon'][0]),