Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_mod.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * Modification of documents
8  *
9  * @author Anakeen
10  * @version $Id: freedom_mod.php,v 1.24 2007/10/09 16:44:47 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 
17 include_once ("FDL/modcard.php");
18 
19 include_once ("FDL/Class.Dir.php");
20 include_once ("FDL/Class.DocFam.php");
21 // -----------------------------------
23 {
24  // -----------------------------------
25  // Get all the params
26  $dirid = GetHttpVars("dirid", 0);
27  $docid = GetHttpVars("id", 0);
28  $retedit = GetHttpVars("retedit", "N") == "Y"; // true if return need edition
29  $dbaccess = $action->dbaccess;
30 
31  $err = modcard($action, $ndocid); // ndocid change if new doc
32  if ($err != "") $action->AddWarningMsg($err);
33  else {
34 
35  $doc = new_Doc($dbaccess, $ndocid);
36  if ($docid > 0) $action->AddLogMsg(sprintf(_("%s has been modified") , $doc->title));
37 
38  if ($docid == 0) {
39  AddLogMsg(sprintf(_("%s has been created") , $doc->title));
40  $fld = null;
41  if ($dirid > 0) {
42  /*
43  * @var Dir $fld
44  */
45  $fld = new_Doc($dbaccess, $dirid);
46  if ($fld->doctype != 'D') $dirid = 0;
47  }
48  // first try in current folder
49  if ($dirid > 0) {
50  $err = $fld->insertDocument($doc->id);
51  if ($err != "") {
52  $action->AddLogMsg($err);
53  $dirid = 0;
54  }
55  }
56  // second try in default folder for family
57  /*
58  if ($dirid == 0) {
59  $cdoc = $doc->getFamilyDocument();
60  if ($cdoc->dfldid>0) {
61  $dirid=$cdoc->dfldid;
62  $fld = new_Doc($dbaccess,$dirid);
63  $err=$fld->AddFile($doc->id);
64  if ($err != "") {
65  $action->AddLogMsg($err);
66  $dirid=0;
67  }
68  }
69  }
70  */
71  // third try in home folder
72  if ($dirid == 0) {
73  $fld = new Dir($dbaccess);
74  $home = $fld->getHome();
75 
76  if ($home->id > 0) $fld = $home;
77  $err = $fld->insertDocument($doc->id);
78  if ($err != "") $action->AddLogMsg($err);
79  }
80  }
81  }
82 
83  if ($retedit) {
84  redirect($action, GetHttpVars("redirect_app", "FREEDOM") , GetHttpVars("redirect_act", "FREEDOM_EDIT&id=$ndocid") , $action->GetParam("CORE_STANDURL"));
85  } else {
86  // $action->register("reload$ndocid","Y"); // to reload cached client file
87  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD&refreshfld=Y&id=$ndocid") , $action->GetParam("CORE_STANDURL"));
88  }
89 }
global $action
AddLogMsg($msg, $cut=80)
Definition: Lib.Common.php:77
$docid
Definition: cleanFamily.php:13
freedom_mod(Action &$action)
Definition: freedom_mod.php:22
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
modcard(Action &$action, &$ndocid, &$info=array())
Definition: modcard.php:30
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen