Offline Server  1.6
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Method.OfflineFolder.php
Go to the documentation of this file.
1 <?php
2 /**
3  * Offline domain
4  *
5  * @author Anakeen
6  * @version $Id: $
7  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
8  * @package OFFLINE
9  */
10 /**
11  */
12 
13 /*
14  * @begin-method-ignore
15  * this part will be deleted when construct document class until end-method-ignore
16  */
17 
18 /**
19  * offline domain fonctionalities
20  *
21  */
22 class _OFFLINEFOLDER extends Dir
23 {
24  /*
25  * @end-method-ignore
26  */
27 
28  public function hookBeforeInsert($docid)
29  {
30  $err = $this->callHookDocument($docid, "onBeforeInsertIntoUserFolder");
31  return $err;
32  }
33  public function hookAfterInsert($docid)
34  {
35  $err = $this->callHookDocument($docid, "onAfterInsertIntoUserFolder");
36  return $err;
37  }
38  public function hookBeforeRemove($docid)
39  {
40  $err = $this->callHookDocument($docid, "onBeforeRemoveFromUserFolder");
41  return $err;
42  }
43  public function hookAfterRemove($docid)
44  {
45  $err = $this->callHookDocument($docid, "onAfterRemoveFromUserFolder");
46  return $err;
47  }
48 
49  protected function callHookDocument($docid, $method) {
50  $err = '';
51  $doc = new_doc($this->dbaccess, $docid, true);
52  if ($doc->isAlive()) {
53  if (method_exists($doc, $method)) {
54  $domain=new_doc($this->dbaccess, $this->getValue("off_domain"));
55  $err = call_user_func(array($doc, $method), $domain, $this);
56  }
57  } else {
58  $err = sprintf(_("document %s not found"), $docid);
59  }
60  return $err;
61  }
62 
63  public function preInsertDoc($docid)
64  {
65  $err = $this->hookBeforeInsert($docid);
66  return $err;
67  }
68 
69  public function postInsertDoc($docid)
70  {
71  $err = "";
72  $doc = new_doc($this->dbaccess, $docid, true);
73  if ($doc->isAlive()) {
74  $doc->updateDomains();
75  /*
76  if ($doc->locked == $doc->userid) {
77  $doc->lockToDomain($this->getValue("off_domain"));
78  */
79  $err=$this->hookAfterInsert($docid);
80  if (method_exists($doc, "onAfterInsertIntoDomain")) {
81  /** @noinspection PhpUndefinedMethodInspection */
82  $err = $doc->onAfterInsertIntoDomain();
83  }
84  }
85  return $err;
86  }
87  public function postUnlinkDoc($docid)
88  {
89  $err = '';
90 
91  $doc = new_doc($this->dbaccess, $docid, true);
92  if ($doc->isAlive()) {
93  $doc->updateDomains();
94  $docuid = $this->getValue("off_user");
95  if ($docuid) {
96  $uid = array();
97  $err .= simpleQuery($this->dbaccess, sprintf("select id from users where fid=%d", $docuid), $uid, true, true);
98  if ($uid) {
99  /** @noinspection PhpIncludeInspection */
100  require_once "FDL/Class.DocWait.php";
101  $docWait = new DocWait($this->dbaccess, array(
102  $doc->initid,
103  $uid
104  ));
105  if ($docWait->isAffected()) {
106  $err .= $docWait->delete();
107  }
108  }
109  }
110  $err .= $this->hookAfterRemove($docid);
111  }
112  return $err;
113  }
114 
115 
116  public function preUnlinkDoc($docid) {
117  $err = $this->hookBeforeRemove($docid);
118  return $err;
119  }
120 
121 /*
122  * @begin-method-ignore
123  * this part will be deleted when construct document class until end-method-ignore
124  */
125 }
126 
127 /*
128  * @end-method-ignore
129  */
callHookDocument($docid, $method)
← centre documentaire © anakeen - published under CC License - Dynacase