diff --git a/phpwf/plugins/class.yui.php b/phpwf/plugins/class.yui.php index a276877c..bfe50fbd 100644 --- a/phpwf/plugins/class.yui.php +++ b/phpwf/plugins/class.yui.php @@ -14135,24 +14135,18 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $action = $this->app->Secure->GetGET("action"); $id = $this->app->Secure->GetGET("id"); if($id)$this->app->Tpl->Set('ID',$id); - if ($speichern != "") { - $titel = $this->app->Secure->GetPOST("titel"); - $beschreibung = $this->app->Secure->GetPOST("beschreibung"); - $stichwort = $this->app->Secure->GetPOST("stichwort"); - $this->app->Tpl->Set('TITLE', $titel); - $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung); - - if ($_FILES['upload']['tmp_name'] == "") { - $this->app->Tpl->Set('ERROR', "
Bitte wählen Sie eine Datei aus und laden Sie diese herauf!
"); - $this->app->erp->EnableTab("tabs-2"); - } else { - //$fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'],$titel,$beschreibung,"",$_FILES['upload']['tmp_name'],$this->app->User->GetName()); - $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $_FILES['upload']['name'], "Neue Version", $_FILES['upload']['tmp_name']); - header("Location: index.php?module=$module&action=$action&id=$id"); - exit; + // Get files here + if ($speichern != "") { + $retval = $this->FilesFromUploadtoDMS(null, null, $datei); + if ($retval !== true) { + $this->app->Tpl->Set('ERROR', implode(', ',$retval)); + $this->app->erp->EnableTab("tabs-2"); + } else { + header("Location: index.php?module=$module&action=$action&id=$id"); } } + $this->app->Tpl->Set('STARTDISABLE', ""); $this->app->Tpl->Parse($parsetarget, "datei_neudirekt.tpl"); @@ -14229,61 +14223,18 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl $id = $this->app->Secure->GetGET("id"); $sid = $this->app->Secure->GetGET("sid"); if($id)$this->app->Tpl->Set('ID', $id); + + // Get files here if ($speichern != "") { - if($parameter == '')$parameter = $id; - if(isset($_POST['dateiv'])) - { - foreach($_POST['dateiv'] as $k => $v) - { - $name = $this->app->DB->real_escape_string($_POST['dateiname'][$k]); - $titel = $this->app->DB->real_escape_string($_POST['dateititel'][$k]); - $beschreibung = $this->app->DB->real_escape_string($_POST['beschreibung'][$k]); - $stichwort = $this->app->DB->real_escape_string($_POST['dateistichwort'][$k]); - - //$getMime = explode('.', $name); - //$mime = end($getMime); - - $data = explode(',', $v); - - $encodedData = str_replace(' ','+',$data[1]); - $decodedData = base64_decode($encodedData); - - $this->app->Tpl->Set('TITLE', $titel); - $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung); - - if ($v == "" ) { - $this->app->Tpl->Set('ERROR', "
Keine Datei ausgewählt!
"); - $this->app->erp->EnableTab("tabs-2"); - } else { - $fileid = $this->app->erp->CreateDatei($name, $titel, $beschreibung, "", $decodedData, $this->app->User->GetName()); - - // stichwoerter hinzufuegen - $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter); - } - } - if($_FILES['upload']['tmp_name'] == "") - { - header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:'')); - } + if($parameter == '') { + $parameter = $id; } - - - - $titel = $this->app->Secure->GetPOST("titel"); - $beschreibung = $this->app->Secure->GetPOST("beschreibung"); - $stichwort = $this->app->Secure->GetPOST("stichwort"); - $this->app->Tpl->Set('TITLE', $titel); - $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung); - - if ($_FILES['upload']['tmp_name'] == "" && empty($_POST['dateiv'])) { - $this->app->Tpl->Set('ERROR', "
Keine Datei ausgewählt!
"); - $this->app->erp->EnableTab("tabs-2"); - } elseif($_FILES['upload']['tmp_name'] != '') { - $fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'], $titel, $beschreibung, "", $_FILES['upload']['tmp_name'], $this->app->User->GetName()); - - // stichwoerter hinzufuegen - $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter); - header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:'')); + $retval = $this->FilesFromUploadtoDMS($objekt, $parameter); + if ($retval !== true) { + $this->app->Tpl->Set('ERROR', implode(', ',$retval)); + $this->app->erp->EnableTab("tabs-2"); + } else { + header("Location: index.php?module=$_module&action=$_action&id=$id&sid=$sid".($typ!=''?"&typ=".$typ:'')); } } @@ -14551,6 +14502,87 @@ source: "index.php?module=ajax&action=filter&filtername=' . $filter . $extendurl } } + /* + * Retrieve uploaded files and put them into DMS + * $datei: given file, just add a new version + * Return array of errors or true + */ + function FilesFromUploadtoDMS($objekt, $parameter, $datei = false) { + + $retval = true; + // Files come from drag'n'drop + if(isset($_POST['dateiv'])) + { + foreach($_POST['dateiv'] as $k => $v) + { + $name = $this->app->DB->real_escape_string($_POST['dateiname'][$k]); + $titel = $this->app->DB->real_escape_string($_POST['dateititel'][$k]); + $beschreibung = $this->app->DB->real_escape_string($_POST['dateibeschreibung'][$k]); + $stichwort = $this->app->DB->real_escape_string($_POST['dateistichwort'][$k]); + + $data = explode(',', $v); + + $encodedData = str_replace(' ','+',$data[1]); + $decodedData = base64_decode($encodedData); + + $this->app->Tpl->Set('TITLE', $titel); + $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung); + + if ($v == "" ) { + $this->app->Tpl->Set('ERROR', "
Keine Datei ausgewählt!
"); + $this->app->erp->EnableTab("tabs-2"); + } else { + // Save file to disk first + $tempfilename = rtrim($this->app->erp->GetTMP(), '/') . "/" . $name; + if($handle = fopen($tempfilename, "wb")){ + fwrite($handle, $decodedData); + fclose($handle); + // Add file to DMS + if ($datei) { + $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $name, "Neue Version", $tempfilename); + } else { + $fileid = $this->app->erp->CreateDatei($name, $titel, $beschreibung, "", $tempfilename, $this->app->User->GetName()); + // stichwoerter hinzufuegen + $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter); + } + } else { + if ($retval === true) { + $retval = array(); + } + $retval[] = "
Datei konnte nicht gespeichert werden: ".$name."
"; + } + } + } + } // drag'n'drop + // Single file comes from browse button + else { + $titel = $this->app->Secure->GetPOST("titel"); + $beschreibung = $this->app->Secure->GetPOST("beschreibung"); + $stichwort = $this->app->Secure->GetPOST("stichwort"); + $this->app->Tpl->Set('TITLE', $titel); + $this->app->Tpl->Set('BESCHREIBUNG', $beschreibung); + + if ($_FILES['upload']['tmp_name'] == "" && empty($_POST['dateiv'])) { + $this->app->erp->EnableTab("tabs-2"); + if ($retval === true) { + $retval = array(); + } + $retval[] = "
Keine Datei ausgewählt!
"; + + } elseif ($_FILES['upload']['tmp_name'] != '') { + if ($datei) { + $this->app->erp->AddDateiVersion($datei, $this->app->User->GetName(), $_FILES['upload']['name'], "Neue Version", $_FILES['upload']['tmp_name']); + } + else { + $fileid = $this->app->erp->CreateDatei($_FILES['upload']['name'], $titel, $beschreibung, "", $_FILES['upload']['tmp_name'], $this->app->User->GetName()); + // stichwoerter hinzufuegen + $this->app->erp->AddDateiStichwort($fileid, $stichwort, $objekt, $parameter); + } + } + } + return($retval); + } + function SortListAdd($parsetarget, &$ref, $menu, $sql, $sort = true) { $module = $this->app->Secure->GetGET("module"); diff --git a/www/pages/content/datei_neudirekt.tpl b/www/pages/content/datei_neudirekt.tpl index f7200905..3321a05d 100644 --- a/www/pages/content/datei_neudirekt.tpl +++ b/www/pages/content/datei_neudirekt.tpl @@ -11,7 +11,7 @@ [ERROR] - +
{|Dateien hier einfügen|}
@@ -333,8 +333,8 @@ $(document).ready(function() { } } - $('#trdatei').before('Datei '+vorschau+''+filenameEncoded+'Titel: '); - }; + $('#trdatei').before(' Datei '+vorschau+' '+filenameEncoded+' Titel: {|Beschreibung|}: '); + }; })(files[index]); fileReader.readAsDataURL(file);