Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_mod.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  * Modify a document
9  *
10  * @author Anakeen 2000
11  * @version $Id: generic_mod.php,v 1.34 2008/03/14 13:58:03 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 
19 include_once ("FDL/modcard.php");
20 
21 include_once ("FDL/Class.DocFam.php");
22 include_once ("FDL/Class.Dir.php");
23 // -----------------------------------
25 {
26  // -----------------------------------
27  // Get all the params
28  $dirid = $action->getArgument("dirid", 0);
29  $docid = $action->getArgument("id", 0);
30  $catgid = $action->getArgument("catgid", 0);
31  $retedit = ($action->getArgument("retedit", "N") == "Y"); // true if return need edition
32  $noredirect = ($action->getArgument("noredirect") == "1"); // true if return need edition
33  $quicksave = ($action->getArgument("quicksave") == "1"); // true if return need edition
34  $rzone = $action->getArgument("rzone"); // special zone when finish edition
35  $rvid = $action->getArgument("rvid"); // special zone when finish edition
36  $viewext = $action->getArgument("viewext") == "yes"; // special zone when finish edition
37  $autoclose = $action->getArgument("autoclose") == "yes"; // special zone when finish edition
38  $recallhelper = $action->getArgument("recallhelper") == "yes"; // special zone when finish edition
39  $updateAttrid = $action->getArgument("updateAttrid");
40 
41  $dbaccess = $action->GetParam("FREEDOM_DB");
42  $action->parent->addJsRef("GENERIC:generic_mod.js", true);
43  $err = modcard($action, $ndocid, $info); // ndocid change if new doc
44  if (!$noredirect) $action->AddWarningMsg($err);
45 
46  if ($err == "") {
47  $doc = new_Doc($dbaccess, $ndocid);
48  if ($docid > 0) AddLogMsg(sprintf(_("%s has been modified") , $doc->title));
49 
50  if ($docid == 0) { // new file => add in a folder
51  AddLogMsg(sprintf(_("%s has been created") , $doc->title));
52 
53  $cdoc = $doc->getFamDoc();
54  //if (($cdoc->dfldid>0) && ($dirid==0)) $dirid=$cdoc->dfldid;// we not insert in defaut folder
55  if ($dirid > 0) {
56  $fld = new_Doc($dbaccess, $dirid);
57  if ($fld->locked == - 1) { // it is revised document
58  $dirid = $fld->latestId();
59  if ($dirid != $fld->id) $fld = new_Doc($dbaccess, $dirid);
60  }
61  if (method_exists($fld, "AddFile")) {
62  $err = $fld->AddFile($doc->id);
63  if ($err != "") {
64  //try in home folder
65  $home = $fld->getHome(false);
66  if ($home && ($home->id > 0)) {
67  $fld = $home;
68  $err = $fld->AddFile($doc->id);
69  }
70  }
71 
72  if ($err != "") {
73  $action->AddLogMsg($err);
74  } else {
75  if (($doc->doctype == 'D') || ($doc->doctype == 'S')) $action->AddActionDone("ADDFOLDER", $fld->initid);
76  else $action->AddActionDone("ADDFILE", $fld->initid);
77  }
78  } else {
79  //try in home folder
80  $fld = new_Doc($dbaccess, UNCLASS_FLD);
81  $home = $fld->getHome(false);
82  if ($home && ($home->id > 0)) {
83  $fld = $home;
84  $err = $fld->AddFile($doc->id);
85  }
86  }
87  }
88  }
89  }
90 
91  if ($noredirect) {
92  if ((!$err) && $updateAttrid) {
93  $action->lay->set("updateData", json_encode(array(
94  "id" => $doc->id,
95  "title" => $doc->getTitle() ,
96  "attrid" => $updateAttrid,
97  "recallhelper" => $recallhelper
98  )));
99  } else {
100  $action->lay->set("updateData", "null");
101  }
102 
103  $action->lay->set("autoclose", $autoclose ? "true" : "false");
104  $action->lay->set("id", $ndocid);
105  if (is_array($info)) {
106  foreach ($info as $k => $v) {
107  $info[$k]["prefix"] = sprintf(_("constraint not validated for %s attribute") , $v["label"]);
108  }
109  }
110  $action->lay->set("constraintinfo", json_encode($info));
111  $action->lay->set("quicksave", $quicksave);
112  if ($rzone != "") $zone = "&zone=$rzone";
113  else $zone = "";
114  if ($rvid != "") $zone = "&vid=$rvid";
115  if ($err == "-") $err = "";
116  $action->lay->set("error", json_encode($err));
117  $warning = $action->parent->getWarningMsg();
118  if ($warning && count($warning) > 0) $warning = implode("\n", $warning);
119  else $warning = '';
120  $action->lay->set("warning", json_encode($warning));
121  if ($retedit) $action->lay->set("url", sprintf("?app=%s&action=%s$zone", getHttpVars("redirect_app", "GENERIC") , getHttpVars("redirect_act", "GENERIC_EDIT&id=$ndocid")));
122  else {
123  if ($viewext) $action->lay->set("url", sprintf("?app=%s&action=%s$zone", getHttpVars("redirect_app", "FDL") , getHttpVars("redirect_act", "VIEWEXTDOC$zone&refreshfld=Y&id=$ndocid")));
124  else $action->lay->set("url", sprintf("?app=%s&action=%s$zone", getHttpVars("redirect_app", "FDL") , getHttpVars("redirect_act", "FDL_CARD$zone&refreshfld=Y&id=$ndocid")));
125  }
126  return;
127  }
128 
129  if ($ndocid == 0) {
130  redirect($action, GetHttpVars("redirect_app", "GENERIC") , GetHttpVars("redirect_act", "GENERIC_LOGO") , $action->GetParam("CORE_STANDURL"));
131  }
132  if ($retedit) {
133  redirect($action, GetHttpVars("redirect_app", "GENERIC") , GetHttpVars("redirect_act", "GENERIC_EDIT&id=$ndocid") , $action->GetParam("CORE_STANDURL"));
134  } else {
135 
136  if ($rzone != "") $zone = "&zone=$rzone";
137  else $zone = "";
138  if ($rvid != "") $zone = "&vid=$rvid";
139  // $action->register("reload$ndocid","Y"); // to reload cached client file
140  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD$zone&refreshfld=Y&id=$ndocid") , $action->GetParam("CORE_STANDURL"));
141  }
142 }
143 ?>
← centre documentaire © anakeen - published under CC License - Dynacase