fixed access to parent container

This commit is contained in:
Roland Gruber 2009-11-24 18:24:39 +00:00
parent dd7ddeade3
commit f42d04f9e5
3 changed files with 28 additions and 28 deletions

View File

@ -210,7 +210,7 @@ class ddns extends baseModule {
$errors = array();
// Main Settings and Account have to different processes.
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn==$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn==$_SESSION['config']->get_suffix('dhcp')) {
// main settings:
$errors = $this->process_attributes_mainSettings();
}
@ -327,7 +327,7 @@ class ddns extends baseModule {
return array();
}
}
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn==$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn==$_SESSION['config']->get_suffix('dhcp')) {
// DHCP main settings
$return[] = array(
array('kind' => 'text', 'text' => _('Activate DynDNS') . ":* "),

View File

@ -100,7 +100,7 @@ class fixed_ip extends baseModule {
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
return "enabled";
}
else {
@ -167,10 +167,10 @@ class fixed_ip extends baseModule {
public function reload_ips() {
// Only run it, when ranges already exists:
if(is_array($this->fixed_ip)) {
$ex_subnet = explode(".", $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]);
$ex_subnet = explode(".", $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]);
$ip_edit = false; // Range were edit?
foreach ($this->fixed_ip AS $id=>$arr) {
if (!empty($this->fixed_ip[$id]['ip']) && !$_SESSION['account']->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'],$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
if (!empty($this->fixed_ip[$id]['ip']) && !$this->getAccountContainer()->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'],$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
// Range anpassen:
$ex = explode(".", $this->fixed_ip[$id]['ip']);
$tmp = $this->fixed_ip[$id]['ip'];
@ -190,9 +190,9 @@ class fixed_ip extends baseModule {
*/
function load_attributes($attr) {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
$sr = @ldap_search($_SESSION['ldap']->server(),'cn='.$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),
$sr = @ldap_search($_SESSION['ldap']->server(),'cn='.$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),
'(objectClass=dhcpHost)', array(), 0, 0, 0, LDAP_DEREF_NEVER);
if ($sr) {
$entries = ldap_get_entries($_SESSION['ldap']->server(), $sr);
@ -218,12 +218,12 @@ class fixed_ip extends baseModule {
*/
public function process_attributes() {
$errors = array();
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
$this->processed = true;
$this->reset_overlapd_ip();
if ($_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]!="") {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]!="") {
$error = false; // errors by process_attributes()?
$pcs = array();
@ -269,7 +269,7 @@ class fixed_ip extends baseModule {
}
// Is ip correct with subnet:
if (check_ip($_POST['ip_'.$id]) && !$_SESSION['account']->getAccountModule('range')->check_subnet_range($_POST['ip_'.$id], $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
if (check_ip($_POST['ip_'.$id]) && !$this->getAccountContainer()->getAccountModule('range')->check_subnet_range($_POST['ip_'.$id], $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
$error = true;
}
@ -316,7 +316,7 @@ class fixed_ip extends baseModule {
* It will output a complete html-table
*/
public function display_html_attributes() {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]=="") {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]=="") {
echo "<b>" . _("Please fill out the DHCP settings first.") . "</b>";
}
else {
@ -346,7 +346,7 @@ class fixed_ip extends baseModule {
$pcs = array();
foreach($this->fixed_ip AS $id=>$arr) {
// pc name
$result = @ldap_search($_SESSION['ldap']->server(),"cn=".$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].",".$_SESSION['config']->get_Suffix('dhcp'),
$result = @ldap_search($_SESSION['ldap']->server(),"cn=".$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0].",".$_SESSION['config']->get_Suffix('dhcp'),
'(cn='.$_POST['pc_'.$id].')', array(), 0, 0, 0, LDAP_DEREF_NEVER);
$num = (@ldap_get_entries($_SESSION['ldap']->server(), $result)=="")?0:ldap_get_entries($_SESSION['ldap']->server(), $result);
$pcError = "";
@ -384,7 +384,7 @@ class fixed_ip extends baseModule {
elseif (($this->fixed_ip[$id]['ip'] == '') || !check_ip($this->fixed_ip[$id]['ip'])) {
$ipError = _("The IP address is invalid.");
}
elseif (!$_SESSION['account']->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'], $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
elseif (!$this->getAccountContainer()->getAccountModule('range')->check_subnet_range($this->fixed_ip[$id]['ip'], $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]) ) {
$ipError = _("The IP address does not match the subnet.");
}
elseif (!$this->overlapd_ip($this->fixed_ip[$id]['ip'])) {
@ -447,7 +447,7 @@ class fixed_ip extends baseModule {
* @param array $attributes LDAP attributes of this entry
*/
public function postModifyActions($newAccount, $attributes) {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
$add = array();
$delete = array();
// Which dns are to delete and to add
@ -487,7 +487,7 @@ class fixed_ip extends baseModule {
}
foreach($delete AS $dn) {
ldap_delete($_SESSION['ldap']->server(),'cn='.$dn.',cn='.$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'));
ldap_delete($_SESSION['ldap']->server(),'cn='.$dn.',cn='.$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'));
}
foreach($add AS $id=>$arr) {
@ -498,7 +498,7 @@ class fixed_ip extends baseModule {
$attr['dhcpHWAddress'] = 'ethernet '.$add[$id]['mac'];
$attr['dhcpStatements'] = 'fixed-address '.$add[$id]['ip'];
if ($attr['cn']!="")
ldap_add($_SESSION['ldap']->server(),'cn='.$add[$id]['cn'].',cn='.$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),$attr);
ldap_add($_SESSION['ldap']->server(),'cn='.$add[$id]['cn'].',cn='.$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0].','.$_SESSION['config']->get_suffix('dhcp'),$attr);
}
}
}

View File

@ -198,7 +198,7 @@ class range extends baseModule {
* @return string status ("enabled", "disabled", "hidden")
*/
public function getButtonStatus() {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
return "enabled";
}
else {
@ -214,7 +214,7 @@ class range extends baseModule {
function load_attributes($attr) {
parent::load_attributes($attr);
// Load DHCP Options:
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
$this->orig = $attr;
$this->attributes = $attr;
@ -241,9 +241,9 @@ class range extends baseModule {
public function reload_ranges() {
// Only run it, when ranges already exists:
if(is_array($this->ranges)) {
$ex_subnet = explode(".", $_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]);
$ex_subnet = explode(".", $this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]);
$range_edit = false; // Range were edit?
$dhcpAttrs = $_SESSION['account']->getAccountModule('dhcp_settings')->getAttributes();
$dhcpAttrs = $this->getAccountContainer()->getAccountModule('dhcp_settings')->getAttributes();
foreach ($this->ranges AS $id=>$arr) {
if (!empty($this->ranges[$id]['range_start']) && !$this->check_subnet_range($this->ranges[$id]['range_start'],$dhcpAttrs['cn'][0])) {
// Range anpassen:
@ -282,8 +282,8 @@ class range extends baseModule {
$errors = array();
$droped = false; // Was a Range droped???
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]!="") {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]!="") {
$was_a_error = false;
$this->reset_overlaped_range();
@ -332,12 +332,12 @@ class range extends baseModule {
}
// Check if Subnet and range first are valid:
if (!$this->check_subnet_range($_POST['range_start_'.$id],$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
if (!$this->check_subnet_range($_POST['range_start_'.$id],$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
$was_a_error = true;
}
// Check if Subnet and range last are valid:
if (!$this->check_subnet_range($_POST['range_end_'.$id],$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
if (!$this->check_subnet_range($_POST['range_end_'.$id],$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
$was_a_error = true;
}
@ -391,7 +391,7 @@ class range extends baseModule {
public function display_html_attributes() {
// user name if no posixAccount
$modules = $_SESSION['config']->get_AccountModules($this->get_scope());
if ($_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0]=="") {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0]=="") {
echo "<b>" . _("Please fill out the DHCP settings first.") . "</b>";
}
else
@ -409,7 +409,7 @@ class range extends baseModule {
$error = "&laquo;&laquo; " . _("The IP address is invalid.");
} elseif($this->processed && !$this->check_range($this->ranges[$id]['range_start'],$this->ranges[$id]['range_end'])) {
$error = "&laquo;&laquo; " . _("The range end needs to be greater than the range start.");
} elseif ($this->processed && !$this->check_subnet_range($this->ranges[$id]['range_start'],$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
} elseif ($this->processed && !$this->check_subnet_range($this->ranges[$id]['range_start'],$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
$error = "&laquo;&laquo; " . _("The IP does not match the subnet.");
} elseif ($this->processed && !$this->overlaped_range($this->ranges[$id]['range_start'],$this->ranges[$id]['range_end']) ) {
$error = "&laquo;&laquo; " . _("The range conflicts with another range.");
@ -425,7 +425,7 @@ class range extends baseModule {
// Range end
if ($this->processed && !check_ip($this->ranges[$id]['range_end'])) {
$error = "&laquo;&laquo; " . _("The IP address is invalid.");
} elseif ($this->processed && !$this->check_subnet_range($this->ranges[$id]['range_end'],$_SESSION['account']->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
} elseif ($this->processed && !$this->check_subnet_range($this->ranges[$id]['range_end'],$this->getAccountContainer()->getAccountModule('dhcp_settings')->attributes['cn'][0])) {
$error = "&laquo;&laquo; " . _("The IP does not match the subnet.");
} else {
$error = "";
@ -467,7 +467,7 @@ class range extends baseModule {
public function save_attributes() {
$return = array();
// Get easy attributes
if ($_SESSION['account']->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
if ($this->getAccountContainer()->getAccountModule('dhcp_settings')->dn!=$_SESSION['config']->get_suffix('dhcp')) {
$return = $this->getAccountContainer()->save_module_attributes($this->attributes, $this->orig);
}
// Return attributes