moved dependencies to meta data

This commit is contained in:
Roland Gruber 2004-06-20 17:32:02 +00:00
parent 6ce5f9d1d3
commit 1da244e2b3
13 changed files with 60 additions and 84 deletions

View File

@ -95,7 +95,7 @@ quota module is no base module as it needs posixAccount.<br>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;"><span
style="font-weight: bold;">function get_ldap_filter($scope)</span><br>
style="font-weight: bold;">function get_ldap_filter()</span><br>
</td>
</tr>
</tbody>
@ -104,9 +104,7 @@ quota module is no base module as it needs posixAccount.<br>
Returns an array('or' =&gt; '...', 'and' =&gt; '...') that is used to
build the LDAP filter. Usually
used to filter object classes.<br>
<span style="font-weight: bold;">$scope</span> is the account type
("user", "group", "host" at this time).<br>
<br>
<span style="font-weight: bold;"></span><br>
All "or" filter parts of the base modules are combined with OR and then
combined with the "and" parts.<br>
The resulting LDAP filter will look like this:
@ -114,7 +112,7 @@ The resulting LDAP filter will look like this:
<br>
<span style="font-weight: bold;">Example: <span
style="font-style: italic;">return "('or' =&gt;
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')"</span></span><br>
'(objectClass=posixAccount)', 'and' =&gt; '(!(uid=*$))')"</span></span><br>
<br>
<span style="font-weight: bold; color: rgb(255, 0, 0);">This function
is only used for base modules. Standard modules do not need to
@ -128,15 +126,13 @@ implement it.</span><br>
<tr>
<td
style="vertical-align: top; background-color: rgb(204, 204, 204); text-align: center;">function
get_dependencies($scope)<br>
get_dependencies()<br>
</td>
</tr>
</tbody>
</table>
<br>
This function returns a list of modules it depends on.<br>
The <span style="font-weight: bold;">$scope</span> parameter defines
the account type ("user", "group", "host" at this time).<br>
<br>
The return value is an array with two sub arrays, <span
style="font-weight: bold;">"depends"</span> and <span
@ -567,6 +563,21 @@ array("user", "host")</span><br style="font-weight: bold;">
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
style="font-style: italic; font-weight: bold;"> array('or' =&gt;
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')</span>
'objectClass=posixAccount', 'and' =&gt; '(!(uid=*$))')<br>
<br>
</span>
<h3>6.4 get_dependencies()<br>
</h3>
&nbsp;&nbsp;&nbsp; "dependencies" =&gt; array<br>
<br>
<span style="font-weight: bold;">&nbsp;&nbsp; Example:</span><span
style="font-style: italic; font-weight: bold;"> array(</span><span
style="font-style: italic; font-weight: bold;"><span
style="font-weight: bold; font-style: italic;">"depends"
=&gt; array("posixAccount", array("qmail", "sendmail")), "conflicts"
=&gt; array("exim")</span></span><span
style="font-style: italic; font-weight: bold;">)</span><span
style="font-style: italic; font-weight: bold;"><br>
</span>
</body>
</html>

View File

@ -118,6 +118,16 @@ class baseModule {
else return get_class($this);
}
/**
* This function returns a list with all depending and conflicting modules.
*
* @return array list of dependencies and conflicts
*/
function get_dependencies() {
if (isset($this->meta['dependencies'])) return $this->meta['dependencies'];
else return array('depends' => array(), 'conflicts' => array());
}
// TODO implement missing interface
}

View File

@ -106,8 +106,8 @@ function getModulesDependencies($scope) {
$mods = getAvailableModules($scope);
$deps = array();
for ($i = 0; $i < sizeof($mods); $i++) {
$deps = call_user_func(array($mods[$i], "get_dependencies"), $scope);
if ($deps != -1) $return[$mods[$i]] = $deps;
$module = new $mods[$i]($scope);
$return[$mods[$i]] = $module->get_dependencies();
}
return $return;
}

View File

@ -50,6 +50,8 @@ class account extends baseModule {
$return["account_types"] = array("host");
// alias name
$return["alias"] = _('Account');
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array('inetOrgPerson'));
return $return;
}
@ -79,13 +81,6 @@ class account extends baseModule {
var $orig;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='host') return array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'posixGroup', 'sambaDomain') );
return -1;
}
/* This function returns true if all required attributes from other
* modules are set. This is required to prevent undefined states
*/

View File

@ -49,6 +49,8 @@ class inetOrgPerson extends baseModule {
$return["account_types"] = array("user");
// alias name
$return["alias"] = _('Personal');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array('account'));
return $return;
}
@ -82,13 +84,6 @@ class inetOrgPerson extends baseModule {
var $orig;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array('account', 'posixGroup', 'sambaDomain') );
return -1;
}
/* This function returns true if all required attributes from other
* modules are set. This is required to prevent undefined states
*/

