implemented profile loading
This commit is contained in:
parent
19cad31616
commit
e8f9e08f06
|
@ -362,10 +362,10 @@ class quota extends baseModule {
|
|||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||
$return[] = array(
|
||||
0 => array('kind' => 'text', 'text' => $dirs[$i], 'align' => 'left'),
|
||||
1 => array('kind' => 'input', 'type' => 'text', 'text' => "", 'align' => 'center', 'size' => '12', 'name' => "quota_softblock_$i"),
|
||||
2 => array('kind' => 'input', 'type' => 'text', 'text' => "", 'align' => 'center', 'size' => '12', 'name' => "quota_hardblock_$i"),
|
||||
3 => array('kind' => 'input', 'type' => 'text', 'text' => "", 'align' => 'center', 'size' => '12', 'name' => "quota_softinode_$i"),
|
||||
4 => array('kind' => 'input', 'type' => 'text', 'text' => "", 'align' => 'center', 'size' => '12', 'name' => "quota_hardinode_$i"),
|
||||
1 => array('kind' => 'input', 'type' => 'text', 'align' => 'center', 'size' => '12', 'name' => "quota_softblock_" . $dirs[$i]),
|
||||
2 => array('kind' => 'input', 'type' => 'text', 'align' => 'center', 'size' => '12', 'name' => "quota_hardblock_" . $dirs[$i]),
|
||||
3 => array('kind' => 'input', 'type' => 'text', 'align' => 'center', 'size' => '12', 'name' => "quota_softinode_" . $dirs[$i]),
|
||||
4 => array('kind' => 'input', 'type' => 'text', 'align' => 'center', 'size' => '12', 'name' => "quota_hardinode_" . $dirs[$i]),
|
||||
);
|
||||
}
|
||||
return $return;
|
||||
|
@ -379,19 +379,41 @@ class quota extends baseModule {
|
|||
*/
|
||||
function check_profileOptions($options) {
|
||||
$return = array();
|
||||
$i = 0;
|
||||
while (isset($options["quota_softblock_$i"])) {
|
||||
if (!get_preg($options["quota_softblock_$i"][0], 'digit')) $return[] = $this->messages['softblock'][0];
|
||||
if (!get_preg($options["quota_hardblock_$i"][0], 'digit')) $return[] = $this->messages['hardblock'][0];
|
||||
if (!get_preg($options["quota_softinode_$i"][0], 'digit')) $return[] = $this->messages['softinode'][0];
|
||||
if (!get_preg($options["quota_hardinode_$i"][0], 'digit')) $return[] = $this->messages['hardinode'][0];
|
||||
if (intval($options["quota_softblock_$i"][0]) > $options["quota_hardblock_$i"][0]) $return[] = $this->messages['block_cmp'][0];
|
||||
if (intval($options["quota_softinode_$i"][0]) > $options["quota_hardinode_$i"][0]) $return[] = $this->messages['inode_cmp'][0];
|
||||
// Get quotas
|
||||
$quotas = lamdaemon(array("+ quota get " . $this->get_scope()));
|
||||
$dirs = split(":", $quotas[0]);
|
||||
array_pop($dirs); // remove empty element at the end
|
||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||
$dirs[$i] = split(",", $dirs[$i]);
|
||||
$dirs[$i] = $dirs[$i][0];
|
||||
}
|
||||
for ($i = 0; $i < sizeof($dirs); $i++) {
|
||||
if (!get_preg($options["quota_softblock_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['softblock'][0];
|
||||
if (!get_preg($options["quota_hardblock_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['hardblock'][0];
|
||||
if (!get_preg($options["quota_softinode_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['softinode'][0];
|
||||
if (!get_preg($options["quota_hardinode_" . $dirs[$i]][0], 'digit')) $return[] = $this->messages['hardinode'][0];
|
||||
if (intval($options["quota_softblock_" . $dirs[$i]][0]) >= $options["quota_hardblock_$i"][0]) $return[] = $this->messages['block_cmp'][0];
|
||||
if (intval($options["quota_softinode_" . $dirs[$i]][0]) >= $options["quota_hardinode_$i"][0]) $return[] = $this->messages['inode_cmp'][0];
|
||||
$i++;
|
||||
}
|
||||
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) {
|
||||
for ($i = 0; $i < sizeof($this->quota); $i++) {
|
||||
$dir = $this->quota[$i][0];
|
||||
if (isset($profile["quota_softblock_" . $dir])) $this->quota[$i][2] = $profile["quota_softblock_" . $dir][0];
|
||||
if (isset($profile["quota_hardblock_" . $dir])) $this->quota[$i][3] = $profile["quota_hardblock_" . $dir][0];
|
||||
if (isset($profile["quota_softinode_" . $dir])) $this->quota[$i][6] = $profile["quota_softinode_" . $dir][0];
|
||||
if (isset($profile["quota_hardinode_" . $dir])) $this->quota[$i][7] = $profile["quota_hardinode_" . $dir][0];
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-PHPDoc)
|
||||
* @see baseModule#get_pdfEntries
|
||||
|
|
|
@ -161,12 +161,21 @@ class sambaAccount extends baseModule {
|
|||
'error_message' => $this->messages['homePath'][0]);
|
||||
$return['profile_checks']['sambaAccount_profilePath'] = array('type' => 'ext_preg', 'regex' => 'UNC',
|
||||
'error_message' => $this->messages['profilePath'][0]);
|
||||
$return['profile_checks']['sambaAccount_scriptPath'] = array('type' => 'ext_preg', 'regex' => 'logonScript',
|
||||
$return['profile_checks']['sambaAccount_scriptPath'] = array('type' => 'ext_preg', 'regex' => 'logonscript',
|
||||
'error_message' => $this->messages['logonScript'][0]);
|
||||
$return['profile_checks']['sambaAccount_userWorkstations'] = array('type' => 'ext_preg', 'regex' => 'unixhost',
|
||||
'error_message' => $this->messages['workstations'][0]);
|
||||
$return['profile_checks']['sambaAccount_domain'] = array('type' => 'ext_preg', 'regex' => 'domainname',
|
||||
'error_message' => $this->messages['domain'][0]);
|
||||
// profile mappings
|
||||
$return['profile_mappings'] = array(
|
||||
'sambaAccount_homeDrive' => 'homeDrive',
|
||||
'sambaAccount_smbhome' => 'smbHome',
|
||||
'sambaAccount_profilePath' => 'profilePath',
|
||||
'sambaAccount_scriptPath' => 'scriptPath',
|
||||
'sambaAccount_userWorkstations' => 'userWorkstations',
|
||||
'sambaAccount_domain' => 'domain'
|
||||
);
|
||||
// available PDF fields
|
||||
$return['PDF_fields'] = array(
|
||||
'displayName',
|
||||
|
@ -377,12 +386,22 @@ class sambaAccount extends baseModule {
|
|||
// call parent init
|
||||
parent::init($base);
|
||||
$this->useunixpwd = false;
|
||||
$this->noexpire = true;
|
||||
$this->nopwd = false;
|
||||
$this->deactivated = false;
|
||||
}
|
||||
|
||||
// Variables
|
||||
// use unix password as samba password?
|
||||
/** use unix password as samba password? */
|
||||
var $useunixpwd;
|
||||
// Array of well known rids
|
||||
/** use no password? */
|
||||
var $nopwd;
|
||||
/** password does not expire? */
|
||||
var $noexpire;
|
||||
/** account deactivated? */
|
||||
var $deactivated;
|
||||
|
||||
/** Array of well known rids */
|
||||
var $rids;
|
||||
|
||||
/* $attribute['lmPassword'] and $attribute['ntPassword'] can't accessed directly because it's enrcypted
|
||||
|
@ -449,6 +468,9 @@ class sambaAccount extends baseModule {
|
|||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->load_ldap_attributes($attr);
|
||||
if (strpos($this->attributes['acctFlags'][0], "D")) $this->deactivated = true;
|
||||
if (strpos($this->attributes['acctFlags'][0], "N")) $this->nopwd = true;
|
||||
if (strpos($this->attributes['acctFlags'][0], "X")) $this->noexpire = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -507,9 +529,27 @@ class sambaAccount extends baseModule {
|
|||
$this->attributes['domain'][0] = $post['domain'];
|
||||
// Start character
|
||||
$flag = "[";
|
||||
if ($post['acctFlagsD']) $flag .= "D";
|
||||
if ($post['acctFlagsX']) $flag .= "X";
|
||||
if ($post['acctFlagsN']) $flag .= "N";
|
||||
if ($post['acctFlagsD']) {
|
||||
$flag .= "D";
|
||||
$this->deactivated = true;
|
||||
}
|
||||
else {
|
||||
$this->deactivated = false;
|
||||
}
|
||||
if ($post['acctFlagsX']) {
|
||||
$flag .= "X";
|
||||
$this->noexpire = true;
|
||||
}
|
||||
else {
|
||||
$this->noexpire = false;
|
||||
}
|
||||
if ($post['acctFlagsN']) {
|
||||
$flag .= "N";
|
||||
$this->nopwd = true;
|
||||
}
|
||||
else {
|
||||
$this->nopwd = false;
|
||||
}
|
||||
if ($post['acctFlagsS']) $flag .= "S";
|
||||
if ($post['acctFlagsH']) $flag .= "H";
|
||||
if ($post['acctFlagsW']) $flag .= "W";
|
||||
|
@ -693,20 +733,14 @@ class sambaAccount extends baseModule {
|
|||
1 => array ( 'kind' => 'input', 'name' => 'useunixpwd', 'type' => 'checkbox', 'checked' => $this->useunixpwd, 'value' => true),
|
||||
2 => array ('kind' => 'help', 'value' => 'useunixpwd'));
|
||||
}
|
||||
$checked = false;
|
||||
if (strpos($this->attributes['acctFlags'][0], "N")) $checked = true;
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Use no password') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsN', 'type' => 'checkbox', 'checked' => $checked),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsN', 'type' => 'checkbox', 'checked' => $this->nopwd),
|
||||
2 => array ('kind' => 'help', 'value' => 'acctFlagsN'));
|
||||
$checked = false;
|
||||
if (strpos($this->attributes['acctFlags'][0], "X")) $checked = true;
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Password does not expire') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsX', 'type' => 'checkbox', 'checked' => $checked),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsX', 'type' => 'checkbox', 'checked' => $this->noexpire),
|
||||
2 => array ('kind' => 'help', 'value' => 'acctFlagsX'));
|
||||
$checked = false;
|
||||
if (strpos($this->attributes['acctFlags'][0], "D")) $checked = true;
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Account is deactivated') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsD', 'type' => 'checkbox', 'checked' => $checked),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'acctFlagsD', 'type' => 'checkbox', 'checked' => $this->deactivated),
|
||||
2 => array ('kind' => 'help', 'value' => 'acctFlagsD'));
|
||||
for ( $i=1; $i<=31; $i++ ) $mday[] = $i;
|
||||
for ( $i=1; $i<=12; $i++ ) $mon[] = $i;
|
||||
|
@ -1098,6 +1132,46 @@ class sambaAccount extends baseModule {
|
|||
return $triggered_messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the values of an account profile into internal variables.
|
||||
*
|
||||
* @param array $profile hash array with profile values (identifier => value)
|
||||
*/
|
||||
function load_profile($profile) {
|
||||
// profile mappings in meta data
|
||||
parent::load_profile($profile);
|
||||
// special profile options
|
||||
// use Unix password
|
||||
if ($profile['sambaAccount_useunixpwd'][0] == "true") {
|
||||
$this->useunixpwd = true;
|
||||
}
|
||||
elseif ($profile['sambaAccount_useunixpwd'][0] == "false") {
|
||||
$this->useunixpwd = false;
|
||||
}
|
||||
// use no password
|
||||
if ($profile['sambaAccount_acctFlagsN'][0] == "true") {
|
||||
$this->nopwd = true;
|
||||
}
|
||||
elseif ($profile['sambaAccount_acctFlagsN'][0] == "false") {
|
||||
$this->nopwd = false;
|
||||
}
|
||||
// password expiration
|
||||
if ($profile['sambaAccount_acctFlagsX'][0] == "true") {
|
||||
$this->noexpire = true;
|
||||
}
|
||||
elseif ($profile['sambaAccount_acctFlagsX'][0] == "false") {
|
||||
$this->noexpire = false;
|
||||
}
|
||||
// use no password
|
||||
if ($profile['sambaAccount_acctFlagsD'][0] == "true") {
|
||||
$this->deactivated = true;
|
||||
}
|
||||
elseif ($profile['sambaAccount_acctFlagsD'][0] == "false") {
|
||||
$this->deactivated = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue