Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
insertdocument.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  * Insert documents in folder
9  *
10  * @author Anakeen 2007
11  * @version $Id: insertdocument.php,v 1.2 2007/08/07 16:56:59 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/Class.Dir.php");
20 include_once ("FDL/Class.DocFam.php");
21 /**
22  * Insert documents in folder
23  * @param Action &$action current action
24  * @global id Http var : folder document identificator to see
25  */
27 {
28 
29  $docid = GetHttpVars("id");
30  $uchange = GetHttpVars("uchange");
31  $dbaccess = $action->GetParam("FREEDOM_DB");
32 
33  if ($docid == "") $action->exitError(_("no document reference"));
34  if (!is_numeric($docid)) $docid = getIdFromName($dbaccess, $docid);
35  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , GetHttpVars("id")));
37  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
38  if ($doc->defDoctype != 'D') $action->exitError(sprintf(_("not a static folder %s") , $doc->title));
39 
40  $err = $doc->canModify();
41  if ($err != "") $action->exitError($err);
42 
43  $erradd = array();
44  $errdel = array();
45  foreach ($uchange as $initid => $state) {
46  if ($initid > 0) {
47 
48  switch ($state) {
49  case "new":
50  $erradd[$initid] = $doc->addFile($initid);
51  break;
52 
53  case "deleted":
54  $errdel[$initid] = $doc->delFile($initid);
55  break;
56  }
57  }
58  }
59 
60  $n = 0;
61  $err = "";
62  foreach ($erradd as $k => $v) {
63  if ($v == "") $n++;
64  else $err.= "$v\n";
65  }
66  if ($n > 0) $action->addWarningMsg(sprintf(_("Add %d document(s)") , $n));
67  $n = 0;
68  foreach ($errdel as $k => $v) {
69  if ($v == "") $n++;
70  else $err.= "$v\n";
71  }
72  if ($n > 0) $action->addWarningMsg(sprintf(_("Suppress %d document(s)") , $n));
73  if ($err != "") $action->addWarningMsg($err);
74 
75  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD&refreshfld=Y&id=$docid") , $action->GetParam("CORE_STANDURL"));
76 }
77 ?>
← centre documentaire © anakeen - published under CC License - Dynacase