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(
"Headline" => _("Organizational units"),
"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
$return['upload_columns'] = array(
array(
@ -215,9 +226,6 @@ class eduPerson extends baseModule {
* @return array HTML meta data
*/
function display_html_attributes() {
if (isset($_POST['form_subpage_eduPerson_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'eduPerson';
}
$return = array();
if (in_array('eduPerson', $this->attributes['objectClass'])) {
// principal name
@ -380,6 +388,13 @@ class eduPerson extends baseModule {
))),
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 {
$return[] = array(
@ -397,6 +412,19 @@ class eduPerson extends baseModule {
* @return array list of info/error messages
*/
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();
// primary affiliation
$this->attributes['eduPersonPrimaryAffiliation'][0] = $_POST['primaryAffiliation'];
@ -493,6 +521,21 @@ class eduPerson extends baseModule {
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.
*

View File

@ -81,8 +81,19 @@ class phpGroupwareUser extends baseModule implements passwordService {
'phpgwAccountExpires' => array(
"Headline" => _("Account expiration date"),
"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
$return['PDF_fields'] = array(
'phpgwAccountStatus', 'phpgwAccountExpires',
@ -340,6 +351,21 @@ class phpGroupwareUser extends baseModule implements passwordService {
}
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.

View File

@ -276,7 +276,7 @@ class sambaGroupMapping extends baseModule {
else {
$return[] = array(
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;

View File

@ -139,6 +139,13 @@ class sambaSamAccount extends baseModule implements passwordService {
'sambaUserWorkstations', 'sambaPrimaryGroupSID', 'sambaDomainName', 'sambaLogonHours', 'sambaMungedDial');
// PHP extensions
$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
$return['profile_checks']['sambaSamAccount_smbhome'] = array(
'type' => 'ext_preg',
@ -376,8 +383,11 @@ 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.")),
'hiddenOptions' => array(
"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
$return['upload_preDepends'] = array('posixAccount', 'inetOrgPerson');
// upload options
@ -703,17 +713,19 @@ class sambaSamAccount extends baseModule implements passwordService {
* <br>"modify" are attributes which have to been modified in LDAP entry
*/
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();
}
if ($this->expirePassword === true) {
$this->attributes['sambaPwdLastSet'][0] = '0';
if (in_array('sambaSamAccount', $this->attributes['objectClass'])) {
if ($this->expirePassword === true) {
$this->attributes['sambaPwdLastSet'][0] = '0';
}
elseif ((isset($this->attributes['sambaPwdLastSet'][0])) && ($this->attributes['sambaPwdLastSet'][0] == '0')) {
$this->attributes['sambaPwdLastSet'][0] = time();
}
}
elseif ((isset($this->attributes['sambaPwdLastSet'][0])) && ($this->attributes['sambaPwdLastSet'][0] == '0')) {
$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
*/
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'])) {
return array();
}
@ -1044,9 +1076,6 @@ class sambaSamAccount extends baseModule implements passwordService {
* @return array HTML meta data
*/
function display_html_attributes() {
if (isset($_POST['form_subpage_sambaSamAccount_attributes_addObjectClass'])) {
$this->attributes['objectClass'][] = 'sambaSamAccount';
}
$return = array();
if (in_array('sambaSamAccount', $this->attributes['objectClass'])) {
if ($this->get_scope() == "host") {
@ -1280,12 +1309,19 @@ class sambaSamAccount extends baseModule implements passwordService {
array('kind' => 'text', 'text' => _('Reset password') ),
array('kind' => 'input', 'type' => 'submit', 'name' => 'ResetSambaPassword', 'value' => _('Reset')),
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 {
$return[] = array(
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;
@ -1565,7 +1601,7 @@ class sambaSamAccount extends baseModule implements passwordService {
* @return profile elements
*/
function get_profileOptions() {
$return = array();
$return = parent::get_profileOptions();
if ($this->get_scope() == 'user') {
// lists for expiration date
$day = array(); $mon = array(); $year = array();
@ -1708,7 +1744,12 @@ class sambaSamAccount extends baseModule implements passwordService {
function load_profile($profile) {
// profile mappings in meta data
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
if ($profile['sambaSamAccount_sambaAcctFlagsN'][0] == "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=2003; $i<=2030; $i++ ) $year[] = $i;
$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
array(
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' => 'help', 'value' => 'shadowExpire'))
array('kind' => 'help', 'value' => 'shadowExpire')),
);
// profile checks
$return['profile_checks']['shadowAccount_shadowMin'] = array(
@ -184,6 +188,10 @@ class shadowAccount extends baseModule implements passwordService {
'shadowExpire' => array (
"Headline" => _("Account expiration date"),
"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
@ -502,7 +510,12 @@ class shadowAccount extends baseModule implements passwordService {
function load_profile($profile) {
// profile mappings in meta data
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
if (isset($profile['shadowAccount_shadowExpire_day'][0]) && ($profile['shadowAccount_shadowExpire_day'][0] != "")) {
$date = intval(mktime(0, 0, 0, intval($profile['shadowAccount_shadowExpire_mon'][0]),