Core  3.2
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  * @package FDL
5 */
6 /**
7  * Insert documents in folder
8  *
9  * @author Anakeen
10  * @version $Id: insertdocument.php,v 1.2 2007/08/07 16:56:59 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 include_once ("FDL/Class.Dir.php");
18 include_once ("FDL/Class.DocFam.php");
19 /**
20  * Insert documents in folder
21  * @param Action &$action current action
22  * @global id int Http var : folder document identifier to see
23  */
25 {
26 
27  $docid = GetHttpVars("id");
28  $uchange = GetHttpVars("uchange");
29  $dbaccess = $action->dbaccess;
30 
31  if ($docid == "") $action->exitError(_("no document reference"));
32  if (!is_numeric($docid)) $docid = getIdFromName($dbaccess, $docid);
33  if (intval($docid) == 0) $action->exitError(sprintf(_("unknow logical reference '%s'") , GetHttpVars("id")));
34  /*
35  * @var Dir $doc
36  */
38  if (!$doc->isAffected()) $action->exitError(sprintf(_("cannot see unknow reference %s") , $docid));
39  if ($doc->defDoctype != 'D') $action->exitError(sprintf(_("not a static folder %s") , $doc->title));
40 
41  $err = $doc->canModify();
42  if ($err != "") $action->exitError($err);
43 
44  $erradd = array();
45  $errdel = array();
46  foreach ($uchange as $initid => $state) {
47  if ($initid > 0) {
48 
49  switch ($state) {
50  case "new":
51  $erradd[$initid] = $doc->addFile($initid);
52  break;
53 
54  case "deleted":
55  $errdel[$initid] = $doc->delFile($initid);
56  break;
57  }
58  }
59  }
60 
61  $n = 0;
62  $err = "";
63  foreach ($erradd as $k => $v) {
64  if ($v == "") $n++;
65  else $err.= "$v\n";
66  }
67  if ($n > 0) $action->addWarningMsg(sprintf(_("Add %d document(s)") , $n));
68  $n = 0;
69  foreach ($errdel as $k => $v) {
70  if ($v == "") $n++;
71  else $err.= "$v\n";
72  }
73  if ($n > 0) $action->addWarningMsg(sprintf(_("Suppress %d document(s)") , $n));
74  if ($err != "") $action->addWarningMsg($err);
75 
76  redirect($action, GetHttpVars("redirect_app", "FDL") , GetHttpVars("redirect_act", "FDL_CARD&refreshfld=Y&id=$docid") , $action->GetParam("CORE_STANDURL"));
77 }
addWarningMsg($msg)
global $action
insertdocument(Action &$action)
exitError($texterr, $exit=true, $code="")
$docid
Definition: cleanFamily.php:13
new_Doc($dbaccess, $id= '', $latest=false)
$dbaccess
Definition: checkVault.php:17
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen