2008-02-19 22:04:23 +01:00
< ? php
2016-07-30 15:51:27 +02:00
/* Copyright ( C ) 2008 - 2016 Laurent Destailleur < eldy @ users . sourceforge . net >
2008-02-25 00:29:30 +01:00
*
* 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
2013-01-16 15:36:08 +01:00
* the Free Software Foundation ; either version 3 of the License , or
2008-02-25 00:29:30 +01:00
* ( 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
2011-08-01 01:45:11 +02:00
* along with this program . If not , see < http :// www . gnu . org / licenses />.
2008-02-19 22:04:23 +01:00
*/
2008-04-29 23:13:49 +02:00
2008-02-19 22:04:23 +01:00
/**
2017-11-20 19:40:34 +01:00
* \file htdocs / ecm / dir_card . php
2008-10-26 00:36:33 +02:00
* \ingroup ecm
* \brief Card of a directory for ECM module
* \author Laurent Destailleur
*/
2012-08-22 23:24:21 +02:00
require '../main.inc.php' ;
2012-08-22 23:11:24 +02:00
require_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/ecm/class/ecmdirectory.class.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php' ;
require_once DOL_DOCUMENT_ROOT . '/core/lib/ecm.lib.php' ;
2008-02-25 00:29:30 +01:00
2018-05-26 16:03:19 +02:00
// Load translation files required by page
2018-05-26 15:41:32 +02:00
$langs -> loadLangs ( array ( 'ecm' , 'companies' , 'other' ));
2008-02-19 22:04:23 +01:00
2017-11-19 22:04:24 +01:00
$action = GETPOST ( 'action' , 'alpha' );
$cancel = GETPOST ( 'cancel' , 'aZ09' );
$backtopage = GETPOST ( 'backtopage' , 'alpha' );
$confirm = GETPOST ( 'confirm' , 'alpha' );
$module = GETPOST ( 'module' , 'alpha' );
$website = GETPOST ( 'website' , 'alpha' );
$pageid = GETPOST ( 'pageid' , 'int' );
if ( empty ( $module )) $module = 'ecm' ;
2012-07-30 22:38:21 +02:00
2008-04-29 23:13:49 +02:00
// Get parameters
2010-11-20 14:08:44 +01:00
$sortfield = GETPOST ( " sortfield " , 'alpha' );
$sortorder = GETPOST ( " sortorder " , 'alpha' );
$page = GETPOST ( " page " , 'int' );
2017-06-06 10:53:53 +02:00
if ( empty ( $page ) || $page == - 1 ) { $page = 0 ; } // If $page is not defined, or '' or -1
2010-11-20 14:08:44 +01:00
$offset = $conf -> liste_limit * $page ;
2008-04-29 23:13:49 +02:00
$pageprev = $page - 1 ;
$pagenext = $page + 1 ;
2010-11-20 14:08:44 +01:00
if ( ! $sortorder ) $sortorder = " ASC " ;
if ( ! $sortfield ) $sortfield = " name " ;
2008-04-29 23:13:49 +02:00
2017-11-19 22:04:24 +01:00
$section = GETPOST ( " section " , 'alpha' ) ? GETPOST ( " section " , 'alpha' ) : GETPOST ( " relativedir " , 'alpha' );
2008-02-25 00:29:30 +01:00
if ( ! $section )
{
2009-02-20 23:53:15 +01:00
dol_print_error ( '' , " ErrorSectionParamNotDefined " );
2008-02-25 00:29:30 +01:00
exit ;
}
2008-02-19 22:04:23 +01:00
2008-04-29 23:13:49 +02:00
// Load ecm object
2011-11-23 15:19:44 +01:00
$ecmdir = new EcmDirectory ( $db );
2017-11-19 22:04:24 +01:00
if ( $module == 'ecm' )
2008-04-29 23:13:49 +02:00
{
2017-11-19 22:04:24 +01:00
$result = $ecmdir -> fetch ( $section );
if ( ! $result > 0 )
{
dol_print_error ( $db , $ecmdir -> error );
exit ;
}
2018-01-07 19:38:20 +01:00
$relativepath = $ecmdir -> getRelativePath ();
2017-11-19 22:04:24 +01:00
$upload_dir = $conf -> ecm -> dir_output . '/' . $relativepath ;
}
else // For example $module == 'medias'
{
$relativepath = $section ;
$upload_dir = $conf -> medias -> multidir_output [ $conf -> entity ] . '/' . $relativepath ;
2008-04-29 23:13:49 +02:00
}
2008-02-19 22:04:23 +01:00
2018-01-07 19:38:20 +01:00
// Permissions
$permtoadd = 0 ;
$permtoupload = 0 ;
if ( $module == 'ecm' )
{
$permtoadd = $user -> rights -> ecm -> setup ;
$permtoupload = $user -> rights -> ecm -> upload ;
}
if ( $module == 'medias' )
{
$permtoadd = ( $user -> rights -> mailing -> creer || $user -> rights -> website -> write );
$permtoupload = ( $user -> rights -> mailing -> creer || $user -> rights -> website -> write );
}
2008-02-19 22:04:23 +01:00
2008-05-04 16:39:14 +02:00
2012-03-21 21:32:36 +01:00
/*
* Actions
*/
2008-02-19 22:04:23 +01:00
2010-10-03 17:42:01 +02:00
// Upload file
if ( GETPOST ( " sendit " ) && ! empty ( $conf -> global -> MAIN_UPLOAD_DOC ))
2008-02-19 22:04:23 +01:00
{
2012-02-19 18:34:22 +01:00
if ( dol_mkdir ( $upload_dir ) >= 0 )
2008-05-04 22:44:46 +02:00
{
2012-05-30 12:43:23 +02:00
$resupload = dol_move_uploaded_file ( $_FILES [ 'userfile' ][ 'tmp_name' ], $upload_dir . " / " . dol_unescapefile ( $_FILES [ 'userfile' ][ 'name' ]), 0 , 0 , $_FILES [ 'userfile' ][ 'error' ]);
2010-05-01 16:28:48 +02:00
if ( is_numeric ( $resupload ) && $resupload > 0 )
2008-05-04 22:44:46 +02:00
{
$result = $ecmdir -> changeNbOfFiles ( '+' );
}
2010-05-01 16:28:48 +02:00
else
2008-05-04 22:44:46 +02:00
{
2010-05-01 16:28:48 +02:00
$langs -> load ( " errors " );
if ( $resupload < 0 ) // Unknown error
{
2015-11-21 17:38:09 +01:00
setEventMessages ( $langs -> trans ( " ErrorFileNotUploaded " ), null , 'errors' );
2010-05-01 16:28:48 +02:00
}
else if ( preg_match ( '/ErrorFileIsInfectedWithAVirus/' , $resupload )) // Files infected by a virus
{
2015-11-21 17:38:09 +01:00
setEventMessages ( $langs -> trans ( " ErrorFileIsInfectedWithAVirus " ), null , 'errors' );
2010-05-01 16:28:48 +02:00
}
else // Known error
{
2015-11-21 17:38:09 +01:00
setEventMessages ( $langs -> trans ( $resupload ), null , 'errors' );
2010-05-01 16:28:48 +02:00
}
2008-05-04 22:44:46 +02:00
}
}
else
{
2015-11-21 17:38:09 +01:00
// Failed transfer (exceeding the limit file?)
2008-05-04 22:44:46 +02:00
$langs -> load ( " errors " );
2015-11-21 17:38:09 +01:00
setEventMessages ( $langs -> trans ( " ErrorFailToCreateDir " , $upload_dir ), null , 'errors' );
2008-05-04 22:44:46 +02:00
}
2008-02-19 22:04:23 +01:00
}
2008-04-30 01:49:00 +02:00
// Remove file
2012-07-30 22:38:21 +02:00
if ( $action == 'confirm_deletefile' && $confirm == 'yes' )
2008-02-19 22:04:23 +01:00
{
2012-05-29 23:50:13 +02:00
$langs -> load ( " other " );
$file = $upload_dir . " / " . GETPOST ( 'urlfile' ); // Do not use urldecode here ($_GET and $_REQUEST are already decoded by PHP).
2012-07-29 16:11:52 +02:00
$ret = dol_delete_file ( $file );
2015-12-04 19:45:39 +01:00
if ( $ret ) setEventMessages ( $langs -> trans ( " FileWasRemoved " , GETPOST ( 'urlfile' )), null , 'mesgs' );
else setEventMessages ( $langs -> trans ( " ErrorFailToDeleteFile " , GETPOST ( 'urlfile' )), null , 'errors' );
2009-05-06 15:39:43 +02:00
2012-05-29 23:50:13 +02:00
$result = $ecmdir -> changeNbOfFiles ( '-' );
2008-02-19 22:04:23 +01:00
}
2008-04-30 01:49:00 +02:00
// Remove dir
2012-07-30 22:38:21 +02:00
if ( $action == 'confirm_deletedir' && $confirm == 'yes' )
2008-04-30 01:49:00 +02:00
{
2017-12-27 20:17:08 +01:00
$backtourl = DOL_URL_ROOT . " /ecm/index.php " ;
if ( $module == 'medias' ) $backtourl = DOL_URL_ROOT . " /website/index.php?file_manager=1 " ;
2018-02-19 23:52:45 +01:00
$deletedirrecursive = ( GETPOST ( 'deletedirrecursive' , 'alpha' ) == 'on' ? 1 : 0 );
2017-12-27 20:17:08 +01:00
if ( $module == 'ecm' )
{
// Fetch was already done
2018-02-19 23:52:45 +01:00
$result = $ecmdir -> delete ( $user , 'all' , $deletedirrecursive );
2018-02-19 23:31:35 +01:00
if ( $result <= 0 )
{
$langs -> load ( 'errors' );
setEventMessages ( $langs -> trans ( $ecmdir -> error , $ecmdir -> label ), null , 'errors' );
}
2017-12-27 20:17:08 +01:00
}
else
{
2018-02-19 23:52:45 +01:00
if ( $deletedirrecursive )
{
$resbool = dol_delete_dir_recursive ( $upload_dir , 0 , 1 );
}
else
{
$resbool = dol_delete_dir ( $upload_dir , 1 );
}
2017-12-27 20:17:08 +01:00
if ( $resbool ) $result = 1 ;
2018-02-19 23:31:35 +01:00
else
{
$langs -> load ( 'errors' );
setEventMessages ( $langs -> trans ( " ErrorFailToDeleteDir " , $upload_dir ), null , 'errors' );
$result = 0 ;
}
2017-12-27 20:17:08 +01:00
}
2009-12-15 11:37:54 +01:00
if ( $result > 0 )
{
2017-12-27 20:17:08 +01:00
header ( " Location: " . $backtourl );
2009-12-15 11:37:54 +01:00
exit ;
}
2008-04-30 01:49:00 +02:00
}
2008-02-19 22:04:23 +01:00
2018-01-07 19:38:20 +01:00
// Update dirname or description
2017-09-15 10:50:50 +02:00
if ( $action == 'update' && ! GETPOST ( 'cancel' , 'alpha' ))
2008-04-30 01:49:00 +02:00
{
2010-10-03 18:59:24 +02:00
$error = 0 ;
2018-01-07 19:38:20 +01:00
if ( $module == 'ecm' )
{
$oldlabel = $ecmdir -> label ;
$olddir = $ecmdir -> getRelativePath ( 0 );
$olddir = $conf -> ecm -> dir_output . '/' . $olddir ;
}
else
{
$olddir = GETPOST ( 'section' , 'alpha' );
$olddir = $conf -> medias -> multidir_output [ $conf -> entity ] . '/' . $relativepath ;
}
if ( $module == 'ecm' )
{
$db -> begin ();
2009-05-06 15:39:43 +02:00
2018-01-07 19:38:20 +01:00
// Fetch was already done
$ecmdir -> label = dol_sanitizeFileName ( GETPOST ( " label " ));
$ecmdir -> description = GETPOST ( " description " );
$result = $ecmdir -> update ( $user );
if ( $result > 0 )
2008-05-04 18:48:12 +02:00
{
2018-01-07 19:38:20 +01:00
// Try to rename file if changed
if ( $oldlabel != $ecmdir -> label && file_exists ( $olddir ))
2008-05-04 18:48:12 +02:00
{
2018-01-07 19:38:20 +01:00
$newdir = $ecmdir -> getRelativePath ( 1 ); // return "xxx/zzz/" from ecm directory
$newdir = $conf -> ecm -> dir_output . '/' . $newdir ;
//print $olddir.'-'.$newdir;
$result =@ rename ( $olddir , $newdir );
if ( ! $result )
{
$langs -> load ( 'errors' );
setEventMessages ( $langs -> trans ( 'ErrorFailToRenameDir' , $olddir , $newdir ), null , 'errors' );
$error ++ ;
}
2008-05-04 18:48:12 +02:00
}
2009-05-06 15:39:43 +02:00
2018-01-07 19:38:20 +01:00
if ( ! $error )
{
$db -> commit ();
2009-05-06 15:39:43 +02:00
2018-01-07 19:38:20 +01:00
// Set new value after renaming
$relativepath = $ecmdir -> getRelativePath ();
$upload_dir = $conf -> ecm -> dir_output . '/' . $relativepath ;
}
else
{
$db -> rollback ();
}
2008-05-04 18:48:12 +02:00
}
else
{
$db -> rollback ();
2018-01-07 19:38:20 +01:00
setEventMessages ( $ecmdir -> error , $ecmdir -> errors , 'errors' );
2009-05-06 15:39:43 +02:00
}
2018-01-07 19:38:20 +01:00
}
else
{
$newdir = $conf -> medias -> multidir_output [ $conf -> entity ] . '/' . GETPOST ( 'oldrelparentdir' , 'alpha' ) . '/' . GETPOST ( 'label' , 'alpha' );
$result =@ rename ( $olddir , $newdir );
if ( ! $result )
{
$langs -> load ( 'errors' );
setEventMessages ( $langs -> trans ( 'ErrorFailToRenameDir' , $olddir , $newdir ), null , 'errors' );
$error ++ ;
}
if ( ! $error )
{
// Set new value after renaming
$relativepath = GETPOST ( 'oldrelparentdir' , 'alpha' ) . '/' . GETPOST ( 'label' , 'alpha' );
$upload_dir = $conf -> medias -> multidir_output [ $conf -> entity ] . '/' . $relativepath ;
$section = $relativepath ;
}
}
2008-04-30 01:49:00 +02:00
}
2008-02-19 22:04:23 +01:00
/*******************************************************************
2017-08-01 18:32:21 +02:00
* View
2008-02-19 22:04:23 +01:00
********************************************************************/
$form = new Form ( $db );
2018-01-07 19:38:20 +01:00
$object = new EcmDirectory ( $db ); // Need to create a new one instance
if ( $module == 'ecm' )
{
$object -> fetch ( $ecmdir -> id );
}
2017-08-01 18:32:21 +02:00
llxHeader ();
2008-02-19 22:04:23 +01:00
2015-11-21 17:38:09 +01:00
// Built the file List
2018-02-19 23:31:35 +01:00
$filearrayall = dol_dir_list ( $upload_dir , " all " , 0 , '' , '' , $sortfield ,( strtolower ( $sortorder ) == 'desc' ? SORT_DESC : SORT_ASC ), 1 );
2017-04-12 11:30:33 +02:00
$filearray = dol_dir_list ( $upload_dir , " files " , 0 , '' , '(\.meta|_preview.*\.png)$' , $sortfield ,( strtolower ( $sortorder ) == 'desc' ? SORT_DESC : SORT_ASC ), 1 );
2008-05-04 15:33:49 +02:00
$totalsize = 0 ;
foreach ( $filearray as $key => $file )
{
$totalsize += $file [ 'size' ];
}
2008-02-19 22:04:23 +01:00
2017-11-20 18:19:41 +01:00
$head = ecm_prepare_head ( $ecmdir , $module , $section );
2017-08-01 18:32:21 +02:00
dol_fiche_head ( $head , 'card' , $langs -> trans ( " ECMSectionManual " ), - 1 , 'dir' );
2008-02-19 22:04:23 +01:00
2012-07-30 22:38:21 +02:00
if ( $action == 'edit' )
2008-04-30 01:49:00 +02:00
{
print '<form name="update" action="' . $_SERVER [ " PHP_SELF " ] . '" method="POST">' ;
2009-05-17 10:01:54 +02:00
print '<input type="hidden" name="token" value="' . $_SESSION [ 'newtoken' ] . '">' ;
2009-05-06 15:39:43 +02:00
print '<input type="hidden" name="section" value="' . $section . '">' ;
2017-11-20 18:19:41 +01:00
print '<input type="hidden" name="module" value="' . $module . '">' ;
2009-05-06 15:39:43 +02:00
print '<input type="hidden" name="action" value="update">' ;
2008-04-30 01:49:00 +02:00
}
2008-02-19 22:04:23 +01:00
2017-11-20 18:19:41 +01:00
$morehtml = '' ;
$morehtmlref = '/' . $module . '/' . $relativepath ;
if ( $module == 'ecm' )
2008-04-28 23:56:42 +02:00
{
2017-11-20 18:19:41 +01:00
$s = '' ;
$result = 1 ;
$i = 0 ;
$tmpecmdir = new EcmDirectory ( $db ); // Need to create a new one
$tmpecmdir -> fetch ( $ecmdir -> id );
while ( $tmpecmdir && $result > 0 )
2008-04-28 23:56:42 +02:00
{
2017-11-20 18:19:41 +01:00
$tmpecmdir -> ref = $tmpecmdir -> label ;
if ( $i == 0 && $action == 'edit' )
{
$s = '<input type="text" name="label" class="minwidth300" maxlength="32" value="' . $tmpecmdir -> label . '">' ;
}
else $s = $tmpecmdir -> getNomUrl ( 1 ) . $s ;
if ( $tmpecmdir -> fk_parent )
{
$s = ' -> ' . $s ;
$result = $tmpecmdir -> fetch ( $tmpecmdir -> fk_parent );
}
else
{
$tmpecmdir = 0 ;
}
$i ++ ;
2008-04-28 23:56:42 +02:00
}
2017-11-20 18:19:41 +01:00
$morehtmlref = '<a href="' . DOL_URL_ROOT . '/ecm/index.php">' . $langs -> trans ( " ECMRoot " ) . '</a> -> ' . $s ;
2008-04-28 23:56:42 +02:00
}
2018-01-07 19:38:20 +01:00
if ( $module == 'medias' )
{
$s = 'medias -> ' ;
$result = 1 ;
$subdirs = explode ( '/' , $section );
$i = 0 ;
foreach ( $subdirs as $subdir )
{
if ( $i == ( count ( $subdirs ) - 1 ))
{
if ( $action == 'edit' )
{
$s .= '<input type="text" name="label" class="minwidth300" maxlength="32" value="' . $subdir . '">' ;
$s .= '<input type="hidden" name="oldrelparentdir" value="' . dirname ( $section ) . '">' ;
$s .= '<input type="hidden" name="oldreldir" value="' . basename ( $section ) . '">' ;
}
else $s .= $subdir ;
}
if ( $i < ( count ( $subdirs ) - 1 ))
{
$s .= $subdir . ' -> ' ;
}
$i ++ ;
}
2008-05-04 16:39:14 +02:00
2018-01-07 19:38:20 +01:00
$morehtmlref = $s ;
}
2017-08-01 18:32:21 +02:00
dol_banner_tab ( $object , '' , $morehtml , 0 , '' , '' , $morehtmlref );
print '<div class="fichecenter">' ;
print '<div class="underbanner clearboth"></div>' ;
2017-11-19 22:04:24 +01:00
print '<table class="border centpercent">' ;
2017-08-01 18:32:21 +02:00
/* print '<tr><td class="titlefield">' . $langs -> trans ( " Ref " ) . '</td><td>' ;
2008-05-04 15:33:49 +02:00
print img_picto ( '' , 'object_dir' ) . ' <a href="' . DOL_URL_ROOT . '/ecm/index.php">' . $langs -> trans ( " ECMRoot " ) . '</a> -> ' ;
2008-04-28 23:56:42 +02:00
print $s ;
2017-08-01 18:32:21 +02:00
print '</td></tr>' ; */
2017-11-19 22:04:24 +01:00
if ( $module == 'ecm' )
{
print '<tr><td class="titlefield tdtop">' . $langs -> trans ( " Description " ) . '</td><td>' ;
if ( $action == 'edit' )
{
print '<textarea class="flat quatrevingtpercent" name="description">' ;
print $ecmdir -> description ;
print '</textarea>' ;
}
else print dol_nl2br ( $ecmdir -> description );
print '</td></tr>' ;
print '<tr><td class="titlefield">' . $langs -> trans ( " ECMCreationUser " ) . '</td><td>' ;
$userecm = new User ( $db );
$userecm -> fetch ( $ecmdir -> fk_user_c );
print $userecm -> getNomUrl ( 1 );
print '</td></tr>' ;
}
print '<tr><td class="titlefield">' . $langs -> trans ( " ECMCreationDate " ) . '</td><td>' ;
if ( $module == 'ecm' )
2008-04-30 01:49:00 +02:00
{
2017-11-19 22:04:24 +01:00
print dol_print_date ( $ecmdir -> date_c , 'dayhour' );
}
else
{
//var_dump($upload_dir);
print dol_print_date ( dol_filemtime ( $upload_dir ), 'dayhour' );
2008-04-30 01:49:00 +02:00
}
2008-04-28 23:56:42 +02:00
print '</td></tr>' ;
2008-04-29 23:13:49 +02:00
print '<tr><td>' . $langs -> trans ( " ECMDirectoryForFiles " ) . '</td><td>' ;
2017-11-20 18:19:41 +01:00
if ( $module == 'ecm' )
{
print '/ecm/' . $relativepath ;
}
else
{
print '/' . $module . '/' . $relativepath ;
}
2008-04-29 23:13:49 +02:00
print '</td></tr>' ;
2008-04-28 23:56:42 +02:00
print '<tr><td>' . $langs -> trans ( " ECMNbOfDocs " ) . '</td><td>' ;
2016-07-30 15:51:27 +02:00
$nbofiles = count ( $filearray );
print $nbofiles ;
2017-11-20 18:19:41 +01:00
if ( $ecmdir -> id > 0 )
2016-07-30 15:51:27 +02:00
{
2017-11-20 18:19:41 +01:00
// Test if nb is same than in cache
if ( $nbofiles != $ecmdir -> cachenbofdoc )
{
$ecmdir -> changeNbOfFiles (( string ) $nbofiles );
}
2016-07-30 15:51:27 +02:00
}
2008-04-28 23:56:42 +02:00
print '</td></tr>' ;
print '<tr><td>' . $langs -> trans ( " TotalSizeOfAttachedFiles " ) . '</td><td>' ;
2008-04-29 23:13:49 +02:00
print dol_print_size ( $totalsize );
2008-04-28 23:56:42 +02:00
print '</td></tr>' ;
2017-08-01 18:32:21 +02:00
print '</table>' ;
2012-07-30 22:38:21 +02:00
if ( $action == 'edit' )
2008-04-30 01:49:00 +02:00
{
2017-08-01 18:32:21 +02:00
print '<br><div align="center">' ;
2008-04-30 01:49:00 +02:00
print '<input type="submit" class="button" name="submit" value="' . $langs -> trans ( " Save " ) . '">' ;
print ' ' ;
print '<input type="submit" class="button" name="cancel" value="' . $langs -> trans ( " Cancel " ) . '">' ;
2017-08-01 18:32:21 +02:00
print '</div>' ;
2008-04-30 01:49:00 +02:00
}
2017-08-01 18:32:21 +02:00
print '</div>' ;
2012-07-30 22:38:21 +02:00
if ( $action == 'edit' )
2008-04-30 01:49:00 +02:00
{
print '</form>' ;
}
2017-08-01 18:32:21 +02:00
dol_fiche_end ();
2008-02-19 22:04:23 +01:00
2008-05-04 18:48:12 +02:00
2008-04-30 01:49:00 +02:00
// Actions buttons
2012-07-30 22:38:21 +02:00
if ( $action != 'edit' && $action != 'delete' )
2008-04-30 01:49:00 +02:00
{
print '<div class="tabsAction">' ;
2009-05-06 15:39:43 +02:00
2018-01-07 19:38:20 +01:00
if ( $permtoadd )
2008-04-30 01:49:00 +02:00
{
2017-11-19 22:04:24 +01:00
print '<a class="butAction" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=edit' . ( $module ? '&module=' . $module : '' ) . '§ion=' . $section . '">' . $langs -> trans ( 'Edit' ) . '</a>' ;
2008-04-30 01:49:00 +02:00
}
2009-05-06 15:39:43 +02:00
2018-01-07 19:38:20 +01:00
if ( $permtoadd )
2010-07-16 19:28:34 +02:00
{
2017-11-20 19:40:34 +01:00
print '<a class="butAction" href="' . DOL_URL_ROOT . '/ecm/dir_add_card.php?action=create' . ( $module ? '&module=' . $module : '' ) . '&catParent=' . $section . '">' . $langs -> trans ( 'ECMAddSection' ) . '</a>' ;
2010-07-16 19:28:34 +02:00
}
else
{
print '<a class="butActionRefused" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( 'ECMAddSection' ) . '</a>' ;
}
2018-02-19 23:52:45 +01:00
//if (count($filearrayall) == 0)
//{
2018-01-07 19:38:20 +01:00
if ( $permtoadd )
2008-04-30 01:49:00 +02:00
{
2017-11-19 22:04:24 +01:00
print '<a class="butActionDelete" href="' . $_SERVER [ 'PHP_SELF' ] . '?action=delete_dir' . ( $module ? '&module=' . $module : '' ) . '§ion=' . $section . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
2008-04-30 01:49:00 +02:00
}
else
{
print '<a class="butActionDeleteRefused" href="#" title="' . $langs -> trans ( " NotAllowed " ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
}
2018-02-19 23:52:45 +01:00
/* }
2008-04-30 01:49:00 +02:00
else
{
2018-02-19 23:31:35 +01:00
if ( count ( $filearray ) > 0 )
print '<a class="butActionRefused" href="#" title="' . $langs -> trans ( " CannotRemoveDirectoryContainsFiles " ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
else
print '<a class="butActionRefused" href="#" title="' . $langs -> trans ( " CannotRemoveDirectoryContainsFilesOrDirs " ) . '">' . $langs -> trans ( 'Delete' ) . '</a>' ;
2018-02-19 23:52:45 +01:00
} */
2008-04-30 01:49:00 +02:00
print '</div>' ;
}
2008-02-19 22:04:23 +01:00
2008-04-30 01:49:00 +02:00
// Confirm remove file
2012-07-30 22:38:21 +02:00
if ( $action == 'delete' )
2008-04-28 23:56:42 +02:00
{
2017-11-19 22:04:24 +01:00
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?section=' . GETPOST ( " section " , 'alpha' ) . '&urlfile=' . urlencode ( $_GET [ " urlfile " ]), $langs -> trans ( 'DeleteFile' ), $langs -> trans ( 'ConfirmDeleteFile' ), 'confirm_deletefile' );
2008-04-28 23:56:42 +02:00
}
2008-04-30 01:49:00 +02:00
// Confirm remove file
2012-07-30 22:38:21 +02:00
if ( $action == 'delete_dir' )
2008-04-30 01:49:00 +02:00
{
2010-10-03 17:42:01 +02:00
$relativepathwithoutslash = preg_replace ( '/[\/]$/' , '' , $relativepath );
2018-02-19 23:52:45 +01:00
//Form to close proposal (signed or not)
if ( count ( $filearrayall ) > 0 )
{
$langs -> load ( " other " );
$formquestion = array (
array ( 'type' => 'checkbox' , 'name' => 'deletedirrecursive' , 'label' => $langs -> trans ( " ContentOfDirectoryIsNotEmpty " ) . '<br>' . $langs -> trans ( " DeleteAlsoContentRecursively " ), 'value' => '0' ) // Field to complete private note (not replace)
);
}
print $form -> formconfirm ( $_SERVER [ " PHP_SELF " ] . '?section=' . GETPOST ( 'section' , 'alpha' ) . ( $module ? '&module=' . $module : '' ), $langs -> trans ( 'DeleteSection' ), $langs -> trans ( 'ConfirmDeleteSection' , $relativepathwithoutslash ), 'confirm_deletedir' , $formquestion , 1 , 1 );
2008-04-30 01:49:00 +02:00
}
2008-02-19 22:04:23 +01:00
2008-10-26 02:30:58 +01:00
/*
2017-11-19 22:04:24 +01:00
$formfile = new FormFile ( $db );
2015-11-21 17:38:09 +01:00
// Display upload form
2008-12-16 20:12:42 +01:00
if ( $user -> rights -> ecm -> upload )
2008-05-04 18:09:54 +02:00
{
2017-11-20 19:40:34 +01:00
$formfile -> form_attach_new_file ( DOL_URL_ROOT . '/ecm/dir_card.php' , '' , 0 , $section );
2008-05-04 18:09:54 +02:00
}
2008-04-29 23:13:49 +02:00
2008-05-04 16:24:29 +02:00
// List of document
2011-05-25 12:35:57 +02:00
if ( $user -> rights -> ecm -> read )
2008-05-04 18:09:54 +02:00
{
$param = '&section=' . $section ;
2008-12-16 20:12:42 +01:00
$formfile -> list_of_documents ( $filearray , '' , 'ecm' , $param , 1 , $relativepath , $user -> rights -> ecm -> upload );
2008-05-04 18:09:54 +02:00
}
2008-10-26 02:30:58 +01:00
*/
2008-02-19 22:04:23 +01:00
// End of page
2011-08-27 16:24:16 +02:00
llxFooter ();
2015-12-11 19:37:12 +01:00
$db -> close ();