From: hickert Date: Thu, 1 Dec 2005 10:07:34 +0000 (+0000) Subject: Added acls for ldapmanager X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c58023bcd8e2250dad63c3779ec4f657eb8d2d36;p=gosa.git Added acls for ldapmanager git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2172 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/plugins/addons/ldapmanager/class_csvimport.inc b/plugins/addons/ldapmanager/class_csvimport.inc index 32c067804..3e3d0fd58 100644 --- a/plugins/addons/ldapmanager/class_csvimport.inc +++ b/plugins/addons/ldapmanager/class_csvimport.inc @@ -19,16 +19,18 @@ class csvimport extends plugin /* Include config object */ $this->config= $config; + /* set permissions */ $ui= get_userinfo(); - $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "all", $config->current['BASE']); - $this->access= $acl; + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $this->acl= get_module_permission($acl, "ldapmanager", $ui->dn); + + } function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* initiate smarty */ $smarty= get_smarty(); @@ -95,7 +97,7 @@ class csvimport extends plugin $smarty->assign("attrs",$this->csvinfo['attr']); /* Check permissions for import */ - if ($this->access != '#all#'){ + if (chkacl($this->acl,"csvimport")!=""){ print_red(_("You've no permission to do CSV imports.")); return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE))); } @@ -152,10 +154,10 @@ class csvimport extends plugin /* If not all needed vars set .... */ if( ( empty($dat['sn']))||( empty($dat['givenName']))||( empty($dat['uid']))|| - (!isset($dat['sn']))||(!isset($dat['givenName']))||(!isset($dat['uid']))){ + (!isset($dat['sn']))||(!isset($dat['givenName']))||(!isset($dat['uid']))){ /* Output Error */ - + print_red (_("Need 'sn','givenName' and 'uid' to create user.")); } else { @@ -166,11 +168,11 @@ class csvimport extends plugin /* Set all submitted vars */ if(is_array($keys)) - foreach($keys as $key) { - if($key != "status"){ - $this->usertab->$key = $dat[$key]; + foreach($keys as $key) { + if($key != "status"){ + $this->usertab->$key = $dat[$key]; + } } - } /* Initialize template */ if($this->csvinfo['tplid']!=0){ @@ -180,11 +182,11 @@ class csvimport extends plugin /* Reset vars */ if(is_array($keys)) - foreach($keys as $key) { - if($key != "status"){ - $this->usertab->by_object['user']->$key = $dat[$key]; + foreach($keys as $key) { + if($key != "status"){ + $this->usertab->by_object['user']->$key = $dat[$key]; + } } - } } // Setting user Password @@ -192,7 +194,7 @@ class csvimport extends plugin $password = $dat['userPassword']; else { - $rand_str=""; + $rand_str=""; $feed = "0123456789abcdefghijklmnopqrstuvwxyz"; for ($i=0; $i < 8; $i++) { @@ -286,18 +288,18 @@ class csvimport extends plugin $smarty->assign("rows",$this->csvinfo['shownrowscount']); - $cnt = 0 ; - $tmp2 = $tmp3 = array(); - if(is_array($dataouts)) - foreach($dataouts as $tmp){ - $tmp2[] = $tmp; - $cnt ++ ; - if($cnt >= count($tmparr2)){ - $tmp3[] = $tmp2; - $tmp2= array(); - $cnt = 0; - } - } + $cnt = 0 ; + $tmp2 = $tmp3 = array(); + if(is_array($dataouts)) + foreach($dataouts as $tmp){ + $tmp2[] = $tmp; + $cnt ++ ; + if($cnt >= count($tmparr2)){ + $tmp3[] = $tmp2; + $tmp2= array(); + $cnt = 0; + } + } $smarty->assign("head",$tmparr2); $smarty->assign("data",$tmp3); @@ -321,9 +323,9 @@ class csvimport extends plugin } else { /* Check if theres a file uploaded */ if(!empty($_FILES['userfile']['name'])){ - - $handle = NULL; - + + $handle = NULL; + if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup']))) { print_red(_("There is no file uploaded.")); @@ -349,7 +351,7 @@ class csvimport extends plugin { $smarty->assign("fileup",TRUE); $str = ""; - + /* Reading content */ while(!feof($handle)) { @@ -363,57 +365,57 @@ class csvimport extends plugin /* check colum count */ if(is_array($lines)) - foreach($lines as $line) { - /* continue if theres a comment */ - if(substr(trim($line),0,1)=="#"){ - continue; - } + foreach($lines as $line) { + /* continue if theres a comment */ + if(substr(trim($line),0,1)=="#"){ + continue; + } - $line= str_replace ("\t","",$line); - $cells = split(",",$line ) ; + $line= str_replace ("\t","",$line); + $cells = split(",",$line ) ; - if(count($cells)> $anz ){ - $anz = count($cells); + if(count($cells)> $anz ){ + $anz = count($cells); + } } - } /* At least one entry */ if($anz >1) { /* Generate array with outpu info */ - if(is_array($lines)) - foreach($lines as $line) { - $rest = 0; - $cnt = 0; - - /* dont use comments or empty lines */ - if((substr(trim($line),0,1)=="#")||(empty($line))){ - continue; - } - - /* replace \t to , */ - $line= str_replace ("\t" ,"" ,$line); - - /* get all elements */ - $cells = split(",",$line ) ; - - /* attach all elements to data array */ - if(is_array($cells)) - foreach($cells as $cell) { - if(!empty($cell)) { - $cnt++; - $data[]=trim($cell); + if(is_array($lines)) + foreach($lines as $line) { + $rest = 0; + $cnt = 0; + + /* dont use comments or empty lines */ + if((substr(trim($line),0,1)=="#")||(empty($line))){ + continue; } - } - /* cell count less than anz, attach some empty fields */ - if(($cnt != $anz)&&(!empty($cnt))) { - $rest = $anz - $cnt; - for($i = 0 ; $i < $rest ; $i ++){ - $data[] = " "; + /* replace \t to , */ + $line= str_replace ("\t" ,"" ,$line); + + /* get all elements */ + $cells = split(",",$line ) ; + + /* attach all elements to data array */ + if(is_array($cells)) + foreach($cells as $cell) { + if(!empty($cell)) { + $cnt++; + $data[]=trim($cell); + } + } + + /* cell count less than anz, attach some empty fields */ + if(($cnt != $anz)&&(!empty($cnt))) { + $rest = $anz - $cnt; + for($i = 0 ; $i < $rest ; $i ++){ + $data[] = " "; + } } - } - } + } unset($this->csvinfo['sorteddata']); unset($this->csvinfo['colsstr']); @@ -442,16 +444,16 @@ class csvimport extends plugin $i = 0; $tmp = $tmp2= array(); if(is_array($this->csvinfo['dataout'])) - foreach($this->csvinfo['dataout'] as $dat){ - $tmp[]= $dat; - $i++; - if($i >=$this->csvinfo['cols']){ - $i = 0; - $tmp2[] = $tmp; - $tmp = array(); - } + foreach($this->csvinfo['dataout'] as $dat){ + $tmp[]= $dat; + $i++; + if($i >=$this->csvinfo['cols']){ + $i = 0; + $tmp2[] = $tmp; + $tmp = array(); + } - } + } /* Set Templateid */ $smarty->assign("tplid",$this->csvinfo['tplid']); @@ -471,7 +473,7 @@ class csvimport extends plugin for($i = 0 ; $i < $anz; $i ++) $this->csvinfo['arr_selected'][]="0"; - + $smarty->assign("selectedattrs",$this->csvinfo['arr_selected']); /* Entrie count5 */ diff --git a/plugins/addons/ldapmanager/class_export.inc b/plugins/addons/ldapmanager/class_export.inc index 4ae91fadb..8f7dd4d39 100644 --- a/plugins/addons/ldapmanager/class_export.inc +++ b/plugins/addons/ldapmanager/class_export.inc @@ -1,12 +1,10 @@ config= $config; + /* set permissions */ $ui= get_userinfo(); - $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "ldifexport", $config->current['BASE']); - $this->access= $acl; + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $this->acl= get_module_permission($acl, "ldapmanager", $ui->dn); + } function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Set government mode */ $smarty= get_smarty(); $smarty->assign("type",FALSE); + $smarty->assign("depselectivbb",""); /* Check permissions for export */ - if ($this->access != '#all#'){ + if (chkacl($this->acl,"export")!=""){ print_red(_("You've no permission to do LDAP exports.")); } else { // fill in old vars in the Export form diff --git a/plugins/addons/ldapmanager/class_exportxls.inc b/plugins/addons/ldapmanager/class_exportxls.inc index 7e6e409e1..47a787064 100644 --- a/plugins/addons/ldapmanager/class_exportxls.inc +++ b/plugins/addons/ldapmanager/class_exportxls.inc @@ -17,10 +17,10 @@ class xlsexport extends plugin /* Include config object */ $this->config= $config; + /* set permissions */ $ui= get_userinfo(); - $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "ldifexport", $config->current['BASE']); - $this->access= $acl; + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $this->acl= get_module_permission($acl, "ldapmanager", $ui->dn); } function execute() @@ -32,9 +32,10 @@ class xlsexport extends plugin $smarty= get_smarty(); $smarty->assign("type",FALSE); + $smarty->assign("depselectivbb",""); /* Check permissions for export */ - if ($this->access != '#all#'){ + if (chkacl($this->acl,"xlsexport")!=""){ print_red(_("You've no permission to do LDAP exports.")); } else { // fill in old vars in the Export form diff --git a/plugins/addons/ldapmanager/class_import.inc b/plugins/addons/ldapmanager/class_import.inc index 2f09c76e7..ec5662c8a 100644 --- a/plugins/addons/ldapmanager/class_import.inc +++ b/plugins/addons/ldapmanager/class_import.inc @@ -16,16 +16,16 @@ class ldifimport extends plugin /* Include config object */ $this->config= $config; + /* set permissions */ $ui= get_userinfo(); - $acl= get_permissions ($config->current['BASE'], $ui->subtreeACL); - $acl= get_module_permission($acl, "ldifimport", $config->current['BASE']); - $this->access= $acl; + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $this->acl= get_module_permission($acl, "ldapmanager", $ui->dn); } function execute() { - /* Call parent execute */ - plugin::execute(); + /* Call parent execute */ + plugin::execute(); /* Set government mode */ $smarty= get_smarty(); @@ -37,7 +37,7 @@ class ldifimport extends plugin $smarty->assign("type",FALSE); /* Check permissions for export */ - if ($this->access != '#all#'){ + if (chkacl($this->acl,"import")!=""){ print_red(_("You've no permission to do LDAP imports.")); } else { if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))) @@ -45,8 +45,8 @@ class ldifimport extends plugin $smarty->assign("type","importfile"); - - $handle = NULL; + + $handle = NULL; // Check if there is a file submitted @@ -91,7 +91,7 @@ class ldifimport extends plugin if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false; // - $ErrorStr=""; + $ErrorStr=""; $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup); if($check == INSERT_OK ) @@ -111,7 +111,7 @@ class ldifimport extends plugin } } return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE))); - + } } diff --git a/plugins/addons/ldapmanager/main.inc b/plugins/addons/ldapmanager/main.inc index 0e071e1f9..ac00e86fe 100644 --- a/plugins/addons/ldapmanager/main.inc +++ b/plugins/addons/ldapmanager/main.inc @@ -30,12 +30,13 @@ if (!$remove_lock){ #print_red(_("Warning: Please check the SIZELIMIT option set on your LDAP server. You may not get all entries, if this value is to low!")); + /* set permissions */ + $acl= get_permissions ($ui->dn, $ui->subtreeACL); + $ldif->acl= get_module_permission($acl, "ldapmanager", $ui->dn); + /* Execute formular */ $display.= $ldif->execute (); - #$ldap= $config->get_ldap_link(); - #$display.= $ldap->gen_ldif("ou=People,ou=Technik,dc=gonicus,dc=de"); - $display.= "\n"; /* Store changes in session */ diff --git a/plugins/admin/groups/acl_definition.inc b/plugins/admin/groups/acl_definition.inc index fa5b8d622..d8b6d4863 100644 --- a/plugins/admin/groups/acl_definition.inc +++ b/plugins/admin/groups/acl_definition.inc @@ -291,5 +291,5 @@ $ACLD['fonreport'] = array("fonreport", "src", "dst", "channel", "lastapp", "di $ACLD['faxreport'] = array("faxreport"); $ACLD['logview'] = array("logview"); $ACLD['mailqueue'] = array("mailqueue"); -$ACLD['ldapmanager']= array("ldapmanager"); +$ACLD['ldapmanager']= array("ldapmanager","import","export","xlsexport","csvimport"); ?>