summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ad59d0e)
raw | patch | inline | side by side (parent: ad59d0e)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Nov 2005 06:45:40 +0000 (06:45 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Tue, 29 Nov 2005 06:45:40 +0000 (06:45 +0000) |
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@2107 594d385d-05f5-0310-b6e9-bd551577e9d8
plugins/addons/ldapmanager/class_csvimport.inc | patch | blob | history | |
plugins/addons/ldapmanager/contentcsv.tpl | patch | blob | history |
diff --git a/plugins/addons/ldapmanager/class_csvimport.inc b/plugins/addons/ldapmanager/class_csvimport.inc
index d9896c84e0f8c6d0b87253e3bc8a18dc1291e8d9..32c06780404650dba6a030aa4ed0aede4595ad01 100644 (file)
/* 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);
}
$arr_temp = array_flip($this->csvinfo['attr']);
- $this->csvinfo['arr_selected']= array(0,0,$arr_temp['uid'],$arr_temp['sn'],$arr_temp['givenName'],$arr_temp['userPassword']);
+ $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']);
$this->csvinfo['sorteddata'][$i]=array();
/* Go through every col */
- for($a = 1; $a <= ($this->csvinfo['cols']+1); $a ++) {
+ for($a = 0; $a <= ($this->csvinfo['cols']); $a ++) {
/* Append a status col at last, to show possibly errors */
- if($a==($this->csvinfo['cols']+1)){
+ 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-1)];
+ if(!empty($_POST[('row'.($a))])) {
+ $this->csvinfo['sorteddata'][$i][$this->csvinfo['attr'][$_POST[('row'.($a))]]]=$this->csvinfo['data'][($cc)];
}
}
}
/* 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']))){
/* Set all submitted vars */
+ if(is_array($keys))
foreach($keys as $key) {
if($key != "status"){
$this->usertab->$key = $dat[$key];
} else {
/* Reset vars */
+ if(is_array($keys))
foreach($keys as $key) {
if($key != "status"){
$this->usertab->by_object['user']->$key = $dat[$key];
/* Get Attributs for Tableheadline */
$this->csvinfo['colsstr'] = array();
- for($i =1; $i <= $this->csvinfo['cols']; $i++) {
+ 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++) {
- foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
- $dataouts[]=$dat;
+ if(is_array($this->csvinfo['sorteddata'][($i-1)])){
+ foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
+ $dataouts[]=$dat;
+ }
}
}
if($this->csvinfo['shownrowscount']> $this->csvinfo['rows'])$this->csvinfo['shownrowscount']=$this->csvinfo['rows'];
+ $dataouts = array();
for($i =$begin; $i <= $end; $i++) {
- foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
- $dataouts[]=$dat;
+ if(is_array($this->csvinfo['sorteddata'][($i-1)])){
+ foreach($this->csvinfo['sorteddata'][($i-1)] as $dat){
+ $dataouts[]=$dat;
+ }
}
}
}
$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",$dataouts);
+ $smarty->assign("data",$tmp3);
/* Set other vars */
$smarty->assign("i",1);
$data = array();
/* check colum count */
+ if(is_array($lines))
foreach($lines as $line) {
/* continue if theres a comment */
if(substr(trim($line),0,1)=="#"){
if($anz >1) {
/* Generate array with outpu info */
+ if(is_array($lines))
foreach($lines as $line) {
$rest = 0;
$cnt = 0;
$cells = split(",",$line ) ;
/* attach all elements to data array */
+ if(is_array($cells))
foreach($cells as $cell) {
if(!empty($cell)) {
$cnt++;
$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']);
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",$this->csvinfo['dataout']);
+ $smarty->assign("data",$tmp2);
@fclose($handle);
} else {
index 1f3ccebffb32f26a5a7ec5bc473ca981ec0d3e97..80ad3ec92ab780c2df8b1aec3bb64adf720005c2 100644 (file)
<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>
+<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>
- {section name=head loop=$head}
+ {foreach from=$head item=h}
<td bgcolor="#BBBBBB">
- <b>{$head[$i]}</b>
+ <b>{$h}</b>
</td>
- <!--{$i++}-->
- {/section}
+ {/foreach}
</tr>
{if $pointsbefore == TRUE}
<tr>
</tr>
{/if}
-
-
-
- {section name=row loop=$rows}
-
+ {foreach from=$data item=row key=key}
<tr>
- {section name=coll loop=$cols}
+ {foreach from=$data[$key] item=col key=key2}
<td bgcolor="#EEEEEE">
- {$data[$ie]}
+ {$data[$key][$key2]}
</td>
- <!--{$ie++}-->
- {/section}
-
+ {/foreach}
</tr>
- {/section}
+ {/foreach}
{if $pointsafter == TRUE}
<tr>
<td colspan={$i} bgcolor = "#EEEEEE">
<br>
<table summary="" cellspacing="1" border=0 cellpadding="4" bgcolor="#FEFEFE">
<tr>
- {section name=attr loop=$anz}
+ {foreach from=$data[0] item=item key=key}
<td bgcolor="#BBBBBB">
- <select name="row{$ia++}" size="1" title="">
- {html_options options=$attrs selected=$selectedattrs[$ia]}
+ <select name="row{$key}" size="1" title="">
+ {html_options options=$attrs selected=$selectedattrs[$key]}
</select>
</td>
- {/section}
+ {/foreach}
</tr>
- {section name=row loop=$rows}
+ {foreach from=$data item=val key=key}
<tr>
- {section name=coll loop=$anz}
+ {foreach from=$data[$key] item=val2 key=key2}
<td bgcolor="#EEEEEE">
- {$data[$i]}
+ {$data[$key][$key2]}
</td>
- <!--{$i++}-->
- {/section}
+ {/foreach}
</tr>
- {/section}
+ {/foreach}
</table>