Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
movedirfile.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  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: movedirfile.php,v 1.12 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 GED
15  */
16 /**
17  */
18 
19 include_once ("FDL/Lib.Dir.php");
20 include_once ("FDL/freedom_util.php");
21 // -----------------------------------
22 function movedirfile(&$action)
23 {
24  // -----------------------------------
25 
26  // Get all the params
27  $todirid = GetHttpVars("todirid");
28  $fromdirid = GetHttpVars("fromdirid");
29  $docid = GetHttpVars("docid");
30  $return = GetHttpVars("return"); // return action may be folio
31  $dbaccess = $action->GetParam("FREEDOM_DB");
32 
34  // add before suppress
35  $dir = new_Doc($dbaccess, $todirid);
36  if ($dir->locked == - 1) { // it is revised document
37  $ldocid = $dir->latestId();
38  if ($ldocid != $dir->id) $dir = new_Doc($dbaccess, $ldocid);
39  }
40  $err = $dir->AddFile($docid);
41  if ($err != "") $action->exitError($err);
42 
43  $action->AddLogMsg(sprintf(_("%s has been added in %s folder") , $doc->title, $dir->title));
44 
45  $dir2 = new_Doc($dbaccess, $fromdirid);
46  if ($dir2->locked == - 1) { // it is revised document
47  $ldocid = $dir2->latestId();
48  if ($ldocid != $dir2->id) $dir2 = new_Doc($dbaccess, $ldocid);
49  }
50 
51  if (method_exists($dir2, "DelFile")) {
52  $err = $dir2->DelFile($docid);
53  if ($err != "") $action->exitError($err);
54 
55  $action->AddLogMsg(sprintf(_("%s has been removed in %s folder") , $doc->title, $dir2->title));
56  }
57  if (($doc->prelid == 0) && ($err == "")) { // because deletion id done after add
58  $doc->prelid = $dir->initid;
59  $doc->modify(true, array(
60  "prelid"
61  ) , true);
62  }
63 
64  if ($return == "folio") redirect($action, GetHttpVars("app") , "FOLIOLIST&dirid=$todirid");
65  else redirect($action, GetHttpVars("app") , "FREEDOM_VIEW&dirid=$todirid");
66 }
67 ?>
← centre documentaire © anakeen - published under CC License - Dynacase