Platform  3.1
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  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Creation of batch document from folder
9  *
10  * @author Anakeen 2005
11  * @version $Id: freedom_addbatch.php,v 1.4 2007/09/10 13:26:47 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Class.Doc.php");
20 /**
21  * Create a batch document from folder
22  * @param Action &$action current action
23  * @global dirid Http var : folder id document
24  * @global bid Http var : family identificator of the batch
25  * @global linkdir Http var : (Y|N) if Y copy reference in batch else copy containt of folder
26  */
28 {
29 
30  $bid = GetHttpVars("bid");
31  $dirid = GetHttpVars("dirid");
32  $linkdir = (GetHttpVars("linkdir", "N") == "Y");
33 
34  $dbaccess = $action->GetParam("FREEDOM_DB");
35 
36  $bdoc = new_Doc($dbaccess, $bid);
37  if (!$bdoc->isAlive()) $action->exitError(sprintf(_("unknown batch document %s") , $bid));
38 
39  $fld = new_Doc($dbaccess, $dirid);
40  if (!$fld->isAlive()) $action->exitError(sprintf(_("unknown folder document %s") , $fld));
41 
42  $doc = createDoc($dbaccess, $bid);
43  if (!$doc) $action->exitError(sprintf(_("no privilege to create this kind (%s) of document") , $bdoc->title));
44 
45  $doc->setTitle(sprintf(_("batch from %s folder") , $fld->title));
46  $doc->setValue("ba_desc", sprintf(_("batch from %s folder") , $fld->title));
47  $famid = $fld->getValue("se_famid");
48  if ($famid) {
49  $doc->setValue("pubm_idfam", $famid);
50  }
51  $err = $doc->Add();
52 
53  if ($err != "") $action->exitError($err);
54  if ($linkdir) {
55  $doc->Addfile($fld->initid);
56  } else {
57  $tdoc = $fld->getContent();
58  foreach ($tdoc as $k => $v) {
59  if (($v["doctype"] == "S") || ($v["doctype"] == "D")) unset($tdoc[$k]);
60  }
61  $doc->InsertMDoc($tdoc);
62  }
63 
64  redirect($action, "FREEDOM", "OPENFOLIO&id=" . $doc->id, $action->GetParam("CORE_STANDURL"));
65 }
66 ?>
← centre documentaire © anakeen - published under CC License - Dynacase