/** * \brief Retourne la liste des categories du type choisi * \param selected Id categorie preselectionnee * \param select_name Nom formulaire HTML */ function select_all_sections($selected='',$select_name='') { global $langs; $langs->load("ecm"); if ($select_name=="") $select_name="catParent"; $cat = new ECMDirectory($this->db); $cate_arbo = $cat->get_full_arbo(); $output = '<select class="flat" name="'.$select_name.'">'; if (is_array($cate_arbo)) { if (! sizeof($cate_arbo)) $output.= '<option value="-1" disabled="true">'.$langs->trans("NoCategoriesDefined").'</option>'; else { $output.= '<option value="-1"> </option>'; foreach($cate_arbo as $key => $value) { if ($cate_arbo[$key]['id'] == $selected) { $add = 'selected="selected" '; } else { $add = ''; } $output.= '<option '.$add.'value="'.$cate_arbo[$key]['id'].'">'.$cate_arbo[$key]['fulllabel'].'</option>'; } } } $output.= '</select>'; $output.= "\n"; return $output; }
$section=isset($_GET["section"])?$_GET["section"]:$_POST['section']; if (! $section) $section=0; $upload_dir = $conf->ecm->dir_output.'/'.$section; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; $ecmdir = new ECMDirectory($db); if (! empty($_REQUEST["section"])) { $result=$ecmdir->fetch($_REQUEST["section"]); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } } /******************************************************************* * ACTIONS * * Put here all code to do according to value of "action" parameter
$section=$_GET["section"]; if (! $section) $section='misc'; $upload_dir = $conf->ecm->dir_output.'/'.$section; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; $pageprev = $page - 1; $pagenext = $page + 1; if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="label"; $ecmdir = new ECMDirectory($db); if (! empty($_GET["section"])) { $result=$ecmdir->fetch($_GET["section"]); if (! $result > 0) { dol_print_error($db,$ecmdir->error); exit; } } /******************************************************************* * ACTIONS * * Put here all code to do according to value of "action" parameter
$head = ecm_prepare_head($ecmdir); dol_fiche_head($head, 'card', $langs->trans("ECMSectionManual"), '', 'dir'); if ($_GET["action"] == 'edit') { print '<form name="update" action="'.$_SERVER["PHP_SELF"].'" method="POST">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="section" value="'.$section.'">'; print '<input type="hidden" name="action" value="update">'; } print '<table class="border" width="100%">'; print '<tr><td width="30%">'.$langs->trans("Ref").'</td><td>'; $s=''; $tmpecmdir=new ECMDirectory($db); // Need to create a new one $tmpecmdir->fetch($ecmdir->id); $result = 1; $i=0; while ($tmpecmdir && $result > 0) { $tmpecmdir->ref=$tmpecmdir->label; if ($i == 0 && $_GET["action"] == 'edit') { $s='<input type="text" name="label" size="40" maxlength="32" value="'.$tmpecmdir->label.'">'; } else $s=$tmpecmdir->getNomUrl(1).$s; if ($tmpecmdir->fk_parent) { $s=' -> '.$s; $result=$tmpecmdir->fetch($tmpecmdir->fk_parent);
if (sizeof($filesarray)) { foreach ($filesarray as $key => $value) { //print "x ".$filesarray[$key]['fullname']."<br>\n"; if ($filesarray[$key]['type'] == 'dir') { $count += dol_delete_dir_recursive($filesarray[$key]['fullname']); } elseif ($filesarray[$key]['type'] == 'file') { // If (file that is not logfile) or (if logfile with option logfile) if ($filesarray[$key]['fullname'] != $filelog || $choice == 'logfile') { $count += dol_delete_file($filesarray[$key]['fullname']); } } } // Update cachenbofdoc if ($conf->ecm->enabled && $choice == 'allfiles') { require_once DOL_DOCUMENT_ROOT . "/ecm/class/ecmdirectory.class.php"; $ecmdirstatic = new ECMDirectory($db); $result = $ecmdirstatic->refreshcachenboffile(1); } } if ($count) { $message = $langs->trans("PurgeNDirectoriesDeleted", $count); } else { $message = $langs->trans("PurgeNothingToDelete"); } $message = '<div class="ok">' . $message . '</div>'; } /* * View */ llxHeader(); $html = new Form($db);
/** * 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; } } }
$section=GETPOST("section"); if (! $section) { dol_print_error('','Error, section parameter missing'); exit; } $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"]);
else { print '</td></tr>'; print '<tr>'; print '<td width="40%" valign="top" style="background: #FFFFFF" rowspan="2">'; } // Left area if (empty($action) || $action == 'file_manager' || preg_match('/refresh/i',$action) || $action == 'delete') { $userstatic = new User($db); $ecmdirstatic = new ECMDirectory($db); // Confirmation de la suppression d'une ligne categorie if ($_GET['action'] == 'delete_section') { $ret=$form->form_confirm($_SERVER["PHP_SELF"].'?section='.urlencode($_GET["section"]), $langs->trans('DeleteSection'), $langs->trans('ConfirmDeleteSection',$ecmdir->label), 'confirm_deletesection','','',1); if ($ret == 'html') print '<br>'; } print '<table width="100%" class="nobordernopadding">'; print '<tr class="liste_titre">'; print '<td class="liste_titre" align="left" colspan="6">'; print ' '.$langs->trans("ECMSections"); print '</td></tr>';