NEW Generated files are now indexed in database
This commit is contained in:
parent
097b660c41
commit
260beed512
@ -440,26 +440,26 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
|
||||
$outputlangs->setDefaultLang($newlang);
|
||||
}
|
||||
|
||||
if(!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT)) {
|
||||
if (!empty($conf->global->USE_PDFTK_FOR_PDF_CONCAT))
|
||||
{
|
||||
// Create output dir if not exists
|
||||
dol_mkdir($diroutputmassaction);
|
||||
|
||||
// Defined name of merged file
|
||||
$filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
|
||||
$filename=preg_replace('/\s/','_',$filename);
|
||||
|
||||
// Save merged file
|
||||
if ($filter=='paye:0')
|
||||
{
|
||||
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
|
||||
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
|
||||
}
|
||||
if ($year) $filename.='_'.$year;
|
||||
if ($month) $filename.='_'.$month;
|
||||
dol_mkdir($diroutputmassaction);
|
||||
|
||||
// Defined name of merged file
|
||||
$filename=strtolower(dol_sanitizeFileName($langs->transnoentities($objectlabel)));
|
||||
$filename=preg_replace('/\s/','_',$filename);
|
||||
|
||||
// Save merged file
|
||||
if ($filter=='paye:0')
|
||||
{
|
||||
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
|
||||
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
|
||||
}
|
||||
if ($year) $filename.='_'.$year;
|
||||
if ($month) $filename.='_'.$month;
|
||||
|
||||
if (count($files)>0)
|
||||
{
|
||||
|
||||
$now=dol_now();
|
||||
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
|
||||
|
||||
@ -474,14 +474,13 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$langs->load("exports");
|
||||
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
|
||||
$langs->load("exports");
|
||||
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans('NoPDFAvailableForDocGenAmongChecked'), null, 'errors');
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
// Create empty PDF
|
||||
@ -519,18 +518,18 @@ if (! $error && $massaction == "builddoc" && $permtoread && ! GETPOST('button_se
|
||||
// Save merged file
|
||||
if ($filter=='paye:0')
|
||||
{
|
||||
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
|
||||
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
|
||||
if ($option=='late') $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid"))).'_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Late")));
|
||||
else $filename.='_'.strtolower(dol_sanitizeFileName($langs->transnoentities("Unpaid")));
|
||||
}
|
||||
if ($year) $filename.='_'.$year;
|
||||
if ($month) $filename.='_'.$month;
|
||||
if ($pagecount)
|
||||
{
|
||||
$now=dol_now();
|
||||
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
|
||||
$pdf->Output($file,'F');
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
$now=dol_now();
|
||||
$file=$diroutputmassaction.'/'.$filename.'_'.dol_print_date($now,'dayhourlog').'.pdf';
|
||||
$pdf->Output($file,'F');
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$langs->load("exports");
|
||||
setEventMessages($langs->trans('FileSuccessfullyBuilt',$filename.'_'.dol_print_date($now,'dayhourlog')), null, 'mesgs');
|
||||
|
||||
@ -3876,7 +3876,7 @@ abstract class CommonObject
|
||||
*
|
||||
* @param string $modelspath Relative folder where generators are placed
|
||||
* @param string $modele Generator to use. Caller must set it to obj->modelpdf or GETPOST('modelpdf') for example.
|
||||
* @param Translate $outputlangs Language to use
|
||||
* @param Translate $outputlangs Output language to use
|
||||
* @param int $hidedetails 1 to hide details. 0 by default
|
||||
* @param int $hidedesc 1 to hide product description. 0 by default
|
||||
* @param int $hideref 1 to hide product reference. 0 by default
|
||||
@ -3885,7 +3885,7 @@ abstract class CommonObject
|
||||
*/
|
||||
protected function commonGenerateDocument($modelspath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref, $moreparams=null)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $conf, $langs, $user;
|
||||
|
||||
$srctemplatepath='';
|
||||
|
||||
@ -3903,7 +3903,6 @@ abstract class CommonObject
|
||||
$srctemplatepath=$tmp[1];
|
||||
}
|
||||
|
||||
|
||||
// Search template files
|
||||
$file=''; $classname=''; $filefound=0;
|
||||
$dirmodels=array('/');
|
||||
@ -3995,7 +3994,10 @@ abstract class CommonObject
|
||||
$arrayofrecords = array(); // The write_file of templates of adherent class need this
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, 'member', 1, $moreparams);
|
||||
}
|
||||
else $resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
else
|
||||
{
|
||||
$resultwritefile = $obj->write_file($this, $outputlangs, $srctemplatepath, $hidedetails, $hidedesc, $hideref, $moreparams);
|
||||
}
|
||||
|
||||
if ($resultwritefile > 0)
|
||||
{
|
||||
@ -4005,6 +4007,58 @@ abstract class CommonObject
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
dol_delete_preview($this);
|
||||
|
||||
// Index file in database
|
||||
if (! empty($obj->result['fullpath']))
|
||||
{
|
||||
$destfull = $obj->result['fullpath'];
|
||||
$upload_dir = dirname($destfull);
|
||||
$destfile = basename($destfull);
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
|
||||
|
||||
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
$rel_dir = preg_replace('/^[\\/]/', '', $rel_dir);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
$ecmfile=new EcmFiles($this->db);
|
||||
$result = $ecmfile->fetch(0, '', ($rel_dir?$rel_dir.'/':'').$filename);
|
||||
if ($result > 0)
|
||||
{
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull));
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->update($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$ecmfile->filepath = $rel_dir;
|
||||
$ecmfile->filename = $filename;
|
||||
$ecmfile->label = md5_file(dol_osencode($destfull));
|
||||
$ecmfile->fullpath_orig = '';
|
||||
$ecmfile->gen_or_uploaded = 'generated';
|
||||
$ecmfile->description = ''; // indexed content
|
||||
$ecmfile->keyword = ''; // keyword content
|
||||
$result = $ecmfile->create($user);
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($ecmfile->error, $ecmfile->errors, 'warnings');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('Method ->write_file was called on object '.get_class($obj).' and return a success but the return array ->result["fullpath"] was not set.', LOG_WARNING);
|
||||
}
|
||||
|
||||
// Success in building document. We build meta file.
|
||||
dol_meta_create($this);
|
||||
|
||||
|
||||
@ -328,7 +328,7 @@ function completeFileArrayWithDatabaseInfo(&$filearray, $relativedir)
|
||||
$filearray[$key]['acl']='';
|
||||
|
||||
$rel_filename = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $filearray[$key]['fullname']);
|
||||
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||
if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||
{
|
||||
dol_syslog("list_of_documents We found a file called '".$filearray[$key]['name']."' not indexed into database. We add it");
|
||||
include_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmfiles.class.php';
|
||||
@ -826,7 +826,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1, $testvi
|
||||
// Rename entry into ecm database
|
||||
$rel_filetorenamebefore = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $srcfile);
|
||||
$rel_filetorenameafter = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $destfile);
|
||||
if (! preg_match('/(\/temp\/|\/thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||
if (! preg_match('/([\\/]temp[\\/]|[\\/]thumbs|\.meta$)/', $rel_filetorenameafter)) // If not a tmp file
|
||||
{
|
||||
$rel_filetorenamebefore = preg_replace('/^[\\/]/', '', $rel_filetorenamebefore);
|
||||
$rel_filetorenameafter = preg_replace('/^[\\/]/', '', $rel_filetorenameafter);
|
||||
@ -1324,16 +1324,17 @@ function dol_delete_preview($object)
|
||||
|
||||
/**
|
||||
* Create a meta file with document file into same directory.
|
||||
* This should allow "grep" search.
|
||||
* This feature is enabled only if option MAIN_DOC_CREATE_METAFILE is set.
|
||||
* This make "grep" search possible.
|
||||
* This feature to generate the meta file is enabled only if option MAIN_DOC_CREATE_METAFILE is set.
|
||||
*
|
||||
* @param CommonObject $object Object
|
||||
* @return int 0 if we did nothing, >0 success, <0 error
|
||||
* @return int 0 if do nothing, >0 if we update meta file too, <0 if KO
|
||||
*/
|
||||
function dol_meta_create($object)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
// Create meta file
|
||||
if (empty($conf->global->MAIN_DOC_CREATE_METAFILE)) return 0; // By default, no metafile.
|
||||
|
||||
// Define parent dir of elements
|
||||
@ -1351,9 +1352,9 @@ function dol_meta_create($object)
|
||||
{
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
$facref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $dir . "/" . $facref;
|
||||
$file = $dir . "/" . $facref . ".meta";
|
||||
$objectref = dol_sanitizeFileName($object->ref);
|
||||
$dir = $dir . "/" . $objectref;
|
||||
$file = $dir . "/" . $objectref . ".meta";
|
||||
|
||||
if (! is_dir($dir))
|
||||
{
|
||||
@ -1368,15 +1369,15 @@ function dol_meta_create($object)
|
||||
DATE=\"" . dol_print_date($object->date,'') . "\"
|
||||
NB_ITEMS=\"" . $nblignes . "\"
|
||||
CLIENT=\"" . $client . "\"
|
||||
TOTAL_HT=\"" . $object->total_ht . "\"
|
||||
TOTAL_TTC=\"" . $object->total_ttc . "\"\n";
|
||||
AMOUNT_WO_TAX=\"" . $object->total_ht . "\"
|
||||
AMOUNT_INC_TAX=\"" . $object->total_ttc . "\"\n";
|
||||
|
||||
for ($i = 0 ; $i < $nblignes ; $i++)
|
||||
{
|
||||
//Pour les articles
|
||||
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\"
|
||||
ITEM_" . $i . "_TOTAL_HT=\"" . $object->lines[$i]->total_ht . "\"
|
||||
ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\"
|
||||
ITEM_" . $i . "_AMOUNT_WO_TAX=\"" . $object->lines[$i]->total_ht . "\"
|
||||
ITEM_" . $i . "_VAT=\"" .$object->lines[$i]->tva_tx . "\"
|
||||
ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\"
|
||||
";
|
||||
}
|
||||
@ -1390,6 +1391,10 @@ function dol_meta_create($object)
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
dol_syslog('FailedToDetectDirInDolMetaCreateFor'.$object->element, LOG_WARNING);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -1428,7 +1433,7 @@ function dol_init_file_process($pathtoscan='', $trackid='')
|
||||
|
||||
|
||||
/**
|
||||
* Get and save an upload file (for example after submitting a new file a mail form).
|
||||
* Get and save an upload file (for example after submitting a new file a mail form). Database index of file is also updated if donotupdatesession is set.
|
||||
* All information used are in db, conf, langs, user and _FILES.
|
||||
* Note: This function can be used only into a HTML page context.
|
||||
*
|
||||
@ -1522,7 +1527,7 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
|
||||
{
|
||||
$rel_dir = preg_replace('/^'.preg_quote(DOL_DATA_ROOT,'/').'/', '', $upload_dir);
|
||||
|
||||
if (! preg_match('/[\\/]temp[\\/]/', $rel_dir)) // If not a tmp dir
|
||||
if (! preg_match('/[\\/]temp[\\/]|[\\/]thumbs|\.meta$/', $rel_dir)) // If not a tmp dir
|
||||
{
|
||||
$filename = basename($destfile);
|
||||
$rel_dir = preg_replace('/[\\/]$/', '', $rel_dir);
|
||||
|
||||
@ -178,6 +178,8 @@ class CommActionRapport
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -249,6 +249,8 @@ class pdf_ban extends ModeleBankAccountDoc
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -396,6 +396,8 @@ class pdf_sepamandate extends ModeleBankAccountDoc
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -193,6 +193,8 @@ class BordereauChequeBlochet extends ModeleChequeReceipts
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
$outputlangs->charset_output=$sav_charset_output;
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
|
||||
@ -467,6 +467,8 @@ class doc_generic_order_odt extends ModelePDFCommandes
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -603,6 +603,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -454,6 +454,8 @@ class doc_generic_contract_odt extends ModelePDFContract
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -396,6 +396,8 @@ class pdf_strato extends ModelePDFContract
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -259,6 +259,8 @@ class html_cerfafr extends ModeleDon
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -510,6 +510,8 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -359,6 +359,8 @@ class pdf_merou extends ModelePdfExpedition
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -567,6 +567,8 @@ class pdf_rouget extends ModelePdfExpedition
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // No error
|
||||
}
|
||||
else
|
||||
|
||||
@ -474,6 +474,8 @@ class pdf_standard extends ModeleExpenseReport
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -474,6 +474,8 @@ class doc_generic_invoice_odt extends ModelePDFFactures
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -701,6 +701,8 @@ class pdf_crabe extends ModelePDFFactures
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // No error
|
||||
}
|
||||
else
|
||||
|
||||
@ -392,6 +392,8 @@ class pdf_soleil extends ModelePDFFicheinter
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
@ -566,6 +566,8 @@ class pdf_typhon extends ModelePDFDeliveryOrder
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -418,6 +418,8 @@ class pdf_standard extends CommonStickerGenerator
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
// Output to http stream
|
||||
if (empty($nooutput))
|
||||
{
|
||||
|
||||
@ -326,8 +326,6 @@ class pdf_standardlabel extends CommonStickerGenerator
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
|
||||
// Output to http stream
|
||||
clearstatcache();
|
||||
|
||||
@ -346,6 +344,8 @@ class pdf_standardlabel extends CommonStickerGenerator
|
||||
|
||||
readfile($file);
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -367,8 +367,6 @@ class pdf_tcpdflabel extends CommonStickerGenerator
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
|
||||
// Output to http stream
|
||||
clearstatcache();
|
||||
|
||||
@ -387,6 +385,8 @@ class pdf_tcpdflabel extends CommonStickerGenerator
|
||||
|
||||
readfile($file);
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -483,6 +483,8 @@ class doc_generic_product_odt extends ModelePDFProduct
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -542,6 +542,8 @@ class pdf_standard extends ModelePDFProduct
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -1066,6 +1066,8 @@ class doc_generic_project_odt extends ModelePDFProjects
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -329,6 +329,8 @@ class pdf_baleine extends ModelePDFProjects
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$ this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -503,6 +503,8 @@ class pdf_beluga extends ModelePDFProjects
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -829,6 +829,8 @@ class doc_generic_task_odt extends ModelePDFTask
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -494,6 +494,8 @@ class doc_generic_proposal_odt extends ModelePDFPropales
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -759,6 +759,8 @@ class pdf_azur extends ModelePDFPropales
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -275,7 +275,9 @@ class pdf_paiement
|
||||
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -274,6 +274,8 @@ class pdf_paiement_fourn
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@ -459,6 +459,8 @@ class doc_generic_odt extends ModeleThirdPartyDoc
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -539,6 +539,8 @@ class pdf_canelle extends ModelePDFSuppliersInvoices
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -638,6 +638,8 @@ class pdf_muscadet extends ModelePDFSuppliersOrders
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -442,6 +442,8 @@ class pdf_standard extends ModelePDFSuppliersPayments
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -486,6 +486,8 @@ class doc_generic_supplier_proposal_odt extends ModelePDFSupplierProposal
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -605,6 +605,8 @@ class pdf_aurore extends ModelePDFSupplierProposal
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($file, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Pas d'erreur
|
||||
}
|
||||
else
|
||||
|
||||
@ -408,6 +408,8 @@ class doc_generic_user_odt extends ModelePDFUser
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -485,6 +485,8 @@ class doc_generic_usergroup_odt extends ModelePDFUserGroup
|
||||
|
||||
$odfHandler=null; // Destroy object
|
||||
|
||||
$this->result = array('fullpath'=>$file);
|
||||
|
||||
return 1; // Success
|
||||
}
|
||||
else
|
||||
|
||||
@ -231,12 +231,12 @@ class EcmFiles //extends CommonObject
|
||||
/**
|
||||
* Load object in memory from the database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param string $ref Not used yet. Will contains a hash id from filename+filepath
|
||||
* @param string $fullpath Full path of file (relative path to document directory)
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
* @param int $id Id object
|
||||
* @param string $ref Not used yet. Will contains a hash id from filename+filepath
|
||||
* @param string $relativepath Relative path of file from document directory. Example: path/path2/file
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetch($id, $ref = null, $fullpath = '')
|
||||
public function fetch($id, $ref = null, $relativepath = '')
|
||||
{
|
||||
dol_syslog(__METHOD__, LOG_DEBUG);
|
||||
|
||||
@ -265,8 +265,8 @@ class EcmFiles //extends CommonObject
|
||||
if (! empty($conf->multicompany->enabled)) {
|
||||
$sql .= " AND entity IN (" . getEntity('ecmfiles') . ")";
|
||||
}*/
|
||||
if ($fullpath) {
|
||||
$sql .= " AND t.filepath = '" . $this->db->escape(dirname($fullpath)) . "' AND t.filename = '".$this->db->escape(basename($fullpath))."'";
|
||||
if ($relativepath) {
|
||||
$sql .= " AND t.filepath = '" . $this->db->escape(dirname($relativepath)) . "' AND t.filename = '".$this->db->escape(basename($relativepath))."'";
|
||||
}
|
||||
elseif (null !== $ref) {
|
||||
$sql .= " AND t.ref = '".$this->db->escape($ref)."'";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user