summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 08842f7)
raw | patch | inline | side by side (parent: 08842f7)
author | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:26:39 +0000 (08:26 +0000) | ||
committer | cajus <cajus@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Thu, 17 Jan 2008 08:26:39 +0000 (08:26 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@8430 594d385d-05f5-0310-b6e9-bd551577e9d8
22 files changed:
diff --git a/gosa-core/plugins/addons/ldapmanager/class_csvimport.inc b/gosa-core/plugins/addons/ldapmanager/class_csvimport.inc
+++ /dev/null
@@ -1,507 +0,0 @@
-<?php
-
-class csvimport extends plugin
-{
- /* Definitions */
- var $plHeadline= "LDIF export";
- var $plDescription= "This does something";
- var $access= "";
-
- /* Array with csv informations*/
- var $csvinfo=array();
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $view_logged = FALSE;
-
- function csvimport (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- /* initiate smarty */
- $smarty= get_smarty();
- $smarty->assign("selectedattrs",array(0=>""));
- $smarty->assign("data",array(0=>""));
- $smarty->assign("head",array(0=>""));
- $smarty->assign("sorted",0);
- $smarty->assign("fileup",0);
-
- /* Get the LDAP link, to generate the Export */
- $ldap = $this->config->get_ldap_link();
-
- $arrtemplates = array();
- $tempvar =0;
-
- /* Array to fill in Formfields */
- $arrtemplates[$tempvar] = "None";
- if(!is_array($this->csvinfo)){
- $this->csvinfo=array();
- }
-
- /* Set Usertemplate information and get all Attribute from userclass */
- unset ($this->csvinfo['arrtemplates']);
- unset ($this->csvinfo['arrtempls']);
-
- /* Generate Template Array, Attribute Array */
- if(!isset($this->csvinfo['arrtempls'])){
-
- /* Generating attributes */
- $attrs = @get_class_vars("user");
- $this->csvinfo['attr'] = $attrs['attributes'];
-
- /* Attach the choise none to discard a csv col */
- $new = array();
- $new[0]="none";
- $new[1]="userPassword";
- for($c = 0; $c < count($this->csvinfo['attr']);$c++){
- $new[$c+2]=$this->csvinfo['attr'][$c];
- }
-
- $this->csvinfo['attr'] = $new;
-
- /* Search all Templates */
- $this->csvinfo['templates'] = $ldap->search("(objectClass=gosaUserTemplate)",array("*"));
-
- /* Array to handle selected Form fiels */
- $this->csvinfo['arrtempls'][$tempvar]['name'] = "";
- $this->csvinfo['arrtempls'][$tempvar]['dn'] = "";
-
- $this->csvinfo['arrtemplates'][]="None";
-
- while($temp = $ldap->fetch($this->csvinfo['templates'])){
- $tempvar ++;
- $this->csvinfo['arrtemplates'][$tempvar] = $temp['sn'][0]." - ".$this->config->idepartments[preg_replace("/^[^,]+,".get_people_ou()."/i", "", $temp['dn'])];
- $this->csvinfo['arrtempls'] [$tempvar]['name'] = $temp['sn'][0];
- $this->csvinfo['arrtempls'] [$tempvar]['dn'] = $temp['dn'];
- }
- }
-
- $arr_temp = array_flip($this->csvinfo['attr']);
- $this->csvinfo['arr_selected']= array($arr_temp['uid'],$arr_temp['sn'],$arr_temp['givenName'],$arr_temp['userPassword']);
-
- $smarty->assign("templates",$this->csvinfo['arrtemplates']);
- $smarty->assign("attrs",$this->csvinfo['attr']);
-
- /* Check permissions for import */
- $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
- if(!preg_match("/w/",$acl)){
- if(isset($_POST['userfile']) || isset($_POST['sorted']) || isset($_POST['fileup'])){
- msg_dialog::display(_("Permission error"), _("You've no permission to import CSV files."), ERROR_DIALOG);
- }
- return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE)));
- }
-
- /* If the given dat from the csv File are sorted by the attributes */
- if(isset($_POST['sorted'])) {
-
- /* Template Handling */
- $smarty->assign("fileup",TRUE);
- $smarty->assign("sorted",TRUE);
-
- for($i = 0 ; $i < $this->csvinfo['rows'];$i++){
- /* Preparing given Data */
- $this->csvinfo['sorteddata'][$i]=array();
-
- /* Go through every col */
- for($a = 0; $a <= ($this->csvinfo['cols']); $a ++) {
- /* Append a status col at last, to show possibly errors */
- if($a==($this->csvinfo['cols'])){
- $this->csvinfo['sorteddata'][$i]["status"]="-";
- } else {
- $cc = ($i * ($this->csvinfo['cols']))+$a;
-
- /* If theres a Attribut given for this col */
- if(!empty($_POST[('row'.($a))])) {
- $this->csvinfo['sorteddata'][$i][$this->csvinfo['attr'][$_POST[('row'.($a))]]]=$this->csvinfo['data'][($cc)];
- }
- }
- }
- }
-
- /* aleast one entry */
- $rowcnt=0;
- if(isset($this->csvinfo['sorteddata'])){
- $rowcnt ++;
-
- /* Set the col count */
- $tblcolcount= count ($this->csvinfo['cols']);
-
- /* entrie count */
- $tbl_entries= count ($this->csvinfo['count']);
-
- /* row count */
- $tbl_rows = $tbl_entries / $tblcolcount;
-
- /* No error occurred */
- $failing = FALSE;
-
- /* For every row */
- for($i = 0; $i < $this->csvinfo['rows']; $i++){
-
- /* Get elemenet */
- $dat = $this->csvinfo['sorteddata'][$i];
-
- /* 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']))){
-
- /* Output Error */
- msg_dialog::display(_("Error"), _("Need at least 'sn', 'givenName' and 'uid' to create users."), ERROR_DIALOG);
- } else {
-
- /* Register usertab to trigger edit dialog */
- $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], 'new');
- $keys = array_keys($dat);
-
-
- /* Set all submitted vars */
- if(is_array($keys))
- foreach($keys as $key) {
- if($key != "status"){
- $this->usertab->$key = $dat[$key];
- }
- }
-
- /* Initialize template */
- if($this->csvinfo['tplid']!=0){
- $this->usertab->adapt_from_template($this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']);
- $this->usertab->save_object();
- } else {
-
- /* Reset vars */
- if(is_array($keys))
- foreach($keys as $key) {
- if($key != "status"){
- $this->usertab->by_object['user']->$key = $dat[$key];
- }
- }
- }
-
- // Setting user Password
- if((isset($dat['userPassword']))&&(!empty($dat['userPassword'])))
- $password = $dat['userPassword'];
- else
- {
- $rand_str="";
- $feed = "0123456789abcdefghijklmnopqrstuvwxyz";
- for ($i=0; $i < 8; $i++)
- {
- $rand_str .= substr($feed, rand(0, strlen($feed)-1), 1);
- }
- $password = $rand_str;
- }
-
- /* Insert in the LDAP tree */
- if(count($this->usertab->check())) {
- show_errors($this->usertab->check());
- $this->csvinfo['sorteddata'][$i]['status']="<b>"._("failed")."</b>";
- $failing = $i+1;
- break;
- } else {
- $this->csvinfo['sorteddata'][$i]['status']=_("ok");
- $this->usertab->save();
- change_password($this->usertab->dn,$password);
- }
- }
- }
-
- $pointsbefore = FALSE;
- $pointsafter = FALSE;
-
- /* Get Attributs for Tableheadline */
- $this->csvinfo['colsstr'] = array();
- for($i =0; $i <= $this->csvinfo['cols']; $i++) {
- if(!empty($_POST[('row'.$i)])){
- $this->csvinfo['colsstr'][$i] = $this->csvinfo['attr'][$_POST[('row'.$i)]];
- }
- }
-
- /*Create array with data for the template */
- if($failing == FALSE){
-
- $dataouts= array();
- for($i =1; $i <= $this->csvinfo['shownrowscount']; $i++) {
- if(is_array($this->csvinfo['sorteddata'][($i-1)])){
- foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
- $dataouts[]=$dat;
- }
- }
- }
-
- if($this->csvinfo['rows']> $this->csvinfo['shownrowscount']){
- $pointsafter = TRUE;
- }
- } else {
- $pointsbefore = TRUE;
- $pointsafter = TRUE;
-
- $begin = $failing -3;
-
- if($begin <0) {
- $begin =0;
- $pointsbefore = FALSE;
- }
-
- $end = $failing + 2;
-
- if($end > $this->csvinfo['rows']) {
- $end = $this->csvinfo['rows']+1;
- $pointsafter = FALSE;
- }
- $this->csvinfo['shownrowscount']=$end - $begin;
-
- if($this->csvinfo['shownrowscount']> $this->csvinfo['rows'])$this->csvinfo['shownrowscount']=$this->csvinfo['rows'];
-
- $dataouts = array();
- for($i =$begin; $i <= $end; $i++) {
- if(is_array($this->csvinfo['sorteddata'][($i-1)])){
- foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
- $dataouts[]=$dat;
- }
- }
- }
- }
- $tmparr2 = $this->csvinfo['colsstr'];
- $tmparr2[]=_("status");
-
- /* Error? */
- if ($failing){
- msg_dialog::display(_("Error"), sprintf(_("Cannot insert entry '%s'!"), $failing), ERROR_DIALOG);
- }
- $smarty->assign("error",$failing);
-
- /* Set vars to smarty */
- $smarty->assign("cols",count($tmparr2));
- $smarty->assign("anz" ,$this->csvinfo['count']);
- $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;
- }
- }
- $smarty->assign("head",$tmparr2);
- $smarty->assign("data",$tmp3);
-
- /* Set other vars */
- $smarty->assign("i",1);
- $smarty->assign("ie",0);
- $smarty->assign("tplid",$this->csvinfo['tplid']);
-
- $smarty->assign("pointsafter",$pointsafter);
- $smarty->assign("pointsbefore",$pointsbefore);
- } else {
- /* Set Template ID */
- $tplid = $_POST['tplid'];
-
-
- $smarty->assign("tpl",$arrtemplates[$tplid]);
- msg_dialog::display(_("Information"), _("Nothing to import!"), INFO_DIALOG);
- }
-
- /* If theres a File uploaded */
- } else {
- /* Check if theres a file uploaded */
- if(!empty($_FILES['userfile']['name'])){
-
- $handle = NULL;
-
- if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup'])))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- elseif(!$_FILES['userfile']['size'] > 0 )
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- /* Is there a tmp file, which we can use ? */
- elseif(!file_exists($_FILES['userfile']['tmp_name']))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- else
- {
- $smarty->assign("fileup",TRUE);
- $str = "";
-
-
- /* Reading content */
- while(!feof($handle)) {
- $str .= fread($handle,1024);
- }
-
- $lines = split("\n",$str);
- $anz = 0;
- $rest = 0;
- $data = array();
-
- /* check colum count */
- if(is_array($lines))
- foreach($lines as $line) {
- /* continue if theres a comment */
- if(substr(trim($line),0,1)=="#"){
- continue;
- }
-
- $line= str_replace ("\t","",$line);
- $cells = split(",",$line ) ;
-
- 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);
- }
- }
-
- /* 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']);
- unset($this->csvinfo['sorteddata']);
-
- $this->csvinfo['cols'] = $anz;
- $this->csvinfo['data'] = array();
- $this->csvinfo['data'] = $data;
- $this->csvinfo['count'] = count($this->csvinfo['data']);
-
- if($this->csvinfo['count']> (6* $this->csvinfo['cols'])) {
- /* only show 6 rows in ouptuttablei */
- $datouttemp = array_chunk($this->csvinfo['data'],(6* $this->csvinfo['cols']));
- $this->csvinfo['dataout']=$datouttemp[0];
- $this->csvinfo['shownrowscount'] = 6;
- } else {
- $this->csvinfo['shownrowscount'] = (count($this->csvinfo['data']))/$this->csvinfo['cols'];
- $this->csvinfo['dataout']= $this->csvinfo['data'];
- }
-
- $this->csvinfo['tplid'] = $_POST['template'];
- $this->csvinfo['templatestr'] = $this->csvinfo['arrtemplates' ][$this->csvinfo['tplid']];
- $this->csvinfo['count'] = count($this->csvinfo['data']);
- $this->csvinfo['rows'] = (count($this->csvinfo['data'])/$anz);
-
- $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();
- }
-
- }
-
- /* Set Templateid */
- $smarty->assign("tplid",$this->csvinfo['tplid']);
-
- /* Set Template */
- $smarty->assign("tpl",$this->csvinfo['templatestr']);
-
- /* Temp var 1 */
- $smarty->assign("ia",1);
-
- /* Temp var 2 */
- $smarty->assign("i",0);
-
- /* Num rows */
- $smarty->assign("rows",$this->csvinfo['shownrowscount']);
-
-
- for($i = 0 ; $i < $anz; $i ++)
- $this->csvinfo['arr_selected'][]="0";
-
- $smarty->assign("selectedattrs",$this->csvinfo['arr_selected']);
-
- /* Entrie count5 */
- $smarty->assign("anz",$this->csvinfo['cols']);
-
- /* Array with data */
- $smarty->assign("data",$tmp2);
-
- @fclose($handle);
- } else {
- $smarty->assign("tpl",$this->csvinfo['attr'][$_POST['template']]);
- $smarty->assign("LDIFError",TRUE);
- $smarty->assign("fileup",FALSE);
- msg_dialog::display(_("Error"), _("Cannot find CSV data in the selected file!"), ERROR_DIALOG);
- }
- }
- }
- }
-
- /* Show main page */
- return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE)));
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/class_export.inc b/gosa-core/plugins/addons/ldapmanager/class_export.inc
+++ /dev/null
@@ -1,125 +0,0 @@
-<?php
-
-class ldifexport extends plugin
-{
- /* Definitions */
- var $plHeadline= "CSV import";
- var $plDescription= "This does something";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $view_logged = FALSE;
-
- function ldifexport (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- /* Set government mode */
- $smarty= get_smarty();
-
- $smarty->assign("type",FALSE);
- $smarty->assign("depselectivbb","");
-
- // fill in old vars in the Export form
- if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
- $smarty->assign("single",$_POST['single']);
- $smarty->assign("type","single");
- $dn = $_POST['single'];
- }
- if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
- $smarty->assign("depselectfull",$_POST['selfull']);
- $smarty->assign("type","full");
- $dn = $_POST['selfull'];
- } else {
- $smarty->assign("depselectfull", "");
- }
- if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
- $smarty->assign("depselectivbb",$_POST['selivbb']);
- $smarty->assign("type","ivbb");
- $dn = $_POST['selivbb'];
- } else {
- $smarty->assign("depselectivbb", "");
- }
-
- // Set values for optionlist in form
- $bases = array();
- $acl_bases = $this->ui->get_module_departments("all");
- foreach($this->config->idepartments as $base_dn => $name){
- if(in_array_ics($base_dn,$acl_bases)){
- $bases[$base_dn] = $name;
- }
- }
- $smarty->assign("deplist", $bases);
-
- // Get the LDAP link, to generate the Export
- $ldap = $this->config->get_ldap_link();
-
- if ($this->config->current['GOVERNMENTMODE'] == 'true'){
- $smarty->assign ("govmode", "true");
- } else {
- $smarty->assign ("govmode", "false");
- }
-
- $smarty->assign("LDIFError",FALSE);
-
- if(isset($dn))
- {
- if(!($ldap->dn_exists($dn) && $dn != "")){
- $smarty->assign("LDIFError",TRUE);
- msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
- }
- }
-
- /* check alcs for given dn */
- $acls ="";
- if(isset($dn)){
- $acls = $this->ui->get_permissions($dn,"all/all");
- }
- if((!preg_match("/r/",$acls)) && (isset($dn))){
-
- /* Show error msg */
- msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
-
- /* Show main page */
- $smarty->assign("LDIFError",TRUE);
- $smarty->assign("para","");
- }else{
-
- // Export a single LDAP entry
- if(isset($_POST['sfrmgetsingle']))
- {
- $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single']));
- }
- elseif(isset($_POST['sfrmgetfull']))
- {
- $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
- }
- elseif(isset($_POST['sfrmgetivbb']))
- {
- $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
- }
- }
-
- /* Show main page */
- return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
- }
-}
-
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/class_exportxls.inc b/gosa-core/plugins/addons/ldapmanager/class_exportxls.inc
+++ /dev/null
@@ -1,141 +0,0 @@
-<?php
-
-class xlsexport extends plugin
-{
- /* Definitions */
- var $plHeadline= "XLS import";
- var $plDescription= "This does something";
- var $access= "";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $ui;
- var $view_logged = FALSE;
-
- function xlsexport (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- $dn = $this->config->current['BASE'];
-
- /* Set government mode */
- $smarty= get_smarty();
- $smarty->assign("type",FALSE);
- $smarty->assign("depselectivbb","");
-
- if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted";
-
- /* Check permissions for export */
- // fill in old vars in the Export form
- if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
- $smarty->assign("single",$_POST['single']);
- $smarty->assign("type","single");
- $a=$_POST['single'];
- $b=$_POST['selfull'];
-
- }
- if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
- $smarty->assign("depselectfull",$_POST['selfull']);
- $smarty->assign("type","full");
- $dn = $_POST['selfull'];
- } else {
- $smarty->assign("depselectfull", "");
- }
- if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
- $smarty->assign("depselectivbb",$_POST['selivbb']);
- $smarty->assign("type","ivbb");
- $dn = $_POST['selivbb'];
- } else {
- $smarty->assign("depselectivbb", "");
- }
-
- // Set values for optionlist in form
- $bases = array();
- $acl_bases = $this->ui->get_module_departments("all");
- foreach($this->config->idepartments as $base_dn => $name){
- if(in_array_ics($base_dn,$acl_bases)){
- $bases[$base_dn] = $name;
- }
- }
- $smarty->assign("deplist", $bases);
- $smarty->assign("choicelist",array( get_people_ou() =>"users" ,
- get_groups_ou() =>"groups" ,
- get_ou('systemsou') =>"computers",
- get_ou('serverou') =>"servers",
- "dc=addressbook," =>"addressbook"));
-
- // Get the LDAP link, to generate the Export
- $ldap = $this->config->get_ldap_link();
-
- if ($this->config->current['GOVERNMENTMODE'] == 'true'){
- $smarty->assign ("govmode", "true");
- } else {
- $smarty->assign ("govmode", "false");
- }
-
- $smarty->assign("LDIFError",FALSE);
-
- if(isset($dn))
- {
- if(!($ldap->dn_exists($dn) && $dn != "")){
- $smarty->assign("LDIFError",TRUE);
- msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
- }
- }
-
- /* check alcs for given dn */
- $acls ="";
- if(isset($dn)){
- $acls = $this->ui->get_permissions($dn,"all/all");
- }
-
- if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
-
- /* Show error msg */
- msg_dialog::display(_("Error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
-
- /* Show main page */
- $smarty->assign("LDIFError",TRUE);
- $smarty->assign("para","");
- }else{
-
- // Export a single LDAP entry
- if(isset($_POST['sfrmgetsingle']))
- {
- $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));
- }
- elseif(isset($_POST['sfrmgetfull']))
- {
- $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
- }
- elseif(isset($_POST['sfrmgetivbb']))
- {
- $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
- }
- }
-
- /* Show main page */
- return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
- }
-
-}
-
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/class_import.inc b/gosa-core/plugins/addons/ldapmanager/class_import.inc
+++ /dev/null
@@ -1,130 +0,0 @@
-<?php
-
-class ldifimport extends plugin
-{
- /* Definitions */
- var $plHeadline= "LDIF export";
- var $plDescription= "This does something";
- var $access= "";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $ui;
- var $view_logged = FALSE;
-
- function ldifimport (&$config, $dn= NULL)
- {
- /* Include config object */
- $this->config= &$config;
-
- $this->ui = get_userinfo();
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Log view */
- if(!$this->view_logged){
- $this->view_logged = TRUE;
- new log("view","all/".get_class($this),$this->dn);
- }
-
- /* Set government mode */
- $smarty= get_smarty();
-
- // Get the LDAP link, to generate the Export
- $ldap = $this->config->get_ldap_link();
-
- $smarty->assign("LDIFError",FALSE);
- $smarty->assign("type",FALSE);
-
- /* Get acls */
- $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
-
- /* Import requested check file and acls */
- if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){
-
- /* Check acls */
- if(!preg_match("/w/",$acl)){
- msg_dialog::display(_("Permission error"), _("You need full write access to the LDAP tree to import data!"), ERROR_DIALOG);
- }else{
-
- $smarty->assign("type","importfile");
- $handle = NULL;
-
- // Check if there is a file submitted
- if(!$_FILES['userfile']['size'] > 0 )
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
-
- // Is there a tmp file, which we can use ?
- elseif(!file_exists($_FILES['userfile']['tmp_name']))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
-
- }
-
- // Can we open the tmp file, for reading
- elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
- {
- msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
- $smarty->assign("LDIFError",TRUE);
- }
- else
- {
- // Everything just fine :)
- $str = "";
-
- // Reading content
- while(!feof($handle))
- {
- $str .= fread($handle,1024);
- }
- @fclose($handle);
-
- // Should we use Overwrite ?
- if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;;
- if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false;
-
- $ErrorStr="";
- $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup);
-
- if($check == INSERT_OK ){
- $smarty->assign("LDIFError",FALSE);
- } else {
- $smarty->assign("LDIFError",TRUE);
- }
-
- switch($check)
- {
- case INSERT_OK:
- break;
-
- case ALREADY_EXISTING_ENTRY:
- msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
- break;
-
- case UNKNOWN_TOKEN_IN_LDIF_FILE:
- msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
- break;
-
- default:
- msg_dialog::display(_("Internal error"), sprintf(_("Undefined flag '%s'!"), $check), ERROR_DIALOG);
- break;
- }
- }
- }
- }
- return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE)));
- }
-}
-
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/class_ldif.inc b/gosa-core/plugins/addons/ldapmanager/class_ldif.inc
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-class ldif extends plugin
-{
- /* Definitions */
- var $plHeadline= "LDAP manager";
- var $plDescription= "This does something";
-
- /* attribute list for save action */
- var $attributes= array();
- var $objectclasses= array();
- var $ldif;
-
- function ldif (&$config)
- {
- /* Include config object */
- $this->ldif= new ldiftab($config, $config->data['TABS']['LDIFTAB'], "");
- }
-
- function execute()
- {
- /* Call parent execute */
- plugin::execute();
-
- /* Show main page */
- return ($this->ldif->execute());
- }
-
- /* Return plugin informations for acl handling
- #FIXME You can only read attributes within this report plugin */
- static function plInfo()
- {
- return (array(
- "plShortName" => _("Ldap manager"),
- "plDescription" => "Dummy entry for menu creation functions, later",
- "plSelfModify" => FALSE,
- "plDepends" => array(),
- "plPriority" => 1,
- "plSection" => array("addon"),
- "plCategory" => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))),
-
- "plProvidedAcls" => array()
- ));
- }
-
-
-
-}
-
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/contentcsv.tpl b/gosa-core/plugins/addons/ldapmanager/contentcsv.tpl
+++ /dev/null
@@ -1,118 +0,0 @@
-<p>
- {t}The CSV import plugin provides methods to generate user accounts from a file containing Comma Seperated Values. The administrator can decide which columns should be transfered to which attribute. Note that you must have at least the UID, GIVENNAME and SURENAME set.{/t}
-</p>
-<p class="seperator"> </p>
-
-{if $fileup != TRUE}
-<table summary="">
- <tr>
- <td>
- <LABEL for="userfile">{t}Select CSV file to import{/t}</LABEL>
- </td>
- <td>
- <input type="hidden" name="MAX_FILE_SIZE" value="2097152">
- <input id="userfile" name="userfile" type="file" value="{t}Browse{/t}">
- </td>
- </tr>
- <tr>
- <td>
- <LABEL for="template">{t}Select template{/t}</LABEL>
- </td>
- <td>
- <select id="template" name="template" size="1" title="">
- {html_options options=$templates selected=""}
- </select>
- </td>
-
- </tr>
-</table>
-{elseif $sorted != FALSE}
-
-
-<br>
- {if $error == FALSE}
- <b>{t}All entries have been written to the LDAP database successfully.{/t}</b>
- {else}
- <b style="color:red">{t}Oups. There was an error during the import of your data.{/t}</b>
- {/if}
-
-<b>{t}Here is the status report for the import:{/t} </b>
-<br>
-<br>
-
-
- <table summary="" cellspacing="1" border=0 cellpadding="4" bgcolor="#FEFEFE">
- <tr>
- {foreach from=$head item=h}
- <td bgcolor="#BBBBBB">
- <b>{$h}</b>
- </td>
- {/foreach}
- </tr>
- {if $pointsbefore == TRUE}
- <tr>
- <td colspan={$i} bgcolor = "#EEEEEE">
- ...
- </td>
- </tr>
- {/if}
-
- {foreach from=$data item=row key=key}
- <tr>
- {foreach from=$data[$key] item=col key=key2}
- <td bgcolor="#EEEEEE">
- {$data[$key][$key2]}
- </td>
- {/foreach}
- </tr>
- {/foreach}
- {if $pointsafter == TRUE}
- <tr>
- <td colspan={$i} bgcolor = "#EEEEEE">
- ...
- </td>
- </tr>
- {/if}
-
- </table>
-
-{else}
-<br><b>{t}Selected Template{/t}:</b> {$tpl}
-<br>
-<br>
- <table summary="" cellspacing="1" border=0 cellpadding="4" bgcolor="#FEFEFE">
- <tr>
- {foreach from=$data[0] item=item key=key}
- <td bgcolor="#BBBBBB">
- <select name="row{$key}" size="1" title="">
- {html_options options=$attrs selected=$selectedattrs[$key]}
- </select>
- </td>
- {/foreach}
- </tr>
- {foreach from=$data item=val key=key}
- <tr>
- {foreach from=$data[$key] item=val2 key=key2}
- <td bgcolor="#EEEEEE">
- {$data[$key][$key2]}
- </td>
- {/foreach}
- </tr>
- {/foreach}
-
- </table>
-
-<!-- {html_table loop=$data cols=$anz table_attr='border="1"'}-->
-{/if}
-<p class="plugbottom">
-{if $fileup != TRUE}
- <input type="submit" value="{t}Import{/t}" name="fileup" >
-{else}
-{if $sorted == FALSE}
- <input name="sorted" value="{t}Import{/t}" type ="submit">
-{else}
- <input type=submit name="back{$plug}" value="{t}Back{/t}">
-{/if}
-{/if}
-</p>
-<input type="hidden" name="ignore">
diff --git a/gosa-core/plugins/addons/ldapmanager/contentexport.tpl b/gosa-core/plugins/addons/ldapmanager/contentexport.tpl
+++ /dev/null
@@ -1,73 +0,0 @@
-{if $LDIFError != FALSE || $type == FALSE}
-<p style="margin-top:5px;">
- {t}The LDIF export plugin provides methods to download a complete snapshot of the running LDAP directory as ldif. You may save these files for backup purpose or when initializing a new server.{/t}
-</p>
-<p class="seperator"> </p>
-
-<table summary="" style="width:100%;">
-<tr>
- <td width="30%">
- <LABEL for="text" >{t}Export single entry{/t}</LABEL>
- </td>
- <td>
- <input id="text" type="text" value="" name="single">
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetsingle">
- </td>
-</tr>
-<tr>
- <td width="30%">
- <LABEL for="selfull">{t}Export complete LDIF for{/t}</LABEL>
- </td>
- <td>
- <select id="selfull" name="selfull" size="1" title="{t}Choose the department you want to Export{/t}">
- {html_options options=$deplist selected=0}
- </select>
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetfull">
- </td>
-</tr>
-
-{if $govmode eq "true"}
-<tr>
- <td width="30%">
- <LABEL for="selivbb">{t}Export IVBB LDIF for{/t}</LABEL>
- </td>
- <td>
- <select id="selivbb" name="selivbb" size="1" title="{t}Choose the department you want to Export{/t}">
- {html_options options=$deplist selected=$depselectivbb}
- </select>
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetivbb">
- </td>
-</tr>
-{/if}
-</table>
-
-
-{else}
-
-
-<br>
- <h1>{t}Export successful{/t}</h1>
-<br>
- <div>
- <img alt="" border="0" align=middle src="images/filesaveas.png">
- <a href = "getldif.php{$para}" title="{t}Click here to save the complete LDAP database to a file{/t} ">{t}Click here to save the LDAP Export {/t}</a>
-
-
- <br>
- <br>
- </div>
- <div align="right">
- <input type="submit" value="{t}Back{/t}" name='back'>
- </div>
-{/if}
-<p class="plugbottom">
-
-</p>
-
-<input type="hidden" name="ignore">
diff --git a/gosa-core/plugins/addons/ldapmanager/contentexportxls.tpl b/gosa-core/plugins/addons/ldapmanager/contentexportxls.tpl
+++ /dev/null
@@ -1,76 +0,0 @@
-{if $LDIFError != FALSE || $type == FALSE}
-<p style="margin-top:5px;">
- {t}The XLS export plugin provides methods to download a complete snapshot of the running LDAP directory as xls. You may save these files for documentation.{/t}
-</p>
-<p class="seperator"> </p>
-
-<table summary="" style="width:100%;">
-<tr>
- <td width="30%">
- <LABEL for="single" >{t}Export single entry{/t}</LABEL>
- </td>
- <td>
- {*<input id="text" type="text" value="" name="single">*}
- <select id="single" name="single" size="1" title="{t}Choose the data you want to Export{/t}">
- {html_options options=$choicelist selected=0}
- </select>
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetsingle">
- </td>
-</tr>
-<tr>
- <td width="30%">
- <LABEL for="selfull">{t}Export complete XLS for{/t}</LABEL>
- </td>
- <td>
- <select id="selfull" name="selfull" size="1" title="{t}Choose the department you want to Export{/t}">
- {html_options options=$deplist selected=0}
- </select>
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetfull">
- </td>
-</tr>
-
-{if $govmode eq "true"}
-<tr>
- <td width="30%">
- <LABEL for="selivbb">{t}Export IVBB LDIF for{/t}</LABEL>
- </td>
- <td>
- <select id="selivbb" name="selivbb" size="1" title="{t}Choose the department you want to Export{/t}">
- {html_options options=$deplist selected=$depselectivbb}
- </select>
- </td>
- <td>
- <input type="submit" value="{t}Export{/t}" name="sfrmgetivbb">
- </td>
-</tr>
-{/if}
-</table>
-
-
-{else}
-
-
-<br>
- <h1>{t}Export successful{/t}</h1>
-<br>
- <div>
- <img alt="" border="0" align=middle src="images/filesaveas.png">
- <a href = "getxls.php{$para}" title="{t}Click here to save the complete LDAP database to a xls file{/t} ">{t}Click here to save the LDAP Export to a xls file{/t}</a>
-
-
- <br>
- <br>
- </div>
- <div align="right">
- <input type="submit" value="{t}Back{/t}" name='back'>
- </div>
-{/if}
-<p class="plugbottom">
-
-</p>
-
-<input type="hidden" name="ignore">
diff --git a/gosa-core/plugins/addons/ldapmanager/contentimport.tpl b/gosa-core/plugins/addons/ldapmanager/contentimport.tpl
+++ /dev/null
@@ -1,52 +0,0 @@
-{if $type == FALSE || $LDIFError != FALSE}
-<p style="margin-top:5px;">
- {t}The LDIF import plugin provides methods to upload a set of entries to your running LDAP directory as ldif. You may use this to add new or modify existing entries. Remember that GOsa will not check your ldifs for GOsa conformance.{/t}
-</p>
-
-<p class="seperator"> </p>
-<table summary="" width="100%">
-<tr>
- <td width="180">
- <LABEL for="userfile">{t}Import LDIF File{/t}</LABEL>
- </td>
- <td>
- <input type="hidden" name="ignore">
- <input type="hidden" name="MAX_FILE_SIZE" value="2097152">
- <input name="userfile" id="userfile" type="file" value="{t}Browse{/t}">
- </td>
-</tr>
-<tr>
- <td>
-
- </td>
- <td>
-<!-- <input type="checkbox" name="overwrite" value="1" id="overwrite">-->
- <input type="radio" name="overwrite" value="1" checked>{t}Modify existing objects, keep untouched attributes{/t}<br>
- <input type="radio" name="overwrite" value="0">{t}Overwrite existing objects, all not listed attributes will be removed{/t}
- </td>
-</tr>
-<tr>
- <td>
-
- </td>
- <td>
- <input type="checkbox" name="cleanup" value="1" id="cleanup">
- <LABEL for="cleanup">{t}Remove existing entries first{/t}</LABEL>
- </td>
-</tr>
-</table>
-{else}
-
-<br>
- <h1>{t}Import successful{/t}</h1>
-<br>
-
-<div align="right">
- <input type="submit" value="{t}Back{/t}" name='back'>
-</div>
-
-{/if}
-<p class="plugbottom">
-<input type="submit" value="{t}Import{/t}" name="fileup" >
-</p>
-<input type="hidden" name="ignore">
diff --git a/gosa-core/plugins/addons/ldapmanager/main.inc b/gosa-core/plugins/addons/ldapmanager/main.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-/*
- This code is part of GOsa (https://gosa.gonicus.de)
- Copyright (C) 2003 Cajus Pollmeier
-
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-*/
-
-if (!$remove_lock){
- /* Create phonelist object on demand */
- if (!session::is_set('ldif') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
- $ldif= new ldif ($config);
- $ldif->set_acl_category("logview");
- session::set('ldif',$ldif);
- }
- $ldif = session::get('ldif');
-
- /* Execute formular */
- $display= $ldif->execute ();
- $display.= "<input type=\"hidden\" name=\"ignore\">\n";
-
- /* Page header*/
- $display= print_header(get_template_path('images/ldif.png'), _("LDAP manager")).$display;
-
- /* Store changes in session */
- session::set('ldif',$ldif);
-}
-?>
diff --git a/gosa-core/plugins/addons/ldapmanager/tabs_ldif.inc b/gosa-core/plugins/addons/ldapmanager/tabs_ldif.inc
+++ /dev/null
@@ -1,24 +0,0 @@
-<?php
-
-class ldiftab extends tabs
-{
-
- function ldiftab($config, $data, $dn)
- {
- tabs::tabs($config, $data, $dn);
- }
-
- function save_object($save_current= FALSE)
- {
- tabs::save_object($save_current);
- }
-
-
- function save($ignore_account= FALSE)
- {
- }
-
-}
-
-// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
-?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_csvimport.inc
--- /dev/null
@@ -0,0 +1,507 @@
+<?php
+
+class csvimport extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "LDIF export";
+ var $plDescription= "This does something";
+ var $access= "";
+
+ /* Array with csv informations*/
+ var $csvinfo=array();
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $view_logged = FALSE;
+
+ function csvimport (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ /* initiate smarty */
+ $smarty= get_smarty();
+ $smarty->assign("selectedattrs",array(0=>""));
+ $smarty->assign("data",array(0=>""));
+ $smarty->assign("head",array(0=>""));
+ $smarty->assign("sorted",0);
+ $smarty->assign("fileup",0);
+
+ /* Get the LDAP link, to generate the Export */
+ $ldap = $this->config->get_ldap_link();
+
+ $arrtemplates = array();
+ $tempvar =0;
+
+ /* Array to fill in Formfields */
+ $arrtemplates[$tempvar] = "None";
+ if(!is_array($this->csvinfo)){
+ $this->csvinfo=array();
+ }
+
+ /* Set Usertemplate information and get all Attribute from userclass */
+ unset ($this->csvinfo['arrtemplates']);
+ unset ($this->csvinfo['arrtempls']);
+
+ /* Generate Template Array, Attribute Array */
+ if(!isset($this->csvinfo['arrtempls'])){
+
+ /* Generating attributes */
+ $attrs = @get_class_vars("user");
+ $this->csvinfo['attr'] = $attrs['attributes'];
+
+ /* Attach the choise none to discard a csv col */
+ $new = array();
+ $new[0]="none";
+ $new[1]="userPassword";
+ for($c = 0; $c < count($this->csvinfo['attr']);$c++){
+ $new[$c+2]=$this->csvinfo['attr'][$c];
+ }
+
+ $this->csvinfo['attr'] = $new;
+
+ /* Search all Templates */
+ $this->csvinfo['templates'] = $ldap->search("(objectClass=gosaUserTemplate)",array("*"));
+
+ /* Array to handle selected Form fiels */
+ $this->csvinfo['arrtempls'][$tempvar]['name'] = "";
+ $this->csvinfo['arrtempls'][$tempvar]['dn'] = "";
+
+ $this->csvinfo['arrtemplates'][]="None";
+
+ while($temp = $ldap->fetch($this->csvinfo['templates'])){
+ $tempvar ++;
+ $this->csvinfo['arrtemplates'][$tempvar] = $temp['sn'][0]." - ".$this->config->idepartments[preg_replace("/^[^,]+,".get_people_ou()."/i", "", $temp['dn'])];
+ $this->csvinfo['arrtempls'] [$tempvar]['name'] = $temp['sn'][0];
+ $this->csvinfo['arrtempls'] [$tempvar]['dn'] = $temp['dn'];
+ }
+ }
+
+ $arr_temp = array_flip($this->csvinfo['attr']);
+ $this->csvinfo['arr_selected']= array($arr_temp['uid'],$arr_temp['sn'],$arr_temp['givenName'],$arr_temp['userPassword']);
+
+ $smarty->assign("templates",$this->csvinfo['arrtemplates']);
+ $smarty->assign("attrs",$this->csvinfo['attr']);
+
+ /* Check permissions for import */
+ $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
+ if(!preg_match("/w/",$acl)){
+ if(isset($_POST['userfile']) || isset($_POST['sorted']) || isset($_POST['fileup'])){
+ msg_dialog::display(_("Permission error"), _("You've no permission to import CSV files."), ERROR_DIALOG);
+ }
+ return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE)));
+ }
+
+ /* If the given dat from the csv File are sorted by the attributes */
+ if(isset($_POST['sorted'])) {
+
+ /* Template Handling */
+ $smarty->assign("fileup",TRUE);
+ $smarty->assign("sorted",TRUE);
+
+ for($i = 0 ; $i < $this->csvinfo['rows'];$i++){
+ /* Preparing given Data */
+ $this->csvinfo['sorteddata'][$i]=array();
+
+ /* Go through every col */
+ for($a = 0; $a <= ($this->csvinfo['cols']); $a ++) {
+ /* Append a status col at last, to show possibly errors */
+ if($a==($this->csvinfo['cols'])){
+ $this->csvinfo['sorteddata'][$i]["status"]="-";
+ } else {
+ $cc = ($i * ($this->csvinfo['cols']))+$a;
+
+ /* If theres a Attribut given for this col */
+ if(!empty($_POST[('row'.($a))])) {
+ $this->csvinfo['sorteddata'][$i][$this->csvinfo['attr'][$_POST[('row'.($a))]]]=$this->csvinfo['data'][($cc)];
+ }
+ }
+ }
+ }
+
+ /* aleast one entry */
+ $rowcnt=0;
+ if(isset($this->csvinfo['sorteddata'])){
+ $rowcnt ++;
+
+ /* Set the col count */
+ $tblcolcount= count ($this->csvinfo['cols']);
+
+ /* entrie count */
+ $tbl_entries= count ($this->csvinfo['count']);
+
+ /* row count */
+ $tbl_rows = $tbl_entries / $tblcolcount;
+
+ /* No error occurred */
+ $failing = FALSE;
+
+ /* For every row */
+ for($i = 0; $i < $this->csvinfo['rows']; $i++){
+
+ /* Get elemenet */
+ $dat = $this->csvinfo['sorteddata'][$i];
+
+ /* 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']))){
+
+ /* Output Error */
+ msg_dialog::display(_("Error"), _("Need at least 'sn', 'givenName' and 'uid' to create users."), ERROR_DIALOG);
+ } else {
+
+ /* Register usertab to trigger edit dialog */
+ $this->usertab= new usertabs($this->config, $this->config->data['TABS']['USERTABS'], 'new');
+ $keys = array_keys($dat);
+
+
+ /* Set all submitted vars */
+ if(is_array($keys))
+ foreach($keys as $key) {
+ if($key != "status"){
+ $this->usertab->$key = $dat[$key];
+ }
+ }
+
+ /* Initialize template */
+ if($this->csvinfo['tplid']!=0){
+ $this->usertab->adapt_from_template($this->csvinfo['arrtempls'][$this->csvinfo['tplid']]['dn']);
+ $this->usertab->save_object();
+ } else {
+
+ /* Reset vars */
+ if(is_array($keys))
+ foreach($keys as $key) {
+ if($key != "status"){
+ $this->usertab->by_object['user']->$key = $dat[$key];
+ }
+ }
+ }
+
+ // Setting user Password
+ if((isset($dat['userPassword']))&&(!empty($dat['userPassword'])))
+ $password = $dat['userPassword'];
+ else
+ {
+ $rand_str="";
+ $feed = "0123456789abcdefghijklmnopqrstuvwxyz";
+ for ($i=0; $i < 8; $i++)
+ {
+ $rand_str .= substr($feed, rand(0, strlen($feed)-1), 1);
+ }
+ $password = $rand_str;
+ }
+
+ /* Insert in the LDAP tree */
+ if(count($this->usertab->check())) {
+ show_errors($this->usertab->check());
+ $this->csvinfo['sorteddata'][$i]['status']="<b>"._("failed")."</b>";
+ $failing = $i+1;
+ break;
+ } else {
+ $this->csvinfo['sorteddata'][$i]['status']=_("ok");
+ $this->usertab->save();
+ change_password($this->usertab->dn,$password);
+ }
+ }
+ }
+
+ $pointsbefore = FALSE;
+ $pointsafter = FALSE;
+
+ /* Get Attributs for Tableheadline */
+ $this->csvinfo['colsstr'] = array();
+ for($i =0; $i <= $this->csvinfo['cols']; $i++) {
+ if(!empty($_POST[('row'.$i)])){
+ $this->csvinfo['colsstr'][$i] = $this->csvinfo['attr'][$_POST[('row'.$i)]];
+ }
+ }
+
+ /*Create array with data for the template */
+ if($failing == FALSE){
+
+ $dataouts= array();
+ for($i =1; $i <= $this->csvinfo['shownrowscount']; $i++) {
+ if(is_array($this->csvinfo['sorteddata'][($i-1)])){
+ foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
+ $dataouts[]=$dat;
+ }
+ }
+ }
+
+ if($this->csvinfo['rows']> $this->csvinfo['shownrowscount']){
+ $pointsafter = TRUE;
+ }
+ } else {
+ $pointsbefore = TRUE;
+ $pointsafter = TRUE;
+
+ $begin = $failing -3;
+
+ if($begin <0) {
+ $begin =0;
+ $pointsbefore = FALSE;
+ }
+
+ $end = $failing + 2;
+
+ if($end > $this->csvinfo['rows']) {
+ $end = $this->csvinfo['rows']+1;
+ $pointsafter = FALSE;
+ }
+ $this->csvinfo['shownrowscount']=$end - $begin;
+
+ if($this->csvinfo['shownrowscount']> $this->csvinfo['rows'])$this->csvinfo['shownrowscount']=$this->csvinfo['rows'];
+
+ $dataouts = array();
+ for($i =$begin; $i <= $end; $i++) {
+ if(is_array($this->csvinfo['sorteddata'][($i-1)])){
+ foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
+ $dataouts[]=$dat;
+ }
+ }
+ }
+ }
+ $tmparr2 = $this->csvinfo['colsstr'];
+ $tmparr2[]=_("status");
+
+ /* Error? */
+ if ($failing){
+ msg_dialog::display(_("Error"), sprintf(_("Cannot insert entry '%s'!"), $failing), ERROR_DIALOG);
+ }
+ $smarty->assign("error",$failing);
+
+ /* Set vars to smarty */
+ $smarty->assign("cols",count($tmparr2));
+ $smarty->assign("anz" ,$this->csvinfo['count']);
+ $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;
+ }
+ }
+ $smarty->assign("head",$tmparr2);
+ $smarty->assign("data",$tmp3);
+
+ /* Set other vars */
+ $smarty->assign("i",1);
+ $smarty->assign("ie",0);
+ $smarty->assign("tplid",$this->csvinfo['tplid']);
+
+ $smarty->assign("pointsafter",$pointsafter);
+ $smarty->assign("pointsbefore",$pointsbefore);
+ } else {
+ /* Set Template ID */
+ $tplid = $_POST['tplid'];
+
+
+ $smarty->assign("tpl",$arrtemplates[$tplid]);
+ msg_dialog::display(_("Information"), _("Nothing to import!"), INFO_DIALOG);
+ }
+
+ /* If theres a File uploaded */
+ } else {
+ /* Check if theres a file uploaded */
+ if(!empty($_FILES['userfile']['name'])){
+
+ $handle = NULL;
+
+ if((!isset($_FILES['userfile']['name']))||(!isset($_POST['fileup'])))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ elseif(!$_FILES['userfile']['size'] > 0 )
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ /* Is there a tmp file, which we can use ? */
+ elseif(!file_exists($_FILES['userfile']['tmp_name']))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ else
+ {
+ $smarty->assign("fileup",TRUE);
+ $str = "";
+
+
+ /* Reading content */
+ while(!feof($handle)) {
+ $str .= fread($handle,1024);
+ }
+
+ $lines = split("\n",$str);
+ $anz = 0;
+ $rest = 0;
+ $data = array();
+
+ /* check colum count */
+ if(is_array($lines))
+ foreach($lines as $line) {
+ /* continue if theres a comment */
+ if(substr(trim($line),0,1)=="#"){
+ continue;
+ }
+
+ $line= str_replace ("\t","",$line);
+ $cells = split(",",$line ) ;
+
+ 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);
+ }
+ }
+
+ /* 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']);
+ unset($this->csvinfo['sorteddata']);
+
+ $this->csvinfo['cols'] = $anz;
+ $this->csvinfo['data'] = array();
+ $this->csvinfo['data'] = $data;
+ $this->csvinfo['count'] = count($this->csvinfo['data']);
+
+ if($this->csvinfo['count']> (6* $this->csvinfo['cols'])) {
+ /* only show 6 rows in ouptuttablei */
+ $datouttemp = array_chunk($this->csvinfo['data'],(6* $this->csvinfo['cols']));
+ $this->csvinfo['dataout']=$datouttemp[0];
+ $this->csvinfo['shownrowscount'] = 6;
+ } else {
+ $this->csvinfo['shownrowscount'] = (count($this->csvinfo['data']))/$this->csvinfo['cols'];
+ $this->csvinfo['dataout']= $this->csvinfo['data'];
+ }
+
+ $this->csvinfo['tplid'] = $_POST['template'];
+ $this->csvinfo['templatestr'] = $this->csvinfo['arrtemplates' ][$this->csvinfo['tplid']];
+ $this->csvinfo['count'] = count($this->csvinfo['data']);
+ $this->csvinfo['rows'] = (count($this->csvinfo['data'])/$anz);
+
+ $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();
+ }
+
+ }
+
+ /* Set Templateid */
+ $smarty->assign("tplid",$this->csvinfo['tplid']);
+
+ /* Set Template */
+ $smarty->assign("tpl",$this->csvinfo['templatestr']);
+
+ /* Temp var 1 */
+ $smarty->assign("ia",1);
+
+ /* Temp var 2 */
+ $smarty->assign("i",0);
+
+ /* Num rows */
+ $smarty->assign("rows",$this->csvinfo['shownrowscount']);
+
+
+ for($i = 0 ; $i < $anz; $i ++)
+ $this->csvinfo['arr_selected'][]="0";
+
+ $smarty->assign("selectedattrs",$this->csvinfo['arr_selected']);
+
+ /* Entrie count5 */
+ $smarty->assign("anz",$this->csvinfo['cols']);
+
+ /* Array with data */
+ $smarty->assign("data",$tmp2);
+
+ @fclose($handle);
+ } else {
+ $smarty->assign("tpl",$this->csvinfo['attr'][$_POST['template']]);
+ $smarty->assign("LDIFError",TRUE);
+ $smarty->assign("fileup",FALSE);
+ msg_dialog::display(_("Error"), _("Cannot find CSV data in the selected file!"), ERROR_DIALOG);
+ }
+ }
+ }
+ }
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('contentcsv.tpl', TRUE)));
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_export.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_export.inc
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+
+class ldifexport extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "CSV import";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $view_logged = FALSE;
+
+ function ldifexport (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ /* Set government mode */
+ $smarty= get_smarty();
+
+ $smarty->assign("type",FALSE);
+ $smarty->assign("depselectivbb","");
+
+ // fill in old vars in the Export form
+ if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
+ $smarty->assign("single",$_POST['single']);
+ $smarty->assign("type","single");
+ $dn = $_POST['single'];
+ }
+ if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
+ $smarty->assign("depselectfull",$_POST['selfull']);
+ $smarty->assign("type","full");
+ $dn = $_POST['selfull'];
+ } else {
+ $smarty->assign("depselectfull", "");
+ }
+ if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
+ $smarty->assign("depselectivbb",$_POST['selivbb']);
+ $smarty->assign("type","ivbb");
+ $dn = $_POST['selivbb'];
+ } else {
+ $smarty->assign("depselectivbb", "");
+ }
+
+ // Set values for optionlist in form
+ $bases = array();
+ $acl_bases = $this->ui->get_module_departments("all");
+ foreach($this->config->idepartments as $base_dn => $name){
+ if(in_array_ics($base_dn,$acl_bases)){
+ $bases[$base_dn] = $name;
+ }
+ }
+ $smarty->assign("deplist", $bases);
+
+ // Get the LDAP link, to generate the Export
+ $ldap = $this->config->get_ldap_link();
+
+ if ($this->config->current['GOVERNMENTMODE'] == 'true'){
+ $smarty->assign ("govmode", "true");
+ } else {
+ $smarty->assign ("govmode", "false");
+ }
+
+ $smarty->assign("LDIFError",FALSE);
+
+ if(isset($dn))
+ {
+ if(!($ldap->dn_exists($dn) && $dn != "")){
+ $smarty->assign("LDIFError",TRUE);
+ msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
+ }
+ }
+
+ /* check alcs for given dn */
+ $acls ="";
+ if(isset($dn)){
+ $acls = $this->ui->get_permissions($dn,"all/all");
+ }
+ if((!preg_match("/r/",$acls)) && (isset($dn))){
+
+ /* Show error msg */
+ msg_dialog::display(_("Permission error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
+
+ /* Show main page */
+ $smarty->assign("LDIFError",TRUE);
+ $smarty->assign("para","");
+ }else{
+
+ // Export a single LDAP entry
+ if(isset($_POST['sfrmgetsingle']))
+ {
+ $smarty->assign("para","?ivbb=2&dn=".base64_encode($_POST['single']));
+ }
+ elseif(isset($_POST['sfrmgetfull']))
+ {
+ $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
+ }
+ elseif(isset($_POST['sfrmgetivbb']))
+ {
+ $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
+ }
+ }
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('contentexport.tpl', TRUE)));
+ }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_exportxls.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_exportxls.inc
--- /dev/null
@@ -0,0 +1,141 @@
+<?php
+
+class xlsexport extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "XLS import";
+ var $plDescription= "This does something";
+ var $access= "";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $ui;
+ var $view_logged = FALSE;
+
+ function xlsexport (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ $dn = $this->config->current['BASE'];
+
+ /* Set government mode */
+ $smarty= get_smarty();
+ $smarty->assign("type",FALSE);
+ $smarty->assign("depselectivbb","");
+
+ if(!isset($_POST['selfull'])) $_POST['selfull'] = "Somehow not posted";
+
+ /* Check permissions for export */
+ // fill in old vars in the Export form
+ if((isset($_POST['single']))&&(isset($_POST['sfrmgetsingle']))){
+ $smarty->assign("single",$_POST['single']);
+ $smarty->assign("type","single");
+ $a=$_POST['single'];
+ $b=$_POST['selfull'];
+
+ }
+ if((isset($_POST['selfull']))&&(isset($_POST['sfrmgetfull']))){
+ $smarty->assign("depselectfull",$_POST['selfull']);
+ $smarty->assign("type","full");
+ $dn = $_POST['selfull'];
+ } else {
+ $smarty->assign("depselectfull", "");
+ }
+ if((isset($_POST['selivbb']))&&(isset($_POST['sfrmgetivbb']))){
+ $smarty->assign("depselectivbb",$_POST['selivbb']);
+ $smarty->assign("type","ivbb");
+ $dn = $_POST['selivbb'];
+ } else {
+ $smarty->assign("depselectivbb", "");
+ }
+
+ // Set values for optionlist in form
+ $bases = array();
+ $acl_bases = $this->ui->get_module_departments("all");
+ foreach($this->config->idepartments as $base_dn => $name){
+ if(in_array_ics($base_dn,$acl_bases)){
+ $bases[$base_dn] = $name;
+ }
+ }
+ $smarty->assign("deplist", $bases);
+ $smarty->assign("choicelist",array( get_people_ou() =>"users" ,
+ get_groups_ou() =>"groups" ,
+ get_ou('systemsou') =>"computers",
+ get_ou('serverou') =>"servers",
+ "dc=addressbook," =>"addressbook"));
+
+ // Get the LDAP link, to generate the Export
+ $ldap = $this->config->get_ldap_link();
+
+ if ($this->config->current['GOVERNMENTMODE'] == 'true'){
+ $smarty->assign ("govmode", "true");
+ } else {
+ $smarty->assign ("govmode", "false");
+ }
+
+ $smarty->assign("LDIFError",FALSE);
+
+ if(isset($dn))
+ {
+ if(!($ldap->dn_exists($dn) && $dn != "")){
+ $smarty->assign("LDIFError",TRUE);
+ msg_dialog::display(_("Error"), _("Cannot export selected entries!"), ERROR_DIALOG);
+ }
+ }
+
+ /* check alcs for given dn */
+ $acls ="";
+ if(isset($dn)){
+ $acls = $this->ui->get_permissions($dn,"all/all");
+ }
+
+ if(!preg_match("/r/",$acls) && (isset($_POST['sfrmgetsingle']) || isset($_POST['sfrmgetfull']) || isset($_POST['sfrmgetivbb']))){
+
+ /* Show error msg */
+ msg_dialog::display(_("Error"), sprintf(_("You have no permission to export '%s'!"),@LDAP::fix($dn)), ERROR_DIALOG);
+
+ /* Show main page */
+ $smarty->assign("LDIFError",TRUE);
+ $smarty->assign("para","");
+ }else{
+
+ // Export a single LDAP entry
+ if(isset($_POST['sfrmgetsingle']))
+ {
+ $smarty->assign("para","?ivbb=2&d=".base64_encode($_POST['single'])."&n=".base64_encode($_POST['selfull']));
+ }
+ elseif(isset($_POST['sfrmgetfull']))
+ {
+ $smarty->assign("para","?ivbb=3&dn=".base64_encode($_POST['selfull']));
+ }
+ elseif(isset($_POST['sfrmgetivbb']))
+ {
+ $smarty->assign("para","?ivbb=4&dn=".base64_encode($_POST['selivbb']));
+ }
+ }
+
+ /* Show main page */
+ return ($smarty->fetch (get_template_path('contentexportxls.tpl', TRUE)));
+ }
+
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_import.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_import.inc
--- /dev/null
@@ -0,0 +1,130 @@
+<?php
+
+class ldifimport extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "LDIF export";
+ var $plDescription= "This does something";
+ var $access= "";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $ui;
+ var $view_logged = FALSE;
+
+ function ldifimport (&$config, $dn= NULL)
+ {
+ /* Include config object */
+ $this->config= &$config;
+
+ $this->ui = get_userinfo();
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Log view */
+ if(!$this->view_logged){
+ $this->view_logged = TRUE;
+ new log("view","all/".get_class($this),$this->dn);
+ }
+
+ /* Set government mode */
+ $smarty= get_smarty();
+
+ // Get the LDAP link, to generate the Export
+ $ldap = $this->config->get_ldap_link();
+
+ $smarty->assign("LDIFError",FALSE);
+ $smarty->assign("type",FALSE);
+
+ /* Get acls */
+ $acl = $this->ui->get_permissions($this->config->current['BASE'],"all/all");
+
+ /* Import requested check file and acls */
+ if((isset($_FILES['userfile']['name']))&&(isset($_POST['fileup']))){
+
+ /* Check acls */
+ if(!preg_match("/w/",$acl)){
+ msg_dialog::display(_("Permission error"), _("You need full write access to the LDAP tree to import data!"), ERROR_DIALOG);
+ }else{
+
+ $smarty->assign("type","importfile");
+ $handle = NULL;
+
+ // Check if there is a file submitted
+ if(!$_FILES['userfile']['size'] > 0 )
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file is empty")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+
+ // Is there a tmp file, which we can use ?
+ elseif(!file_exists($_FILES['userfile']['tmp_name']))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not found")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+
+ }
+
+ // Can we open the tmp file, for reading
+ elseif(!$handle = @fopen($_FILES['userfile']['tmp_name'],"r"))
+ {
+ msg_dialog::display(_("Error"), sprintf(_("Cannot read uploaded file: %s"), _("file not readable")), ERROR_DIALOG);
+ $smarty->assign("LDIFError",TRUE);
+ }
+ else
+ {
+ // Everything just fine :)
+ $str = "";
+
+ // Reading content
+ while(!feof($handle))
+ {
+ $str .= fread($handle,1024);
+ }
+ @fclose($handle);
+
+ // Should we use Overwrite ?
+ if(!empty($_POST['overwrite'])) $overwrite = true; else $overwrite = false;;
+ if(!empty($_POST['cleanup'])) $cleanup = true; else $cleanup = false;
+
+ $ErrorStr="";
+ $check = $ldap->import_complete_ldif($str,$ErrorStr,$overwrite,$cleanup);
+
+ if($check == INSERT_OK ){
+ $smarty->assign("LDIFError",FALSE);
+ } else {
+ $smarty->assign("LDIFError",TRUE);
+ }
+
+ switch($check)
+ {
+ case INSERT_OK:
+ break;
+
+ case ALREADY_EXISTING_ENTRY:
+ msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
+ break;
+
+ case UNKNOWN_TOKEN_IN_LDIF_FILE:
+ msg_dialog::display(_("LDAP error"), $ErrorStr, ERROR_DIALOG);
+ break;
+
+ default:
+ msg_dialog::display(_("Internal error"), sprintf(_("Undefined flag '%s'!"), $check), ERROR_DIALOG);
+ break;
+ }
+ }
+ }
+ }
+ return ($smarty->fetch (get_template_path('contentimport.tpl', TRUE)));
+ }
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/class_ldif.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/class_ldif.inc
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+class ldif extends plugin
+{
+ /* Definitions */
+ var $plHeadline= "LDAP manager";
+ var $plDescription= "This does something";
+
+ /* attribute list for save action */
+ var $attributes= array();
+ var $objectclasses= array();
+ var $ldif;
+
+ function ldif (&$config)
+ {
+ /* Include config object */
+ $this->ldif= new ldiftab($config, $config->data['TABS']['LDIFTAB'], "");
+ }
+
+ function execute()
+ {
+ /* Call parent execute */
+ plugin::execute();
+
+ /* Show main page */
+ return ($this->ldif->execute());
+ }
+
+ /* Return plugin informations for acl handling
+ #FIXME You can only read attributes within this report plugin */
+ static function plInfo()
+ {
+ return (array(
+ "plShortName" => _("Ldap manager"),
+ "plDescription" => "Dummy entry for menu creation functions, later",
+ "plSelfModify" => FALSE,
+ "plDepends" => array(),
+ "plPriority" => 1,
+ "plSection" => array("addon"),
+ "plCategory" => array("ldapmanager" => array("objectClass" => "none", "description" => _("Ldap manager addon"))),
+
+ "plProvidedAcls" => array()
+ ));
+ }
+
+
+
+}
+
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/contentcsv.tpl b/gosa-plugins/ldapmanager/addons/ldapmanager/contentcsv.tpl
--- /dev/null
@@ -0,0 +1,118 @@
+<p>
+ {t}The CSV import plugin provides methods to generate user accounts from a file containing Comma Seperated Values. The administrator can decide which columns should be transfered to which attribute. Note that you must have at least the UID, GIVENNAME and SURENAME set.{/t}
+</p>
+<p class="seperator"> </p>
+
+{if $fileup != TRUE}
+<table summary="">
+ <tr>
+ <td>
+ <LABEL for="userfile">{t}Select CSV file to import{/t}</LABEL>
+ </td>
+ <td>
+ <input type="hidden" name="MAX_FILE_SIZE" value="2097152">
+ <input id="userfile" name="userfile" type="file" value="{t}Browse{/t}">
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <LABEL for="template">{t}Select template{/t}</LABEL>
+ </td>
+ <td>
+ <select id="template" name="template" size="1" title="">
+ {html_options options=$templates selected=""}
+ </select>
+ </td>
+
+ </tr>
+</table>
+{elseif $sorted != FALSE}
+
+
+<br>
+ {if $error == FALSE}
+ <b>{t}All entries have been written to the LDAP database successfully.{/t}</b>
+ {else}
+ <b style="color:red">{t}Oups. There was an error during the import of your data.{/t}</b>
+ {/if}
+
+<b>{t}Here is the status report for the import:{/t} </b>
+<br>
+<br>
+
+
+ <table summary="" cellspacing="1" border=0 cellpadding="4" bgcolor="#FEFEFE">
+ <tr>
+ {foreach from=$head item=h}
+ <td bgcolor="#BBBBBB">
+ <b>{$h}</b>
+ </td>
+ {/foreach}
+ </tr>
+ {if $pointsbefore == TRUE}
+ <tr>
+ <td colspan={$i} bgcolor = "#EEEEEE">
+ ...
+ </td>
+ </tr>
+ {/if}
+
+ {foreach from=$data item=row key=key}
+ <tr>
+ {foreach from=$data[$key] item=col key=key2}
+ <td bgcolor="#EEEEEE">
+ {$data[$key][$key2]}
+ </td>
+ {/foreach}
+ </tr>
+ {/foreach}
+ {if $pointsafter == TRUE}
+ <tr>
+ <td colspan={$i} bgcolor = "#EEEEEE">
+ ...
+ </td>
+ </tr>
+ {/if}
+
+ </table>
+
+{else}
+<br><b>{t}Selected Template{/t}:</b> {$tpl}
+<br>
+<br>
+ <table summary="" cellspacing="1" border=0 cellpadding="4" bgcolor="#FEFEFE">
+ <tr>
+ {foreach from=$data[0] item=item key=key}
+ <td bgcolor="#BBBBBB">
+ <select name="row{$key}" size="1" title="">
+ {html_options options=$attrs selected=$selectedattrs[$key]}
+ </select>
+ </td>
+ {/foreach}
+ </tr>
+ {foreach from=$data item=val key=key}
+ <tr>
+ {foreach from=$data[$key] item=val2 key=key2}
+ <td bgcolor="#EEEEEE">
+ {$data[$key][$key2]}
+ </td>
+ {/foreach}
+ </tr>
+ {/foreach}
+
+ </table>
+
+<!-- {html_table loop=$data cols=$anz table_attr='border="1"'}-->
+{/if}
+<p class="plugbottom">
+{if $fileup != TRUE}
+ <input type="submit" value="{t}Import{/t}" name="fileup" >
+{else}
+{if $sorted == FALSE}
+ <input name="sorted" value="{t}Import{/t}" type ="submit">
+{else}
+ <input type=submit name="back{$plug}" value="{t}Back{/t}">
+{/if}
+{/if}
+</p>
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/contentexport.tpl b/gosa-plugins/ldapmanager/addons/ldapmanager/contentexport.tpl
--- /dev/null
@@ -0,0 +1,73 @@
+{if $LDIFError != FALSE || $type == FALSE}
+<p style="margin-top:5px;">
+ {t}The LDIF export plugin provides methods to download a complete snapshot of the running LDAP directory as ldif. You may save these files for backup purpose or when initializing a new server.{/t}
+</p>
+<p class="seperator"> </p>
+
+<table summary="" style="width:100%;">
+<tr>
+ <td width="30%">
+ <LABEL for="text" >{t}Export single entry{/t}</LABEL>
+ </td>
+ <td>
+ <input id="text" type="text" value="" name="single">
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetsingle">
+ </td>
+</tr>
+<tr>
+ <td width="30%">
+ <LABEL for="selfull">{t}Export complete LDIF for{/t}</LABEL>
+ </td>
+ <td>
+ <select id="selfull" name="selfull" size="1" title="{t}Choose the department you want to Export{/t}">
+ {html_options options=$deplist selected=0}
+ </select>
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetfull">
+ </td>
+</tr>
+
+{if $govmode eq "true"}
+<tr>
+ <td width="30%">
+ <LABEL for="selivbb">{t}Export IVBB LDIF for{/t}</LABEL>
+ </td>
+ <td>
+ <select id="selivbb" name="selivbb" size="1" title="{t}Choose the department you want to Export{/t}">
+ {html_options options=$deplist selected=$depselectivbb}
+ </select>
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetivbb">
+ </td>
+</tr>
+{/if}
+</table>
+
+
+{else}
+
+
+<br>
+ <h1>{t}Export successful{/t}</h1>
+<br>
+ <div>
+ <img alt="" border="0" align=middle src="images/filesaveas.png">
+ <a href = "getldif.php{$para}" title="{t}Click here to save the complete LDAP database to a file{/t} ">{t}Click here to save the LDAP Export {/t}</a>
+
+
+ <br>
+ <br>
+ </div>
+ <div align="right">
+ <input type="submit" value="{t}Back{/t}" name='back'>
+ </div>
+{/if}
+<p class="plugbottom">
+
+</p>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/contentexportxls.tpl b/gosa-plugins/ldapmanager/addons/ldapmanager/contentexportxls.tpl
--- /dev/null
@@ -0,0 +1,76 @@
+{if $LDIFError != FALSE || $type == FALSE}
+<p style="margin-top:5px;">
+ {t}The XLS export plugin provides methods to download a complete snapshot of the running LDAP directory as xls. You may save these files for documentation.{/t}
+</p>
+<p class="seperator"> </p>
+
+<table summary="" style="width:100%;">
+<tr>
+ <td width="30%">
+ <LABEL for="single" >{t}Export single entry{/t}</LABEL>
+ </td>
+ <td>
+ {*<input id="text" type="text" value="" name="single">*}
+ <select id="single" name="single" size="1" title="{t}Choose the data you want to Export{/t}">
+ {html_options options=$choicelist selected=0}
+ </select>
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetsingle">
+ </td>
+</tr>
+<tr>
+ <td width="30%">
+ <LABEL for="selfull">{t}Export complete XLS for{/t}</LABEL>
+ </td>
+ <td>
+ <select id="selfull" name="selfull" size="1" title="{t}Choose the department you want to Export{/t}">
+ {html_options options=$deplist selected=0}
+ </select>
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetfull">
+ </td>
+</tr>
+
+{if $govmode eq "true"}
+<tr>
+ <td width="30%">
+ <LABEL for="selivbb">{t}Export IVBB LDIF for{/t}</LABEL>
+ </td>
+ <td>
+ <select id="selivbb" name="selivbb" size="1" title="{t}Choose the department you want to Export{/t}">
+ {html_options options=$deplist selected=$depselectivbb}
+ </select>
+ </td>
+ <td>
+ <input type="submit" value="{t}Export{/t}" name="sfrmgetivbb">
+ </td>
+</tr>
+{/if}
+</table>
+
+
+{else}
+
+
+<br>
+ <h1>{t}Export successful{/t}</h1>
+<br>
+ <div>
+ <img alt="" border="0" align=middle src="images/filesaveas.png">
+ <a href = "getxls.php{$para}" title="{t}Click here to save the complete LDAP database to a xls file{/t} ">{t}Click here to save the LDAP Export to a xls file{/t}</a>
+
+
+ <br>
+ <br>
+ </div>
+ <div align="right">
+ <input type="submit" value="{t}Back{/t}" name='back'>
+ </div>
+{/if}
+<p class="plugbottom">
+
+</p>
+
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/contentimport.tpl b/gosa-plugins/ldapmanager/addons/ldapmanager/contentimport.tpl
--- /dev/null
@@ -0,0 +1,52 @@
+{if $type == FALSE || $LDIFError != FALSE}
+<p style="margin-top:5px;">
+ {t}The LDIF import plugin provides methods to upload a set of entries to your running LDAP directory as ldif. You may use this to add new or modify existing entries. Remember that GOsa will not check your ldifs for GOsa conformance.{/t}
+</p>
+
+<p class="seperator"> </p>
+<table summary="" width="100%">
+<tr>
+ <td width="180">
+ <LABEL for="userfile">{t}Import LDIF File{/t}</LABEL>
+ </td>
+ <td>
+ <input type="hidden" name="ignore">
+ <input type="hidden" name="MAX_FILE_SIZE" value="2097152">
+ <input name="userfile" id="userfile" type="file" value="{t}Browse{/t}">
+ </td>
+</tr>
+<tr>
+ <td>
+
+ </td>
+ <td>
+<!-- <input type="checkbox" name="overwrite" value="1" id="overwrite">-->
+ <input type="radio" name="overwrite" value="1" checked>{t}Modify existing objects, keep untouched attributes{/t}<br>
+ <input type="radio" name="overwrite" value="0">{t}Overwrite existing objects, all not listed attributes will be removed{/t}
+ </td>
+</tr>
+<tr>
+ <td>
+
+ </td>
+ <td>
+ <input type="checkbox" name="cleanup" value="1" id="cleanup">
+ <LABEL for="cleanup">{t}Remove existing entries first{/t}</LABEL>
+ </td>
+</tr>
+</table>
+{else}
+
+<br>
+ <h1>{t}Import successful{/t}</h1>
+<br>
+
+<div align="right">
+ <input type="submit" value="{t}Back{/t}" name='back'>
+</div>
+
+{/if}
+<p class="plugbottom">
+<input type="submit" value="{t}Import{/t}" name="fileup" >
+</p>
+<input type="hidden" name="ignore">
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/main.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/main.inc
--- /dev/null
@@ -0,0 +1,40 @@
+<?php
+/*
+ This code is part of GOsa (https://gosa.gonicus.de)
+ Copyright (C) 2003 Cajus Pollmeier
+
+ 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
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+if (!$remove_lock){
+ /* Create phonelist object on demand */
+ if (!session::is_set('ldif') || (isset($_GET['reset']) && $_GET['reset'] == 1)){
+ $ldif= new ldif ($config);
+ $ldif->set_acl_category("logview");
+ session::set('ldif',$ldif);
+ }
+ $ldif = session::get('ldif');
+
+ /* Execute formular */
+ $display= $ldif->execute ();
+ $display.= "<input type=\"hidden\" name=\"ignore\">\n";
+
+ /* Page header*/
+ $display= print_header(get_template_path('images/ldif.png'), _("LDAP manager")).$display;
+
+ /* Store changes in session */
+ session::set('ldif',$ldif);
+}
+?>
diff --git a/gosa-plugins/ldapmanager/addons/ldapmanager/tabs_ldif.inc b/gosa-plugins/ldapmanager/addons/ldapmanager/tabs_ldif.inc
--- /dev/null
@@ -0,0 +1,24 @@
+<?php
+
+class ldiftab extends tabs
+{
+
+ function ldiftab($config, $data, $dn)
+ {
+ tabs::tabs($config, $data, $dn);
+ }
+
+ function save_object($save_current= FALSE)
+ {
+ tabs::save_object($save_current);
+ }
+
+
+ function save($ignore_account= FALSE)
+ {
+ }
+
+}
+
+// vim:tabstop=2:expandtab:shiftwidth=2:filetype=php:syntax:ruler:
+?>