19 include_once (
"FDL/import_file.php");
20 include_once (
"FREEDOM/freedom_import.php");
23 $usage->setDefinitionText(
"Import documents from description file");
29 $archive =
$usage->addOptionalParameter(
"archive",
"description file is an standard archive (not xml)", array(
34 $policy =
$usage->addOptionalParameter(
"policy",
"policy import - \n\t\t[update] to auto update same document (the default), \n\t\t[add] to always create new document, \n\t\t[keep] to do nothing if same document already present", array(
39 $htmlmode =
$usage->addOptionalParameter(
"htmlmode",
"analyze report mode in html", array(
43 $reinit =
$usage->addOptionalParameter(
"reinitattr",
"reset attribute before import family update (deprecated)", array(
47 $reset =
$usage->addOptionalParameter(
"reset",
"reset options",
function ($values, $argName,
ApiUsage $apiusage)
61 $apiusage->
exitError(sprintf(
"Error: wrong value for argument 'reset' : %s", $error));
65 $to =
$usage->addOptionalParameter(
"to",
"email address to send report");
66 $dirid =
$usage->addOptionalParameter(
"dir",
"folder where imported documents are put");
68 $strict =
$usage->addOptionalParameter(
"strict",
"don't import if one error detected", array(
73 $csvSeparator =
$usage->addOptionalParameter(
"csv-separator",
"character to delimiter fields - generaly a comma",
function ($values, $argName,
ApiUsage $apiusage)
76 return sprintf(
' use single character or "auto"');
78 if (!is_string($values)) {
79 return sprintf(
"must be a character [%s] ", print_r($values,
true));
81 if ($values !=
"auto") {
82 if (mb_strlen($values) > 1) {
83 return sprintf(
"must be a only one character [%s] ", $values);
90 $csvEnclosure =
$usage->addOptionalParameter(
"csv-enclosure",
"character to enclose fields - generaly double-quote",
function ($values, $argName,
ApiUsage $apiusage)
93 return sprintf(
' use single character or "auto"');
95 if (!is_string($values)) {
96 return sprintf(
"must be a character [%s] ", print_r($values,
true));
98 if ($values !=
"auto") {
99 if (mb_strlen($values) > 1) {
100 return sprintf(
"must be a only one character [%s] ", $values);
107 $csvLinebreak =
$usage->addOptionalParameter(
"csv-linebreak",
"character sequence to be import like CRLF", null,
'\n');
113 $action->log->deprecated(
"importDocuments :reinitattr option is deprecated, use --reset=attributes");
119 $action->exitError(sprintf(_(
"import file '%s' is not a valid file") ,
$filename));
133 setHttpVar(
'analyze', (
$analyze ==
"yes") ?
'Y' :
'N');
134 setHttpVar(
'htmlmode', (
$htmlmode ==
"yes") ?
'Y' :
'N');
139 if (!
$dir->isAlive()) {
140 $action->exitError(sprintf(
"folder %s not found (dir option)",
$dirid));
150 $oImport->setVerifyAttributeAccess(
false);
168 include_once (
"FDL/sendmail.php");
172 $message->setBody(
new \Dcp\Mail\Body(file_get_contents(
$logfile) , ((
$htmlmode ==
'yes') ?
'text/html' :
'text/plain')));
178 $subject = sprintf(_(
"result of import %s") , basename(GetHttpVars(
"file")));
180 if (
$err) error_log(
"import sending mail: Error:$err");
getMailAddr($userid, $full=false)
sendmail($to, $from, $cc, $bcc, $subject, &$mimemail, $multipart=null)
if((!$logfile)&&$to) if($logfile) if($to) $err
getParam($name, $def="")
must be in core or global type
static matchValues($value, $restrictions)
Verify arguments for wsh programs.