Offline Server  1.6
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
testHook.php
Go to the documentation of this file.
1 <?php
2 
3 include_once ("OFFLINE/Interface.DomainHook.php");
4 
5 class testHook implements DomainHook
6 {
7  public function onBeforePushTransaction(_OfflineDomain &$domain)
8  {
9  $domain->addComment(__METHOD__);
10  return '';
11  }
12 
13  public function onAfterPushTransaction(_OfflineDomain &$domain)
14  {
15 
16  $domain->addComment(__METHOD__);
17  }
18  public function onAfterSaveTransaction(_OfflineDomain &$domain)
19  {
20 
21  $domain->addComment(__METHOD__);
22  }
23  public function onBeforePullUserDocuments(_OfflineDomain &$domain)
24  {
25  $domain->addComment(__METHOD__);
26  return '';
27  }
28 
29  public function onAfterPullSharedDocuments(_OfflineDomain &$domain)
30  {
31 
32  $domain->addComment(__METHOD__);
33  }
34 
35  public function onBeforePullSharedDocuments(_OfflineDomain &$domain)
36  {
37  $domain->addComment(__METHOD__);
38 
39  //return 'pas de partage';
40  }
41 
42  public function onAfterPullUserDocuments(_OfflineDomain &$domain)
43  {
44 
45  $domain->addComment(__METHOD__);
46  }
47  public function onAfterSaveDocument(_OfflineDomain &$domain, Doc &$updatedDoc, $data = null)
48  {
49 
50  $domain->addComment(__METHOD__ . $updatedDoc->getTitle());
51  $updatedDoc->addComment(__METHOD__ . ':' . serialize($data));
52  }
53  public function onPullDocument(_OfflineDomain &$domain, Doc &$doc)
54  {
55  //$domain->addExtraData($doc, "test", "one");
56  //$doc->addComment(__METHOD__);
57  return true;
58  $doc->addComment(__METHOD__);
59  $classid = $doc->getValue("es_classe");
60  if ($classid != '1126') {
61 
62  $domain->addComment(__METHOD__ . ' ' . $doc->getTitle(), HISTO_INFO);
63 
64  } else {
65 
66  $domain->addComment(__METHOD__ . " not pull $classid " . $doc->getTitle(), HISTO_ERROR);
67  return 'not a reptilia';
68  }
69  return true;
70 
71  }
72 
73  public function onBeforePushDocument(_OfflineDomain &$domain, Doc &$doc, $data = null)
74  {
75  $domain->addComment(__METHOD__ . $doc->getTitle());
76  $doc->addComment(__METHOD__ . ':' . serialize($data));
77  // return "stop the push";
78  }
79  public function onAfterPushDocument(_OfflineDomain &$domain, Doc &$doc, $data = null)
80  {
81  $domain->addComment(__METHOD__ . $doc->getTitle());
82  $doc->addComment(__METHOD__ . ':' . serialize($data));
83  }
84  public function onBeforeSaveDocument(_OfflineDomain &$domain, Doc &$waitDoc, Doc &$refererDoc = null, $data = null)
85  {
86 
87  if ($refererDoc) {
88  $domain->addComment(__METHOD__ . $refererDoc->getTitle());
89  $refererDoc->addComment(__METHOD__ . ':' . serialize($data));
90  $err .= simpleQuery($refererDoc->dbaccess, "select id, locked, revision from doc where locked != -1 and initid=" . $refererDoc->initid, $res, false, true);
91  //print "Before";print_r2($res);
92  $err = $refererDoc->addRevision("before save in synchro");
93  $err .= simpleQuery($refererDoc->dbaccess, "select id, locked, revision from doc where locked != -1 and initid=" . $refererDoc->initid, $res, false, true);
94  }
95  //print "After";print_r2($res);
96  // if ($refererDoc->getValue("es_poids") < 98) {
97  // $waitDoc->setValue("es_poids", $refererDoc->getValue("es_poids") + 1);
98  //}
99  //$refererDoc->addComment("add one in es_poids :" . ($waitDoc->getValue("es_poids") ));
100  return $err;
101  }
102 
103 }
onBeforePullSharedDocuments(_OfflineDomain &$domain)
Definition: testHook.php:35
onAfterSaveTransaction(_OfflineDomain &$domain)
Definition: testHook.php:18
onAfterPushDocument(_OfflineDomain &$domain, Doc &$doc, $data=null)
Definition: testHook.php:79
onAfterPushTransaction(_OfflineDomain &$domain)
Definition: testHook.php:13
onBeforePushDocument(_OfflineDomain &$domain, Doc &$doc, $data=null)
Definition: testHook.php:73
onBeforeSaveDocument(_OfflineDomain &$domain, Doc &$waitDoc, Doc &$refererDoc=null, $data=null)
Definition: testHook.php:84
onAfterPullSharedDocuments(_OfflineDomain &$domain)
Definition: testHook.php:29
onBeforePullUserDocuments(_OfflineDomain &$domain)
Definition: testHook.php:23
onPullDocument(_OfflineDomain &$domain, Doc &$doc)
Definition: testHook.php:53
onAfterSaveDocument(_OfflineDomain &$domain, Doc &$updatedDoc, $data=null)
Definition: testHook.php:47
onAfterPullUserDocuments(_OfflineDomain &$domain)
Definition: testHook.php:42
onBeforePushTransaction(_OfflineDomain &$domain)
Definition: testHook.php:7
← centre documentaire © anakeen - published under CC License - Dynacase