diff --git a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml index bc1edd1b0aef5921af5439afedfcd9e77491e35b..a8cc98c5d8874e2b38d17d28eed54d2a6f29a485 100755 --- a/apps/maarch_entreprise/xml/IVS/requests_definitions.xml +++ b/apps/maarch_entreprise/xml/IVS/requests_definitions.xml @@ -17,12 +17,6 @@ </requestDefinition> <!-- Admin architecture --> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="admin_architecture" > - <parameter name="admin" value="architecture"/> - <parameter name="page" value="choose_tree"/> - <parameter name="display" value="true"/> - <parameter name="tree_id"/> - </requestDefinition> <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="admin_structure" > <parameter name="page" value="structure_up"/> <parameter name="display" value="true"/> diff --git a/modules/convert/Controllers/ProcessConvertController.php b/modules/convert/Controllers/ProcessConvertController.php deleted file mode 100755 index 6c7af694ac8a19c8c427c9a1624facb09004a201..0000000000000000000000000000000000000000 --- a/modules/convert/Controllers/ProcessConvertController.php +++ /dev/null @@ -1,430 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** -* @brief process convert class -* -* <ul> -* <li>Services to process the convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -namespace Convert\Controllers; - -use Attachment\models\AttachmentModel; -use Docserver\controllers\DocserverController; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Resource\models\ResModel; -use Respect\Validation\Validator; -use Convert\Models\ProcessConvertModel; -use Docserver\models\DocserverModel; -use Docserver\models\ResDocserverModel; -use SrcCore\controllers\LogsController; - -class ProcessConvertController -{ - protected $libreOfficeExecutable; - - //public function __construct($libreOfficeExecutable = 'cloudooo') - public function __construct($libreOfficeExecutable = 'soffice') - //public function __construct($libreOfficeExecutable = 'unoconv') - { - $this->libreOfficeExecutable = $libreOfficeExecutable; - } - - public function create(RequestInterface $request, ResponseInterface $response) - { - $data = $request->getParams(); - - $check = Validator::notEmpty()->validate($data['collId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['resTable']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['adrTable']); - $check = $check && Validator::intType()->notEmpty()->validate($data['resId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['tmpDir']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $return = ProcessConvertController::convert($data); - - if (empty($return) || !empty($return['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ProcessConvertController create] ' . $return['errors']]); - } - - return $response->withJson($return); - } - - /** - * Ask for conversion - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function convert(array $args=[]) - { - $timestart = microtime(true); - // LogsController::info(['message'=>'debut convert', 'code'=>111, ]); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - if ($args['resTable'] == 'res_letterbox') { - $res = ResModel::getById(['resId' => $resId]); - } elseif ($args['resTable'] == 'res_attachments') { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'false']); - } else { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'true']); - } - - if ($res['res_id'] <> '') { - $resourcePath = ResDocserverModel::getSourceResourcePath( - [ - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $res['res_id'], - 'adrType' => 'DOC' - ] - ); - } - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'file not exists : ' . $resourcePath, - ); - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed', - ); - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - //now do the conversion ! - if (strtoupper($res['format']) <> 'PDF') { - $resultOfConversion = $this->launchConvert( - $fileNameOnTmp, - 'pdf', - $tmpDir, - pathinfo($resourcePath, PATHINFO_EXTENSION) - ); - } else { - copy($fileNameOnTmp, $fileNameOnTmp . '.pdf'); - $resultOfConversion = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - if ($resultOfConversion['status'] <> '0') { - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $resultOfConversion; - } - //copy the result on docserver - // LogsController::info(['message'=>'avant cp ds', 'code'=>1112, ]); - $storeResult = DocserverController::storeResourceOnDocServer([ - 'collId' => $collId, - 'fileInfos' => [ - 'tmpDir' => $tmpDir, - 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.pdf', - ], - 'docserverTypeId' => 'CONVERT' - ]); - - if (empty($storeResult)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection and ds type not found for convert:' - . $collId . ' CONVERT', - ); - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - if (!empty($storeResult['errors'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $storeResult['errors'] . ' error for convert:' - . $fileNameOnTmp, - ); - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - $targetDs = DocserverModel::getByDocserverId(['docserverId' => $storeResult['docserver_id']]); - - // LogsController::info(['message'=>'avant update', 'code'=>19, ]); - //update the \Database - $resultOfUpDb = ProcessConvertModel::updateDatabase( - [ - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'docserver' => $targetDs, - 'path' => $storeResult['destination_dir'], - 'fileName' => $storeResult['file_destination_name'] - ] - ); - // LogsController::info(['message'=>var_export($resultOfUpDb, true), 'code'=>111111, ]); - // LogsController::info(['message'=>$collId, 'code'=>2, ]); - // LogsController::info(['message'=>$resTable, 'code'=>3, ]); - // LogsController::info(['message'=>$adrTable, 'code'=>4, ]); - // LogsController::info(['message'=>$resId, 'code'=>5, ]); - // LogsController::info(['message'=>'apres res_id', 'code'=>6, ]); - // LogsController::info(['message'=>$targetDs, 'code'=>6, ]); - // LogsController::info(['message'=>var_export($resultCopyDs, true), 'code'=>7, ]); - - if ($resultOfUpDb['status'] <> '0') { - ProcessConvertModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.pdf'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessConvertAbstract_Service::convert' - ); - return $returnArray; - } - - /** - * Launch the conversion - * - * @param string $srcfile source file - * @param string $tgtfmt target format - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - public function launchConvert( - $srcfile, - $tgtfmt, - $tgtdir=false, - $srcfmt=null - ) { - $timestart=microtime(true); - - $processHtml = false; - $executable=''; - - // LogsController::info(['message'=>'[TIMER] Debut Convert_ProcessConvertAbstract_Service::launchConvert']); - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $processHtml = true; - // LogsController::info(['message'=>'[TIMER] srcfmt ' . $srcfmt]); - copy($srcfile, str_ireplace('.maarch', '.', $srcfile) . '.html'); - if (file_exists('/usr/bin/mywkhtmltopdf')) { - $command = "mywkhtmltopdf " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.pdf'); - } else { - $envVar = "export DISPLAY=FRPAROEMINT:0.0 ; "; - $command = $envVar . "wkhtmltopdf " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.pdf'); - } - $executable='wkhtmltopdf'; - } else { - $executable='soffice'; - // LogsController::info(['message'=>'[TIMER] let LO do it ' . $this->libreOfficeExecutable]); - if ($this->libreOfficeExecutable == "cloudooo") { - $serverAddress = "http://192.168.21.40:8011"; - $tokens = array(); - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpc.inc'; - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpcs.inc'; - require_once 'apps/maarch_entreprise/tools/phpxmlrpc/lib/xmlrpc_wrappers.inc'; - $fileContent = file_get_contents($srcfile, FILE_BINARY); - $encodedContent = base64_encode($fileContent); - $params = array(); - array_push($params, new PhpXmlRpc\Value($encodedContent)); - array_push($params, new PhpXmlRpc\Value($srcfmt)); - array_push($params, new PhpXmlRpc\Value($tgtfmt)); - array_push($params, new PhpXmlRpc\Value(false)); - $v = new PhpXmlRpc\Value($params, "array"); - } elseif ($this->libreOfficeExecutable == "unoconv") { - $tokens = array('"' . $this->libreOfficeExecutable . '"'); - $tokens[] = "-f"; - $tokens[] = $tgtfmt; - $tokens[] = '-o "' . $srcfile . '.' . $tgtfmt . '"'; - $tokens[] = '"' . $srcfile . '"'; - } else { - $tokens = array('"' . $this->libreOfficeExecutable . '"'); - $tokens[] = "--headless"; - $tokens[] = "--convert-to"; - $tokens[] = $tgtfmt; - $tokens[] = '"' . $srcfile . '"'; - if (!$tgtdir) { - $tgtdir = dirname($srcfile); - } - $tokens[] = '--outdir "' . $tgtdir . '"'; - } - - if (!$srcfmt) { - $tokens[] = $srcfmt; - } - - $command = implode(' ', $tokens); - - $output = array(); - $return = null; - $this->errors = array(); - } - //echo $command . '<br />';exit; - if ($this->libreOfficeExecutable == "cloudooo" && !$processHtml) { - // LogsController::info(['message'=>'[TIMER] commande : cloudooo url ' . $serverAddress]); - // LogsController::info(['message'=>'[TIMER] Debut Convert_ProcessConvertAbstract_Service::launchConvert__exec']); - $req = new PhpXmlRpc\Request('convertFile', $v); - //LogsController::info(['message'=>'[TIMER] commande : cloudooo url ' . $serverAddress]); - // LogsController::info(['message'=>'[TIMER] Fin Convert_ProcessConvertAbstract_Service::launchConvert__exec']); - $client = new PhpXmlRpc\Client($serverAddress); - $resp = $client->send($req); - if (!$resp->faultCode()) { - $encoder = new PhpXmlRpc\Encoder(); - $value = $encoder->decode($resp->value()); - $theFile = fopen($srcfile . '.' . $tgtfmt, 'w+'); - fwrite($theFile, base64_decode($value)); - fclose($theFile); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - //print "An error occurred: "; - //print "Code: " . htmlspecialchars($resp->faultCode()) - // . " Reason: '" . htmlspecialchars($resp->faultString()) . "'\n"; - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => "Code: " . htmlspecialchars($resp->faultCode()) - . " Reason: '" . htmlspecialchars($resp->faultString()), - ); - } - } else { - $timestart_command = microtime(true); - exec("timeout -k 5m 3m " . $command, $output, $return); - // LogsController::debug(['message'=>'[TIMER] commande : ' . $command]); - LogsController::executionTimeLog($timestart_command, '', 'info', '[TIMER] ' . $executable . ' - Convert_ProcessConvertAbstract_Service::launchConvert__exec'); - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - } - } - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $returnArray = array(); - unlink(str_ireplace('.maarch', '.', $srcfile) . '.html'); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - LogsController::executionTimeLog( - $timestart, - '', - 'info', - '[TIMER] Fin Convert_ProcessConvertAbstract_Service::launchConvert' - ); - return $returnArray; - } -} diff --git a/modules/convert/Controllers/ProcessFulltextController.php b/modules/convert/Controllers/ProcessFulltextController.php deleted file mode 100755 index 36ec2f7326213ff2f7ab968413c34a50594af34b..0000000000000000000000000000000000000000 --- a/modules/convert/Controllers/ProcessFulltextController.php +++ /dev/null @@ -1,626 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** -* @brief process fulltext class -* -* <ul> -* <li>Services to process the fulltext of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -namespace Convert\Controllers; - -use Attachment\models\AttachmentModel; -use Docserver\controllers\DocserverController; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Resource\models\ResModel; -use Respect\Validation\Validator; -use Convert\Models\ProcessFulltextModel; -use Docserver\models\DocserverModel; -use Docserver\models\ResDocserverModel; -use SrcCore\controllers\LogsController; -use SrcCore\models\TextFormatModel; - - -class ProcessFulltextController -{ - protected $pdftotext; - - public function __construct($pdftotext = 'pdftotext') - { - // Storing text in lucene index - set_include_path('apps/maarch_entreprise/tools/' - . PATH_SEPARATOR . get_include_path() - ); - - //if(!@include('Zend/Search/Lucene.php')) { - set_include_path($GLOBALS['MaarchDirectory'] - . 'apps/maarch_entreprise/tools/' - . PATH_SEPARATOR . get_include_path() - ); - - require_once("Zend/Search/Lucene.php"); - //} - - $this->pdftotext = $pdftotext; - } - - public function create(RequestInterface $request, ResponseInterface $response) - { - $data = $request->getParams(); - - $check = Validator::notEmpty()->validate($data['collId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['resTable']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['adrTable']); - $check = $check && Validator::intType()->notEmpty()->validate($data['resId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['tmpDir']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - if ($data['createZendIndex']) { - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == 'letterbox_coll') { - $pathToLucene = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - - $data['zendIndex'] = ProcessFulltextController::createZendIndexObject( - $pathToLucene - ); - } - - $return = ProcessFulltextController::fulltext($data); - - if (empty($return) || !empty($return['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ProcessFulltextController create] ' . $return['errors']]); - } - - return $response->withJson($return); - } - - /** - * Ask for fulltext - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function fulltext(array $args=[]) - { - $timestart = microtime(true); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty for fulltext', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty for fulltext', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty for fulltext', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty for fulltext', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - if (isset($args['path_to_lucene']) && !empty($args['path_to_lucene'])) { - $indexFileDirectory = $args['path_to_lucene']; - } else { - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == $collId) { - $indexFileDirectory - = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - } - if ($args['createZendIndex']) { - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == 'letterbox_coll') { - $pathToLucene = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - - $args['zendIndex'] = ProcessFulltextController::createZendIndexObject( - $pathToLucene - ); - } - - if ($args['resTable'] == 'res_letterbox') { - $res = ResModel::getById(['resId' => $resId]); - } elseif ($args['resTable'] == 'res_attachments') { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'false']); - } else { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'true']); - } - - if ($res['res_id'] <> '') { - $resourcePath = ResDocserverModel::getSourceResourcePath( - [ - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $res['res_id'], - 'adrType' => 'CONV' - ] - ); - } - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'file not already converted in pdf for fulltext. path :' - . $resourcePath . ", adrType : CONV, adr_table : " . $adrTable, - ); - ProcessFulltextController::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed for fulltext. Copy ' . $resourcePath . ' to ' . $fileNameOnTmp, - ); - ProcessFulltextController::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - //now do the fulltext ! - if (!empty($args['zendIndex'])) { - $resultOfConversion = $this->launchFulltext( - $fileNameOnTmp, - $resId, - $indexFileDirectory, - $tmpDir, - $args['zendIndex'] - ); - } else { - $resultOfConversion = $this->launchFulltext( - $fileNameOnTmp, - $resId, - $indexFileDirectory, - $tmpDir - ); - } - - if ($resultOfConversion['status'] <> '0') { - ProcessFulltextController::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessFulltextAbstract_Service::fulltext aucunContenuAIndexer' - ); - return $resultOfConversion; - } - - //copy the result on docserver - // LogsController::info(['message'=>'avant cp ds', 'code'=>1112, ]); - $storeResult = DocserverController::storeResourceOnDocServer([ - 'collId' => $collId, - 'fileInfos' => [ - 'tmpDir' => $tmpDir, - 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.txt', - ], - 'docserverTypeId' => 'FULLTEXT' - ]); - - if (empty($storeResult)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection and ds type not found for fulltext:' - . $collId . ' FULLTEXT', - ); - ProcessFulltextController::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - $targetDs = DocserverModel::getByDocserverId(['docserverId' => $storeResult['docserver_id']]); - - // LogsController::info(['message'=>'avant update', 'code'=>19, ]); - //update the Database - $resultOfUpDb = ProcessFulltextModel::updateDatabase( - [ - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'docserver' => $targetDs, - 'path' => $storeResult['destination_dir'], - 'fileName' => $storeResult['file_destination_name'], - 'zendIndex' => $args['zendIndex'] - ] - ); - - if ($resultOfUpDb['status'] <> '0') { - ProcessFulltextModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.txt'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessFulltextAbstract_Service::fulltext' - ); - return $returnArray; - } - - /** - * Launch the fulltext process - * - * @param string $srcfile source file - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - private function launchFulltext( - $srcfile, - $resId, - $indexFileDirectory, - $tgtdir=false, - $zendIndex='' - ) { - if (!empty($zendIndex)) { - $return = $this->prepareIndexFullTextPdf( - $srcfile, - $tgtdir, - $indexFileDirectory, - $resId, - $zendIndex - ); - } else { - $return = $this->prepareIndexFullTextPdf( - $srcfile, - $tgtdir, - $indexFileDirectory, - $resId - ); - } - - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - return $returnArray; - } - } - - /** - * Read a txt file - * @param $file string path of the file to read - * @return string contents of the file - */ - private function readFileF($file) - { - $result = ""; - if (is_file($file)) { - $fp = fopen($file, "r"); - $result = fread($fp, filesize($file)); - fclose($fp); - } - return $result; - } - - private function prepareIndexFullTextPdf($pathToFile, $tmpDir, $indexFileDirectory, $resId, $zendIndex = "") - { - $timestart = microtime(true); - if (is_file($pathToFile)) { - $tmpFile = $tmpDir . basename($pathToFile) . ".txt"; - $timestart_fulltext = microtime(true); - $resultExtraction = exec("pdftotext " . escapeshellarg($pathToFile) - . " " . escapeshellarg($tmpFile) - ); - LogsController::executionTimeLog( - $timestart_fulltext, - '', - 'debug', - '[TIMER] Convert_ProcessFulltextAbstract_Service::prepareIndexFullTextPdf__exec' - ); - - $fileContent = trim($this->readFileF($tmpFile)); - - if (!empty($zendIndex)) { - $result = $this->launchIndexFullTextWithZendIndex( - $fileContent, - $indexFileDirectory, - $resId, - $zendIndex - ); - } else { - // TODO : will be done only by the batch convert in OnlyIndexes mode - //$result = $this->launchIndexFullText($fileContent, $indexFileDirectory, $resId); - $result = 0; - } - - } else { - $result = 'file not found ' . $pathToFile; - } - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessFulltextAbstract_Service::prepareIndexFullTextPdf' - ); - return $result; - } - - /** - * Return zend index object for batch mode - * @param $indexFileDirectory string directory of the lucene index - * @return zend index object - */ - public function createZendIndexObject($tempIndexFileDirectory, $numberOfIndexes = 1000) - { - //echo 'createZendIndexObject : ' . $numberOfIndexes . PHP_EOL; - $indexFileDirectory = (string) $tempIndexFileDirectory; - // with version 1.12, we need a string, not an XML element - - if (!is_dir($indexFileDirectory)) { - $index = \Zend_Search_Lucene::create($indexFileDirectory); - } else { - if ($this->isDirEmpty($indexFileDirectory)) { - $index = \Zend_Search_Lucene::create($indexFileDirectory); - } else { - $index = \Zend_Search_Lucene::open($indexFileDirectory); - } - } - $index->setFormatVersion(\Zend_Search_Lucene::FORMAT_2_3); - // we set the lucene format to 2.3 - \Zend_Search_Lucene_Analysis_Analyzer::setDefault( - new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive() - ); - - //$index->MaxBufferedDocs(); - $index->setMaxBufferedDocs($numberOfIndexes); - - return $index; - } - - /** - * Checks if a directory is empty - * - * @param $dir string The directory to check - * @return bool True if empty, False otherwise - */ - function isDirEmpty($dir) - { - $dir = opendir($dir); - $isEmpty = true; - while (($entry = readdir($dir)) !== false) { - if ($entry !== '.' && $entry !== '..' && $entry !== '.svn') { - $isEmpty = false; - break; - } - } - closedir($dir); - return $isEmpty; - } - - /** - * Commit the zend index at the end of the batch - * @return nothing - */ - public function commitZendIndex($index) - { - //echo 'the commit' . PHP_EOL; - $index->commit(); - } - - /** - * Retrieve the text of a pdftext and launch the lucene engine - * @param $pathToFile string path of the file to index - * @param $indexFileDirectory string directory of the lucene index - * @param $id integer id of the document to index - * @return integer user exit code is stored in fulltext_result column of the - * document in "res_x" - */ - private function launchIndexFullText($fileContent, $tempIndexFileDirectory, $Id) - { - // $IndexFileDirectory is replace by tempIndexFileDirectory - $fileContent = TextFormatModel::normalize(['string' => $fileContent]); - $fileContent = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileContent); - $indexFileDirectory = (string) $tempIndexFileDirectory; - // with version 1.12, we need a string, not an XML element - $result = -1; - if (strlen($fileContent) > 2) { - if (!is_dir($indexFileDirectory)) { - //$_ENV['logger']->write($indexFileDirectory . " not exists !", "ERROR", 2); - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - if ($this->isDirEmpty($indexFileDirectory)) { - //$_ENV['logger']->write($indexFileDirectory . " empty !"); - $index = Zend_Search_Lucene::create($indexFileDirectory); - } else { - $index = Zend_Search_Lucene::open($indexFileDirectory); - } - } - $index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3); - // we set the lucene format to 2.3 - Zend_Search_Lucene_Analysis_Analyzer::setDefault( - new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive() - ); - // we need utf8 for accents - $term = new \Zend_Search_Lucene_Index_Term($Id, 'Id'); - foreach ($index->termDocs($term) as $id) { - $index->delete($id); - } - //echo $fileContent; - $doc = new \Zend_Search_Lucene_Document(); - $doc->addField(\Zend_Search_Lucene_Field::UnIndexed('Id', (integer) $Id)); - $doc->addField(\Zend_Search_Lucene_Field::UnStored( - 'contents', $fileContent) - ); - $index->addDocument($doc); - $index->commit(); - //$index->optimize(); - $result = 0; - } else { - $result = 1; - } - return $result; - } - - /** - * Retrieve the text of a pdftext and launch the lucene engine - * @param $pathToFile string path of the file to index - * @param $indexFileDirectory string directory of the lucene index - * @param $id integer id of the document to index - * @return integer user exit code is stored in fulltext_result column of the - * document in "res_x" - */ - private function launchIndexFullTextWithZendIndex($fileContent, $tempIndexFileDirectory, $Id, $index) - { - //echo 'launchIndexFullTextWithZendIndex' . PHP_EOL; - // $IndexFileDirectory is replace by tempIndexFileDirectory - $fileContent = TextFormatModel::normalize(['string' => $fileContent]); - $fileContent = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileContent); - - // with version 1.12, we need a string, not an XML element - $result = -1; - if (strlen($fileContent) > 2) { - try { - // we need utf8 for accents - $term = new \Zend_Search_Lucene_Index_Term($Id, 'Id'); - foreach ($index->termDocs($term) as $id) { - $index->delete($id); - } - //echo $fileContent; - $doc = new \Zend_Search_Lucene_Document(); - $doc->addField(\Zend_Search_Lucene_Field::UnIndexed('Id', (integer) $Id)); - $doc->addField(\Zend_Search_Lucene_Field::UnStored( - 'contents', $fileContent) - ); - //$func->show_array($doc); - $index->addDocument($doc); - //$index->commit(); - //$func->show_array($index); - //$index->optimize(); - $result = 0; - } catch (Exception $e) { - $result = $e->getMessage(); - } - - } else if (strlen($fileContent) >= 0){ - $result = 0; - } - return $result; - } - - public static function optimizeLuceneIndex(array $args=[]){ - $timestart = microtime(true); - // prerequisites - self::checkRequired($args, ['collId']); - self::checkString($args, ['collId']); - - $collId = $args['collId']; - - $countColl = count($_SESSION['collections']); - for ($i=0;$i<$countColl;$i++) { - if ($_SESSION['collections'][$i]['id'] == $collId) { - $path_to_lucene = $_SESSION['collections'][$i]['path_to_lucene_index']; - } - } - - if(!empty($path_to_lucene)){ - exec( - 'php '.$_SESSION['config']['corepath'] . - 'modules/convert/optimizeLuceneIndex.php ' . - $path_to_lucene . ' ' . - $_SESSION['config']['corepath'] . ' > /dev/null 2>&1 &' - ); - } - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessFulltextAbstract_Service::optimizeLuceneIndex' - ); - - return true; - } -} diff --git a/modules/convert/Controllers/ProcessManageConvertController.php b/modules/convert/Controllers/ProcessManageConvertController.php deleted file mode 100755 index 3b85205b81684a5f55acf8c3e82651820e1f4d15..0000000000000000000000000000000000000000 --- a/modules/convert/Controllers/ProcessManageConvertController.php +++ /dev/null @@ -1,224 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** -* @brief process manageConvert class -* -* <ul> -* <li>Services to process the management of convertion of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -namespace Convert\Controllers; - -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Respect\Validation\Validator; -use Convert\Controllers\ProcessConvertController; -use Convert\Controllers\ProcessFulltextController; -use Convert\Controllers\ProcessThumbnailsController; -use SrcCore\controllers\LogsController; - -class ProcessManageConvertController -{ - protected $libreOfficeExecutable; - - //public function __construct($libreOfficeExecutable = 'cloudooo') - public function __construct($libreOfficeExecutable = 'soffice') - //public function __construct($libreOfficeExecutable = 'unoconv') - { - $this->libreOfficeExecutable = $libreOfficeExecutable; - } - - public function create(RequestInterface $request, ResponseInterface $response) - { - $data = $request->getParams(); - - $check = Validator::notEmpty()->validate($data['collId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['resTable']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['adrTable']); - $check = $check && Validator::intType()->notEmpty()->validate($data['resId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['tmpDir']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $return = ProcessManageConvertController::convertAll($data); - - if (empty($return) || !empty($return['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ProcessConvertController create] ' . $return['errors']]); - } - - return $response->withJson($return); - } - - /** - * Ask for conversion in all mode - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @throws Exception Check des valeurs d'entrées - * @return array $returnArray the result - */ - public function convertAll(array $args=[]) - { - $timestart = microtime(true); - // prerequisites - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty for manage convert', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty for manage convert', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty for manage convert', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty for manage convert', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - $path_to_lucene = ''; - if (isset($args['path_to_lucene']) && !empty($args['path_to_lucene'])){ - $path_to_lucene = $args['path_to_lucene']; - } - - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene - ); - - //CONV - $ProcessConvertService = new ProcessConvertController(); - $resultOfConversion = $ProcessConvertService->convert($params); - - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'CONV:' . $resultOfConversion['error'], - ); - return $returnArray; - } - - //TNL - $ProcessConvertService = new ProcessThumbnailsController(); - $resultOfConversion = $ProcessConvertService->thumbnails($params); - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'TNL:' . $resultOfConversion['error'], - ); - return $returnArray; - } - - //FULLTEXT - if ($args['createZendIndex']) { - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene, - 'createZendIndex' => true - ); - } else { - $params = array( - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'tmpDir' => $tmpDir, - 'path_to_lucene' => $path_to_lucene - ); - } - $ProcessConvertServiceFulltext = new ProcessFulltextController(); - - $resultOfConversion = $ProcessConvertServiceFulltext->fulltext($params); - - if ($resultOfConversion['status'] <> '0') { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'TXT:' . $resultOfConversion['error'], - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ManageConvertAbstract_Service::convertAll aucun contenu a indexer dans fulltext' - ); - return $returnArray; - } - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ManageConvertAbstract_Service::convertAll' - ); - - return $returnArray; - } -} \ No newline at end of file diff --git a/modules/convert/Controllers/ProcessThumbnailsController.php b/modules/convert/Controllers/ProcessThumbnailsController.php deleted file mode 100755 index 78d02acee160ecae7ffb290ef07e8d39f5877513..0000000000000000000000000000000000000000 --- a/modules/convert/Controllers/ProcessThumbnailsController.php +++ /dev/null @@ -1,343 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** -* @brief process thumbnails class -* -* <ul> -* <li>Services to process the thumbnails of resources</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -namespace Convert\Controllers; - -use Attachment\models\AttachmentModel; -use Docserver\controllers\DocserverController; -use Psr\Http\Message\RequestInterface; -use Psr\Http\Message\ResponseInterface; -use Resource\models\ResModel; -use Respect\Validation\Validator; -use Convert\Models\ProcessThumbnailsModel; -use Docserver\models\DocserverModel; -use Docserver\models\ResDocserverModel; -use SrcCore\controllers\LogsController; - -class ProcessThumbnailsController -{ - protected $tnlExecutable; - - public function __construct($tnlExecutable = 'convert') - { - $this->tnlExecutable = $tnlExecutable; - } - - public function create(RequestInterface $request, ResponseInterface $response) - { - $data = $request->getParams(); - - $check = Validator::notEmpty()->validate($data['collId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['resTable']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['adrTable']); - $check = $check && Validator::intType()->notEmpty()->validate($data['resId']); - $check = $check && Validator::stringType()->notEmpty()->validate($data['tmpDir']); - if (!$check) { - return $response->withStatus(400)->withJson(['errors' => 'Bad Request']); - } - - $return = ProcessThumbnailsController::thumbnails($data); - - if (empty($return) || !empty($return['errors'])) { - return $response->withStatus(500)->withJson(['errors' => '[ProcessThumbnailsController create] ' . $return['errors']]); - } - - return $response->withJson($return); - } - - /** - * Ask for thumbnails - * - * @param string $collId collection - * @param string $resTable resource table - * @param string $adrTable adr table - * @param long $resId res_id - * @param string $tmpDir path to tmp - * @param array $tgtfmt array of target format - * @return array $returnArray the result - */ - public function thumbnails(array $args=[]) - { - $timestart = microtime(true); - $returnArray = array(); - if (empty($args['collId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'collId empty for thumbnails', - ); - return $returnArray; - } else { - $collId = $args['collId']; - } - if (empty($args['resTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resTable empty for thumbnails', - ); - return $returnArray; - } else { - $resTable = $args['resTable']; - } - if (empty($args['adrTable'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'adrTable empty for thumbnails', - ); - return $returnArray; - } else { - $adrTable = $args['adrTable']; - } - if (empty($args['resId'])) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'resId empty for thumbnails', - ); - return $returnArray; - } else { - $resId = $args['resId']; - } - - if (!isset($args['tmpDir']) || $args['tmpDir'] == '') { - $tmpDir = $_SESSION['config']['tmppath']; - } else { - $tmpDir = $args['tmpDir']; - } - - if ($args['resTable'] == 'res_letterbox') { - $res = ResModel::getById(['resId' => $resId]); - } elseif ($args['resTable'] == 'res_attachments') { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'false']); - } else { - $res = AttachmentModel::getById(['id' => $resId, 'isVersion' => 'true']); - } - - if ($res['res_id'] <> '') { - $adrType = 'CONV'; - if ( - strtoupper($res['format']) == 'HTML' || - strtoupper($res['format']) == 'MAARCH' - ) { - $adrType = 'DOC'; - } - $resourcePath = ResDocserverModel::getSourceResourcePath( - [ - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $res['res_id'], - 'adrType' => $adrType - ] - ); - } - if (!file_exists($resourcePath)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'file not already converted in pdf for thumbnails. path :' - . $resourcePath . ", adrType : CONV, adr_table : " . $adrTable, - ); - ProcessThumbnailsModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - //copy the resource on tmp directory - $fileNameOnTmp = $tmpDir . rand() . rand(); - if (!copy($resourcePath, $fileNameOnTmp)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'copy on tmp failed for thumbnails. Copy ' . $resourcePath . ' to ' . $fileNameOnTmp, - ); - ProcessThumbnailsModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - //now do the thumbnails ! - $resultOfConversion = $this->launchThumbnails( - $fileNameOnTmp, - $tmpDir, - pathinfo($resourcePath, PATHINFO_EXTENSION) - ); - - - if ($resultOfConversion['status'] <> '0') { - ProcessThumbnailsModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessThumbnailsAbstract_Service::thumbnails aucunContenuAIndexer' - ); - return $resultOfConversion; - } - - //copy the result on docserver - // LogsController::info(['message'=>'avant cp ds', 'code'=>1112, ]); - $storeResult = DocserverController::storeResourceOnDocServer([ - 'collId' => $collId, - 'fileInfos' => [ - 'tmpDir' => $tmpDir, - 'tmpFileName' => pathinfo($fileNameOnTmp, PATHINFO_FILENAME) . '.png', - ], - 'docserverTypeId' => 'TNL' - ]); - - if (empty($storeResult)) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => 'Ds of collection and ds type not found for thumbnails:' - . $collId . ' THUMBNAILS', - ); - ProcessThumbnailsModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $returnArray; - } - - $targetDs = DocserverModel::getByDocserverId(['docserverId' => $storeResult['docserver_id']]); - - // LogsController::info(['message'=>'avant update', 'code'=>19, ]); - //update the Database - $resultOfUpDb = ProcessThumbnailsModel::updateDatabase( - [ - 'collId' => $collId, - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $resId, - 'docserver' => $targetDs, - 'path' => $storeResult['destination_dir'], - 'fileName' => $storeResult['file_destination_name'] - ] - ); - - if ($resultOfUpDb['status'] <> '0') { - ProcessThumbnailsModel::manageErrorOnDb( - ['resTable' => $resTable, 'resId' => $resId, 'result' => '-1'] - ); - return $resultOfUpDb; - } - - unlink($fileNameOnTmp); - unlink($fileNameOnTmp . '.png'); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessThumbnailsAbstract_Service::thumbnails' - ); - return $returnArray; - } - - /** - * Launch the thumbnails process - * - * @param string $srcfile source file - * @param string $tgtdir target dir - * @param string $srcfmt source format - * @return array $returnArray the result - */ - private function launchThumbnails( - $srcfile, - $tgtdir=false, - $srcfmt - ) { - $timestart = microtime(true); - if (!$tgtdir) { - $tgtdir = dirname($srcfile); - } - - $output = array(); - $return = null; - $this->errors = array(); - - //wkhtmltoimage must be installed with compiled sources - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - copy($srcfile, str_ireplace('.maarch', '.', $srcfile) . '.html'); - if (file_exists('/usr/bin/mywkhtmltoimage')) { - $command = "mywkhtmltoimage --width 164 --height 105 --quality 100 --zoom 0.2 " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.png'); - } else { - $envVar = "export DISPLAY=FRPAROEMINT:0.0 ; "; - $command = $envVar . "wkhtmltoimage --width 164 --height 105 --quality 100 --zoom 0.2 " - . escapeshellarg(str_ireplace('.maarch', '.', $srcfile) . '.html') . " " - . escapeshellarg($tgtdir . basename(str_ireplace('.maarch', '.', $srcfile)) . '.png'); - } - } else { - $command = "convert -thumbnail 200x300 -background white -alpha remove " - . escapeshellarg($srcfile) . "[0] " - . escapeshellarg($tgtdir . basename($srcfile) . '.png'); - } - //echo $command . PHP_EOL;exit; - $timestart_command = microtime(true); - exec($command, $output, $return); - // LogsController::debug(['message'=>'[TIMER] Commande : ' . $command]); - LogsController::executionTimeLog($timestart_command, '', 'debug', '[TIMER] Convert_ProcessThumbnailsAbstract_Service::launchThumbnails__exec'); - - if ($return === 0) { - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } else { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $return . $output, - ); - } - if (strtoupper($srcfmt) == 'MAARCH' || strtoupper($srcfmt) == 'HTML') { - $returnArray = array(); - unlink(str_ireplace('.maarch', '.', $srcfile) . '.html'); - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - } - LogsController::executionTimeLog( - $timestart, - '', - 'debug', - '[TIMER] Convert_ProcessThumbnailsAbstract_Service::launchThumbnails - '); - return $returnArray; - } -} diff --git a/modules/convert/Models/ProcessConvertModel.php b/modules/convert/Models/ProcessConvertModel.php deleted file mode 100755 index e8abb657f83f02783a37bff000f090aaea728a6a..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessConvertModel.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief Process Convert Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -class ProcessConvertModel extends ProcessConvertModelAbstract -{ - // Do your stuff in this class -} diff --git a/modules/convert/Models/ProcessConvertModelAbstract.php b/modules/convert/Models/ProcessConvertModelAbstract.php deleted file mode 100755 index 9b48b17b46dce0169094401c613641102d172347..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessConvertModelAbstract.php +++ /dev/null @@ -1,218 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief ProcessConvert Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -use History\controllers\HistoryController; -use SrcCore\models\DatabaseModel; -use SrcCore\models\ValidatorModel; - -class ProcessConvertModelAbstract -{ - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @return array $returnArray the result - */ - public static function updateDatabase(array $aArgs = []) - { - try { - ValidatorModel::notEmpty($aArgs, ['collId']); - ValidatorModel::notEmpty($aArgs, ['resTable']); - ValidatorModel::notEmpty($aArgs, ['adrTable']); - ValidatorModel::intVal($aArgs, ['resId']); - ValidatorModel::notEmpty($aArgs, ['docserver']); - ValidatorModel::notEmpty($aArgs, ['path']); - ValidatorModel::notEmpty($aArgs, ['fileName']); - - $aArgs['docserver']['path_template'] = str_replace( - DIRECTORY_SEPARATOR, - '#', - $aArgs['docserver']['path_template'] - ); - $aArgs['path'] = str_replace( - $aArgs['docserver']['path_template'], - '', - $aArgs['path'] - ); - - DatabaseModel::update([ - 'table' => 'convert_stack', - 'set' => [ - 'status' => 'P' - ], - 'where' => ['coll_id = ?', 'res_id = ?'], - 'data' => [$aArgs['collId'], $aArgs['resId']] - ]); - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - 'order' => ['adr_priority'], - ]); - - if (empty($returnAdr)) { - $returnRes = DatabaseModel::select([ - 'select' => ['docserver_id, path, filename, offset_doc, fingerprint'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - $returnRes = $returnRes[0]; - // LogsController::info(['message'=>$returnRes, 'code'=>8, ]); - $resDocserverId = $returnRes['docserver_id']; - $resPath = $returnRes['path']; - $resFilename = $returnRes['filename']; - $resOffsetDoc = $returnRes['offset_doc']; - $fingerprintInit = $returnRes['fingerprint']; - - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $resDocserverId, - 'path' => $resPath, - 'filename' => $resFilename, - 'offset_doc' => $resOffsetDoc, - 'fingerprint' => $fingerprintInit, - 'adr_priority' => 1, - ] - ]); - } - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?', 'adr_type= ?'], - 'data' => [$aArgs['resId'], 'CONV'], - ]); - - if (empty($returnAdr)) { - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - 'adr_type' => 'CONV', - ] - ]); - } else { - DatabaseModel::update([ - 'table' => $aArgs['adrTable'], - 'set' => [ - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - ], - 'where' => ['res_id = ?', "adr_type = ?"], - 'data' => [$aArgs['resId'], 'CONV'] - ]); - } - - HistoryController::add([ - 'tableName' => $aArgs['resTable'], - 'recordId' => (string) $aArgs['resId'], - 'eventType' => 'ADD', - 'info' => 'process convert done', - 'moduleId' => 'convert', - 'eventId' => 'convert', - ]); - - $queryCpt = DatabaseModel::select([ - 'select' => ["convert_attempts"], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - $cptConvert = $queryCpt[0]['convert_attempts'] + 1; - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'convert_result' => '1', - 'is_multi_docservers' => 'Y', - 'convert_attempts' => $cptConvert, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - return $returnArray; - } - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - public static function manageErrorOnDb(array $aArgs = []) - { - $attemptsRecord = DatabaseModel::select([ - 'select' => ['convert_attempts'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - if (empty($attemptsRecord)) { - $attempts = 0; - } else { - $attempts = $attemptsRecord[0]['convert_attempts'] + 1; - } - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'convert_result' => $aArgs['result'], - 'convert_attempts' => $attempts, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - } -} diff --git a/modules/convert/Models/ProcessFulltextModel.php b/modules/convert/Models/ProcessFulltextModel.php deleted file mode 100755 index ce546d414fe74e3225d65f93554701f3ccb4ef9b..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessFulltextModel.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief Process Fulltext Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -class ProcessFulltextModel extends ProcessFulltextModelAbstract -{ - // Do your stuff in this class -} diff --git a/modules/convert/Models/ProcessFulltextModelAbstract.php b/modules/convert/Models/ProcessFulltextModelAbstract.php deleted file mode 100755 index f6e123fd77b5f5c8beaedf012d81ab035b8e082d..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessFulltextModelAbstract.php +++ /dev/null @@ -1,246 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief ProcessFulltext Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -use History\controllers\HistoryController; -use SrcCore\models\DatabaseModel; -use SrcCore\models\ValidatorModel; - -class ProcessFulltextModelAbstract -{ - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @param complex $zendIndex zend index object - * @return array $returnArray the result - */ - public static function updateDatabase(array $aArgs = []) - { - try { - ValidatorModel::notEmpty($aArgs, ['collId']); - ValidatorModel::notEmpty($aArgs, ['resTable']); - ValidatorModel::notEmpty($aArgs, ['adrTable']); - ValidatorModel::intVal($aArgs, ['resId']); - ValidatorModel::notEmpty($aArgs, ['docserver']); - ValidatorModel::notEmpty($aArgs, ['path']); - ValidatorModel::notEmpty($aArgs, ['fileName']); - - $aArgs['docserver']['path_template'] = str_replace( - DIRECTORY_SEPARATOR, - '#', - $aArgs['docserver']['path_template'] - ); - $aArgs['path'] = str_replace( - $aArgs['docserver']['path_template'], - '', - $aArgs['path'] - ); - - DatabaseModel::update([ - 'table' => 'convert_stack', - 'set' => [ - 'status' => 'P' - ], - 'where' => ['coll_id = ?', 'res_id = ?'], - 'data' => [$aArgs['collId'], $aArgs['resId']] - ]); - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - 'order' => ['adr_priority'], - ]); - - if (empty($returnAdr)) { - $returnRes = DatabaseModel::select([ - 'select' => ['docserver_id, path, filename, offset_doc, fingerprint'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - $returnRes = $returnRes[0]; - // LogsController::info(['message'=>$returnRes, 'code'=>8, ]); - $resDocserverId = $returnRes['docserver_id']; - $resPath = $returnRes['path']; - $resFilename = $returnRes['filename']; - $resOffsetDoc = $returnRes['offset_doc']; - $fingerprintInit = $returnRes['fingerprint']; - - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $resDocserverId, - 'path' => $resPath, - 'filename' => $resFilename, - 'offset_doc' => $resOffsetDoc, - 'fingerprint' => $fingerprintInit, - 'adr_priority' => 1, - ] - ]); - } - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?', 'adr_type= ?'], - 'data' => [$aArgs['resId'], 'TXT'], - ]); - - if (empty($returnAdr)) { - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - 'adr_type' => 'TXT', - ] - ]); - } else { - DatabaseModel::update([ - 'table' => $aArgs['adrTable'], - 'set' => [ - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - ], - 'where' => ['res_id = ?', "adr_type = ?"], - 'data' => [$aArgs['resId'], 'TXT'] - ]); - } - - HistoryController::add([ - 'tableName' => $aArgs['resTable'], - 'recordId' => (string) $aArgs['resId'], - 'eventType' => 'ADD', - 'info' => 'process fulltext done', - 'moduleId' => 'convert', - 'eventId' => 'fulltext', - ]); - - $queryCpt = DatabaseModel::select([ - 'select' => ["fulltext_attempts"], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - $cptFulltext = $queryCpt[0]['fulltext_attempts'] + 1; - - if (!empty($aArgs['zendIndex'])) { - $fResult = 1; - } else { - $fResult = 0; - } - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'fulltext_result' => $fResult, - 'is_multi_docservers' => 'Y', - 'fulltext_attempts' => $cptFulltext, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - - return $returnArray; - } - } - - public static function getById(array $aArgs = []) - { - ValidatorModel::notEmpty($aArgs, ['resId']); - ValidatorModel::intVal($aArgs, ['resId']); - - $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['res_letterbox'], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - if (empty($aReturn[0])) { - return []; - } - - return $aReturn[0]; - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - public static function manageErrorOnDb(array $aArgs = []) - { - $attemptsRecord = DatabaseModel::select([ - 'select' => ['fulltext_attempts'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - if (empty($attemptsRecord)) { - $attempts = 0; - } else { - $attempts = $attemptsRecord[0]['fulltext_attempts'] + 1; - } - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'fulltext_result' => $aArgs['result'], - 'fulltext_attempts' => $attempts, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - } -} diff --git a/modules/convert/Models/ProcessThumbnailsModel.php b/modules/convert/Models/ProcessThumbnailsModel.php deleted file mode 100755 index c334b9fbccea69251c82b77eeaf7825d5797cd18..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessThumbnailsModel.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief Process Thumbnails Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -class ProcessThumbnailsModel extends ProcessThumbnailsModelAbstract -{ - // Do your stuff in this class -} diff --git a/modules/convert/Models/ProcessThumbnailsModelAbstract.php b/modules/convert/Models/ProcessThumbnailsModelAbstract.php deleted file mode 100755 index 63a23ebde95149525ae6fdfc0f8430ac6b6db137..0000000000000000000000000000000000000000 --- a/modules/convert/Models/ProcessThumbnailsModelAbstract.php +++ /dev/null @@ -1,240 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -/** -* @brief ProcessThumbnails Model -* @author dev@maarch.org -* @ingroup convert -*/ - -namespace Convert\Models; - -use History\controllers\HistoryController; -use SrcCore\models\DatabaseModel; -use SrcCore\models\ValidatorModel; - -class ProcessThumbnailsModelAbstract -{ - /** - * Updating the database with the location information of the document on the - * new docserver - * @param string $collId collection - * @param string $resTable res table - * @param string $adrTable adr table - * @param bigint $resId Id of the resource to process - * @param docserver $docserver docserver object - * @param string $path location of the resource on the docserver - * @param string $fileName file name of the resource on the docserver - * @param complex $zendIndex zend index object - * @return array $returnArray the result - */ - public static function updateDatabase(array $aArgs = []) - { - try { - ValidatorModel::notEmpty($aArgs, ['collId']); - ValidatorModel::notEmpty($aArgs, ['resTable']); - ValidatorModel::notEmpty($aArgs, ['adrTable']); - ValidatorModel::intVal($aArgs, ['resId']); - ValidatorModel::notEmpty($aArgs, ['docserver']); - ValidatorModel::notEmpty($aArgs, ['path']); - ValidatorModel::notEmpty($aArgs, ['fileName']); - - $aArgs['docserver']['path_template'] = str_replace( - DIRECTORY_SEPARATOR, - '#', - $aArgs['docserver']['path_template'] - ); - $aArgs['path'] = str_replace( - $aArgs['docserver']['path_template'], - '', - $aArgs['path'] - ); - - DatabaseModel::update([ - 'table' => 'convert_stack', - 'set' => [ - 'status' => 'P' - ], - 'where' => ['coll_id = ?', 'res_id = ?'], - 'data' => [$aArgs['collId'], $aArgs['resId']] - ]); - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - 'order' => ['adr_priority'], - ]); - - if (empty($returnAdr)) { - $returnRes = DatabaseModel::select([ - 'select' => ['docserver_id, path, filename, offset_doc, fingerprint'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - $returnRes = $returnRes[0]; - // LogsController::info(['message'=>$returnRes, 'code'=>8, ]); - $resDocserverId = $returnRes['docserver_id']; - $resPath = $returnRes['path']; - $resFilename = $returnRes['filename']; - $resOffsetDoc = $returnRes['offset_doc']; - $fingerprintInit = $returnRes['fingerprint']; - - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $resDocserverId, - 'path' => $resPath, - 'filename' => $resFilename, - 'offset_doc' => $resOffsetDoc, - 'fingerprint' => $fingerprintInit, - 'adr_priority' => 1, - ] - ]); - } - - $returnAdr = DatabaseModel::select([ - 'select' => ['*'], - 'table' => [$aArgs['adrTable']], - 'where' => ['res_id = ?', 'adr_type= ?'], - 'data' => [$aArgs['resId'], 'TNL'], - ]); - - if (empty($returnAdr)) { - DatabaseModel::insert([ - 'table' => $aArgs['adrTable'], - 'columnsValues' => [ - 'res_id' => $aArgs['resId'], - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - 'adr_type' => 'TNL', - ] - ]); - } else { - DatabaseModel::update([ - 'table' => $aArgs['adrTable'], - 'set' => [ - 'docserver_id' => $aArgs['docserver']['docserver_id'], - 'path' => $aArgs['path'], - 'filename' => $aArgs['fileName'], - 'offset_doc' => '', - 'fingerprint' => '', - 'adr_priority' => 1, - ], - 'where' => ['res_id = ?', "adr_type = ?"], - 'data' => [$aArgs['resId'], 'TNL'] - ]); - } - - HistoryController::add([ - 'tableName' => $aArgs['resTable'], - 'recordId' => (string) $aArgs['resId'], - 'eventType' => 'ADD', - 'info' => 'process thumbnails done', - 'moduleId' => 'convert', - 'eventId' => 'thumbnails', - ]); - - $queryCpt = DatabaseModel::select([ - 'select' => ["tnl_attempts"], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - $cptThumbnails = $queryCpt[0]['tnl_attempts'] + 1; - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'tnl_result' => 1, - 'is_multi_docservers' => 'Y', - 'tnl_attempts' => $cptThumbnails, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - $returnArray = array( - 'status' => '0', - 'value' => '', - 'error' => '', - ); - - return $returnArray; - } catch (Exception $e) { - $returnArray = array( - 'status' => '1', - 'value' => '', - 'error' => $e->getMessage(), - ); - - return $returnArray; - } - } - - public static function getById(array $aArgs = []) - { - ValidatorModel::notEmpty($aArgs, ['resId']); - ValidatorModel::intVal($aArgs, ['resId']); - - $aReturn = DatabaseModel::select([ - 'select' => empty($aArgs['select']) ? ['*'] : $aArgs['select'], - 'table' => ['res_letterbox'], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - - if (empty($aReturn[0])) { - return []; - } - - return $aReturn[0]; - } - - /** - * Updating the database with the error code - * @param string $resTable res table - * @param bigint $resId Id of the resource to process - * @param string $result error code - * @return nothing - */ - public static function manageErrorOnDb(array $aArgs = []) - { - $attemptsRecord = DatabaseModel::select([ - 'select' => ['tnl_attempts'], - 'table' => [$aArgs['resTable']], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']], - ]); - - if (empty($attemptsRecord)) { - $attempts = 0; - } else { - $attempts = $attemptsRecord[0]['tnl_attempts'] + 1; - } - - DatabaseModel::update([ - 'table' => $aArgs['resTable'], - 'set' => [ - 'tnl_result' => $aArgs['result'], - 'tnl_attempts' => $attempts, - ], - 'where' => ['res_id = ?'], - 'data' => [$aArgs['resId']] - ]); - } -} diff --git a/modules/convert/Test/ProcessConvertTest.php b/modules/convert/Test/ProcessConvertTest.php deleted file mode 100755 index 14537a76d43831042bce058d1234cc02b071303f..0000000000000000000000000000000000000000 --- a/modules/convert/Test/ProcessConvertTest.php +++ /dev/null @@ -1,117 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -namespace MaarchTest; -use PHPUnit\Framework\TestCase; - -class ProcessConvertTest extends TestCase -{ - public function testconvert () - { - $action = new \Resource\controllers\ResController(); - - $environment = \Slim\Http\Environment::mock( - [ - 'REQUEST_METHOD' => 'POST', - ] - ); - - $samplePath = 'modules/convert/Test/Samples/'; - - //SAMPLE TXT - $fileSource = 'test.txt'; - $fileFormat = 'txt'; - - $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; - - $data = []; - - array_push( - $data, - array( - 'column' => 'subject', - 'value' => 'UNIT TEST CONVERT from slim', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t1', - 'value' => 'TEST', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', - 'type' => 'string', - ) - ); - - $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => $fileFormat, - 'status' => 'new', - ]; - - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - - $resId = $responseBody->resId; - - if (!defined("_RES_ID_TEST_CONVERT")) { - define("_RES_ID_TEST_CONVERT", $resId); - } - - //real test - $request = \Slim\Http\Request::createFromEnvironment($environment); - $action = new \Convert\Controllers\ProcessConvertController(); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => _RES_ID_TEST_CONVERT, - 'tmpDir' => $_SESSION['config']['tmppath'] - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - //var_dump($response); - $responseBody = json_decode((string)$response->getBody()); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - } -} diff --git a/modules/convert/Test/ProcessFulltextTest.php b/modules/convert/Test/ProcessFulltextTest.php deleted file mode 100755 index fa01d225016e76ccee894ffb2b6a8e0f3254f62c..0000000000000000000000000000000000000000 --- a/modules/convert/Test/ProcessFulltextTest.php +++ /dev/null @@ -1,53 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -namespace MaarchTest; -use PHPUnit\Framework\TestCase; - -class ProcessFulltextTest extends TestCase -{ - - public function testfulltext () - { - - if (!defined("_RES_ID_TEST_CONVERT")) { - define("_RES_ID_TEST_CONVERT", 100); - } - - $action = new \Convert\Controllers\ProcessFulltextController(); - - $environment = \Slim\Http\Environment::mock( - [ - 'REQUEST_METHOD' => 'POST', - ] - ); - - $request = \Slim\Http\Request::createFromEnvironment($environment); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => _RES_ID_TEST_CONVERT, - 'tmpDir' => $_SESSION['config']['tmppath'], - 'createZendIndex' => true - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - //var_dump($response); - $responseBody = json_decode((string)$response->getBody()); - //var_dump($responseBody); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - } -} diff --git a/modules/convert/Test/ProcessManageConvertTest.php b/modules/convert/Test/ProcessManageConvertTest.php deleted file mode 100755 index 3a61a1a123dac4260b5687baad7a9b1d0a7bcd6e..0000000000000000000000000000000000000000 --- a/modules/convert/Test/ProcessManageConvertTest.php +++ /dev/null @@ -1,373 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -namespace MaarchTest; -use PHPUnit\Framework\TestCase; - -class ManageProcessConvertTest extends TestCase -{ - public function testmanageConvert () - { - $action = new \Resource\controllers\ResController(); - - $environment = \Slim\Http\Environment::mock( - [ - 'REQUEST_METHOD' => 'POST', - ] - ); - - $samplePath = 'modules/convert/Test/Samples/'; - - //SAMPLE TXT - $fileSource = 'test.txt'; - $fileFormat = 'txt'; - - $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; - - $data = []; - - array_push( - $data, - array( - 'column' => 'subject', - 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t1', - 'value' => 'TEST', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', - 'type' => 'string', - ) - ); - - $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => $fileFormat, - 'status' => 'new', - ]; - - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - - $resIdTxt = $responseBody->resId; - - //SAMPLE PDF - $fileSource = 'test.pdf'; - $fileFormat = 'pdf'; - - $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; - - $data = []; - - array_push( - $data, - array( - 'column' => 'subject', - 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t1', - 'value' => 'TEST', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', - 'type' => 'string', - ) - ); - - $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => $fileFormat, - 'status' => 'new', - ]; - - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - - $resIdPdf = $responseBody->resId; - - //SAMPLE ODT - $fileSource = 'test.odt'; - $fileFormat = 'odt'; - - $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; - - $data = []; - - array_push( - $data, - array( - 'column' => 'subject', - 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t1', - 'value' => 'TEST', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', - 'type' => 'string', - ) - ); - - $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => $fileFormat, - 'status' => 'new', - ]; - - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - - $resIdOdt = $responseBody->resId; - - //SAMPLE HTML - $fileSource = 'test.html'; - $fileFormat = 'html'; - - $fileContent = file_get_contents($samplePath . $fileSource, FILE_BINARY); - $encodedFile = base64_encode($fileContent); - //echo $encodedFile . PHP_EOL;exit; - - $data = []; - - array_push( - $data, - array( - 'column' => 'subject', - 'value' => 'UNIT TEST CONVERT ALL from slim with ' . $fileFormat . ' file', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'type_id', - 'value' => 110, - 'type' => 'integer', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t1', - 'value' => 'TEST', - 'type' => 'string', - ) - ); - - array_push( - $data, - array( - 'column' => 'custom_t10', - 'value' => 'lgi@maarch.org', - 'type' => 'string', - ) - ); - - $aArgs = [ - 'encodedFile' => $encodedFile, - 'data' => $data, - 'collId' => 'letterbox_coll', - 'table' => 'res_letterbox', - 'fileFormat' => $fileFormat, - 'status' => 'new', - ]; - - $request = \Slim\Http\Request::createFromEnvironment($environment); - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - - $resIdHtml = $responseBody->resId; - - /***************************************************************************/ - - //test TXT - $request = \Slim\Http\Request::createFromEnvironment($environment); - $action = new \Convert\Controllers\ProcessManageConvertController(); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => $resIdTxt, - 'tmpDir' => $_SESSION['config']['tmppath'], - 'createZendIndex' => true - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - - //test PDF - $request = \Slim\Http\Request::createFromEnvironment($environment); - $action = new \Convert\Controllers\ProcessManageConvertController(); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => $resIdPdf, - 'tmpDir' => $_SESSION['config']['tmppath'], - 'createZendIndex' => true - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - - //test ODT - $request = \Slim\Http\Request::createFromEnvironment($environment); - $action = new \Convert\Controllers\ProcessManageConvertController(); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => $resIdOdt, - 'tmpDir' => $_SESSION['config']['tmppath'], - 'createZendIndex' => true - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - - //test HTML - $request = \Slim\Http\Request::createFromEnvironment($environment); - $action = new \Convert\Controllers\ProcessManageConvertController(); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => $resIdHtml, - 'tmpDir' => $_SESSION['config']['tmppath'], - 'createZendIndex' => true - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - $responseBody = json_decode((string)$response->getBody()); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - } -} diff --git a/modules/convert/Test/ProcessThumbnailsTest.php b/modules/convert/Test/ProcessThumbnailsTest.php deleted file mode 100755 index 0007f083f24fe1ea3098d8e6830302e9ae54b2ce..0000000000000000000000000000000000000000 --- a/modules/convert/Test/ProcessThumbnailsTest.php +++ /dev/null @@ -1,52 +0,0 @@ -<?php - -/** -* Copyright Maarch since 2008 under licence GPLv3. -* See LICENCE.txt file at the root folder for more details. -* This file is part of Maarch software. -* -*/ - -namespace MaarchTest; -use PHPUnit\Framework\TestCase; - -class ProcessThumbnailsTest extends TestCase -{ - - public function testthumbnails () - { - - if (!defined("_RES_ID_TEST_CONVERT")) { - define("_RES_ID_TEST_CONVERT", 100); - } - - $action = new \Convert\Controllers\ProcessThumbnailsController(); - - $environment = \Slim\Http\Environment::mock( - [ - 'REQUEST_METHOD' => 'POST', - ] - ); - - $request = \Slim\Http\Request::createFromEnvironment($environment); - - $aArgs = [ - 'collId' => 'letterbox_coll', - 'resTable' => 'res_letterbox', - 'adrTable' => 'adr_letterbox', - 'resId' => _RES_ID_TEST_CONVERT, - 'tmpDir' => $_SESSION['config']['tmppath'] - ]; - - $response = new \Slim\Http\Response(); - $fullRequest = \httpRequestCustom::addContentInBody($aArgs, $request); - - $response = $action->create($fullRequest, $response); - //var_dump($response); - $responseBody = json_decode((string)$response->getBody()); - //var_dump($responseBody); - $status = $responseBody->status; - - $this->assertEquals('0', $status); - } -} diff --git a/modules/convert/Test/Samples/test.html b/modules/convert/Test/Samples/test.html deleted file mode 100755 index 974952b211c429304d9dd8d28c22e6a0eb9a1209..0000000000000000000000000000000000000000 --- a/modules/convert/Test/Samples/test.html +++ /dev/null @@ -1,8 +0,0 @@ -<html><head><meta content="text/html; charset=UTF-8" http-equiv="Content-Type"></head> - <!--<body id="validation_page" - onload="javascript:moveTo(0,0);"> - <div id="template_content" style="width:100%;">--> - <body><p style="text-align: center;" data-mce-style="text-align: center;"><span style="font-size: small; text-decoration: underline;" data-mce-style="font-size: small; text-decoration: underline;">ENREGISTREMENT DEMANDE Allo Mairie - DIVERS</span></p><p style="text-align: center;" data-mce-style="text-align: center;"> </p><table style="border: 1pt solid #000000; width: 800px; background-color: #40a497;" data-mce-style="border: 1pt solid #000000; width: 800px; background-color: #40a497;" cellpadding="5" cellspacing="1" border="1"><tbody><tr><td style="width: 200px;" data-mce-style="width: 200px;">DECLARATION DU BESOIN</td><td>DATE: 17-11-2015</td><td>HEURE: 18:01:46</td></tr></tbody></table><table style="border: 1pt solid #000000; width: 800px;" data-mce-style="border: 1pt solid #000000; width: 800px;" cellpadding="5" cellspacing="1" border="1"><tbody><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">OBJET</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> laurent</td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DATE ET HEURE ESTIMEES DU DECLENCHEMENT</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">IMPLANTATION / LOCALISATION</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> montest</td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DESCRIPTION</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">ETENDUE DU PROBLEME</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">NATURE DU DESAGREMENT</td><td> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">DELAIS DE TRAITEMENT SOUHAITE</td><td style="background-color: #bef3ec;" data-mce-style="background-color: #bef3ec;"> </td></tr><tr><td style="width: 200px; background-color: #40a497;" data-mce-style="width: 200px; background-color: #40a497;">AUTRES OBSERVATIONS</td><td> </td></tr></tbody></table><p><br data-mce-bogus="1"></p> <!--</div> - </body> - </html>--> - </body></html> \ No newline at end of file diff --git a/modules/convert/Test/Samples/test.odt b/modules/convert/Test/Samples/test.odt deleted file mode 100755 index 3038c23914d8df78dbda22d8437ab599bf36509b..0000000000000000000000000000000000000000 Binary files a/modules/convert/Test/Samples/test.odt and /dev/null differ diff --git a/modules/convert/Test/Samples/test.pdf b/modules/convert/Test/Samples/test.pdf deleted file mode 100755 index f698ff53d41575b222e6778f87f9e9fd8da4f2b1..0000000000000000000000000000000000000000 Binary files a/modules/convert/Test/Samples/test.pdf and /dev/null differ diff --git a/modules/convert/Test/Samples/test.txt b/modules/convert/Test/Samples/test.txt deleted file mode 100755 index 322dd17d9e0c31454494e3ccac534ada7a156000..0000000000000000000000000000000000000000 --- a/modules/convert/Test/Samples/test.txt +++ /dev/null @@ -1 +0,0 @@ -a unit test for PHP CONVERSION lorem ipsum... \ No newline at end of file diff --git a/modules/convert/ajax_convert.php b/modules/convert/ajax_convert.php deleted file mode 100755 index c6975a255fb10bca08b644b62e708e33f6657704..0000000000000000000000000000000000000000 --- a/modules/convert/ajax_convert.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php - -// sample for attachments in allMode : -// http://urltomaarch/apps/maarch_entreprise/index.php?page=ajax_convert&module=convert&id=1&collId=attachments_coll - -$func = new functions(); - -for ($i=0;$i<count($_SESSION['collections']);$i++) { - if ($_SESSION['collections'][$i]['id'] == $_REQUEST['collId']) { - $resTable = $_SESSION['collections'][$i]['table']; - $adrTable = $_SESSION['collections'][$i]['adr']; - } -} - -// echo $_REQUEST['collId'] . '<br />'; -// echo $resTable . PHP_EOL . '<br />'; -// echo $adrTable . PHP_EOL . '<br />'; -// echo $_REQUEST['id'] . PHP_EOL . '<br />'; - -$params = array( - 'collId' => $_REQUEST['collId'], - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $_REQUEST['id'], - 'tmpDir' => $_SESSION['config']['tmppath'] -); - -require_once 'core/services/ManageDocservers.php'; -$ManageDocservers = new Core_ManageDocservers_Service(); - -require_once 'modules/convert/services/ManageConvert.php'; -$ManageConvertService = new Convert_ManageConvert_Service(); -$resultOfConversion = $ManageConvertService->convertAll($params); - -//var_dump($resultOfConversion); diff --git a/modules/convert/batch/LoggerLog4php.php b/modules/convert/batch/LoggerLog4php.php deleted file mode 100755 index 22eb7fab0ec1991a89d935a48175b59b5a55f4d2..0000000000000000000000000000000000000000 --- a/modules/convert/batch/LoggerLog4php.php +++ /dev/null @@ -1,321 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** Logger class - * - * @author Laurent Giovannoni <dev@maarch.org> - **/ - -class Logger4Php -{ - - /** - * Array of errors levels - * - * @protected - **/ - protected $error_levels = array('DEBUG' => 0, 'INFO' => 1, 'NOTICE' => 2, 'WARNING' => 3, 'ERROR' => 4); - - /** - * Maps each handler with its log threshold. - * - * @protected - **/ - protected $mapping; - - /** - * Minimum log level - * - * @protected - **/ - protected $threshold_level; - - /** - * Path to log4Php library - * - * @protected - **/ - protected $log4PhpLibrary; - - /** - * Name of the logger - * - * @protected - **/ - protected $log4PhpLogger; - - /** - * Name of the business code - * - * @protected - **/ - protected $log4PhpBusinessCode; - - /** - * Path of the param of log4php - * - * @protected - **/ - protected $log4PhpConfigPath; - - /** - * Name of the batch - * - * @protected - **/ - protected $log4PhpBatchName; - - /** Class constructor - * - * Inits the threshold level - * - * @param $threshold_level (string) Threshold level (set to 'INFO' by default) - **/ - function __construct($threshold_level = 'WARNING') - { - $this->threshold_level = $threshold_level; - $this->mapping = array_fill(0, count($this->error_levels), array()); - } - - /** Writes error message in current handlers - * - * writes only if the error level is greater or equal the threshold level - * - * @param $msg (string) Error message - * @param $error_level (string) Error level (set to 'INFO' by default) - * @param $error_code (integer) Error code (set to 0 by default) - **/ - public function write($msg, $error_level = 'INFO', $error_code = 0, $other_params = array()) - { - if (!array_key_exists($error_level, $this->error_levels)) { - $error_level = 'INFO'; - } - $foundLogger = false; - if ($this->error_levels[$error_level] >= $this->error_levels[$this->threshold_level]) { - for ($i=$this->error_levels[$error_level];$i>=0;$i--) { - foreach ($this->mapping[$i] as $handler) { - $handler->write($msg, $error_level, $error_code, $other_params); - if ( - get_class($handler) == 'FileHandler' - && (isset($this->log4PhpLibrary) - && !empty($this->log4PhpLibrary)) - ) { - if ($error_code == 0) { - $result = 'OK'; - } else { - $result = 'KO'; - $msg = '%error_code:' . $error_code . '% ' . $msg; - } - require_once($this->log4PhpLibrary); - $remote_ip = '127.0.0.1'; - Logger::configure($this->log4PhpConfigPath); - $logger = Logger::getLogger($this->log4PhpLogger); - $searchPatterns = array('%ACCESS_METHOD%', - '%RESULT%', - '%BUSINESS_CODE%', - '%HOW%', - '%WHAT%', - '%REMOTE_IP%', - '%BATCH_NAME%' - ); - $replacePatterns = array('Script', - $result, - $this->log4PhpBusinessCode, - 'UP', - $msg, - $remote_ip, - $this->log4PhpBatchName - ); - $logLine = str_replace($searchPatterns, - $replacePatterns, - '[%ACCESS_METHOD%][%RESULT%]' - . '[%BUSINESS_CODE%][%HOW%][%WHAT%][%BATCH_NAME%]' - ); - $this->writeLog4php($logger, $logLine, $error_level); - } - } - } - } - } - - /** - * - * write a log entry with a specific log level - * @param object $logger Log4php logger - * @param string $logLine Line we want to trace - * @param enum $level Log level - */ - function writeLog4php($logger, $logLine, $level) { - switch ($level) { - case 'DEBUG': - $logger->debug($logLine); - break; - case 'INFO': - $logger->info($logLine); - break; - case 'WARNING': - $logger->warn($logLine); - break; - case 'ERROR': - $logger->error($logLine); - break; - case 'FATAL': - $logger->fatal($logLine); - break; - } - } - - /** Adds a new handler in the current handlers array - * - * @param $handler (object) Handler object - **/ - public function add_handler(&$handler, $error_level = NULL) - { - if(!isset($handler)) - return false; - - if(!isset($error_level) || !array_key_exists($error_level, $this->error_levels)) - { - $error_level = $this->threshold_level; - } - - $this->mapping[$this->error_levels[$error_level]][] = $handler; - return true; - } - - /** Adds a new handler in the current handlers array - * - * @param $handler (object) Handler object - **/ - public function change_handler_log_level(&$handler, $log_level ) - { - if (!isset($handler) || !isset($log_level)) - return false; - - if (!array_key_exists($log_level, $this->error_levels)) { - return false; - } - - for ($i=0; $i<count($this->mapping);$i++) { - for($j=0;$j<count($this->mapping[$i]);$j++) { - if($handler == $this->mapping[$i][$j]) { - unset($this->mapping[$i][$j]); - } - } - } - $this->mapping = array_values($this->mapping); - $this->mapping[$this->error_levels[$log_level]][] = $handler; - return true; - } - - /** Sets treshold level - * - * @param $treshold (string) treshold level - **/ - public function set_threshold_level($treshold) - { - if (isset($treshold) && array_key_exists($treshold, $this->error_levels)) { - $this->threshold_level = $treshold; - return true; - } - $this->threshold_level = 'WARNING'; - return false; - } - - /** Sets log4Php library path - * - * @param $log4PhpLibrary (string) path - **/ - public function set_log4PhpLibrary($log4PhpLibrary) - { - if (isset($log4PhpLibrary) && !empty($log4PhpLibrary)) { - if (file_exists($log4PhpLibrary)) { - $this->log4PhpLibrary = $log4PhpLibrary; - return true; - } else { - return false; - } - } - return false; - } - - /** Sets log4php logger name - * - * @param $log4PhpLogger (string) logger name - **/ - public function set_log4PhpLogger($log4PhpLogger) - { - if (isset($log4PhpLogger) && !empty($log4PhpLogger)) { - $this->log4PhpLogger = $log4PhpLogger; - return true; - } - $this->log4PhpLogger = 'loggerTechnique'; - return false; - } - - /** Sets log4php path to log4php xml config - * - * @param $log4PhpPath (string) path to log4php xml config - **/ - public function set_log4PhpConfigPath($log4PhpConfigPath) - { - if (isset($log4PhpConfigPath) && !empty($log4PhpConfigPath)) { - if (file_exists($log4PhpConfigPath)) { - $this->log4PhpConfigPath = $log4PhpConfigPath; - return true; - } else { - return false; - } - } - return false; - } - - /** Sets log4php business code - * - * @param $log4PhpBusinessCode (string) business code - **/ - public function set_log4PhpBusinessCode($log4PhpBusinessCode) - { - if (isset($log4PhpBusinessCode) && !empty($log4PhpBusinessCode)) { - $this->log4PhpBusinessCode = $log4PhpBusinessCode; - return true; - } - $this->log4PhpBusinessCode = 'Maarch'; - return false; - } - - /** Sets log4php batch name - * - * @param $log4PhpBatchName (string) BatchName - **/ - public function set_log4PhpBatchName($log4PhpBatchName) - { - if (isset($log4PhpBatchName) && !empty($log4PhpBatchName)) { - $this->log4PhpBatchName = $log4PhpBatchName; - return true; - } - $this->log4PhpBatchName = 'MaarchBatch'; - return false; - } - - /** Class destructor - * - * Calls handlers destructors - **/ - function __destruct() - { - for($i=0; $i<count($this->mapping);$i++) - { - foreach($this->mapping[$i] as $handler) - { - unset($handler); - } - } - } -} diff --git a/modules/convert/batch/batch_tools.php b/modules/convert/batch/batch_tools.php deleted file mode 100755 index 8b55200228fc7c1a9a0a28a0511a9ed4d1fa0f73..0000000000000000000000000000000000000000 --- a/modules/convert/batch/batch_tools.php +++ /dev/null @@ -1,291 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** - * @brief API to manage batchs - * - * @file - * @author Laurent Giovannoni - * @date $date$ - * @version $Revision$ - * @ingroup convert - */ - -/** - * Execute a sql query - * - * @param object $dbConn connection object to the database - * @param string $queryTxt path of the file to include - * @param boolean $transaction for rollback if error - * @return true if ok, exit if ko and rollback if necessary - */ -function Bt_doQuery($dbConn, $queryTxt, $param=array(), $transaction=false) -{ - if (count($param) > 0) { - $stmt = $dbConn->query($queryTxt, $param); - } else { - $stmt = $dbConn->query($queryTxt); - } - if (!$stmt) { - if ($transaction) { - $GLOBALS['logger']->write('ROLLBACK', 'INFO'); - $dbConn->query('ROLLBACK'); - } - $GLOBALS['logger']->write('SQL query error:' . $queryTxt, 'WARNING'); - } - $GLOBALS['logger']->write('SQL query:' . $queryTxt, 'DEBUG'); - return $stmt; -} - -/** - * Exit the batch with a return code, message in the log and - * in the database if necessary - * - * @param int $returnCode code to exit (if > O error) - * @param string $message message to the log and the DB - * @return nothing, exit the program - */ -function Bt_exitBatch($returnCode, $message='', $logLevel='') -{ - if (file_exists($GLOBALS['lckFile'])) { - unlink($GLOBALS['lckFile']); - } - if ($returnCode > 0) { - $GLOBALS['totalProcessedResources']--; - if ($GLOBALS['totalProcessedResources'] == -1) { - $GLOBALS['totalProcessedResources'] = 0; - } - if($returnCode < 100) { - if (file_exists($GLOBALS['errorLckFile'])) { - unlink($GLOBALS['errorLckFile']); - } - $semaphore = fopen($GLOBALS['errorLckFile'], "a"); - fwrite($semaphore, '1'); - fclose($semaphore); - } - if($logLevel == 'WARNING'){ - $GLOBALS['logger']->write($message, 'WARNING', $returnCode); - } else { - $GLOBALS['logger']->write($message, 'ERROR', $returnCode); - } - Bt_logInDataBase($GLOBALS['totalProcessedResources'], 1, 'return code:' - . $returnCode . ', ' . $message); - } elseif ($message <> '') { - $GLOBALS['logger']->write($message, 'INFO', $returnCode); - Bt_logInDataBase($GLOBALS['totalProcessedResources'], 0, 'return code:' - . $returnCode . ', ' . $message); - } - - $query = "delete from convert_stack " - . " where coll_id = ? "; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['collection'] - ) - ); - - exit($returnCode); -} - -/** -* Insert in the database the report of the batch -* @param long $totalProcessed total of resources processed in the batch -* @param long $totalErrors total of errors in the batch -* @param string $info message in db -*/ -function Bt_logInDataBase($totalProcessed=0, $totalErrors=0, $info='') -{ - $query = "insert into history_batch(module_name, batch_id, event_date, " - . "total_processed, total_errors, info) values(?, ?, " - . $GLOBALS['db']->current_datetime() . ", ?, ?, ?)"; - $stmt = $GLOBALS['dbLog']->query( - $query, - array( - $GLOBALS['batchName'], - $GLOBALS['wb'], - $totalProcessed, - $totalErrors, - substr(str_replace('\\', '\\\\', str_replace("'", "`", $info)), 0, 999) - ) - ); -} - -/** - * Get the batch if of the batch - * - * @return nothing - */ -function Bt_getWorkBatch() -{ - $req = "select param_value_int from parameters where id = ?"; - $stmt = $GLOBALS['db']->query($req, array($GLOBALS['batchName'] . "_id")); - while ($reqResult = $stmt->fetchObject()) { - $GLOBALS['wbCompute'] = $reqResult->param_value_int + 1; - } - if ($GLOBALS['wbCompute'] == '') { - $req = "insert into parameters(id, param_value_int) values " - . "(?, 1)"; - $stmt = $GLOBALS['db']->query($req, array($GLOBALS['batchName'] . "_id")); - $GLOBALS['wbCompute'] = 1; - } -} - -/** - * Update the database with the new batch id of the batch - * - * @return nothing - */ -function Bt_updateWorkBatch() -{ - $req = "update parameters set param_value_int = ? where id = ?"; - $stmt = $GLOBALS['db']->query($req, array($GLOBALS['wbCompute'], $GLOBALS['batchName'] . "_id")); -} - -/** - * Include the file requested if exists - * - * @param string $file path of the file to include - * @return nothing - */ -function Bt_myInclude($file) -{ - if (file_exists($file)) { - include_once ($file); - } else { - throw new IncludeFileError($file); - } -} - -/** - * Get the current date to process - * - * @return nothing - */ -function Bt_getCurrentDateToProcess() -{ - $req = "select param_value_date from parameters where id = ?"; - $stmt = $GLOBALS['db']->query( - $req, - array( - $GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date" - ) - ); - $reqResult = $stmt->fetchObject(); - if ($reqResult->param_value_date == '') { - $req = "insert into parameters(id, param_value_date) values (?, ?)"; - $stmt = $GLOBALS['db']->query( - $req, - array( - $GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date", - $GLOBALS['startDateRecovery'] - ) - ); - $GLOBALS['currentDate'] = $GLOBALS['startDateRecovery']; - } else { - $resultDate = formatDateFromDb($reqResult->param_value_date); - if ( - $GLOBALS['func']->compare_date( - $GLOBALS['startDateRecovery'], - $resultDate - ) == 'date1' - ) { - $GLOBALS['currentDate'] = $GLOBALS['startDateRecovery']; - } else { - $GLOBALS['currentDate'] = $resultDate; - } - } -} - -/** - * Update the database with the current date to process - * - * @return nothing - */ -function Bt_updateCurrentDateToProcess() -{ - $req = "update parameters set param_value_date = ? where id = ?"; - $stmt = $GLOBALS['db']->query( - $req, - array( - $GLOBALS['currentDate'], - $GLOBALS['batchName'] . "_" . $GLOBALS['collection'] . "_current_date" - ) - ); -} - -/** - * Compute the end current date to process - * - * @return nothing - */ -function Bt_getEndCurrentDateToProcess() -{ - $dateArray = array(); - $tabDate = explode('/' , $GLOBALS['currentDate']); - $theDate = $tabDate[2] . '-' . $tabDate[1] . '-' . $tabDate[0]; - $dateArray = date_parse($theDate); - $GLOBALS['endCurrentDate'] = strftime( - "%d/%m/%Y", mktime(0, 0, 0, $dateArray['month'] +1 , 0, $dateArray['year']) - ); -} - -/** - * Compute the next month currentDate - * - * @return nothing - */ -function Bt_computeNextMonthCurrentDate() -{ - $tabDate = array(); - $tabDate = explode('/' , $GLOBALS['currentDate']); - $theDate = $tabDate[2] . '-' . $tabDate[1] . '-' . $tabDate[0]; - $GLOBALS['currentDate'] = date("d/m/Y", strtotime('+1 month', strtotime($theDate))); - Bt_getEndCurrentDateToProcess(); -} - -/** - * Compute the creation date clause - * - * @return nothing - */ -function Bt_computeCreationDateClause() -{ - $GLOBALS['creationDateClause'] = ''; - if ($GLOBALS['currentDate'] <> '') { - $GLOBALS['creationDateClause'] = " and (creation_date >= '" . $GLOBALS['currentDate'] . "'"; - if ($GLOBALS['endCurrentDate'] <> '') { - $GLOBALS['creationDateClause'] .= " and creation_date <= '" . $GLOBALS['endCurrentDate'] . "'"; - } - $GLOBALS['creationDateClause'] .= ")"; - } -} - -/** -* Formats a datetime to a dd/mm/yyyy format (date) -* -* @param $date datetime The date to format -* @return datetime The formated date -*/ -function formatDateFromDb($date) -{ - $lastDate = ''; - if ($date <> "") { - if (strpos($date," ")) { - $date_ex = explode(" ",$date); - $theDate = explode("-",$date_ex[0]); - $lastDate = $theDate[0] . "/" . $theDate[1] . "/" . $theDate[2]; - } else { - $theDate = explode("-",$date); - $lastDate = $theDate[0] . "/" . $theDate[1] . "/" . $theDate[2]; - } - } - return $lastDate; -} diff --git a/modules/convert/batch/config/config.xml b/modules/convert/batch/config/config.xml deleted file mode 100755 index c3ee180b52933a0de30365eafd9ce968706e5704..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/config.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>DEBUG</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>DEBUG</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>1000</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>false</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrierTest</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/config.xml.default b/modules/convert/batch/config/config.xml.default deleted file mode 100755 index 7094b227dffadc524911ca8cc852b3b20d468495..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/config.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>false</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/config_only_convert.xml.default b/modules/convert/batch/config/config_only_convert.xml.default deleted file mode 100755 index 55549d7aa49458c8e7b7092734cf17665c77fb97..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/config_only_convert.xml.default +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>1000</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>false</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - <OnlyIndexes>false</OnlyIndexes> - <ProcessIndexesSize>50</ProcessIndexesSize> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/config_only_indexes.xml.default b/modules/convert/batch/config/config_only_indexes.xml.default deleted file mode 100755 index 71c692441f10fa5996ae2b4751cad7c0de216da7..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/config_only_indexes.xml.default +++ /dev/null @@ -1,67 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>1000</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>false</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - <OnlyIndexes>true</OnlyIndexes> - <ProcessIndexesSize>50</ProcessIndexesSize> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> diff --git a/modules/convert/batch/config/parallel/config_0.xml.default b/modules/convert/batch/config/parallel/config_0.xml.default deleted file mode 100755 index 28a7ec2312c24ae8c714d075cd0a6673d4197256..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/parallel/config_0.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>(0|1)$</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/parallel/config_1.xml.default b/modules/convert/batch/config/parallel/config_1.xml.default deleted file mode 100755 index 123ed3ac145ac19714a13e3441d7ec72c68339e2..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/parallel/config_1.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>(2|3)$</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/parallel/config_2.xml.default b/modules/convert/batch/config/parallel/config_2.xml.default deleted file mode 100755 index b30e3ba84c85ec2d34cde9f6d46315de6155f151..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/parallel/config_2.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>(4|5)$</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/parallel/config_3.xml.default b/modules/convert/batch/config/parallel/config_3.xml.default deleted file mode 100755 index aa851ceddb41a39e9c7c3acbea514e096e1e96c7..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/parallel/config_3.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>(6|7)$</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/config/parallel/config_4.xml.default b/modules/convert/batch/config/parallel/config_4.xml.default deleted file mode 100755 index 46d9f6993e0127c3469cee84849ec9ef8f672228..0000000000000000000000000000000000000000 --- a/modules/convert/batch/config/parallel/config_4.xml.default +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<ROOT> - <CONFIG> - <Lang>fr</Lang> <!-- fr, en--> - <MaarchDirectory>/var/www/html/MaarchCourrier/</MaarchDirectory> - <TmpDirectory>/var/www/html/MaarchCourrier/modules/convert/batch/tmp/</TmpDirectory> - <LogLevel>INFO</LogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <DisplayedLogLevel>INFO</DisplayedLogLevel> <!-- DEBUG, INFO, NOTICE, WARNING, ERROR--> - <StackSizeLimit>50</StackSizeLimit> - <ApacheUserAndGroup>lgi:lgi</ApacheUserAndGroup> - <UnoconvPath>unoconv</UnoconvPath> <!-- only for Windows --> - <OpenOfficePath>soffice</OpenOfficePath> <!-- only for Windows --> - <UnoconvOptions>--port 8100</UnoconvOptions> - <RegExResId>(8|9)$</RegExResId> - <StartDateRecovery>false</StartDateRecovery> <!-- false or date dd/mm/yyyy --> - <CurrentMonthOnly>false</CurrentMonthOnly> <!-- true or false --> - </CONFIG> - <CONVERT> - <OutputFormat>pdf</OutputFormat> - <InputFormat>odt,ott,odm,html,oth,ods,ots,odg,otg,odp,otp,odf,doc,docx,xls,xlsx,ppt,pptx,tiff,tif,png,jpeg,jpg,gif</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>html</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONVERT> - <OutputFormat>png</OutputFormat> - <InputFormat>odt,ods,doc,docx,xls,xlsx,ppt,pptx</InputFormat> - </CONVERT> - <CONFIG_BASE> - <databaseserver>127.0.0.1</databaseserver> - <databaseserverport>5432</databaseserverport> - <databasetype>POSTGRESQL</databasetype> - <databasename>MaarchCourrier</databasename> - <databaseuser>maarch</databaseuser> - <databasepassword>maarch</databasepassword> - </CONFIG_BASE> - <COLLECTION> - <Id>letterbox_coll</Id> - <Table>res_letterbox</Table> - <View>res_view_letterbox</View> - <Adr>adr_letterbox</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/letterbox_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>attachments_coll</Id> - <Table>res_attachments</Table> - <View>res_view_attachments</View> - <Adr>adr_attachments</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/attachments_coll/</path_to_lucene_index> - </COLLECTION> - <COLLECTION> - <Id>version_attachments_coll</Id> - <Table>res_version_attachments</Table> - <View>res_version_attachments</View> - <Adr>adr_attachments_version</Adr> - <path_to_lucene_index>/opt/maarch/docservers/indexes/version_attachments_coll/</path_to_lucene_index> - </COLLECTION> - <LOG4PHP> - <enabled>true</enabled> - <Log4PhpLogger>loggerTechnique</Log4PhpLogger> - <Log4PhpBusinessCode>Convert</Log4PhpBusinessCode> - <Log4PhpConfigPath>/var/www/html/MaarchCourrier/apps/maarch_entreprise/xml/log4php.xml</Log4PhpConfigPath> - </LOG4PHP> -</ROOT> \ No newline at end of file diff --git a/modules/convert/batch/fill_stack.php b/modules/convert/batch/fill_stack.php deleted file mode 100755 index 98c8930e40558f201cc2a833d0f969924b73d10a..0000000000000000000000000000000000000000 --- a/modules/convert/batch/fill_stack.php +++ /dev/null @@ -1,247 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** - * @brief Batch to convert - * - * @file - * @author Laurent Giovannoni <dev@maarch.org> - * @date $date$ - * @version $Revision$ - * @ingroup convert - */ - -/** - * ***** LIGHT PROBLEMS without an error semaphore - * 101 : Configuration file missing - * 102 : Configuration file does not exist - * 103 : Error on loading config file - * 104 : SQL Query Error - * 105 : a parameter is missin - * 106 : Maarch_CLITools is missing - * 107 : Stack full for the policy and the cycle requested - * 108 : Problem with the php include path - * 109 : An instance of the batch for the required policy and cyle is already - * in progress - * 110 : Problem with collection parameter - * 111 : No resource found - * **** HEAVY PROBLEMS with an error semaphore - * 11 : Cycle not found - * 12 : Previous cycle not found - * 13 : Error persists - * 14 : Cycle step not found - */ - -date_default_timezone_set('Europe/Paris'); -// load the config and prepare to process -include('load_fill_stack.php'); - -//TODO ONLY FOR DEBUG -// $query = "truncate table convert_stack"; -// $stmt = Bt_doQuery( -// $GLOBALS['db'], -// $query -// ); -// $query = "truncate table adr_letterbox"; -// $stmt = Bt_doQuery( -// $GLOBALS['db'], -// $query -// ); -// $query = "update res_letterbox set convert_result = 0"; -// $stmt = Bt_doQuery( -// $GLOBALS['db'], -// $query -// ); - -/******************************************************************************/ -/* beginning */ -$state = 'CONTROL_STACK'; -while ($state <> 'END') { - if (isset($GLOBALS['logger'])) { - $GLOBALS['logger']->write('STATE:' . $state, 'INFO'); - } - switch ($state) { - /**********************************************************************/ - /* CONTROL_STACK */ - /* Checking if the stack is full */ - /**********************************************************************/ - case 'CONTROL_STACK' : - //ONLY FOR TEST - $query = "truncate table convert_stack"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query - ); - - $query = "select count(1) as cpt from convert_stack " - . " where coll_id = ? and regex = ?"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array($GLOBALS['collection'], $GLOBALS['regExResId']) - ); - $resultCpt = $stmt->fetchObject(); - if ($resultCpt->cpt > 0) { - Bt_exitBatch(107, 'stack is full for collection:' - . $GLOBALS['collection'] . ', regex:' - . $GLOBALS['regExResId'] - , 'WARNING'); - break; - } - $state = 'SELECT_RES'; - break; - /**********************************************************************/ - /* SELECT_RES */ - /* Selects candidates */ - /**********************************************************************/ - case 'SELECT_RES' : - $orderBy = ' order by res_id '; - if ($GLOBALS['stackSizeLimit'] <> '') { - $limit = ' LIMIT ' . $GLOBALS['stackSizeLimit']; - } - - if ($GLOBALS['OnlyIndexes']) { - $where_clause = " convert_result = '1' and ( (fulltext_result = '0' or fulltext_result = '' " - . "or fulltext_result is null) or (fulltext_result= '-1' and (convert_attempts < 3))) "; - $where_clause .= $GLOBALS['creationDateClause'] - . $GLOBALS['whereRegex']; - } else { - $where_clause = " (convert_result = '0' or convert_result = '' " - . "or convert_result is null) or (convert_result= '-1' and (convert_attempts < 3)) " - . $GLOBALS['creationDateClause'] - . $GLOBALS['whereRegex']; - } - - $query = $GLOBALS['db']->limit_select( - 0, - $GLOBALS['stackSizeLimit'], - 'res_id', - $GLOBALS['table'], - $where_clause, - $orderBy - ); - $stmt = Bt_doQuery($GLOBALS['db'], $query); - $resourcesArray = array(); - - while ($resoucesRecordset = $stmt->fetchObject()) { - array_push( - $resourcesArray, - array('res_id' => $resoucesRecordset->res_id) - ); - } - - if (count($resourcesArray) == 0) { - if ($GLOBALS['creationDateClause'] <> '') { - $GLOBALS['logger']->write('No resource found for collection', 'INFO'); - // test if we have to change the current date - if ($GLOBALS['currentMonthOnly'] == 'false') { - if ($GLOBALS['OnlyIndexes']) { - $queryTestDate = " convert_result = '1' and ( (fulltext_result = '0' or fulltext_result = '' " - . "or fulltext_result is null) or (fulltext_result= '-1' and (fulltext_attempts < 3))) "; - $queryTestDate .= $GLOBALS['creationDateClause']; - } else { - $queryTestDate = " select count(res_id) as totalres from " - . $GLOBALS['table'] . " (convert_result = '0' or convert_result = '' " - . "or convert_result is null) or (convert_result= '-1' and (convert_attempts < 3)) " - . $GLOBALS['creationDateClause']; - } - $stmt = Bt_doQuery( - $GLOBALS['db'], - $queryTestDate - ); - $resultTotal = $stmt->fetchObject(); - if ($resultTotal->totalres == 0) { - Bt_computeNextMonthCurrentDate(); - Bt_computeCreationDateClause(); - Bt_updateCurrentDateToProcess(); - if ($GLOBALS['OnlyIndexes']) { - $where_clause = " convert_result = '1' and ( (fulltext_result = '0' or fulltext_result = '' " - . "or fulltext_result is null) or (fulltext_result= '-1' and (fulltext_attempts < 3))) "; - $where_clause .= $GLOBALS['creationDateClause'] - . $GLOBALS['whereRegex']; - } else { - $where_clause = " (convert_result = '0' or convert_result = '' " - . "or convert_result is null) or (convert_result= '-1' and (convert_attempts < 3)) " - . $GLOBALS['creationDateClause'] - . $GLOBALS['whereRegex']; - } - - $query = $GLOBALS['db']->limit_select( - 0, - $GLOBALS['stackSizeLimit'], - 'res_id', - $GLOBALS['table'], - $where_clause, - $orderBy - ); - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query - ); - $resourcesArray = array(); - while ($resoucesRecordset = $stmt->fetchObject()) { - array_push( - $resourcesArray, - array('res_id' => $resoucesRecordset->res_id) - ); - } - if (count($resourcesArray) == 0) { - $GLOBALS['logger']->write('No resource found for collection', 'INFO'); - } - } - } - } else { - $GLOBALS['logger']->write('No resource found for collection', 'INFO'); - } - } - $state = 'FILL_STACK'; - break; - /**********************************************************************/ - /* FILL_STACK */ - /* Fill the stack of candidates */ - /**********************************************************************/ - case 'FILL_STACK' : - for ($cptRes = 0;$cptRes < count($resourcesArray);$cptRes++) { - $query = "insert into convert_stack" - . " (coll_id, res_id, status, work_batch, regex) " - . "values (?, ?, 'I', ?, ?)"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['collection'], - $resourcesArray[$cptRes]["res_id"], - $GLOBALS['wb'], - $GLOBALS['regExResId'] - ) - ); - //history - $query = "insert into " . HISTORY_TABLE - . " (table_name, record_id, event_type, user_id, " - . "event_date, info, id_module) values (?, ?, 'ADD', 'CONVERT_BOT', " - . $GLOBALS['db']->current_datetime() - . ", ?, 'convert')"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['table'], - $resourcesArray[$cptRes]["res_id"], - "convert fill stack for collection:" . $GLOBALS['collection'] - ) - ); - $GLOBALS['totalProcessedResources']++; - } - $state = 'END'; - break; - } -} -$GLOBALS['logger']->write('End of process fill stack', 'INFO'); -include('process_stack.php'); -exit($GLOBALS['exitCode']); diff --git a/modules/convert/batch/load_fill_stack.php b/modules/convert/batch/load_fill_stack.php deleted file mode 100755 index 3721e3515a0e0fb22a8c98dd3e8a3a2ece853e24..0000000000000000000000000000000000000000 --- a/modules/convert/batch/load_fill_stack.php +++ /dev/null @@ -1,383 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** - * @brief Library to convert - * - * @file - * @author Laurent Giovannoni <dev@maarch.org> - * @date $date$ - * @version $Revision$ - * @ingroup convert - */ - -/** -* @brief Class to include the file error -* -* @ingroup convert -*/ -class IncludeFileError extends Exception -{ - public function __construct($file) - { - $this->file = $file; - parent :: __construct('Include File \'$file\' is missing!', 1); - } -} - -try { - include('Maarch_CLITools/ArgsParser.php'); - include('LoggerLog4php.php'); - include('Maarch_CLITools/FileHandler.php'); - include('Maarch_CLITools/ConsoleHandler.php'); -} catch (IncludeFileError $e) { - echo 'Maarch_CLITools required ! \n (pear.maarch.org)\n'; - exit(106); -} -include('batch_tools.php'); -// Globals variables definition -$state = ''; -$configFile = ''; -$MaarchDirectory = ''; -$batchDirectory = ''; -$batchName = 'convert'; -$TmpDirectory = ''; -$table = ''; -$adrTable = ''; -$view = ''; -$coll = ''; -$creationDateClause = ''; -$currentStep = ''; -$docservers = Array(); -$docserverSourcePath = ''; -$docserverSourceFingerprint = ''; -$databasetype = ''; -$exitCode = 0; -$running_date = date('Y-m-d H:i:s'); -$func = ''; -$db = ''; -$db2 = ''; -$db3 = ''; -$docserverControler = ''; -$wb = ''; -$wbCompute = ''; -$stackSizeLimit = ''; -$docserversFeatures = array(); -$lckFile = ''; -$errorLckFile = ''; -$totalProcessedResources = 0; -$apacheUserAndGroup = ''; -$regExResId = 'false'; -$startDateRecovery = 'false'; -$currentDate = 'false'; -$endCurrentDate = 'false'; -$currentMonthOnly = 'false'; -$OnlyIndexes = 'false'; -$ProcessIndexesSize = 1000; -$whereRegex = ''; -$log4PhpEnabled = false; - -// Defines scripts arguments -$argsparser = new ArgsParser(); -// The config file -$argsparser->add_arg( - 'config', - array( - 'short' => 'c', - 'long' => 'config', - 'mandatory' => true, - 'help' => 'Config file path is mandatory.', - ) -); -// The res collection target -$argsparser->add_arg( - 'collection', - array( - 'short' => 'coll', - 'long' => 'collection', - 'mandatory' => true, - 'help' => 'Collection target is mandatory.', - ) -); -// The path of the log directory -$argsparser->add_arg( - 'logs', - array( - 'short' => 'logs', - 'long' => 'logs', - 'mandatory' => false, - 'help' => '', - ) -); -// Parsing script options -try { - $options = $argsparser->parse_args($GLOBALS['argv']); - // If option = help then options = false and the script continues ... - if ($options == false) { - exit(0); - } -} catch (MissingArgumentError $e) { - if ($e->arg_name == 'config') { - $GLOBALS['logger']->write('Configuration file missing', 'ERROR', 101); - exit(101); - } - if ($e->arg_name == 'collection') { - $GLOBALS['logger']->write('Collection missing', 'ERROR', 1); - exit(105); - } -} -// Log management -$GLOBALS['logger'] = new Logger4Php(); -$GLOBALS['logger']->set_threshold_level('DEBUG'); -$console = new ConsoleHandler(); -$GLOBALS['logger']->add_handler($console); -if (!empty($options['logs'])) { - $logFile = $options['logs'] . '/' . date('Y-m-d_H-i-s') . '.log'; -} else { - $logFile = 'logs' . '/' . date('Y-m-d_H-i-s') . '.log'; -} -$file = new FileHandler($logFile); -$GLOBALS['logger']->add_handler($file); -$GLOBALS['logger']->write('STATE:INIT', 'INFO'); -$txt = ''; -foreach (array_keys($options) as $key) { - if (isset($options[$key]) && $options[$key] == false) { - $txt .= $key . '=false,'; - } else { - $txt .= $key . '=' . $options[$key] . ','; - } -} -$GLOBALS['logger']->write($txt, 'DEBUG'); -$GLOBALS['configFile'] = $options['config']; -$GLOBALS['collection'] = $options['collection']; -$GLOBALS['logger']->write($txt, 'INFO'); -// Tests existence of config file -if (!file_exists($GLOBALS['configFile'])) { - $GLOBALS['logger']->write('Configuration file ' . $GLOBALS['configFile'] - . ' does not exist', 'ERROR', 102); - exit(102); -} -// Loading config file -$GLOBALS['logger']->write('Load xml config file:' . $GLOBALS['configFile'], - 'INFO'); -$xmlconfig = simplexml_load_file($GLOBALS['configFile']); -if ($xmlconfig == FALSE) { - $GLOBALS['logger']->write('Error on loading config file:' - . $GLOBALS['configFile'], 'ERROR', 103); - exit(103); -} -// Load the config vars -$CONFIG = $xmlconfig->CONFIG; -$lang = (string) $CONFIG->Lang; -$GLOBALS['MaarchDirectory'] = (string) $CONFIG->MaarchDirectory; -$GLOBALS['batchDirectory'] = $GLOBALS['MaarchDirectory'] . 'modules/convert/batch'; -$GLOBALS['tmpDirectoryRoot'] = (string) $CONFIG->TmpDirectory; -$MaarchApps = (string) $CONFIG->MaarchApps; -$logLevel = (string) $CONFIG->LogLevel; -$GLOBALS['logger']->set_threshold_level($logLevel); -$DisplayedLogLevel = (string) $CONFIG->DisplayedLogLevel; -$GLOBALS['apacheUserAndGroup'] = (string) $CONFIG->ApacheUserAndGroup; -$GLOBALS['stackSizeLimit'] = (string) $CONFIG->StackSizeLimit; -$GLOBALS['databasetype'] = (string) $xmlconfig->CONFIG_BASE->databasetype; -$GLOBALS['unoconvPath'] = (string) $CONFIG->UnoconvPath; -$GLOBALS['openOfficePath'] = (string) $CONFIG->OpenOfficePath; -$GLOBALS['unoconvOptions'] = (string) $CONFIG->UnoconvOptions; - -$GLOBALS['regExResId'] = (string) $CONFIG->RegExResId; -$GLOBALS['startDateRecovery'] = (string) $CONFIG->StartDateRecovery; -$GLOBALS['currentMonthOnly'] = (string) $CONFIG->CurrentMonthOnly; -$GLOBALS['OnlyIndexes'] = (string) $CONFIG->OnlyIndexes; - -if ($GLOBALS['OnlyIndexes'] == 'true') { - $GLOBALS['OnlyIndexes'] = true; -} else { - $GLOBALS['OnlyIndexes'] = false; -} - -$GLOBALS['ProcessIndexesSize'] = (string) $CONFIG->ProcessIndexesSize; - -if ($GLOBALS['regExResId'] <> 'false') { - if ($GLOBALS['databasetype'] == 'POSTGRESQL') { - $GLOBALS['whereRegex'] = " and cast(res_id as character varying(255)) ~ '" - . $GLOBALS['regExResId'] . "' "; - } elseif ($GLOBALS['databasetype'] == 'ORACLE') { - $GLOBALS['whereRegex'] = " and REGEXP_LIKE (to_char(res_id), '" - . $GLOBALS['regExResId'] . "') "; - } -} - -$arrayOfInputs = array(); -$GLOBALS['convertFormats'] = array(); -$i = 0; -foreach ($xmlconfig->CONVERT as $convert) { - $outputFormat = (string) $convert->OutputFormat; - $arrayOfInputs = explode(',', (string) $convert->InputFormat); - $cptInputs = count($arrayOfInputs); - for ($j=0;$j<$cptInputs;$j++) { - if (!empty($GLOBALS['convertFormats'][$arrayOfInputs[$j]])) { - $GLOBALS['convertFormats'][$arrayOfInputs[$j]] .= "_" . $outputFormat; - } else { - $GLOBALS['convertFormats'][$arrayOfInputs[$j]] .= $outputFormat; - } - } - $i++; -} - -//var_dump($GLOBALS['convertFormats']); - -$i = 0; -foreach ($xmlconfig->COLLECTION as $col) { - $GLOBALS['collections'][$i] = array ( - 'id' => (string) $col->Id, - 'table' => (string) $col->Table, - 'view' => (string) $col->View, - 'adr' => (string) $col->Adr, - 'path_to_lucene' => (string) $col->path_to_lucene_index - ); - if ($GLOBALS['collections'][$i]['id'] == $GLOBALS['collection']) { - $GLOBALS['table'] = $GLOBALS['collections'][$i]['table']; - $GLOBALS['adrTable'] = $GLOBALS['collections'][$i]['adr']; - $GLOBALS['view'] = $GLOBALS['collections'][$i]['view']; - $GLOBALS['path_to_lucene'] = $GLOBALS['collections'][$i]['path_to_lucene']; - } - $i++; -} - -set_include_path(get_include_path() . PATH_SEPARATOR - . $GLOBALS['MaarchDirectory']); -//log4php params -$log4phpParams = $xmlconfig->LOG4PHP; -if ((string) $log4phpParams->enabled == 'true') { - $GLOBALS['logger']->set_log4PhpLibrary( - $GLOBALS['MaarchDirectory'] - . 'apps/maarch_entreprise/tools/log4php/Logger.php' - ); - $GLOBALS['logger']->set_log4PhpLogger((string) $log4phpParams->Log4PhpLogger); - $GLOBALS['logger']->set_log4PhpBusinessCode((string) $log4phpParams->Log4PhpBusinessCode); - $GLOBALS['logger']->set_log4PhpConfigPath((string) $log4phpParams->Log4PhpConfigPath); - $GLOBALS['logger']->set_log4PhpBatchName('convert'); -} - -if ($GLOBALS['table'] == '' - || $GLOBALS['adrTable'] == '' - || $GLOBALS['view'] == '' -) { - $GLOBALS['logger']->write('Collection:' . $GLOBALS['collection'].' unknow' - , 'ERROR', 110); - exit(110); -} -if (file_exists($GLOBALS['MaarchDirectory'] . 'modules/convert/lang/' . $lang . '.php') -) { - include($GLOBALS['MaarchDirectory'] . 'modules/convert/lang/' . $lang . '.php'); -} -/*if ($logLevel == 'DEBUG') { - error_reporting(E_ALL); -}*/ -$GLOBALS['logger']->change_handler_log_level($file, $logLevel); -$GLOBALS['logger']->change_handler_log_level($console, $DisplayedLogLevel); -unset($xmlconfig); - -// Include library -try { - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'vendor/autoload.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_functions.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_db_pdo.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/class_core_tools.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/core_tables.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docservers_controler.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/docservers_tools.php'); - Bt_myInclude($GLOBALS['MaarchDirectory'] . 'core/class/docserver_types_controler.php'); - //Bt_myInclude($GLOBALS['MaarchDirectory'] . 'modules/convert/services/ManageConvert.php'); -} catch (IncludeFileError $e) { - $GLOBALS['logger']->write( - 'Problem with the php include path:' - . get_include_path(), 'ERROR', 111 - ); - exit(111); -} -if (!is_dir($GLOBALS['tmpDirectoryRoot'])) { - mkdir($GLOBALS['tmpDirectoryRoot']); - // echo PHP_EOL.'tmpDirectoryRoot '.$GLOBALS['tmpDirectoryRoot'].PHP_EOL; - // $GLOBALS['logger']->write( - // 'Problem with the tmp dir:' . $GLOBALS['tmpDirectoryRoot'], 'ERROR', 17 - // ); - // exit(17); -} - -$coreTools = new core_tools(); -$coreTools->load_lang($lang, $GLOBALS['MaarchDirectory'], $MaarchApps); -session_start(); -$_SESSION['modules_loaded'] = array(); -$_SESSION['user']['UserId'] = 'BOT_CONVERT'; -$GLOBALS['func'] = new functions(); -$GLOBALS['db'] = new Database($GLOBALS['configFile']); -$GLOBALS['db2'] = new Database($GLOBALS['configFile']); -$GLOBALS['db3'] = new Database($GLOBALS['configFile']); -$GLOBALS['dbLog'] = new Database($GLOBALS['configFile']); -$GLOBALS['docserverControler'] = new docservers_controler(); -$GLOBALS['processConvert'] = new \Convert\Controllers\ProcessManageConvertController($GLOBALS['openOfficePath']); -$GLOBALS['processIndexes'] = new \Convert\Controllers\ProcessFulltextController(); - -$configFileName = basename($GLOBALS['configFile'], '.xml'); -$GLOBALS['errorLckFile'] = $GLOBALS['batchDirectory'] . '/' - . $GLOBALS['batchName'] . '_' . $GLOBALS['collection'] - . '_' . $configFileName - . '_error.lck'; -$GLOBALS['lckFile'] = $GLOBALS['batchDirectory'] . '/' - . $GLOBALS['batchName'] . '_' . $GLOBALS['collection'] - . '_' . $configFileName - . '.lck'; -if (file_exists($GLOBALS['errorLckFile'])) { - $GLOBALS['logger']->write( - 'Error persists, please solve this before launching a new batch', - 'ERROR', 29 - ); - exit(29); -} -if (file_exists($GLOBALS['lckFile'])) { - $GLOBALS['logger']->write( - 'An instance of the batch :' . $GLOBALS['batchName'] . '_' - . $GLOBALS['collection'] . '_' . $configFileName - . ' is already in progress', - 'ERROR', 109 - ); - exit(109); -} - -if ($GLOBALS['currentMonthOnly'] == 'true') { - $GLOBALS['currentDate'] = date( - "d/m/Y", - mktime(0, 0, 0, date("m"), 1, date("Y")) - ); - Bt_getEndCurrentDateToProcess(); - Bt_computeCreationDateClause(); - $GLOBALS['logger']->write('current begin date to process : ' - . $GLOBALS['currentDate'], 'INFO'); -} elseif ($GLOBALS['startDateRecovery'] <> 'false') { - Bt_getCurrentDateToProcess(); - Bt_updateCurrentDateToProcess(); - Bt_getEndCurrentDateToProcess(); - Bt_computeCreationDateClause(); - $GLOBALS['logger']->write('current begin date to process : ' - . $GLOBALS['currentDate'], 'INFO'); -} - -$semaphore = fopen($GLOBALS['lckFile'], 'a'); -fwrite($semaphore, '1'); -fclose($semaphore); -Bt_getWorkBatch(); -$GLOBALS['wb'] = rand() . $GLOBALS['wbCompute']; -Bt_updateWorkBatch(); -$GLOBALS['logger']->write('Batch number:' . $GLOBALS['wb'], 'INFO'); -$GLOBALS['tmpDirectory'] = $GLOBALS['tmpDirectoryRoot'] . '/' - . $GLOBALS['wb'] . '/'; -if (!is_dir($GLOBALS['tmpDirectory'])) { - mkdir($GLOBALS['tmpDirectory'], 0777); -} diff --git a/modules/convert/batch/process_stack.php b/modules/convert/batch/process_stack.php deleted file mode 100755 index c5d46ecbf4536a054f6d17fd4d600c17b68ad7c1..0000000000000000000000000000000000000000 --- a/modules/convert/batch/process_stack.php +++ /dev/null @@ -1,233 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -/** - * @brief Batch to process the stack - * - * @file - * @author Laurent Giovannoni <dev@maarch.org> - * @date $date$ - * @version $Revision$ - * @ingroup convert - */ - -/** - * ***** LIGHT PROBLEMS without an error semaphore - * 101 : Configuration file missing - * 102 : Configuration file does not exist - * 103 : Error on loading config file - * 104 : SQL Query Error - * 105 : a parameter is missing - * 106 : Maarch_CLITools is missing - * 107 : Stack empty for the request - * 108 : There are still documents to be processed - * 109 : An instance of the batch for the required collection already - * in progress - * 110 : Problem with collection parameter - * 111 : Problem with the php include path - * 112 : Problem with the setup of esign - * **** HEAVY PROBLEMS with an error semaphore - * 12 : Docserver type not found - * 13 : Docserver not found - * 14 : ... - * 15 : Error to copy file on docserver - * 16 : ... - * 17 : Tmp dir not exists - * 18 : Problem to create path on docserver, maybe batch number - * already exists - * 19 : Tmp dir not empty - * 20 : ... - * 21 : Problem to create directory on the docserver - * 22 : Problem during transfert of file (fingerprint control) - * 23 : Problem with compression - * 24 : Problem with extract - * 25 : Pb with fingerprint of the source - * 26 : File deletion impossible - * 27 : Resource not found - * 28 : The docserver will be full at 95 percent - * 29 : Error persists - * 30 : Esign problem - */ - -date_default_timezone_set('Europe/Paris'); - -/******************************************************************************/ -/* beginning */ -$GLOBALS['state'] = "CONTROL_STACK"; -while ($GLOBALS['state'] <> "END") { - if (isset($GLOBALS['logger'])) { - $GLOBALS['logger']->write("STATE:" . $GLOBALS['state'], 'DEBUG'); - } - switch($GLOBALS['state']) { - /**********************************************************************/ - /* CONTROL_STACK */ - /* Checking the stack is empty for the required parameters */ - /**********************************************************************/ - case "CONTROL_STACK" : - $query = "select * from convert_stack" - . " where coll_id = ? and work_batch = ?"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['collection'], - $GLOBALS['wb'] - ) - ); - Bt_updateWorkBatch(); - $GLOBALS['logger']->write("Batch number:" . $GLOBALS['wb'], 'INFO'); - $query = "update convert_stack" - . " set status = 'I' where status = 'W'" - . " and work_batch = ?"; - $stmt = Bt_doQuery($GLOBALS['db'], $query, array($GLOBALS['wb'])); - if ($GLOBALS['OnlyIndexes']) { - //echo 'avant createZendIndexObject : ' . $GLOBALS['ProcessIndexesSize'] . PHP_EOL; - $GLOBALS['zendIndex'] = - $GLOBALS['processIndexes']->createZendIndexObject( - $GLOBALS['path_to_lucene'], $GLOBALS['ProcessIndexesSize'] - ); - //$GLOBALS['zendIndex']->setMergeFactor(10); - //print_r($GLOBALS['zendIndex']); - } - $GLOBALS['state'] = "GET_DOCSERVERS"; - break; - /**********************************************************************/ - /* GET_DOCSERVERS */ - /* Get the list of the docservers of the collection */ - /**********************************************************************/ - case "GET_DOCSERVERS" : - //retrieve docservers of the collection to process - $query = "select * from docservers " - . " where coll_id = ?"; - $stmt = Bt_doQuery( - $GLOBALS['db2'], - $query, - array($GLOBALS['collection']) - ); - $stmtCpt = $stmt; - if ($stmtCpt->fetchObject()->docserver_id == '') { - Bt_exitBatch(13, 'Docserver not found'); - break; - } else { - while($docserversRecordset = $stmt->fetchObject()) { - $GLOBALS['docservers'][$docserversRecordset->docserver_id] - = $GLOBALS['func']->object2array($docserversRecordset); - } - } - $GLOBALS['state'] = "A_RECORD"; - break; - /**********************************************************************/ - /* A_RECORD */ - /* Process a record */ - /**********************************************************************/ - case "A_RECORD" : - $GLOBALS['totalProcessedResources']++; - $query = "select * from convert_stack " - . " where coll_id = ? " - . " and status = 'I' " - . " and work_batch = ? limit 1"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['collection'], - $GLOBALS['wb'] - ) - ); - $stackRecordset = $stmt->fetchObject(); - if (!($stackRecordset->res_id)) { - if ($GLOBALS['OnlyIndexes']) { - $GLOBALS['processIndexes']->commitZendIndex($GLOBALS['zendIndex']); - } - $GLOBALS['state'] = "END"; - $GLOBALS['logger']->write('No more records to process', 'INFO'); - break; - } else { - $currentRecordInStack = array(); - $currentRecordInStack = $GLOBALS['func']->object2array( - $stackRecordset - ); - $GLOBALS['logger']->write( - "current record:" . $currentRecordInStack['res_id'], - 'DEBUG' - ); - $GLOBALS['state'] = "CONVERT_IT"; - } - break; - /**********************************************************************/ - /* CONVERT_IT */ - /* Removes the address of the resource in the database */ - /**********************************************************************/ - case "CONVERT_IT" : - if ($GLOBALS['OnlyIndexes']) { - $resultConvert = $GLOBALS['processIndexes']->fulltext( - array( - 'collId' => $GLOBALS['collection'], - 'resTable' => $GLOBALS['table'], - 'adrTable' => $GLOBALS['adrTable'], - 'resId' => $currentRecordInStack['res_id'], - 'tmpDir' => $GLOBALS['tmpDirectory'], - 'path_to_lucene' => $GLOBALS['path_to_lucene'], - 'zendIndex' => $GLOBALS['zendIndex'] - ) - ); - } else { - $resultConvert = $GLOBALS['processConvert']->convertAll( - array( - 'collId' => $GLOBALS['collection'], - 'resTable' => $GLOBALS['table'], - 'adrTable' => $GLOBALS['adrTable'], - 'resId' => $currentRecordInStack['res_id'], - 'tmpDir' => $GLOBALS['tmpDirectory'], - 'path_to_lucene' => $GLOBALS['path_to_lucene'], - //'createZendIndex' => false - ) - ); - } - - $logInfo = "Problem with the record:" . $currentRecordInStack['res_id'] - . " details " . $resultConvert['error']; - - if ($resultConvert['status'] == '2') { - $GLOBALS['logger']->write($logInfo, 'WARNING'); - - } elseif ($resultConvert['status'] <> '0') { - $GLOBALS['logger']->write($logInfo, 'ERROR'); - } - $GLOBALS['state'] = "UPDATE_DATABASE"; - break; - - /**********************************************************************/ - /* UPDATE_DATABASE */ - /* Updating the database */ - /**********************************************************************/ - case "UPDATE_DATABASE" : - $query = "delete from convert_stack " - . " where coll_id = ? " - . " and res_id = ?"; - $stmt = Bt_doQuery( - $GLOBALS['db'], - $query, - array( - $GLOBALS['collection'], - $currentRecordInStack['res_id'] - ) - ); - $GLOBALS['state'] = "A_RECORD"; - break; - } -} - -$GLOBALS['logger']->write('End of process', 'INFO'); -Bt_logInDataBase( - $GLOBALS['totalProcessedResources'], 0, 'process without error' -); -Ds_washTmp($GLOBALS['tmpDirectory']); -unlink($GLOBALS['lckFile']); -exit($GLOBALS['exitCode']); diff --git a/modules/convert/batch/scripts/launch_convert_all_coll.sh.default b/modules/convert/batch/scripts/launch_convert_all_coll.sh.default deleted file mode 100755 index b729fa249c89b459cd31e2622551c541ebb48359..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_convert_all_coll.sh.default +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -#rm convert_letterbox_coll_config.lck -#rm convert_letterbox_coll_config_error.lck - -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll letterbox_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll attachments_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll attachments_version_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll calendar_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll folder_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll chrono_coll -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll reprise_coll diff --git a/modules/convert/batch/scripts/launch_convert_attachments.sh.default b/modules/convert/batch/scripts/launch_convert_attachments.sh.default deleted file mode 100755 index 0969b997b169a1f0d0e4b1b30a47b9fdc51d47bc..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_convert_attachments.sh.default +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll attachments_coll \ No newline at end of file diff --git a/modules/convert/batch/scripts/launch_convert_letterbox.sh.default b/modules/convert/batch/scripts/launch_convert_letterbox.sh.default deleted file mode 100755 index e94302372579c84d0329d073dc7b87e289436b95..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_convert_letterbox.sh.default +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -php $Mypath/fill_stack.php -c $ConfigPath/config.xml -coll letterbox_coll \ No newline at end of file diff --git a/modules/convert/batch/scripts/launch_fulltext_all_coll.sh.default b/modules/convert/batch/scripts/launch_fulltext_all_coll.sh.default deleted file mode 100755 index 4055fb238f98332acad447dd481c6c2272c86072..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_fulltext_all_coll.sh.default +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -#rm convert_letterbox_coll_config_only_indexes.lck -#rm convert_letterbox_coll_config_only_indexes_error.lck - -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll letterbox_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll attachments_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll attachments_version_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll calendar_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll folder_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll chrono_coll -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll reprise_coll diff --git a/modules/convert/batch/scripts/launch_fulltext_attachments.sh.default b/modules/convert/batch/scripts/launch_fulltext_attachments.sh.default deleted file mode 100755 index 897e3b5c720d396655b14ed816e616cf55d93272..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_fulltext_attachments.sh.default +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -rm convert_attachments_coll_config_only_indexes.lck -rm convert_attachments_coll_config_only_indexes_error.lck - -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll attachments_coll diff --git a/modules/convert/batch/scripts/launch_fulltext_letterbox.sh.default b/modules/convert/batch/scripts/launch_fulltext_letterbox.sh.default deleted file mode 100755 index 11906732bbf9ad748b7828160f3297d5f0333aca..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/launch_fulltext_letterbox.sh.default +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config' - -rm convert_letterbox_coll_config_only_indexes.lck -rm convert_letterbox_coll_config_only_indexes_error.lck - -php $Mypath/fill_stack.php -c $ConfigPath/config_only_indexes.xml -coll letterbox_coll diff --git a/modules/convert/batch/scripts/mywkhtmltoimage.sh b/modules/convert/batch/scripts/mywkhtmltoimage.sh deleted file mode 100755 index 2be138daf9ce6d8cf3880aa7d331cd19d2309af0..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/mywkhtmltoimage.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -xvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltoimage -q $* diff --git a/modules/convert/batch/scripts/mywkhtmltopdf.sh b/modules/convert/batch/scripts/mywkhtmltopdf.sh deleted file mode 100755 index 76c76e2c5869e7afffb7adcc641769ca06f9ff3e..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/mywkhtmltopdf.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -xvfb-run -a --server-args="-screen 0, 1024x768x24" /usr/bin/wkhtmltopdf -q $* diff --git a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_0.sh.default b/modules/convert/batch/scripts/parallel/launch_convert_letterbox_0.sh.default deleted file mode 100755 index 3ffef248dfc2869c38490b71b40350a645ce4ef2..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_0.sh.default +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config/parallel' - -for (( i=0; i < 3; i++ )); - do php $Mypath/fill_stack.php -c $ConfigPath/config_0.xml -coll letterbox_coll -done diff --git a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_1.sh.default b/modules/convert/batch/scripts/parallel/launch_convert_letterbox_1.sh.default deleted file mode 100755 index ccd8fb0406df97eb1a1385b8e054a364c3b75d27..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_1.sh.default +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config/parallel' - -for (( i=0; i < 3; i++ )); - do php $Mypath/fill_stack.php -c $ConfigPath/config_1.xml -coll letterbox_coll -done diff --git a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_2.sh.default b/modules/convert/batch/scripts/parallel/launch_convert_letterbox_2.sh.default deleted file mode 100755 index 4405d6e3a3adf489456af10d1a6f8b24c360cefc..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_2.sh.default +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config/parallel/' - -for (( i=0; i < 3; i++ )); - do php $Mypath/fill_stack.php -c $ConfigPath/config_2.xml -coll letterbox_coll -done diff --git a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_3.sh.default b/modules/convert/batch/scripts/parallel/launch_convert_letterbox_3.sh.default deleted file mode 100755 index 45e28e9bdb467e25c24e67435dbdc03b76141dc7..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_3.sh.default +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config/parallel/' - -for (( i=0; i < 3; i++ )); - do php $Mypath/fill_stack.php -c $ConfigPath/config_3.xml -coll letterbox_coll -done diff --git a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_4.sh.default b/modules/convert/batch/scripts/parallel/launch_convert_letterbox_4.sh.default deleted file mode 100755 index 5e2d68f800d13f9684735f8bcc66b03e05248d97..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/launch_convert_letterbox_4.sh.default +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash -Mypath='/var/www/html/MaarchCourrier/modules/convert/batch' -cd $Mypath -ConfigPath='/var/www/html/MaarchCourrier/modules/convert/batch/config/parallel/' - -for (( i=0; i < 3; i++ )); - do php $Mypath/fill_stack.php -c $ConfigPath/config_4.xml -coll letterbox_coll -done diff --git a/modules/convert/batch/scripts/parallel/param_cron.txt b/modules/convert/batch/scripts/parallel/param_cron.txt deleted file mode 100755 index de6869a344b0632ffd57c5832acdc4bee71b2d36..0000000000000000000000000000000000000000 --- a/modules/convert/batch/scripts/parallel/param_cron.txt +++ /dev/null @@ -1,6 +0,0 @@ -# tous les jours toutes les 2 heures de 0h a 20h du lundi au samedi lancement des batchs de conversion -0 0-20/2 * * 1-6 maarch /var/www/html/MaarchCourrier/modules/convert/batch/scripts/parallel/launch_convert_letterbox_0.sh -1 0-20/2 * * 1-6 maarch /var/www/html/MaarchCourrier/modules/convert/batch/scripts/parallel/launch_convert_letterbox_1.sh -2 0-20/2 * * 1-6 maarch /var/www/html/MaarchCourrier/modules/convert/batch/scripts/parallel/launch_convert_letterbox_2.sh -3 0-20/2 * * 1-6 maarch /var/www/html/MaarchCourrier/modules/convert/batch/scripts/parallel/launch_convert_letterbox_3.sh -4 0-20/2 * * 1-6 maarch /var/www/html/MaarchCourrier/modules/convert/batch/scripts/parallel/launch_convert_letterbox_4.sh diff --git a/modules/convert/batch/verif_index.php b/modules/convert/batch/verif_index.php deleted file mode 100755 index 203f6be90d0c7f2884e99de8a3de9f97f34b3fd3..0000000000000000000000000000000000000000 --- a/modules/convert/batch/verif_index.php +++ /dev/null @@ -1,23 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - * - */ - -date_default_timezone_set('Europe/Paris'); - -// load the config and prepare to process -include('load_fill_stack.php'); - - -/******************************************************************************/ -$GLOBALS['zendIndex'] = - $GLOBALS['processIndexes']->createZendIndexObject( - $GLOBALS['path_to_lucene'], $GLOBALS['ProcessIndexesSize'] - ); -unlink($GLOBALS['lckFile']); -exit($GLOBALS['zendIndex']->numDocs()); - diff --git a/modules/convert/class/class_modules_tools.php b/modules/convert/class/class_modules_tools.php deleted file mode 100755 index 949f379d3a9450e65f648faf2eb7862d9b83f67e..0000000000000000000000000000000000000000 --- a/modules/convert/class/class_modules_tools.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php - -/* -* Copyright 2008-2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework 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 -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @defgroup convert convert Module -*/ - -/** -* @brief Module convert : Module Tools Class -* -* <ul> -* <li>Set the session variables needed to run the convert module</li> -* </ul> -* -* @file -* @author Laurent Giovannoni <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - -/** -* @brief Module convert : Module Tools Class -* -* <ul> -* <li>Loads the tables used by the convert</li> -* <li>Set the session variables needed to run the convert module</li> -* </ul> -* -* @ingroup convert -*/ -class convert extends Database -{ - function __construct() - { - parent::__construct(); - $this->index = array(); - } - - /** - * Loads convert tables into sessions vars from the - * convert/xml/config.xml - * Loads convert log setting into sessions vars from the - * convert/xml/config.xml - */ - public function build_modules_tables() - { - if (file_exists($_SESSION['config']['corepath'].'custom' - .DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'] - .DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR - ."convert".DIRECTORY_SEPARATOR - ."xml".DIRECTORY_SEPARATOR."config.xml") - ) { - $path = $_SESSION['config']['corepath'].'custom' - .DIRECTORY_SEPARATOR.$_SESSION['custom_override_id'] - .DIRECTORY_SEPARATOR."modules".DIRECTORY_SEPARATOR."convert" - .DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."config.xml"; - } else { - $path = "modules".DIRECTORY_SEPARATOR."convert" - .DIRECTORY_SEPARATOR."xml".DIRECTORY_SEPARATOR."config.xml"; - } - $xmlconfig = simplexml_load_file($path); - //$CONFIG = $xmlconfig->CONFIG; - // Loads the tables of the module convert - // into session ($_SESSION['tablename'] array) - - // Loads the log setting of the module convert - // into session ($_SESSION['history'] array) - $HISTORY = $xmlconfig->HISTORY; - $_SESSION['history']['convertadd'] = (string) $HISTORY->convertadd; - $_SESSION['history']['convertup'] = (string) $HISTORY->convertup; - $_SESSION['history']['convertdel'] = (string) $HISTORY->convertdel; - } - - /** - * Load into session vars all the convert specific vars : - * calls private methods - */ - public function load_module_var_session($userData) - { - //functions::show_array($_SESSION['convertFeatures']); - } -} diff --git a/modules/convert/class/ws.php b/modules/convert/class/ws.php deleted file mode 100755 index e9f0494bcda6befe7f8b5bf5eaea63218a537c8d..0000000000000000000000000000000000000000 --- a/modules/convert/class/ws.php +++ /dev/null @@ -1,5 +0,0 @@ -<?php -global $SOAP_dispatch_map; -global $XMLRPC_dispatch_map; -global $SOAP_typedef; - diff --git a/modules/convert/css/module.css b/modules/convert/css/module.css deleted file mode 100755 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/modules/convert/js/functions.js b/modules/convert/js/functions.js deleted file mode 100755 index 5f7c77da42a31858501935467493f7aa968f0a4c..0000000000000000000000000000000000000000 --- a/modules/convert/js/functions.js +++ /dev/null @@ -1 +0,0 @@ -// diff --git a/modules/convert/lang/en.php b/modules/convert/lang/en.php deleted file mode 100755 index 533aa85eecca7405c8c34c5f83cf57b2ae158861..0000000000000000000000000000000000000000 --- a/modules/convert/lang/en.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework 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 - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. - */ - diff --git a/modules/convert/lang/fr.php b/modules/convert/lang/fr.php deleted file mode 100755 index 533aa85eecca7405c8c34c5f83cf57b2ae158861..0000000000000000000000000000000000000000 --- a/modules/convert/lang/fr.php +++ /dev/null @@ -1,22 +0,0 @@ -<?php - -/* - * - * Copyright 2008-2016 Maarch - * - * This file is part of Maarch Framework. - * - * Maarch Framework is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Maarch Framework 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 - * along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. - */ - diff --git a/modules/convert/lang/nl.php b/modules/convert/lang/nl.php deleted file mode 100644 index 33b0bef78c581e053ae41358c68e38881efb3ab0..0000000000000000000000000000000000000000 --- a/modules/convert/lang/nl.php +++ /dev/null @@ -1,7 +0,0 @@ -<?php - -/** - * Copyright Maarch since 2008 under licence GPLv3. - * See LICENCE.txt file at the root folder for more details. - * This file is part of Maarch software. - */ diff --git a/modules/convert/optimizeLuceneIndex.php b/modules/convert/optimizeLuceneIndex.php deleted file mode 100755 index bb022b92bd69f9c5bf93ff267392e6ba0db9ae9b..0000000000000000000000000000000000000000 --- a/modules/convert/optimizeLuceneIndex.php +++ /dev/null @@ -1,70 +0,0 @@ -<?php - -/* -* Copyright 2016 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework 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 -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** -* @brief process fulltext class -* -* <ul> -* <li>Services to process the fulltext of resources</li> -* </ul> -* -* @file -* @author <dev@maarch.org> -* @date $date$ -* @version $Revision$ -* @ingroup convert -*/ - - if(strpos($_SERVER['argv'][1], '/indexes/') >= 0){ - - $_ENV['maarch_tools_path'] = $_SERVER['argv'][2].'/apps/maarch_entreprise/tools/'; - - // Storing text in lucene index - set_include_path('../../../apps/maarch_entreprise/tools/' . PATH_SEPARATOR . get_include_path()); - - if(!@include('Zend/Search/Lucene.php')) { - set_include_path('apps/maarch_entreprise/tools/'. PATH_SEPARATOR . get_include_path() - ); - require_once("Zend/Search/Lucene.php"); - } - require_once 'Zend/Search/Lucene/Storage/File/Filesystem.php'; - require_once 'Zend/Search/Lucene/Storage/Directory/Filesystem.php'; - - $directory = new Zend_Search_Lucene_Storage_Directory_Filesystem((string) $_SERVER['argv'][1]); - - $testDir = Zend_Search_Lucene::getActualGeneration($directory); - - if ($testDir != -1) { - $index = Zend_Search_Lucene::open((string) $_SERVER['argv'][1]); - - if (!empty($index)) { - $index->setFormatVersion(Zend_Search_Lucene::FORMAT_2_3); - Zend_Search_Lucene_Analysis_Analyzer::setDefault( - new Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive() - ); - $index->optimize(); - } - } - - } - - -?> diff --git a/modules/convert/test_convert.php b/modules/convert/test_convert.php deleted file mode 100755 index 25ec308b0e4fa178b9620aec6897b41436e35b2e..0000000000000000000000000000000000000000 --- a/modules/convert/test_convert.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php - -// sample for letterbox : -// http:/urltomaarch/apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1931&collId=letterbox_coll - -// sample for attachments : -// http:/urltomaarch/apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1&collId=attachments_coll - -// sample for thumbnails : -// http:/urltomaarch//apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1939&collId=letterbox_coll&convertMode=thumbnails - -// sample for fulltext : -// http:/urltomaarch//apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1989&collId=letterbox_coll&convertMode=fulltext - -// sample for letterbox in allMode : -// http:/urltomaarch/apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1931&collId=letterbox_coll&convertMode=allMode - -// sample for attachments in allMode : -// http:/urltomaarch/apps/maarch_entreprise/index.php?page=test_convert&module=convert&id=1&collId=attachments_coll&convertMode=allMode - -$func = new functions(); - -for ($i=0;$i<count($_SESSION['collections']);$i++) { - if ($_SESSION['collections'][$i]['id'] == $_REQUEST['collId']) { - $resTable = $_SESSION['collections'][$i]['table']; - $adrTable = $_SESSION['collections'][$i]['adr']; - } -} - -if (empty($_REQUEST['convertMode'])) { - $convertMode = 'convert'; -} else { - $convertMode = $_REQUEST['convertMode']; -} - -echo $_REQUEST['convertMode'] . '<br />'; -echo $_REQUEST['collId'] . '<br />'; -echo $resTable . PHP_EOL . '<br />'; -echo $adrTable . PHP_EOL . '<br />'; -echo $_REQUEST['id'] . PHP_EOL . '<br />'; - -$params = array( - 'collId' => $_REQUEST['collId'], - 'resTable' => $resTable, - 'adrTable' => $adrTable, - 'resId' => $_REQUEST['id'], - 'tmpDir' => $_SESSION['config']['tmppath'] -); - -require_once 'core/services/ManageDocservers.php'; -$ManageDocservers = new Core_ManageDocservers_Service(); - -if ($convertMode == 'allMode') { - require_once 'modules/convert/services/ManageConvert.php'; - $ManageConvertService = new Convert_ManageConvert_Service(); - $resultOfConversion = $ManageConvertService->convertAll($params); - $adrType = 'CONV'; -} elseif ($convertMode == 'thumbnails') { - $adrType = 'TNL'; - require_once 'modules/convert/services/ProcessThumbnails.php'; - $ProcessConvertService = new Convert_ProcessThumbnails_Service(); - $resultOfConversion = $ProcessConvertService->thumbnails($params); - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $_REQUEST['id'], - $adrType - ); -} elseif ($convertMode == 'fulltext') { - $adrType = 'TXT'; - require_once 'modules/convert/services/ProcessFulltext.php'; - $ProcessConvertService = new Convert_ProcessFulltext_Service(); - $resultOfConversion = $ProcessConvertService->fulltext($params); - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $_REQUEST['id'], - $adrType - ); -} else { - $adrType = 'CONV'; - require_once 'modules/convert/services/ProcessConvert.php'; - $ProcessConvertService = new Convert_ProcessConvert_Service(); - $resultOfConversion = $ProcessConvertService->convert($params); - $resourcePath = $ManageDocservers->getSourceResourcePath( - $resTable, - $adrTable, - $_REQUEST['id'], - $adrType - ); -} - -echo $resourcePath . '<br />'; - -$func->show_array($resultOfConversion); - -$link .= $_SESSION['config']['businessappurl'] - . 'index.php?display=true' - . '&dir=indexing_searching' - . '&page=ViewRes' - . '&collId=' . $_REQUEST['collId'] - . '&id=' . $_REQUEST['id'] - . '&adrType=' . $adrType; -$linkToRes = '<a href="' . $link . '" target="_blank">clic to view the new resource !</a>'; - -echo '<br />' . $linkToRes; \ No newline at end of file diff --git a/modules/convert/xml/IVS/data_types.xml b/modules/convert/xml/IVS/data_types.xml deleted file mode 100755 index d182eb100928695356cb6d78bc710f956cf331f0..0000000000000000000000000000000000000000 --- a/modules/convert/xml/IVS/data_types.xml +++ /dev/null @@ -1,2 +0,0 @@ -<dataTypes> -</dataTypes> \ No newline at end of file diff --git a/modules/convert/xml/IVS/requests_definitions.xml b/modules/convert/xml/IVS/requests_definitions.xml deleted file mode 100755 index de13c79b15367cb425620879d493ddcb06df6ef1..0000000000000000000000000000000000000000 --- a/modules/convert/xml/IVS/requests_definitions.xml +++ /dev/null @@ -1,2 +0,0 @@ -<requestDefinitions> -</requestDefinitions> \ No newline at end of file diff --git a/modules/convert/xml/IVS/validation_rules.xml b/modules/convert/xml/IVS/validation_rules.xml deleted file mode 100755 index bfc6f655dba2a9e75d2bb4d8200ede18b3ebfe59..0000000000000000000000000000000000000000 --- a/modules/convert/xml/IVS/validation_rules.xml +++ /dev/null @@ -1,2 +0,0 @@ -<validationRules> -</validationRules> \ No newline at end of file diff --git a/modules/convert/xml/config.xml b/modules/convert/xml/config.xml deleted file mode 100755 index 3837913ef90fc5ef9659bb382c4c708ebe7a8733..0000000000000000000000000000000000000000 --- a/modules/convert/xml/config.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> - <CONFIG> - <name>convert</name> - <comment>_CONVERT_COMMENT</comment> - <file_prefix>convert</file_prefix> - <loaded>true</loaded> - </CONFIG> - <TABLENAME/> - <HISTORY> - <convertadd>true</convertadd> - <convertup>true</convertup> - <convertdel>true</convertdel> - </HISTORY> -</root> diff --git a/modules/convert/xml/menu.xml b/modules/convert/xml/menu.xml deleted file mode 100755 index d15cc8033fce6abb48b9de486ec5ffba3204a7d5..0000000000000000000000000000000000000000 --- a/modules/convert/xml/menu.xml +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> -</root> diff --git a/modules/convert/xml/services.xml b/modules/convert/xml/services.xml deleted file mode 100755 index d15cc8033fce6abb48b9de486ec5ffba3204a7d5..0000000000000000000000000000000000000000 --- a/modules/convert/xml/services.xml +++ /dev/null @@ -1,3 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<root> -</root> diff --git a/modules/entities/admin_entities.php b/modules/entities/admin_entities.php deleted file mode 100755 index 4d5da201f661cfb40a8f4f8c6c6067b794d1e057..0000000000000000000000000000000000000000 --- a/modules/entities/admin_entities.php +++ /dev/null @@ -1,91 +0,0 @@ -<?php -/* -* Copyright 2008,2009 Maarch -* -* This file is part of Maarch Framework. -* -* Maarch Framework is free software: you can redistribute it and/or modify -* it under the terms of the GNU General Public License as published by -* the Free Software Foundation, either version 3 of the License, or -* (at your option) any later version. -* -* Maarch Framework 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 -* along with Maarch Framework. If not, see <http://www.gnu.org/licenses/>. -*/ - -/** - * File : admin_entities.php. - * - * @brief Entities Administration summary Page - * - * @version 1 - * - * @since 03/2009 - * - * @license GPL - * @author C�dric Ndoumba <dev@maarch.org> - */ -$admin = new core_tools(); -$admin->test_admin('manage_entities', 'entities'); -/****************Management of the location bar ************/ -$init = false; -if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') { - $init = true; -} -$level = ''; -if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 || $_REQUEST['level'] == 1)) { - $level = $_REQUEST['level']; -} -$page_path = $_SESSION['config']['businessappurl'].'index.php?page=admin_entities&module=entities'; -$page_label = _ENTITIES; -$page_id = 'admin_entities'; -$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level); -/***********************************************************/ -unset($_SESSION['m_admin']); - -?> -<h1><i class="fa fa-sitemap fa-2x"></i> <?php echo _ENTITIES; ?></h1> - -<div id="inner_content" class="clearfix"> -<div class="block"> -<h2 style="text-align:center;"><?php echo _ENTITIES; ?></h2> - <div class="admin_item" title="<?php echo _MANAGE_ENTITIES_DESC; ?>" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=manage_entities&module=entities';"> - <div><i class="fa fa-sitemap fa-4x"></i></div> - <div> - <strong><?php echo _MANAGE_ENTITIES; ?></strong> - </div> - </div> - <div class="admin_item" title="<?php echo _ENTITY_TREE_DESC; ?>" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=view_tree_entities&module=entities';"> - <div><i class="fa fa-code-branch fa-4x"></i></div> - <div> - <strong><?php echo _ENTITY_TREE; ?></strong> - </div> - </div> - <?php if ($admin->test_admin('admin_difflist_types', 'entities', false)) { - ?> - <div class="admin_item" title="<?php echo _DIFFLIST_TYPES_DESC; ?>" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=admin_difflist_types&module=entities';"> - <div><i class="fa fa-share-alt fa-4x"></i></div> - <div> - <strong><?php echo _DIFFLIST_TYPES; ?></strong> - </div> - </div> - <?php -} ?> - <?php if ($admin->test_admin('admin_listmodels', 'entities', false)) { - ?> - <div class="admin_item" title="<?php echo _LISTMODELS_DESC; ?>" onclick="window.top.location='<?php echo $_SESSION['config']['businessappurl']; ?>index.php?page=admin_listmodels&module=entities';"> - <div><i class="fa fa-share-alt-square fa-4x"></i></div> - <div> - <strong><?php echo _LISTMODELS; ?></strong> - </div> - </div> - <?php - } ?> -<div class="clearfix"></div> - </div> -</div> diff --git a/modules/entities/choose_tree.php b/modules/entities/choose_tree.php deleted file mode 100755 index 509a8614f4e45a637c45c8cc53211cb3f87bbf18..0000000000000000000000000000000000000000 --- a/modules/entities/choose_tree.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php - -require_once("core".DIRECTORY_SEPARATOR."class".DIRECTORY_SEPARATOR."class_request.php"); -$core_tools = new core_tools(); -$core_tools->load_lang(); -$func = new functions(); -$core_tools->load_html(); -$core_tools->load_header('', true, false); -$_SESSION['entities_chosen_tree'] = array(); -if(isset($_REQUEST['tree_id']) && !empty($_REQUEST['tree_id'])) -{ - $_SESSION['entities_chosen_tree'] = $_REQUEST['tree_id']; - ?> - <script type="text/javascript">window.top.frames['show_trees'].location.href='<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=show_trees';?>';</script> - <?php -} -else -{ - $_SESSION['entities_chosen_tree'] = ""; -} -?> -<body> -<div class="block"> - <h2> - <form name="frm_choose_tree" id="frm_choose_tree" method="get" action="<?php echo $_SESSION['config']['businessappurl'];?>index.php"> - <input type="hidden" name="display" value="true" /> - <input type="hidden" name="module" value="entities" /> - <input type="hidden" name="page" value="choose_tree" /> - <p align="left"> - <label><?php echo _ENTITY;?> :</label> - <select name="tree_id" id="tree_id" onchange="this.form.submit();"> - <option value=""><?php echo _CHOOSE_ENTITY;?></option> - <?php - for($i=0;$i<count($_SESSION['tree_entities']);$i++) - { - ?> - <option value="<?php functions::xecho($_SESSION['tree_entities'][$i]['ID']);?>" <?php if($_SESSION['entities_chosen_tree'] == $_SESSION['tree_entities'][$i]['ID'] ){ echo 'selected="selected"';}?>><?php echo $_SESSION['tree_entities'][$i]['LABEL'];?></option> - <?php - } - ?> - </select> - </p> - </form> - </h2> -</div> - <?php $core_tools->load_js();?> -</body> -</html> diff --git a/modules/entities/redirect.php b/modules/entities/redirect.php index 22fd398dea57e25e86a7183116bcc31c11601bf4..1463c7429766f04139af679611ef22c117f5f10d 100755 --- a/modules/entities/redirect.php +++ b/modules/entities/redirect.php @@ -311,7 +311,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col $stmt = $db->query( "select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label " . "FROM " . $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, " - . ENT_USERS_ENTITIES . " ue WHERE u.status <> 'DEL' and u.enabled = 'Y' and" + . ENT_USERS_ENTITIES . " ue WHERE u.status <> 'DEL' and u.status != 'SPD' and" . " e.entity_id = ue.entity_id and u.user_id = ue.user_id and" . " e.enabled = 'Y' and ue.primary_entity='Y' and u.user_id = ?", array($userId) diff --git a/modules/entities/show_trees.php b/modules/entities/show_trees.php deleted file mode 100755 index de125c8462d0236e39a60de9491690c9aa539019..0000000000000000000000000000000000000000 --- a/modules/entities/show_trees.php +++ /dev/null @@ -1,152 +0,0 @@ -<?php - -require_once("core/class/class_request.php"); -require_once("modules/entities/entities_tables.php"); -require_once('modules/entities/class/class_manage_entities.php'); - -$core_tools = new core_tools(); -$core_tools->load_lang(); -$func = new functions(); -$core_tools->load_html(); -$core_tools->load_header(); -?> - -<body> -<?php - -if (count($_SESSION['tree_entities']) < 1) { - echo _NO_DEFINED_TREES; -} else { - if (isset($_SESSION['entities_chosen_tree']) && !empty($_SESSION['entities_chosen_tree'])) { - $ent = new entity(); - $db = new Database(); - $_SESSION['EntitiesIdExclusion'] = array(); - $whereExclusion = ' and (1=1)'; - if ($_SESSION['user']['UserId'] != 'superadmin') { - require_once('modules/entities/class/class_manage_entities.php'); - $ent = new entity(); - $my_tab_entities_id = $ent->get_all_entities_id_user($_SESSION['user']['entities']); - $my_tab_entities_id = array_unique($my_tab_entities_id); - //var_dump($my_tab_entities_id); - if (count($my_tab_entities_id) > 0) { - $listOfMyEntities = implode(',', $my_tab_entities_id); - $stmt = $db->query( - "select entity_id from " - . ENT_ENTITIES . " where entity_id not in (" . $listOfMyEntities .") and enabled= 'Y' order by entity_id" - ); - //$ent->show(); - while ($res = $stmt->fetchObject()) { - array_push($_SESSION['EntitiesIdExclusion'], "'". $res->entity_id . "'"); - } - } - } - ?> - <script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl'] . 'tools/tafelTree/';?>js/scriptaculous.js"></script> - <script type="text/javascript" src="<?php echo $_SESSION['config']['businessappurl'] . 'tools/tafelTree/';?>Tree.js"></script> - <?php - //$where = ""; - $level1 = array(); - $stmt = $db->query("select u.user_id, u.lastname, u.firstname from " . ENT_USERS_ENTITIES . " ue, " - . $_SESSION['tablename']['users'] . " u where ue.entity_id = ? and ue.user_id = u.user_id and u.status <> 'DEL' " - . $whereExclusionUE . " order by u.lastname, u.firstname",array($_SESSION['entities_chosen_tree'])); - - - //$ent->show(); - while ($res = $stmt->fetchObject()) { - array_push( - $level1, array( - 'id' => $res->user_id, - 'tree' => $_SESSION['entities_chosen_tree'], - 'key_value' => $res->user_id, - 'label_value' => functions::show_string($res->lastname.' '.$res->firstname, true), - 'is_entity' => false - ) - ); - } - $stmt = $db->query("select entity_id, entity_label from " . ENT_ENTITIES . " where parent_entity_id = ? and enabled ='Y' order by entity_label",array($_SESSION['entities_chosen_tree'])); - //$ent->show(); - $level1 = array(); - while ($res = $stmt->fetchObject()) { - if (!is_integer(array_search("'" . $res->entity_id . "'", $_SESSION['EntitiesIdExclusion'])) || count($_SESSION['EntitiesIdExclusion']) == 0) { - $labelValue = '<span class="entity_tree_element_ok"><i class="fa"></i><a href="index.php?page=entity_up&module=entities&id=' - . $res->entity_id . '" target="_top">' . functions::show_string($res->entity_label, true) . '</a></span>'; - } else { - $labelValue = '<small><i>' . functions::show_string($res->entity_label, true) . '</i></small>'; - } - array_push( - $level1, - array( - 'id' => $res->entity_id, - 'tree' => $_SESSION['entities_chosen_tree'], - 'key_value' => $res->entity_id, - 'label_value' => $labelValue, - 'script' => "", - 'is_entity' => true - ) - ); - } - for ($i=0;$i<count($_SESSION['tree_entities']);$i++) { - if ($_SESSION['tree_entities'][$i]['ID'] == $_SESSION['entities_chosen_tree']) { - if (!is_integer(array_search("'" . $_SESSION['tree_entities'][$i]['ID'] . "'", $_SESSION['EntitiesIdExclusion'])) || count($_SESSION['EntitiesIdExclusion']) == 0) { - $label = $_SESSION['tree_entities'][$i]['ID'] . ' - <a href="index.php?page=entity_up&module=entities&id=' - . $_SESSION['tree_entities'][$i]['ID'] . '" target="_top">' . $ent->show_string($_SESSION['tree_entities'][$i]['LABEL'], true) . '</a>'; - } else { - $label = "<b>" . $_SESSION['tree_entities'][$i]['ID'] . ' - ' - . $_SESSION['tree_entities'][$i]['LABEL'] . "</b>"; - } - $valId=$_SESSION['tree_entities'][$i]['ID']; - } - } - $stmt = $db->query("select u.user_id, u.lastname, u.firstname, u.enabled, ue.entity_id as entity_id from " - . ENT_USERS_ENTITIES . " ue, " . $_SESSION['tablename']['users'] - . " u where ue.entity_id = ? and ue.user_id = u.user_id and u.status <> 'DEL' order by u.lastname, u.firstname",array($_SESSION['entities_chosen_tree'])); - while ($res = $stmt->fetchObject()) { - if (!is_integer(array_search("'" . $res->entity_id . "'", $_SESSION['EntitiesIdExclusion'])) || count($_SESSION['EntitiesIdExclusion']) == 0) { - if($res->enabled == 'N'){ - $labelValue = '<span class="entity_tree_element_ok">' . functions::show_string('<a style="color:red;" href="index.php?page=users_management_controler&mode=up&admin=users&id=' - . $res->user_id . '" target="_top">' . $res->lastname . ' ' . $res->firstname . '</a>', true) . '</span>'; - }else{ - $labelValue = '<span class="entity_tree_element_ok">' . functions::show_string('<a href="index.php?page=users_management_controler&mode=up&admin=users&id=' - . $res->user_id . '" target="_top">' . $res->lastname . ' ' . $res->firstname . '</a>', true) . '</span>'; - } - - } else { - $labelValue = '<small><i>' . functions::show_string($res->lastname . ' ' . $res->firstname, true) . '</i></small>'; - } - array_push( - $level1, - array( - 'id' => $res->user_id, - 'tree' => $_SESSION['entities_chosen_tree'], - 'key_value' => $res->user_id, - 'label_value' => $labelValue, - 'is_entity' => false - ) - ); - } - ?> - <div class="tree" id='divTree'> - <ul> - <li id=<?php echo "'".$valId."'"; ?> > - <span class="root"> - <span class="icon"><i class="fa fa-plus-square" style='cursor:pointer' onClick=<?php echo "\"getChildrenHtml('".$valId."','divTree','index.php?display=true&module=entities&page=get_tree_childs','fa fa-minus-square','fa fa-plus-square')\""?>></i></span> - <?php echo $label;?> - - </span> - </li> - </ul> - </div> - <script type="text/javascript"> - - var tree = $j('#divTree'); - BootstrapTree.init(tree); - </script> - <div id="trees_div"></div> - <?php - } else { - //echo "<div align='left'> "._CHOOSE_FOLDERTYPE."</div>"; - } -} -?> -</body> -</html> diff --git a/modules/entities/view_tree_entities.php b/modules/entities/view_tree_entities.php deleted file mode 100755 index 90c213b6960ea6dd7b8284f7d8d3ec93719feca7..0000000000000000000000000000000000000000 --- a/modules/entities/view_tree_entities.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php -/** -* File : view_tree_entities.php. -* -* Entities Administration view tree -* -* @version 1 -* -* @since 03/2009 -* -* @license GPL -* @author C�dric Ndoumba <dev@maarch.org> -*/ -require_once 'modules/entities/entities_tables.php'; -$admin = new core_tools(); -$admin->test_admin('manage_entities', 'entities'); -$db = new Database(); -/****************Management of the location bar ************/ -$init = false; -if (isset($_REQUEST['reinit']) && $_REQUEST['reinit'] == 'true') { - $init = true; -} -$level = ''; -if (isset($_REQUEST['level']) && ($_REQUEST['level'] == 2 - || $_REQUEST['level'] == 3 || $_REQUEST['level'] == 4 - || $_REQUEST['level'] == 1) -) { - $level = $_REQUEST['level']; -} -$page_path = $_SESSION['config']['businessappurl'].'index.php?page=view_tree_entities&module=entities'; -$page_label = _ENTITY_TREE; -$page_id = 'view_tree_entities'; -$admin->manage_location_bar($page_path, $page_label, $page_id, $init, $level); -/***********************************************************/ -unset($_SESSION['m_admin']); -$_SESSION['tree_entities'] = array(); - -$stmt = $db->query('select entity_id, entity_label from '.ENT_ENTITIES." where parent_entity_id = '' or parent_entity_id is null order by entity_label"); -while ($res = $stmt->fetchObject()) { - array_push($_SESSION['tree_entities'], array('ID' => $res->entity_id, 'LABEL' => $res->entity_label)); -} -?> -<h1><i class="fa fa-code-branch fa-2x"></i> <?php echo _ENTITY_TREE; ?></h1> -<div id="inner_content" class="clearfix"> - <table width="100%" border="0"> - <tr> - <td> - <iframe name="choose_tree" id="choose_tree" width="550" height="40" frameborder="0" scrolling="no" src="<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=choose_tree'; ?>" style="width:100%;"></iframe> - </td> - </tr> - <tr> - <td> - <iframe name="show_trees" class="block" id="show_trees" width="550" height="600" frameborder="0" scrolling="auto" src="<?php echo $_SESSION['config']['businessappurl'].'index.php?display=true&module=entities&page=show_trees';?>" style="width:99%;"></iframe> - </td> - </tr> - </table> -</div> diff --git a/modules/entities/xml/IVS/requests_definitions.xml b/modules/entities/xml/IVS/requests_definitions.xml index 20a539a16c82fe790d14ff8d12b2c2d8ab410990..b1de4c2066c801706f2a90375ece0fc8437ddf98 100755 --- a/modules/entities/xml/IVS/requests_definitions.xml +++ b/modules/entities/xml/IVS/requests_definitions.xml @@ -64,15 +64,6 @@ <parameter name="display" value="true"/> <parameter name="module" value="entities"/> </requestDefinition> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="view_tree_entities" > - <parameter name="page" value="view_tree_entities"/> - <parameter name="module" value="entities"/> - </requestDefinition> - <requestDefinition method="GET" path="/apps/maarch_entreprise/index.php" validationRule="choose_tree" > - <parameter name="page" value="choose_tree"/> - <parameter name="display" value="true"/> - <parameter name="module" value="entities"/> - </requestDefinition> <requestDefinition method="POST" path="/apps/maarch_entreprise/index.php" validationRule="get_tree_childs" > <parameter name="page" value="get_tree_childs"/> diff --git a/modules/entities/xml/IVS/validation_rules.xml b/modules/entities/xml/IVS/validation_rules.xml index e87c6a4a42f431077b757f317dbc0f06edeb7d7f..28868cf4f5b7c13cf62e1e372eb4d07ad82c2d9a 100755 --- a/modules/entities/xml/IVS/validation_rules.xml +++ b/modules/entities/xml/IVS/validation_rules.xml @@ -67,10 +67,6 @@ <parameter name="archival_agreement" type="string" /> <parameter name="archival_agency" type="string" /> </validationRule> - <validationRule name="choose_tree" extends="standardForm" mode="error"> - <parameter name="module" type="identifier" /> - <parameter name="tree_id" type="identifier" /> - </validationRule> <validationRule name="get_tree_childs" extends="standardForm" mode="error"> <parameter name="module" type="identifier" /> <parameter name="branch" type="string" /> diff --git a/modules/folder/get_folder_view_stats_val.php b/modules/folder/get_folder_view_stats_val.php index 94e9c41e95ebac88346db6f382e4341f2b39e2b4..0c69bde54383d9ed3c7c2bdab4dd1e50a6befe48 100755 --- a/modules/folder/get_folder_view_stats_val.php +++ b/modules/folder/get_folder_view_stats_val.php @@ -176,7 +176,7 @@ elseif(isset($_REQUEST['type_report']) && $_REQUEST['type_report'] == 'user') $stmt = $db->query("SELECT u.user_id, u.lastname ,u.firstname, (SELECT COUNT(DISTINCT h.record_id) FROM ".$_SESSION['tablename']['history']." h INNER JOIN ".$_SESSION['tablename']['users']." u ON h.user_id = u.user_id WHERE h.event_type = 'VIEW' AND h.table_name = :foldFolder ".$whereUser.") AS nbr - FROM ".$_SESSION['tablename']['users']." u WHERE u.enabled = 'Y' ".$whereUser, $arrayPDO); + FROM ".$_SESSION['tablename']['users']." u WHERE u.status != 'SPD' ".$whereUser, $arrayPDO); $tab=array(); while($line = $stmt->fetch(PDO::FETCH_ASSOC)) diff --git a/src/app/convert/controllers/FullTextController.php b/src/app/convert/controllers/FullTextController.php index bdbb1496eedc6d628ae324c6fff0e08f0725592b..d77595a44770d5b54d04aa622e7ca0827f70e7d6 100644 --- a/src/app/convert/controllers/FullTextController.php +++ b/src/app/convert/controllers/FullTextController.php @@ -55,19 +55,8 @@ class FullTextController return ['errors' => 'FullText docserver is not writable']; } - if (FullTextController::isDirEmpty($fullTextDocserver['path_template'])) { - $index = \Zend_Search_Lucene::create($fullTextDocserver['path_template']); - } else { - $index = \Zend_Search_Lucene::open($fullTextDocserver['path_template']); - } - - $index->setFormatVersion(\Zend_Search_Lucene::FORMAT_2_3); - \Zend_Search_Lucene_Analysis_Analyzer::setDefault(new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive()); - $index->setMaxBufferedDocs(1000); - $tmpFile = CoreConfigModel::getTmpPath() . basename($pathToDocument) . rand() . '.txt'; $pdfToText = exec("pdftotext " . escapeshellarg($pathToDocument) . " " . escapeshellarg($tmpFile)); - if (!is_file($tmpFile)) { return ['errors' => 'Command pdftotext did not work : ' . $pdfToText]; } @@ -78,14 +67,28 @@ class FullTextController $fileContent = FullTextController::cleanFileContent($fileContent); - $doc = new \Zend_Search_Lucene_Document(); + try { + if (FullTextController::isDirEmpty($fullTextDocserver['path_template'])) { + $index = \Zend_Search_Lucene::create($fullTextDocserver['path_template']); + } else { + $index = \Zend_Search_Lucene::open($fullTextDocserver['path_template']); + } + + $index->setFormatVersion(\Zend_Search_Lucene::FORMAT_2_3); + \Zend_Search_Lucene_Analysis_Analyzer::setDefault(new \Zend_Search_Lucene_Analysis_Analyzer_Common_Utf8Num_CaseInsensitive()); + $index->setMaxBufferedDocs(1000); - $doc->addField(\Zend_Search_Lucene_Field::UnIndexed('Id', (integer)$args['resId'])); - $doc->addField(\Zend_Search_Lucene_Field::UnStored('contents', $fileContent)); + $doc = new \Zend_Search_Lucene_Document(); - $index->addDocument($doc); - $index->commit(); - $index->optimize(); + $doc->addField(\Zend_Search_Lucene_Field::UnIndexed('Id', (integer)$args['resId'])); + $doc->addField(\Zend_Search_Lucene_Field::UnStored('contents', $fileContent)); + + $index->addDocument($doc); + $index->commit(); + $index->optimize(); + } catch (\Exception $e) { + return ['errors' => 'Full Text index failed : ' . $e]; + } unlink($tmpFile); @@ -110,8 +113,8 @@ class FullTextController private static function cleanFileContent($fileContent) { $fileContent = TextFormatModel::normalize(['string' => $fileContent]); - $fileContent = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $fileContent); $fileContent = preg_replace('/[[:punct:]]/', ' ', $fileContent); + $fileContent = preg_replace('/[[:cntrl:]]/', ' ', $fileContent); $fileContent = trim($fileContent); $cleanArrayFile = [];