Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_addbatch.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Creation of batch document from folder
8  *
9  * @author Anakeen
10  * @version $Id: freedom_addbatch.php,v 1.4 2007/09/10 13:26:47 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Doc.php");
18 /**
19  * Create a batch document from folder
20  * @param Action &$action current action
21  * @global dirid int Http var : folder id document
22  * @global bid int Http var : family identifier of the batch
23  * @global linkdir string Http var : (Y|N) if Y copy reference in batch else copy containt of folder
24  */
26 {
27 
28  $bid = GetHttpVars("bid");
29  $dirid = GetHttpVars("dirid");
30  $linkdir = (GetHttpVars("linkdir", "N") == "Y");
31 
32  $dbaccess = $action->dbaccess;
33 
34  $bdoc = new_Doc($dbaccess, $bid);
35  if (!$bdoc->isAlive()) $action->exitError(sprintf(_("unknown batch document %s") , $bid));
36  /*
37  * @var Dir $fld
38  */
39  $fld = new_Doc($dbaccess, $dirid);
40  if (!$fld->isAlive()) $action->exitError(sprintf(_("unknown folder document %s") , $fld));
41  /*
42  * @var Dir $doc
43  */
44  $doc = createDoc($dbaccess, $bid);
45  if (!$doc) $action->exitError(sprintf(_("no privilege to create this kind (%s) of document") , $bdoc->title));
46 
47  $doc->setTitle(sprintf(_("batch from %s folder") , $fld->title));
48  $doc->setValue("ba_desc", sprintf(_("batch from %s folder") , $fld->title));
49  $famid = $fld->getRawValue("se_famid");
50  if ($famid) {
51  $doc->setValue("pubm_idfam", $famid);
52  }
53  $err = $doc->Add();
54 
55  if ($err != "") $action->exitError($err);
56  if ($linkdir) {
57  $doc->Addfile($fld->initid);
58  } else {
59  $tdoc = $fld->getContent();
60  foreach ($tdoc as $k => $v) {
61  if (($v["doctype"] == "S") || ($v["doctype"] == "D")) unset($tdoc[$k]);
62  }
63  $doc->InsertMDoc($tdoc);
64  }
65 
66  redirect($action, "FREEDOM", "OPENFOLIO&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
67 }
$tdoc
global $action
freedom_addbatch(Action &$action)
exitError($texterr, $exit=true, $code="")
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen