17 include_once (
"FREEDOM/freedom_import_tar.php");
25 $analyze = GetHttpVars(
"analyze",
"Y");
29 if ($handle = opendir(
$ldir)) {
30 while (
false !== (
$file = readdir($handle))) {
31 if (
$file[0] !=
".") {
44 $ttar[0][
"selected"] =
"selected";
45 $selfile = $ttar[0][
"filename"];
50 if (
$analyze ==
"Y") $action->lay->setBlockData(
"AFORM", array(
56 $action->lay->set(
"huge", ($action->
Read(
"navigator",
"") ==
"EXPLORER") ?
"" :
"huge");
58 $action->lay->
Set(
"nbdoc",
"$nbdoc");
59 $action->lay->
Set(
"importtext", sprintf(_(
"proceed background import of %d documents") , $nbdoc));
64 $dirid = GetHttpVars(
"dirid");
65 $famid = GetHttpVars(
"famid", 7);
66 $dfldid = GetHttpVars(
"dfldid", 2);
67 $onlycsv = GetHttpVars(
"onlycsv");
68 $topfld = (GetHttpVars(
"topfld") !=
"");
69 $analyze = (GetHttpVars(
"analyze",
"Y") ==
"Y");
72 $selectclass = array();
76 foreach ($tclassdoc as $k => $cdoc) {
77 $selectclass[$k][
"idcdoc"] = $cdoc[
"initid"];
78 $selectclass[$k][
"classname"] = $cdoc[
"title"];
79 if ($cdoc[
"initid"] ==
$famid) $selectclass[$k][
"selected"] =
"selected";
80 else $selectclass[$k][
"selected"] =
"";
82 $action->lay->SetBlockData(
"SELECTCLASS", $selectclass);
86 foreach ($tclassdoc as $k => $cdoc) {
87 $selectfld[$k][
"idcdoc"] = $cdoc[
"initid"];
88 $selectfld[$k][
"classname"] = $cdoc[
"title"];
89 if ($cdoc[
"initid"] == $dfldid) $selectfld[$k][
"selected"] =
"selected";
90 else $selectfld[$k][
"selected"] =
"";
93 $action->lay->SetBlockData(
"SELECTDFLD", $selectfld);
98 $dirtitle =
$dir->title;
99 if (!method_exists(
$dir,
"addfile")) {
100 $action->AddWarningMsg(sprintf(_(
"The document <%s> is not a folder") , $dirtitle));
106 $dirtitle =
$dir->title;
108 $action->AddWarningMsg(sprintf(_(
"Use your home folder instead <%s>") , $dirtitle));
119 $err =
$dir->insertDocument($pdir->id);
122 $dirtitle = $dirtitle .
"/" . $pdir->title;
126 else $onlycsv = ($onlycsv !=
"2");
130 foreach ($tr as $k => $v) {
131 if ($v[
"familyid"] > 0) {
133 $tr[$k][
"familyname"] = $f->title;
134 $tr[$k][
"foldername"] = $dirtitle .
'/' . substr($v[
"foldername"],
strposn($v[
"foldername"],
'/', 6));
136 $tr[$k][
"familyname"] =
"";
137 $tr[$k][
"foldername"] =
"";
142 $action->lay->eSet(
"dirid",
$dirid);
143 $action->lay->SetBlockCorresp(
"ADDEDDOC",
"filename");
144 $action->lay->SetBlockCorresp(
"ADDEDDOC",
"err");
145 $action->lay->SetBlockCorresp(
"ADDEDDOC",
"anaclass");
146 $action->lay->SetBlockData(
"ADDEDDOC", $tr);
147 $action->lay->eSet(
"selfile", $selfile);
148 $action->lay->
Set(
"oselected", $onlycsv ?
"checked" :
"");
149 $action->lay->
Set(
"notoselected", $onlycsv ?
"" :
"checked");
150 $action->lay->
Set(
"tselected", $topfld ?
"checked" :
"");
151 $action->lay->
Set(
"fdisabled", $onlycsv ?
"disabled" :
"");
152 $action->lay->eSet(
"mailaddr",
getMailAddr($action->user->id));
153 $action->lay->
Set(
"bgdisabled", (count($tr) > 0) ?
"" :
"disabled");
163 for ($j = 0; $j < $i; $j++) {
164 $p = strpos(
$s,
$c, $p);
167 if ($p == 0) $p = strlen(
$s);
173 $found = file_exists(
"$dir/fdl.csv");
175 if ($handle = opendir(
$dir)) {
176 while ((!$found) && (
false !== (
$file = readdir($handle)))) {
177 if (is_dir(
"$dir/$file")) {
178 $found = file_exists(
"$dir/$file/fdl.csv");
getMailAddr($userid, $full=false)
analyze_tar(Action &$action, $selfile)
freedom_ana_tar(Action &$action)
getTarExtractDir(Action &$action, $tar)
exitError($texterr, $exit=true, $code="")
GetClassesDoc($dbaccess, $userid, $classid=0, $qtype="LIST", $extraFilters=array())
getTarUploadDir(Action &$action)
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
new_Doc($dbaccess, $id= '', $latest=false)
setMaxExecutionTimeTo($limit)
if($file) if($subject==""&&$file) if($subject=="") $err
import_directory(&$action, $ldir, $dirid=0, $famid=7, $dfldid=2, $onlycsv=false, $analyze=false, $csvLinebreak= '\n')