[4898] | 1 | <?php |
---|
| 2 | /*********************************************** |
---|
| 3 | * File : streamimporter.php |
---|
| 4 | * Project : Z-Push |
---|
| 5 | * Descr : Stream import classes |
---|
| 6 | * |
---|
| 7 | * Created : 01.10.2007 |
---|
| 8 | * |
---|
| 9 | * ᅵ Zarafa Deutschland GmbH, www.zarafaserver.de |
---|
| 10 | * This file is distributed under GPL v2. |
---|
| 11 | * Consult LICENSE file for details |
---|
| 12 | ************************************************/ |
---|
| 13 | |
---|
| 14 | // We don't support caching changes for messages |
---|
| 15 | class ImportContentsChangesStream { |
---|
| 16 | var $_encoder; |
---|
| 17 | var $_type; |
---|
| 18 | var $_seenObjects; |
---|
| 19 | |
---|
| 20 | function ImportContentsChangesStream(&$encoder, $type) { |
---|
| 21 | $this->_encoder = &$encoder; |
---|
| 22 | $this->_type = $type; |
---|
| 23 | $this->_seenObjects = array(); |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | function ImportMessageChange($id, $message) { |
---|
| 27 | if(strtolower(get_class($message)) != $this->_type) |
---|
| 28 | return true; // ignore other types |
---|
| 29 | |
---|
| 30 | // prevent sending the same object twice in one request |
---|
| 31 | if (in_array($id, $this->_seenObjects)) { |
---|
| 32 | debugLog("Object $id discarded! Object already sent in this request."); |
---|
| 33 | return true; |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | $this->_seenObjects[] = $id; |
---|
| 37 | |
---|
| 38 | if ($message->flags === false || $message->flags === SYNC_NEWMESSAGE) |
---|
| 39 | $this->_encoder->startTag(SYNC_ADD); |
---|
| 40 | else |
---|
| 41 | $this->_encoder->startTag(SYNC_MODIFY); |
---|
| 42 | |
---|
| 43 | $this->_encoder->startTag(SYNC_SERVERENTRYID); |
---|
| 44 | $this->_encoder->content($id); |
---|
| 45 | $this->_encoder->endTag(); |
---|
| 46 | $this->_encoder->startTag(SYNC_DATA); |
---|
| 47 | $message->encode($this->_encoder); |
---|
| 48 | $this->_encoder->endTag(); |
---|
| 49 | $this->_encoder->endTag(); |
---|
| 50 | |
---|
| 51 | return true; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | function ImportMessageDeletion($id) { |
---|
| 55 | $this->_encoder->startTag(SYNC_REMOVE); |
---|
| 56 | $this->_encoder->startTag(SYNC_SERVERENTRYID); |
---|
| 57 | $this->_encoder->content($id); |
---|
| 58 | $this->_encoder->endTag(); |
---|
| 59 | $this->_encoder->endTag(); |
---|
| 60 | |
---|
| 61 | return true; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | function ImportMessageReadFlag($id, $flags) { |
---|
| 65 | if($this->_type != "syncmail") |
---|
| 66 | return true; |
---|
| 67 | $this->_encoder->startTag(SYNC_MODIFY); |
---|
| 68 | $this->_encoder->startTag(SYNC_SERVERENTRYID); |
---|
| 69 | $this->_encoder->content($id); |
---|
| 70 | $this->_encoder->endTag(); |
---|
| 71 | $this->_encoder->startTag(SYNC_DATA); |
---|
| 72 | $this->_encoder->startTag(SYNC_POOMMAIL_READ); |
---|
| 73 | $this->_encoder->content($flags); |
---|
| 74 | $this->_encoder->endTag(); |
---|
| 75 | $this->_encoder->endTag(); |
---|
| 76 | $this->_encoder->endTag(); |
---|
| 77 | |
---|
| 78 | return true; |
---|
| 79 | } |
---|
| 80 | |
---|
| 81 | function ImportMessageMove($message) { |
---|
| 82 | return true; |
---|
| 83 | } |
---|
| 84 | }; |
---|
| 85 | |
---|
| 86 | class ImportHierarchyChangesStream { |
---|
| 87 | |
---|
| 88 | function ImportHierarchyChangesStream() { |
---|
| 89 | return true; |
---|
| 90 | } |
---|
| 91 | |
---|
| 92 | function ImportFolderChange($folder) { |
---|
| 93 | return true; |
---|
| 94 | } |
---|
| 95 | |
---|
| 96 | function ImportFolderDeletion($folder) { |
---|
| 97 | return true; |
---|
| 98 | } |
---|
| 99 | }; |
---|
| 100 | |
---|
| 101 | ?> |
---|