View File

@ -79,12 +79,6 @@ class main extends baseModule {
var $base;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
return array('depends' => array(), 'conflicts' => array() );
}
function module_ready() {
return true;
}

View File

@ -69,6 +69,12 @@ class posixAccount extends baseModule {
$return["is_base"] = true;
// LDAP filter
$return["ldap_filter"] = array('or' => "(objectClass=posixAccount)", 'and' => "(!(uid=*$))");
// module dependencies
$return['dependencies'] = array('depends' => array('inetOrgPerson'), 'conflicts' => array());
}
elseif ($this->get_scope() == "host") {
// module dependencies
$return['dependencies'] = array('depends' => array('account'), 'conflicts' => array());
}
// alias name
$return["alias"] = _("Unix");
@ -152,14 +158,6 @@ class posixAccount extends baseModule {
}
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='host') return array('depends' => array('account'), 'conflicts' => array() );
if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1;
}
function module_ready() {
return true;
}

View File

@ -71,6 +71,8 @@ class posixGroup extends baseModule {
}
// alias name
$return["alias"] = _('Unix');
// module dependencies
$return['dependencies'] = array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'account', 'sambaDomain'));
return $return;
}
@ -141,13 +143,6 @@ class posixGroup extends baseModule {
}
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='group') return array('depends' => array(), 'conflicts' => array('inetOrgPerson', 'account', 'sambaDomain') );
return -1;
}
function module_ready() {
return true;
}

View File

@ -34,6 +34,14 @@ class quota extends baseModule {
$return["account_types"] = array("user", "group");
// alias name
$return["alias"] = _('Quota');
if ($this->get_scope() == 'group') {
// module dependencies
$return['dependencies'] = array('depends' => array('posixGroup'), 'conflicts' => array());
}
if ($this->get_scope() == 'user') {
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
}
return $return;
}
@ -83,14 +91,6 @@ class quota extends baseModule {
var $quota;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='group') return array('depends' => array('posixGroup'), 'conflicts' => array() );
if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array() );
return -1;
}
function module_ready() {
if (!isset($_SESSION[$_SESSION[$this->base]->config]->scriptPath)) return $false;
if ($_SESSION[$this->base]->type=='user' && $_SESSION[$this->base]->module['posixAccount']->attributes['uid'][0]=='') return false;

View File

@ -71,6 +71,8 @@ class sambaAccount extends baseModule {
}
// alias name
$return["alias"] = _('Samba 2');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
return $return;
}
@ -143,14 +145,6 @@ class sambaAccount extends baseModule {
}
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='host') return array('depends' => array('account'), 'conflicts' => array() );
if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1;
}
function module_ready() {
if ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]=='') return false;
if ($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]=='') return false;

View File

@ -65,6 +65,8 @@ class sambaGroupMapping extends baseModule {
$return["account_types"] = array("group");
// alias name
$return["alias"] = _('Samba 3');
// module dependencies
$return['dependencies'] = array('depends' => array('posixGroup'), 'conflicts' => array());
return $return;
}
@ -109,13 +111,6 @@ class sambaGroupMapping extends baseModule {
var $rids;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='group') return array('depends' => array('posixGroup'), 'conflicts' => array() );
return -1;
}
function module_ready() {
if ($_SESSION[$this->base]->module['posixGroup']->attributes['gidNumber'][0]=='') return false;
return true;

View File

@ -71,6 +71,8 @@ class sambaSamAccount extends baseModule {
}
// alias name
$return["alias"] = _('Samba 3');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
return $return;
}
@ -144,14 +146,6 @@ class sambaSamAccount extends baseModule {
}
}
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='host') return array('depends' => array('posixAccount'), 'conflicts' => array() );
if ($scope=='user') return array('depends' => array('posixAccount'), 'conflicts' => array() );
return -1;
}
function module_ready() {
if ($_SESSION[$this->base]->module['posixAccount']->attributes['gidNumber'][0]=='') return false;
if ($_SESSION[$this->base]->module['posixAccount']->attributes['uidNumber'][0]=='') return false;

View File

@ -65,6 +65,8 @@ class shadowAccount extends baseModule {
$return["account_types"] = array("user");
// alias name
$return["alias"] = _('Shadow');
// module dependencies
$return['dependencies'] = array('depends' => array('posixAccount'), 'conflicts' => array());
return $return;
}
@ -103,13 +105,6 @@ class shadowAccount extends baseModule {
var $orig;
/* This function returns a list with all required modules
*/
function get_dependencies($scope) {
if ($scope=='user') return array('depends' => array('inetOrgPerson'), 'conflicts' => array() );
return -1;
}
function module_ready() {
return true;
}