Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.Archivage.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * archive documents
8  */
9 namespace Dcp\Core;
11 {
12  /**
13  * all document's folder are archieved
14  * @apiExpose
15  * @return string error message empty message if no error
16  */
17  function arc_close()
18  {
19  $err = $this->canEdit();
20  if (!$err) {
21 
22  $s = new \SearchDoc($this->dbaccess);
23  $s->dirid = $this->id;
24  $s->orderby = '';
25  $s->setObjectReturn();
26  $s->search();
27 
29  while ($doc = $s->getNextDoc()) {
30  $doc->disableEditControl();
31  $err.= $doc->archive($this);
32  $doc->enableEditControl();
33  }
34 
35  $err = $this->setValue("arc_status", "C");
36  $err = $this->setValue("arc_clotdate", $this->getDate());
37  if (!$err) $err = $this->modify();
38  $this->addHistoryEntry(sprintf(_("Close archive")));
39  }
40  return $err;
41  }
42  /**
43  * all document's archivied by it are unarchieved
44  * @apiExpose
45  * @return string error message empty message if no error
46  */
47  function arc_reopen()
48  {
49  $err = $this->canEdit();
50  if (!$err) {
51  $err = $this->setValue("arc_status", "O");
52  $err = $this->clearValue("arc_clotdate");
53  if (!$err) $err = $this->modify();
54  if (!$err) {
55  include_once ("FDL/Class.SearchDoc.php");
56 
57  $s = new \SearchDoc($this->dbaccess);
58  $s->addFilter("archiveid=%d", $this->id);
59  $s->orderby = '';
60  $s->setObjectReturn();
61  $s->search();
62 
64  while ($doc = $s->getNextDoc()) {
65  $doc->disableEditControl();
66  $err.= $doc->unArchive($this);
67  $doc->enableEditControl();
68  }
69  }
70  $this->addHistoryEntry(sprintf(_("Reopen archive")));
71  }
72  return $err;
73  }
74  /**
75  * all document's archivied by it are unarchieved
76  * @apiExpose
77  * @return string error message empty message if no error
78  */
79  function arc_purge()
80  {
81  $err = $this->canEdit();
82  if (!$err) {
83  $err = $this->setValue("arc_status", "P");
84  $err.= $this->setValue("arc_purgedate", $this->getDate());
85  if (!$err) $err = $this->modify();
86  if (!$err) {
87  include_once ("FDL/Class.SearchDoc.php");
88 
89  $s = new \SearchDoc($this->dbaccess);
90  $s->addFilter("archiveid=%d", $this->id);
91  $s->orderby = '';
92  $s->setObjectReturn();
93  $s->search();
94 
96  $t = "<ol>";
97  while ($doc = $s->getNextDoc()) {
98  if ($doc->doctype != 'C') {
99  $t.= sprintf('<li><a href="?app=FDL&action=VIEWDESTROYDOC&id=%d">%s</a></li> ', $doc->id, $doc->title);
100  $doc->disableEditControl();
101  $doc->addHistoryEntry(sprintf(_("destroyed by archive purge from %s") , $this->getTitle()));
102  $err.= $doc->delete(true, false);
103  $doc->enableEditControl();
104  }
105  }
106  $t.= "</ol>";
107  $err = $this->setValue("arc_purgemanif", $t);
108  if (!$err) $err = $this->modify();
109  $this->clear();
110  $this->addHistoryEntry(sprintf(_("Purge archive")));
111  }
112  }
113  return $err;
114  }
115  /**
116  * delete all archive contain
117  * @apiExpose
118  * @return string
119  */
120  function arc_clear()
121  {
122  $err = $this->canEdit();
123  if (!$err) {
124  $err = $this->Clear();
125  }
126  return $err;
127  }
128  function postStore()
129  {
130  $err = parent::postStore();
131  $err.= $this->createProfil();
132  return $err;
133  }
134  /**
135  * @deprecated use postStore() instead
136  * @return string
137  */
138  public function postModify()
139  {
141  return self::postStore();
142  }
143  function preInsertDocument($docid, $multiple = false)
144  {
145  if ($this->getRawValue("arc_status") != "O") {
146  return _("archieve status must be open to modify content");
147  }
148  return '';
149  }
150  function preRemoveDocument($docid, $multiple = false)
151  {
152  if ($this->getRawValue("arc_status") != "O") {
153  return _("archieve status must be open to modify content");
154  }
155  return '';
156  }
157  /**
158  * return specfic filters instead of normal content
159  * @return array of sql filters
160  */
161  public function getSpecificFilters()
162  {
163  if ($this->getRawValue("arc_status") == "C") {
164  return array(
165  sprintf("archiveid=%d", $this->id)
166  );
167  }
168  return array();
169  }
170  /**
171  * create an init a profil to be use if document archived
172  */
173  function createProfil()
174  {
175  $err = '';
176  $prfid = $this->getRawValue("arc_profil");
177  if ($prfid) {
178  $prf = new_doc($this->dbaccess, $prfid);
179  if (!$prf->isAlive()) $prfid = 0; // redo the profil
180  else {
181  $prf->setValue("ba_title", sprintf(_("Profil for document's archive %s") , $this->getTitle()));
182  $prf->modify();
183  }
184  }
185 
186  if (!$prfid) {
187  $prf = createDoc($this->dbaccess, "PDIR", false);
188  $prf->setValue("ba_title", sprintf(_("Profil for document's archive %s") , $this->getTitle()));
189  $prf->add();
190  $prf->setControl();
191  $err = $this->setValue("arc_profil", $prf->id);
192  if (!$err) $err = $this->modify();
193  }
194 
195  return $err;
196  }
197 }
preRemoveDocument($docid, $multiple=false)
static getDate($daydelta=0, $dayhour="", $daymin="", $getlocale=false)
Definition: Class.Doc.php:8783
Clear()
Definition: Class.Dir.php:108
canEdit($verifyDomain=true)
Definition: Class.Doc.php:1364
clearValue($attrid)
Definition: Class.Doc.php:4409
if($famId) $s
modify($nopost=false, $sfields="", $nopre=false)
$docid
Definition: cleanFamily.php:13
setValue($attrid, $value, $index=-1, &$kvalue=null)
Definition: Class.Doc.php:3528
createDoc($dbaccess, $fromid, $control=true, $defaultvalues=true, $temporary=false)
getTitle($id="-1", $def="", $latest=false)
Definition: Class.Doc.php:8715
deprecatedFunction($msg= '')
Definition: Lib.Common.php:86
setMaxExecutionTimeTo($limit)
Definition: Lib.Common.php:121
preInsertDocument($docid, $multiple=false)
if($file) if($subject==""&&$file) if($subject=="") $err
addHistoryEntry($comment= '', $level=DocHisto::INFO, $code= '', $uid= '')
Definition: Class.Doc.php:4707
getRawValue($idAttr, $def="")
Definition: Class.Doc.php:3117
← centre documentaire © anakeen