1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11:
12: 13: 14: 15: 16:
17:
18: define("SYNC_MOVE_MOVES","Move:Moves");
19: define("SYNC_MOVE_MOVE","Move:Move");
20: define("SYNC_MOVE_SRCMSGID","Move:SrcMsgId");
21: define("SYNC_MOVE_SRCFLDID","Move:SrcFldId");
22: define("SYNC_MOVE_DSTFLDID","Move:DstFldId");
23: define("SYNC_MOVE_RESPONSE","Move:Response");
24: define("SYNC_MOVE_STATUS","Move:Status");
25: define("SYNC_MOVE_DSTMSGID","Move:DstMsgId");
26: class Horde_ActiveSync_Request_MoveItems extends Horde_ActiveSync_Request_Base
27: {
28: 29: 30: 31: 32:
33: public function handle()
34: {
35: if (!$this->_decoder->getElementStartTag(SYNC_MOVE_MOVES)) {
36: return false;
37: }
38:
39: $moves = array();
40: while ($this->_decoder->getElementStartTag(SYNC_MOVE_MOVE)) {
41: $move = array();
42: if ($this->_decoder->getElementStartTag(SYNC_MOVE_SRCMSGID)) {
43: $move['srcmsgid'] = $this->_decoder->getElementContent();
44: if(!$this->_decoder->getElementEndTag())
45: break;
46: }
47: if ($this->_decoder->getElementStartTag(SYNC_MOVE_SRCFLDID)) {
48: $move['srcfldid'] = $this->_decoder->getElementContent();
49: if (!$this->_decoder->getElementEndTag()) {
50: break;
51: }
52: }
53: if ($this->_decoder->getElementStartTag(SYNC_MOVE_DSTFLDID)) {
54: $move['dstfldid'] = $this->_decoder->getElementContent();
55: if (!$this->_decoder->getElementEndTag()) {
56: break;
57: }
58: }
59: array_push($moves, $move);
60:
61: if (!$this->_decoder->getElementEndTag()) {
62: return false;
63: }
64: }
65:
66: if (!$this->_decoder->getElementEndTag())
67: return false;
68:
69: $this->_encoder->StartWBXML();
70:
71: $this->_encoder->startTag(SYNC_MOVE_MOVES);
72:
73: foreach ($moves as $move) {
74: $this->_encoder->startTag(SYNC_MOVE_RESPONSE);
75: $this->_encoder->startTag(SYNC_MOVE_SRCMSGID);
76: $this->_encoder->content($move['srcmsgid']);
77: $this->_encoder->endTag();
78:
79: $importer = $this->_driver->getContentsImporter($move['srcfldid']);
80: $result = $importer->importMessageMove($move['srcmsgid'], $move['dstfldid']);
81:
82:
83: $this->_encoder->startTag(SYNC_MOVE_STATUS);
84: $this->_encoder->content($result ? 3 : 1);
85: $this->_encoder->endTag();
86:
87: $this->_encoder->startTag(SYNC_MOVE_DSTMSGID);
88: $this->_encoder->content(is_string($result) ? $result : $move['srcmsgid']);
89: $this->_encoder->endTag();
90: $this->_encoder->endTzg();
91: }
92: $this->_encoder->endTag();
93:
94: return true;
95: }
96: }