print '</tr>'; $butshown++; } //if ($butshown % 2 == 1) // print '<td> </td><td> </td></tr>'; print '<tr '. $bc[false].'><td colspan="4" align="center"><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>'; print "</table></form>"; //print $langs->trans("ECMSectionAutoDesc"); print '</td><td valign="top">'; // Right area $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; $filearray=dol_dir_list($upload_dir,"files",0,'','\.meta$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $formfile=new FormFile($db); $param='&section='.$section; $textifempty=($section?$langs->trans("NoFileFound"):$langs->trans("ECMSelectASection")); $formfile->list_of_documents($filearray,'','ecm',$param,1,$relativepath,$user->rights->ecm->upload,1,$textifempty); // print '<table width="100%" class="border">'; // print '<tr><td> </td></tr></table>'; print '</td></tr>';
/** * Create record into database * @param user User that create * @return int <0 if KO, >0 if OK */ function create($user) { global $conf, $langs; $now=dol_now(); // Clean parameters $this->label=dol_sanitizeFileName(trim($this->label)); $this->fk_parent=trim($this->fk_parent); $this->description=trim($this->description); if (! $this->cachenbofdoc) $this->cachenbofdoc=0; $this->date_c=$now; $this->fk_user_c=$user->id; if ($this->fk_parent <= 0) $this->fk_parent=0; // Check if same directory does not exists with this name $relativepath=$this->label; if ($this->fk_parent) { $parent = new ECMDirectory($this->db); $parent->fetch($this->fk_parent); $relativepath=$parent->getRelativePath().$relativepath; } $relativepath=preg_replace('/([\/])+/i','/',$relativepath); // Avoid duplicate / or \ //print $relativepath.'<br>'; $cat = new ECMDirectory($this->db); $cate_arbo = $cat->get_full_arbo(1); $pathfound=0; foreach ($cate_arbo as $key => $categ) { $path=str_replace($this->forbiddenchars,'_',$categ['fulllabel']); //print $path.'<br>'; if ($path == $relativepath) { $pathfound=1; break; } } if ($pathfound) { $this->error="ErrorDirAlreadyExists"; dol_syslog("EcmDirectories::create ".$this->error, LOG_WARNING); return -1; } else { $this->db->begin(); // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."ecm_directories("; $sql.= "label,"; $sql.= "entity,"; $sql.= "fk_parent,"; $sql.= "description,"; $sql.= "cachenbofdoc,"; $sql.= "date_c,"; $sql.= "fk_user_c"; $sql.= ") VALUES ("; $sql.= " '".$this->db->escape($this->label)."',"; $sql.= " '".$conf->entity."',"; $sql.= " '".$this->fk_parent."',"; $sql.= " '".$this->db->escape($this->description)."',"; $sql.= " ".($this->cachenbofdoc).","; $sql.= " '".$this->db->idate($this->date_c)."',"; $sql.= " '".$this->fk_user_c."'"; $sql.= ")"; dol_syslog("EcmDirectories::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."ecm_directories"); $dir=$conf->ecm->dir_output.'/'.$this->getRelativePath(); $result=create_exdir($dir); // Appel des triggers include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); $interface=new Interfaces($this->db); $result=$interface->run_triggers('MYECMDIR_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers if (! $error) { $this->db->commit(); return $this->id; } else { $this->db->rollback(); return -1; } } else { $this->error="Error ".$this->db->lasterror(); dol_syslog("EcmDirectories::create ".$this->error, LOG_ERR); $this->db->rollback(); return -1; } } }
if (! $section) { dol_print_error('',"ErrorSectionParamNotDefined"); exit; } // Load ecm object $ecmdir = new ECMDirectory($db); $result=$ecmdir->fetch(GETPOST("section")); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; /******************************************************************* * ACTIONS * * Put here all code to do according to value of "action" parameter ********************************************************************/ // Upload file if (GETPOST("sendit") && ! empty($conf->global->MAIN_UPLOAD_DOC)) { require_once(DOL_DOCUMENT_ROOT."/lib/files.lib.php");
$urlfile=GETPOST("urlfile"); if (! $urlfile) { dol_print_error('',"ErrorParamNotDefined"); exit; } // Load ecm object $ecmdir = new ECMDirectory($db); $result=$ecmdir->fetch(GETPOST("section")); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } $relativepath=$ecmdir->getRelativePath(); $upload_dir = $conf->ecm->dir_output.'/'.$relativepath; /* $ecmfile = new ECMFile($db); if (! empty($_GET["fileid"])) { $result=$ecmfile->fetch($_GET["fileid"]); if (! $result > 0) { dol_print_error($db,$ecmfile->error); exit; } } */