From 6cd040e9c120bb27eafdb4dcf7cce2313fb73280 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Sun, 20 Apr 2014 12:59:36 +0000 Subject: [PATCH] made can_manage() abstract in baseModule to save memory --- lam/lib/modules/account.inc | 13 ++++++++++--- lam/lib/modules/asteriskAccount.inc | 11 +++++++++-- lam/lib/modules/asteriskExtension.inc | 11 +++++++++-- lam/lib/modules/asteriskVoicemail.inc | 11 +++++++++-- lam/lib/modules/authorizedServiceObject.inc | 15 +++++++++++---- lam/lib/modules/ddns.inc | 13 ++++++++++--- lam/lib/modules/dhcp_settings.inc | 13 ++++++++++--- lam/lib/modules/eduPerson.inc | 11 +++++++++-- lam/lib/modules/fixed_ip.inc | 11 +++++++++-- lam/lib/modules/freeRadius.inc | 11 +++++++++-- lam/lib/modules/generalInformation.inc | 11 +++++++++-- 11 files changed, 104 insertions(+), 27 deletions(-) diff --git a/lam/lib/modules/account.inc b/lam/lib/modules/account.inc index da0b1d55..477a33c7 100644 --- a/lam/lib/modules/account.inc +++ b/lam/lib/modules/account.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2003 - 2006 Tilo Lutz - 2005 - 2013 Roland Gruber + 2005 - 2014 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,6 +38,15 @@ $Id$ */ class account extends baseModule { + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array("host", "user")); + } + /** * Returns meta data that is interpreted by parent class * @@ -52,8 +61,6 @@ class account extends baseModule { $return = array(); // icon $return['icon'] = 'uid.png'; - // manages host accounts - $return["account_types"] = array("host", "user"); // alias name $return["alias"] = _('Account'); // this is a base module diff --git a/lam/lib/modules/asteriskAccount.inc b/lam/lib/modules/asteriskAccount.inc index c5c0880f..68c0f866 100644 --- a/lam/lib/modules/asteriskAccount.inc +++ b/lam/lib/modules/asteriskAccount.inc @@ -52,6 +52,15 @@ class asteriskAccount extends baseModule implements passwordService { $this->autoAddObjectClasses = false; } + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('user')); + } + /** * Returns meta data that is interpreted by parent class. * @@ -59,8 +68,6 @@ class asteriskAccount extends baseModule implements passwordService { */ function get_metaData() { $return = array(); - // manages users accounts - $return["account_types"] = array("user"); $return["is_base"] = false; // alias name $return["alias"] = _("Asterisk"); diff --git a/lam/lib/modules/asteriskExtension.inc b/lam/lib/modules/asteriskExtension.inc index 74c7e652..8196e925 100644 --- a/lam/lib/modules/asteriskExtension.inc +++ b/lam/lib/modules/asteriskExtension.inc @@ -54,6 +54,15 @@ class asteriskExtension extends baseModule { /** flag if new rule should be added */ private $addRuleFlag = false; + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('asteriskExt')); + } + /** * Returns meta data that is interpreted by parent class * @@ -61,8 +70,6 @@ class asteriskExtension extends baseModule { */ function get_metaData() { $return = array(); - // manages users accounts - $return["account_types"] = array("asteriskExt"); $return["is_base"] = true; // RDN attribute $return["RDN"] = array("cn" => "normal"); diff --git a/lam/lib/modules/asteriskVoicemail.inc b/lam/lib/modules/asteriskVoicemail.inc index 1b7abdab..cfb51f10 100644 --- a/lam/lib/modules/asteriskVoicemail.inc +++ b/lam/lib/modules/asteriskVoicemail.inc @@ -50,6 +50,15 @@ class asteriskVoicemail extends baseModule implements passwordService { $this->autoAddObjectClasses = false; } + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('user')); + } + /** * Returns meta data that is interpreted by parent class * @@ -57,8 +66,6 @@ class asteriskVoicemail extends baseModule implements passwordService { */ function get_metaData() { $return = array(); - // manages users accounts - $return["account_types"] = array("user"); $return["is_base"] = false; // alias name $return["alias"] = _("Asterisk voicemail"); diff --git a/lam/lib/modules/authorizedServiceObject.inc b/lam/lib/modules/authorizedServiceObject.inc index 49b3bef9..10b2a251 100644 --- a/lam/lib/modules/authorizedServiceObject.inc +++ b/lam/lib/modules/authorizedServiceObject.inc @@ -4,7 +4,7 @@ $Id$ This code is not yet part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2011 J de Jong - 2012 - 2013 Roland Gruber + 2012 - 2014 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -49,7 +49,16 @@ class authorizedServiceObject extends baseModule { } - /** + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('user')); + } + + /** * Returns meta data that is interpreted by parent class * * @return array array with meta data @@ -58,8 +67,6 @@ class authorizedServiceObject extends baseModule { $return = array(); // icon $return['icon'] = 'services.png'; - // manages user accounts - $return["account_types"] = array("user"); // alias name $return["alias"] = _("Authorized Services"); // module dependencies diff --git a/lam/lib/modules/ddns.inc b/lam/lib/modules/ddns.inc index 148de267..1b79a0a2 100644 --- a/lam/lib/modules/ddns.inc +++ b/lam/lib/modules/ddns.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2013 Roland Gruber + 2008 - 2014 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,15 @@ class ddns extends baseModule { public $ddns = array(); + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('dhcp')); + } + /** * Returns meta data that is interpreted by parent class. * @@ -50,8 +59,6 @@ class ddns extends baseModule { */ public function get_metaData() { $return = array(); - // manages host accounts - $return["account_types"] = array("dhcp"); // alias name $return["alias"] = _("DDNS"); // this is a base module diff --git a/lam/lib/modules/dhcp_settings.inc b/lam/lib/modules/dhcp_settings.inc index 9d82376e..f65ffbce 100644 --- a/lam/lib/modules/dhcp_settings.inc +++ b/lam/lib/modules/dhcp_settings.inc @@ -4,7 +4,7 @@ $Id$ This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/) Copyright (C) 2008 Thomas Manninger - 2008 - 2013 Roland Gruber + 2008 - 2014 Roland Gruber This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -107,6 +107,15 @@ class dhcp_settings extends baseModule { parent::__construct($scope); } + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('dhcp')); + } + /** * Returns meta data that is interpreted by parent class * @@ -114,8 +123,6 @@ class dhcp_settings extends baseModule { */ public function get_metaData() { $return = array(); - // manages host accounts - $return["account_types"] = array("dhcp"); // alias name $return["alias"] = _("DHCP settings"); // this is a base module diff --git a/lam/lib/modules/eduPerson.inc b/lam/lib/modules/eduPerson.inc index 3dddc9b3..120bf3ea 100644 --- a/lam/lib/modules/eduPerson.inc +++ b/lam/lib/modules/eduPerson.inc @@ -48,6 +48,15 @@ class eduPerson extends baseModule { $this->autoAddObjectClasses = false; } + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('user')); + } + /** * Returns meta data that is interpreted by parent class * @@ -59,8 +68,6 @@ class eduPerson extends baseModule { $return = array(); // icon $return['icon'] = 'eduPerson.png'; - // manages host accounts - $return["account_types"] = array("user"); // alias name $return["alias"] = _("EDU person"); // module dependencies diff --git a/lam/lib/modules/fixed_ip.inc b/lam/lib/modules/fixed_ip.inc index 92b7184f..eeb829d5 100644 --- a/lam/lib/modules/fixed_ip.inc +++ b/lam/lib/modules/fixed_ip.inc @@ -58,6 +58,15 @@ class fixed_ip extends baseModule { /** cached host entries (list of array('cn' => ..., 'iphostnumber' => ..., 'macaddress' => ...)) */ private $hostCache = null; + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('dhcp')); + } + /** * Returns meta data that is interpreted by parent class * @@ -67,8 +76,6 @@ class fixed_ip extends baseModule { */ public function get_metaData() { $return = array(); - // manages host accounts - $return["account_types"] = array("dhcp"); // alias name $return["alias"] = _("Hosts"); // this is a base module diff --git a/lam/lib/modules/freeRadius.inc b/lam/lib/modules/freeRadius.inc index 854681f5..25bb79db 100644 --- a/lam/lib/modules/freeRadius.inc +++ b/lam/lib/modules/freeRadius.inc @@ -50,6 +50,15 @@ class freeRadius extends baseModule { $this->autoAddObjectClasses = false; } + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), array('user')); + } + /** * Returns meta data that is interpreted by parent class * @@ -61,8 +70,6 @@ class freeRadius extends baseModule { $return = array(); // icon $return['icon'] = 'freeRadius.png'; - // manages user accounts - $return["account_types"] = array("user"); // alias name $return["alias"] = _("FreeRadius"); // module dependencies diff --git a/lam/lib/modules/generalInformation.inc b/lam/lib/modules/generalInformation.inc index 978b5b0c..f8220456 100644 --- a/lam/lib/modules/generalInformation.inc +++ b/lam/lib/modules/generalInformation.inc @@ -34,6 +34,15 @@ $Id$ */ class generalInformation extends baseModule { + /** + * Returns true if this module can manage accounts of the current type, otherwise false. + * + * @return boolean true if module fits + */ + public function can_manage() { + return in_array($this->get_scope(), getTypes()); + } + /** * Returns meta data that is interpreted by parent class * @@ -45,8 +54,6 @@ class generalInformation extends baseModule { $return = array(); // icon $return['icon'] = 'info.png'; - // manages all accounts - $return["account_types"] = getTypes(); // alias name $return["alias"] = _("General information"); // module dependencies