changed function order in module.
First are all function variables, second constructor. All other functions will follow in alphabetical order
This commit is contained in:
parent
9b4c88bcdf
commit
a4a0a2f255
|
@ -20,40 +20,78 @@ $Id$
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Session variables which are used:
|
||||
* $_SESSION['cacheAttributes']: This variable contains a list of attributes and their scope which should be cached
|
||||
*
|
||||
* Coockie variables which are used:
|
||||
* $_COOKIE["IV"], $_COOKIE["Key"]: Needed to en/decrypt passwords.
|
||||
*
|
||||
* Variables in basearray which are no objects:
|
||||
* type: Type of account. Can be user, group, host
|
||||
* attributes: List of all attributes, how to get them and are theiy required or optional
|
||||
* dn: current DN without uid= or cn=
|
||||
* dn_orig: old DN if account was loaded with uid= or cn=
|
||||
|
||||
* External functions which are used
|
||||
* account.inc: findgroups, incache, get_cache, array_delete, getshells
|
||||
* ldap.inc: pwd_is_enabled, pwd_hash
|
||||
*/
|
||||
|
||||
/* This class contains all sambaGroupMapping LDAP attributes
|
||||
* and funtioncs required to deal with sambaGroupMapping
|
||||
* sambaGroupMapping can only be created when it should be added
|
||||
* to an array.
|
||||
* basearray is the same array sambaGroupMapping should be added
|
||||
* to. If basearray is not given the constructor tries to
|
||||
* create an array with sambaGroupMapping and all other required
|
||||
* objects.
|
||||
* Example: $user[] = new sambaGroupMapping($user);
|
||||
*
|
||||
* In container array the following things have to exist:
|
||||
* account or inetOrgPerson object
|
||||
* type: 'user' or 'host'
|
||||
* 'attributes': this is a list of arrays with all ldap attributes wich are allowed for this account
|
||||
*/
|
||||
class sambaGroupMapping extends baseModule {
|
||||
|
||||
// Variables
|
||||
// Array of well known rids
|
||||
var $rids;
|
||||
|
||||
|
||||
function delete_attributes($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* This function will create the html-page
|
||||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
// Get Domain-SID from group SID
|
||||
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
// List with all valid domains
|
||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||
if ($domainSID==$sambaDomains[$i]->SID) {
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$sel_domain = $sambaDomains[$i]->name;
|
||||
}
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
||||
|
||||
if (!$profile) {
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||
$selected[] = $names[$i];
|
||||
$wrid=true;
|
||||
}
|
||||
else $options[] = $names[$i];
|
||||
}
|
||||
if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||
else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
|
||||
}
|
||||
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function display_html_delete($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of sambaGroupMapping and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns meta data that is interpreted by parent class
|
||||
*
|
||||
|
@ -106,12 +144,43 @@ class sambaGroupMapping extends baseModule {
|
|||
return $return;
|
||||
}
|
||||
|
||||
/** this functin fills the error message array with messages
|
||||
**/
|
||||
function loadErrorMessages() {
|
||||
$this->errormessages['sambaSID'][0] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID');
|
||||
|
||||
/*
|
||||
* (non-PHPDoc)
|
||||
* @see baseModule#get_pdfEntries
|
||||
*/
|
||||
function get_pdfEntries($account_type = "User") {
|
||||
return array( 'sambaGroupMapping_gidNumber' => array('<block><key>' . _('GID number') . '</key><value>' . $this->attributes['gidNumber'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_sambaSID' => array('<block><key>' . _('Windows group') . '</key><value>' . $this->attributes['sambaSID'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_displayName' => array('<block><key>' . _('Display name') . '</key><value>' . $this->attributes['displayName'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_sambaGroupType' => array('<block><key>' . _('Samba group type') . '</key><value>' . $this->attributes['sambaGroupType'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a list of elements for the account profiles.
|
||||
*
|
||||
* @return profile elements
|
||||
*/
|
||||
function get_profileOptions() {
|
||||
$return = array();
|
||||
// get list of domains
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
$sambaDomainNames = array();
|
||||
for ($i = 0; $i < count($sambaDomains); $i++ ) {
|
||||
// extract names
|
||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||
}
|
||||
// domain
|
||||
$return[] = array (
|
||||
0 => array('kind' => 'text', 'text' => _('Domain')),
|
||||
1 => array('kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ()),
|
||||
2 => array('kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
// Constructor
|
||||
function init($base) {
|
||||
// call parent init
|
||||
|
@ -120,16 +189,23 @@ class sambaGroupMapping extends baseModule {
|
|||
_('Domain Certificate Admins') => 517, _('Domain Schema Admins') => 518, _('Domain Enterprise Admins') => 519, _('Domain Policy Admins') => 520 );
|
||||
}
|
||||
|
||||
// Variables
|
||||
// Array of well known rids
|
||||
var $rids;
|
||||
|
||||
|
||||
function module_ready() {
|
||||
if ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]=='') return false;
|
||||
return true;
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->load_ldap_attributes($attr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/** this functin fills the error message array with messages
|
||||
**/
|
||||
function load_errorMessages() {
|
||||
$this->errormessages['sambaSID'][0] = array('ERROR', _('Special Group'),sprintf( _('There can be only one group %s.'), $rids[$i]), 'sambaSID');
|
||||
}
|
||||
|
||||
|
||||
/* This functions return true
|
||||
* if all needed settings are done
|
||||
*/
|
||||
|
@ -140,6 +216,13 @@ class sambaGroupMapping extends baseModule {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
function module_ready() {
|
||||
if ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]=='') return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/* This function returns a list of all html-pages in module
|
||||
* This is usefull for mass upload and pdf-files
|
||||
* because lam can walk trough all pages itself and do some
|
||||
|
@ -149,53 +232,6 @@ class sambaGroupMapping extends baseModule {
|
|||
return array('attributes');
|
||||
}
|
||||
|
||||
/* This function returns all ldap attributes
|
||||
* which are part of sambaGroupMapping and returns
|
||||
* also their values.
|
||||
*/
|
||||
function get_attributes() {
|
||||
return $this->attributes;
|
||||
}
|
||||
|
||||
/* This function loads all attributes into the object
|
||||
* $attr is an array as it's retured from ldap_get_attributes
|
||||
*/
|
||||
function load_attributes($attr) {
|
||||
$this->load_ldap_attributes($attr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* This function returns an array with 3 entries:
|
||||
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
|
||||
* DN is the DN to change. It may be possible to change several DNs,
|
||||
* e.g. create a new user and add him to some groups via attribute memberUid
|
||||
* add are attributes which have to be added to ldap entry
|
||||
* remove are attributes which have to be removed from ldap entry
|
||||
* modify are attributes which have to been modified in ldap entry
|
||||
*/
|
||||
function save_attributes() {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
// Get Domain-SID from group SID
|
||||
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
|
||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||
if ($domainSID==$sambaDomains[$i]->SID)
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++)
|
||||
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||
$wrid=true;
|
||||
}
|
||||
if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase);
|
||||
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function delete_attributes($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Write variables into object and do some regexp checks
|
||||
*/
|
||||
|
@ -237,89 +273,35 @@ class sambaGroupMapping extends baseModule {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* This function will create the html-page
|
||||
* to show a page with all attributes.
|
||||
* It will output a complete html-table
|
||||
|
||||
/* This function returns an array with 3 entries:
|
||||
* array( DN1 ('add' => array($attr), 'remove' => array($attr), 'modify' => array($attr)), DN2 .... )
|
||||
* DN is the DN to change. It may be possible to change several DNs,
|
||||
* e.g. create a new user and add him to some groups via attribute memberUid
|
||||
* add are attributes which have to be added to ldap entry
|
||||
* remove are attributes which have to be removed from ldap entry
|
||||
* modify are attributes which have to been modified in ldap entry
|
||||
*/
|
||||
function display_html_attributes($post, $profile=false) {
|
||||
function save_attributes() {
|
||||
// Get Domain SID from name
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
// Get Domain-SID from group SID
|
||||
$domainSID = substr($this->attributes['sambaSID'][0], 0, strrpos($this->attributes['sambaSID'][0], "-"));
|
||||
for ($i=0; $i<count($sambaDomains); $i++ ) {
|
||||
// List with all valid domains
|
||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||
if ($domainSID==$sambaDomains[$i]->SID) {
|
||||
for ($i=0; $i<count($sambaDomains); $i++ )
|
||||
if ($domainSID==$sambaDomains[$i]->SID)
|
||||
$SID = $sambaDomains[$i]->SID;
|
||||
$sel_domain = $sambaDomains[$i]->name;
|
||||
}
|
||||
}
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Display name') ),
|
||||
1 => array ( 'kind' => 'input', 'name' => 'displayName', 'type' => 'text', 'size' => '30', 'maxlength' => '50', 'value' => $this->attributes['displayName'][0]),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'displayName' ));
|
||||
|
||||
if (!$profile) {
|
||||
$names = array_keys($this->rids);
|
||||
$wrid=false;
|
||||
for ($i=0; $i<count($names); $i++) {
|
||||
for ($i=0; $i<count($names); $i++)
|
||||
if ($this->attributes['sambaSID'][0]==$SID."-".$this->rids[$names[$i]]) {
|
||||
$selected[] = $names[$i];
|
||||
$wrid=true;
|
||||
}
|
||||
else $options[] = $names[$i];
|
||||
}
|
||||
if ($wrid) $options[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||
else $selected[] = $_SESSION[$this->base]->module['posixGroup']->attributes['cn'][0];
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Windows group') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaSID', 'options' => $options, 'options_selected' => $selected),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaSID' ));
|
||||
}
|
||||
|
||||
$return[] = array ( 0 => array ( 'kind' => 'text', 'text' => _('Domain') ),
|
||||
1 => array ( 'kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ( $sel_domain ) ),
|
||||
2 => array ( 'kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
if (!$wrid) $this->attributes['sambaSID'][0] == $SID."-".($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]*2+1+$RIDbase);
|
||||
$return = $_SESSION[$this->base]->save_module_attributes($this->attributes, $this->orig);
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
function display_html_delete($post) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of elements for the account profiles.
|
||||
*
|
||||
* @return profile elements
|
||||
*/
|
||||
function get_profileOptions() {
|
||||
$return = array();
|
||||
// get list of domains
|
||||
$sambaDomains = search_domains($_SESSION['config']->get_domainSuffix());
|
||||
$sambaDomainNames = array();
|
||||
for ($i = 0; $i < count($sambaDomains); $i++ ) {
|
||||
// extract names
|
||||
$sambaDomainNames[] = $sambaDomains[$i]->name;
|
||||
}
|
||||
// domain
|
||||
$return[] = array (
|
||||
0 => array('kind' => 'text', 'text' => _('Domain')),
|
||||
1 => array('kind' => 'select', 'name' => 'sambaDomainName', 'options' => $sambaDomainNames, 'options_selected' => array ()),
|
||||
2 => array('kind' => 'help', 'value' => 'sambaDomainName' ));
|
||||
return $return;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-PHPDoc)
|
||||
* @see baseModule#get_pdfEntries
|
||||
*/
|
||||
function get_pdfEntries($account_type = "User") {
|
||||
return array( 'sambaGroupMapping_gidNumber' => array('<block><key>' . _('GID number') . '</key><value>' . $this->attributes['gidNumber'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_sambaSID' => array('<block><key>' . _('Windows group') . '</key><value>' . $this->attributes['sambaSID'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_displayName' => array('<block><key>' . _('Display name') . '</key><value>' . $this->attributes['displayName'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_sambaGroupType' => array('<block><key>' . _('Samba group type') . '</key><value>' . $this->attributes['sambaGroupType'][0] . '</value></block>'),
|
||||
'sambaGroupMapping_description' => array('<block><key>' . _('Description') . '</key><value>' . $this->attributes['description'][0] . '</value></block>'));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue