~olivier-chatelain/php-addressbook/trunk

« back to all changes in this revision

Viewing changes to z-push/lib/request/resolverecipients.php

  • Committer: chatelao
  • Date: 2016-09-11 07:59:37 UTC
  • Revision ID: git-v1:03926e44d99a04a3b05d4761e322a1f5e8a405d7
Chg: Upgrade z-push from 2.0.3 to 2.2.12 (stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/***********************************************
 
3
* File      :   resolverecipients.php
 
4
* Project   :   Z-Push
 
5
* Descr     :   Provides the ResolveRecipients command
 
6
*
 
7
* Created   :   15.10.2012
 
8
*
 
9
* Copyright 2007 - 2013 Zarafa Deutschland GmbH
 
10
*
 
11
* This program is free software: you can redistribute it and/or modify
 
12
* it under the terms of the GNU Affero General Public License, version 3,
 
13
* as published by the Free Software Foundation with the following additional
 
14
* term according to sec. 7:
 
15
*
 
16
* According to sec. 7 of the GNU Affero General Public License, version 3,
 
17
* the terms of the AGPL are supplemented with the following terms:
 
18
*
 
19
* "Zarafa" is a registered trademark of Zarafa B.V.
 
20
* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
 
21
* The licensing of the Program under the AGPL does not imply a trademark license.
 
22
* Therefore any rights, title and interest in our trademarks remain entirely with us.
 
23
*
 
24
* However, if you propagate an unmodified version of the Program you are
 
25
* allowed to use the term "Z-Push" to indicate that you distribute the Program.
 
26
* Furthermore you may use our trademarks where it is necessary to indicate
 
27
* the intended purpose of a product or service provided you use it in accordance
 
28
* with honest practices in industrial or commercial matters.
 
29
* If you want to propagate modified versions of the Program under the name "Z-Push",
 
30
* you may only do so if you have a written permission by Zarafa Deutschland GmbH
 
31
* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
 
32
*
 
33
* This program is distributed in the hope that it will be useful,
 
34
* but WITHOUT ANY WARRANTY; without even the implied warranty of
 
35
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 
36
* GNU Affero General Public License for more details.
 
37
*
 
38
* You should have received a copy of the GNU Affero General Public License
 
39
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
40
*
 
41
* Consult LICENSE file for details
 
42
************************************************/
 
43
 
 
44
class ResolveRecipients extends RequestProcessor {
 
45
 
 
46
    /**
 
47
     * Handles the ResolveRecipients command
 
48
     *
 
49
     * @param int       $commandCode
 
50
     *
 
51
     * @access public
 
52
     * @return boolean
 
53
     */
 
54
    public function Handle($commandCode) {
 
55
        // Parse input
 
56
        if(!self::$decoder->getElementStartTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS))
 
57
            return false;
 
58
 
 
59
        $resolveRecipients = new SyncResolveRecipients();
 
60
        $resolveRecipients->Decode(self::$decoder);
 
61
 
 
62
        if(!self::$decoder->getElementEndTag())
 
63
            return false; // SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS
 
64
 
 
65
        $resolveRecipients = self::$backend->ResolveRecipients($resolveRecipients);
 
66
 
 
67
 
 
68
        self::$encoder->startWBXML();
 
69
        self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS);
 
70
 
 
71
            self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_STATUS);
 
72
            self::$encoder->content($resolveRecipients->status);
 
73
            self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_STATUS
 
74
 
 
75
 
 
76
            foreach ($resolveRecipients->to as $i => $to) {
 
77
                self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_RESPONSE);
 
78
                    self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_TO);
 
79
                    self::$encoder->content($to);
 
80
                    self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_TO
 
81
 
 
82
                    self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_STATUS);
 
83
                    self::$encoder->content($resolveRecipients->status);
 
84
                    self::$encoder->endTag();
 
85
 
 
86
                    // do only if recipient is resolved
 
87
                    if ($resolveRecipients->status != SYNC_RESOLVERECIPSSTATUS_RESPONSE_UNRESOLVEDRECIP) {
 
88
                        self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_RECIPIENTCOUNT);
 
89
                        self::$encoder->content(count($resolveRecipients->recipient));
 
90
                        self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_RECIPIENTCOUNT
 
91
 
 
92
                        self::$encoder->startTag(SYNC_RESOLVERECIPIENTS_RECIPIENT);
 
93
                        $resolveRecipients->recipient[$i]->Encode(self::$encoder);
 
94
                        self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_RECIPIENT
 
95
                    }
 
96
 
 
97
                self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_RESPONSE
 
98
            }
 
99
 
 
100
        self::$encoder->endTag(); // SYNC_RESOLVERECIPIENTS_RESOLVERECIPIENTS
 
101
        return true;
 
102
    }
 
103
}
 
104
?>
 
 
b'\\ No newline at end of file'