Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Method.Archivage.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  * Detailled search
9  *
10  * @author Anakeen 2000
11  * @version $Id: Method.DetailSearch.php,v 1.73 2009/01/08 17:52:54 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  * @begin-method-ignore
20  * this part will be deleted when construct document class until end-method-ignore
21  */
22 class _ARCHIVING extends Dir
23 {
24  /*
25  * @end-method-ignore
26  */
27  /**
28  * all document's folder are archieved
29  * @return string error message empty message if no error
30  */
31  function arc_close()
32  {
33  $err = "";
34  if (!$err) {
35  include_once ("FDL/Class.SearchDoc.php");
36 
37  $s = new SearchDoc($this->dbaccess);
38  $s->dirid = $this->id;
39  $s->orderby = '';
40  $s->setObjectReturn();
41  $s->search();
42  if (ini_get("max_execution_time") < 3600) ini_set("max_execution_time", 3600);
43  while ($doc = $s->nextDoc()) {
44  $doc->disableEditControl();
45  $err.= $doc->archive($this);
46  $doc->enableEditControl();
47  }
48  }
49 
50  $err = $this->setValue("arc_status", "C");
51  $err = $this->setValue("arc_clotdate", $this->getDate());
52  if (!$err) $err = $this->modify();
53  $this->addComment(sprintf(_("Close archive")));
54  return $err;
55  }
56  /**
57  * all document's archivied by it are unarchieved
58  * @return string error message empty message if no error
59  */
60  function arc_reopen()
61  {
62  $err = $this->setValue("arc_status", "O");
63  $err = $this->deleteValue("arc_clotdate");
64  if (!$err) $err = $this->modify();
65  if (!$err) {
66  include_once ("FDL/Class.SearchDoc.php");
67 
68  $s = new SearchDoc($this->dbaccess);
69  $s->addFilter("archiveid=%d", $this->id);
70  $s->orderby = '';
71  $s->setObjectReturn();
72  $s->search();
73  if (ini_get("max_execution_time") < 3600) ini_set("max_execution_time", 3600);
74  while ($doc = $s->nextDoc()) {
75  $doc->disableEditControl();
76  $err.= $doc->unArchive($this);
77  $doc->enableEditControl();
78  }
79  }
80  $this->addComment(sprintf(_("Reopen archive")));
81  return $err;
82  }
83  /**
84  * all document's archivied by it are unarchieved
85  * @return string error message empty message if no error
86  */
87  function arc_purge()
88  {
89  $err = $this->setValue("arc_status", "P");
90  $err = $this->setValue("arc_purgedate", $this->getDate());
91  if (!$err) $err = $this->modify();
92  if (!$err) {
93  include_once ("FDL/Class.SearchDoc.php");
94 
95  $s = new SearchDoc($this->dbaccess);
96  $s->addFilter("archiveid=%d", $this->id);
97  $s->orderby = '';
98  $s->setObjectReturn();
99  $s->search();
100  if (ini_get("max_execution_time") < 3600) ini_set("max_execution_time", 3600);
101  $t = "<ol>";
102  while ($doc = $s->nextDoc()) {
103  if ($doc->doctype != 'C') {
104  $t.= sprintf('<li><a href="?app=FDL&action=VIEWDESTROYDOC&id=%d">%s</a></li> ', $doc->id, $doc->title);
105  $doc->disableEditControl();
106  $doc->addComment(sprintf(_("destroyed by archive purge from %s") , $this->getTitle()));
107  $err.= $doc->delete(true, false);
108  $doc->enableEditControl();
109  }
110  }
111  $t.= "</ol>";
112  $err = $this->setValue("arc_purgemanif", $t);
113  if (!$err) $err = $this->modify();
114  $this->clear();
115  $this->addComment(sprintf(_("Purge archive")));
116  }
117  return $err;
118  }
119  function postModify()
120  {
121  $err = parent::postModify();
122  $err.= $this->createProfil();
123  return $err;
124  }
125 
126  function preInsertDoc()
127  {
128  if ($this->getValue("arc_status") != "O") {
129  return _("archieve status must be open to modify content");
130  }
131  }
132  function preUnlinkDoc()
133  {
134  if ($this->getValue("arc_status") != "O") {
135  return _("archieve status must be open to modify content");
136  }
137  }
138  /**
139  * return specfic filters instead of normal content
140  * @return array of sql filters
141  */
142  public function getSpecificFilters()
143  {
144  if ($this->getValue("arc_status") == "C") {
145  return array(
146  sprintf("archiveid=%d", $this->id)
147  );
148  }
149  return array();
150  }
151  /**
152  * create an init a profil to be use if document archived
153  */
154  function createProfil()
155  {
156  $prfid = $this->getValue("arc_profil");
157  if ($prfid) {
158  $prf = new_doc($this->dbaccess, $prfid);
159  if (!$prf->isAlive()) $prfid = 0; // redo the profil
160  else {
161  $prf->setValue("ba_title", sprintf(_("Profil for document's archive %s") , $this->getTitle()));
162  $prf->modify();
163  }
164  }
165 
166  if (!$prfid) {
167  $prf = createDoc($this->dbaccess, "PDIR", false);
168  $prf->setValue("ba_title", sprintf(_("Profil for document's archive %s") , $this->getTitle()));
169  $prf->add();
170  $prf->setControl();
171  $err = $this->setValue("arc_profil", $prf->id);
172  if (!$err) $err = $this->modify();
173  }
174 
175  return $err;
176  }
177  /**
178  * @begin-method-ignore
179  * this part will be deleted when construct document class until end-method-ignore
180  */
181 }
182 /*
183  * @end-method-ignore
184 */
185 ?>
← centre documentaire © anakeen - published under CC License - Dynacase