@@ -148,14 +148,14 @@ |
||
148 | 148 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
149 | 149 | |
150 | 150 | SYNC_PROVISION_MAXEMAILAGEFILTER => array ( self::STREAMER_VAR => "maxemailagefilter", |
151 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1, |
|
152 | - self::STREAMER_CHECK_CMPLOWER => 6 )), |
|
151 | + self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1, |
|
152 | + self::STREAMER_CHECK_CMPLOWER => 6 )), |
|
153 | 153 | |
154 | 154 | SYNC_PROVISION_MAXEMAILBODYTRUNCSIZE => array ( self::STREAMER_VAR => "maxemailbodytruncsize", |
155 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
155 | + self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
156 | 156 | |
157 | 157 | SYNC_PROVISION_MAXEMAILHTMLBODYTRUNCSIZE => array ( self::STREAMER_VAR => "maxemailhtmlbodytruncsize", |
158 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
158 | + self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
159 | 159 | |
160 | 160 | SYNC_PROVISION_REQSIGNEDSMIMEMESSAGES => array ( self::STREAMER_VAR => "reqsignedsmimemessages", |
161 | 161 | self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
@@ -59,139 +59,139 @@ |
||
59 | 59 | |
60 | 60 | |
61 | 61 | function __construct() { |
62 | - $mapping = array ( |
|
63 | - SYNC_PROVISION_DEVPWENABLED => array ( self::STREAMER_VAR => "devpwenabled", |
|
64 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
62 | + $mapping = array( |
|
63 | + SYNC_PROVISION_DEVPWENABLED => array(self::STREAMER_VAR => "devpwenabled", |
|
64 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
65 | 65 | |
66 | - SYNC_PROVISION_ALPHANUMPWREQ => array ( self::STREAMER_VAR => "alphanumpwreq", |
|
67 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
66 | + SYNC_PROVISION_ALPHANUMPWREQ => array(self::STREAMER_VAR => "alphanumpwreq", |
|
67 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
68 | 68 | |
69 | - SYNC_PROVISION_PWRECOVERYENABLED => array ( self::STREAMER_VAR => "pwrecoveryenabled", |
|
70 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
69 | + SYNC_PROVISION_PWRECOVERYENABLED => array(self::STREAMER_VAR => "pwrecoveryenabled", |
|
70 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
71 | 71 | |
72 | - SYNC_PROVISION_DEVENCENABLED => array ( self::STREAMER_VAR => "devencenabled", |
|
73 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
72 | + SYNC_PROVISION_DEVENCENABLED => array(self::STREAMER_VAR => "devencenabled", |
|
73 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
74 | 74 | |
75 | - SYNC_PROVISION_DOCBROWSEENABLED => array ( self::STREAMER_VAR => "docbrowseenabled"), // deprecated |
|
76 | - SYNC_PROVISION_ATTENABLED => array ( self::STREAMER_VAR => "attenabled", |
|
77 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
75 | + SYNC_PROVISION_DOCBROWSEENABLED => array(self::STREAMER_VAR => "docbrowseenabled"), // deprecated |
|
76 | + SYNC_PROVISION_ATTENABLED => array(self::STREAMER_VAR => "attenabled", |
|
77 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
78 | 78 | |
79 | - SYNC_PROVISION_MINDEVPWLENGTH => array ( self::STREAMER_VAR => "mindevpwlenngth", |
|
80 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => 0, |
|
81 | - self::STREAMER_CHECK_CMPLOWER => 17 )), |
|
79 | + SYNC_PROVISION_MINDEVPWLENGTH => array(self::STREAMER_VAR => "mindevpwlenngth", |
|
80 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => 0, |
|
81 | + self::STREAMER_CHECK_CMPLOWER => 17)), |
|
82 | 82 | |
83 | - SYNC_PROVISION_MAXINACTTIMEDEVLOCK => array ( self::STREAMER_VAR => "maxinacttimedevlock"), |
|
84 | - SYNC_PROVISION_MAXDEVPWFAILEDATTEMPTS => array ( self::STREAMER_VAR => "maxdevpwfailedattempts", |
|
85 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => 3, |
|
86 | - self::STREAMER_CHECK_CMPLOWER => 17 )), |
|
83 | + SYNC_PROVISION_MAXINACTTIMEDEVLOCK => array(self::STREAMER_VAR => "maxinacttimedevlock"), |
|
84 | + SYNC_PROVISION_MAXDEVPWFAILEDATTEMPTS => array(self::STREAMER_VAR => "maxdevpwfailedattempts", |
|
85 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => 3, |
|
86 | + self::STREAMER_CHECK_CMPLOWER => 17)), |
|
87 | 87 | |
88 | - SYNC_PROVISION_MAXATTSIZE => array ( self::STREAMER_VAR => "maxattsize", |
|
88 | + SYNC_PROVISION_MAXATTSIZE => array(self::STREAMER_VAR => "maxattsize", |
|
89 | 89 | self::STREAMER_PROP => self::STREAMER_TYPE_SEND_EMPTY, |
90 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1 )), |
|
90 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1)), |
|
91 | 91 | |
92 | - SYNC_PROVISION_ALLOWSIMPLEDEVPW => array ( self::STREAMER_VAR => "allowsimpledevpw", |
|
93 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
92 | + SYNC_PROVISION_ALLOWSIMPLEDEVPW => array(self::STREAMER_VAR => "allowsimpledevpw", |
|
93 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
94 | 94 | |
95 | - SYNC_PROVISION_DEVPWEXPIRATION => array ( self::STREAMER_VAR => "devpwexpiration", |
|
96 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1 )), |
|
95 | + SYNC_PROVISION_DEVPWEXPIRATION => array(self::STREAMER_VAR => "devpwexpiration", |
|
96 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1)), |
|
97 | 97 | |
98 | - SYNC_PROVISION_DEVPWHISTORY => array ( self::STREAMER_VAR => "devpwhistory", |
|
99 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1 )), |
|
98 | + SYNC_PROVISION_DEVPWHISTORY => array(self::STREAMER_VAR => "devpwhistory", |
|
99 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1)), |
|
100 | 100 | |
101 | 101 | ); |
102 | 102 | |
103 | - if(Request::GetProtocolVersion() >= 12.1) { |
|
104 | - $mapping += array ( |
|
105 | - SYNC_PROVISION_ALLOWSTORAGECARD => array ( self::STREAMER_VAR => "allowstoragecard", |
|
106 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
103 | + if (Request::GetProtocolVersion() >= 12.1) { |
|
104 | + $mapping += array( |
|
105 | + SYNC_PROVISION_ALLOWSTORAGECARD => array(self::STREAMER_VAR => "allowstoragecard", |
|
106 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
107 | 107 | |
108 | - SYNC_PROVISION_ALLOWCAM => array ( self::STREAMER_VAR => "allowcam", |
|
109 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
108 | + SYNC_PROVISION_ALLOWCAM => array(self::STREAMER_VAR => "allowcam", |
|
109 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
110 | 110 | |
111 | - SYNC_PROVISION_REQDEVENC => array ( self::STREAMER_VAR => "reqdevenc", |
|
112 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
111 | + SYNC_PROVISION_REQDEVENC => array(self::STREAMER_VAR => "reqdevenc", |
|
112 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
113 | 113 | |
114 | - SYNC_PROVISION_ALLOWUNSIGNEDAPPS => array ( self::STREAMER_VAR => "allowunsignedapps", |
|
115 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
114 | + SYNC_PROVISION_ALLOWUNSIGNEDAPPS => array(self::STREAMER_VAR => "allowunsignedapps", |
|
115 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
116 | 116 | |
117 | - SYNC_PROVISION_ALLOWUNSIGNEDINSTALLATIONPACKAGES => array ( self::STREAMER_VAR => "allowunsigninstallpacks", |
|
118 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
117 | + SYNC_PROVISION_ALLOWUNSIGNEDINSTALLATIONPACKAGES => array(self::STREAMER_VAR => "allowunsigninstallpacks", |
|
118 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
119 | 119 | |
120 | - SYNC_PROVISION_MINDEVPWCOMPLEXCHARS => array ( self::STREAMER_VAR => "mindevcomplexchars", |
|
121 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(1,2,3,4) )), |
|
120 | + SYNC_PROVISION_MINDEVPWCOMPLEXCHARS => array(self::STREAMER_VAR => "mindevcomplexchars", |
|
121 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(1, 2, 3, 4))), |
|
122 | 122 | |
123 | - SYNC_PROVISION_ALLOWWIFI => array ( self::STREAMER_VAR => "allowwifi", |
|
124 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
123 | + SYNC_PROVISION_ALLOWWIFI => array(self::STREAMER_VAR => "allowwifi", |
|
124 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
125 | 125 | |
126 | - SYNC_PROVISION_ALLOWTEXTMESSAGING => array ( self::STREAMER_VAR => "allowtextmessaging", |
|
127 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
126 | + SYNC_PROVISION_ALLOWTEXTMESSAGING => array(self::STREAMER_VAR => "allowtextmessaging", |
|
127 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
128 | 128 | |
129 | - SYNC_PROVISION_ALLOWPOPIMAPEMAIL => array ( self::STREAMER_VAR => "allowpopimapemail", |
|
130 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
129 | + SYNC_PROVISION_ALLOWPOPIMAPEMAIL => array(self::STREAMER_VAR => "allowpopimapemail", |
|
130 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
131 | 131 | |
132 | - SYNC_PROVISION_ALLOWBLUETOOTH => array ( self::STREAMER_VAR => "allowbluetooth", |
|
133 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2) )), |
|
132 | + SYNC_PROVISION_ALLOWBLUETOOTH => array(self::STREAMER_VAR => "allowbluetooth", |
|
133 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2))), |
|
134 | 134 | |
135 | - SYNC_PROVISION_ALLOWIRDA => array ( self::STREAMER_VAR => "allowirda", |
|
136 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
135 | + SYNC_PROVISION_ALLOWIRDA => array(self::STREAMER_VAR => "allowirda", |
|
136 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
137 | 137 | |
138 | - SYNC_PROVISION_REQMANUALSYNCWHENROAM => array ( self::STREAMER_VAR => "reqmansyncroam", |
|
139 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
138 | + SYNC_PROVISION_REQMANUALSYNCWHENROAM => array(self::STREAMER_VAR => "reqmansyncroam", |
|
139 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
140 | 140 | |
141 | - SYNC_PROVISION_ALLOWDESKTOPSYNC => array ( self::STREAMER_VAR => "allowdesktopsync", |
|
142 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
141 | + SYNC_PROVISION_ALLOWDESKTOPSYNC => array(self::STREAMER_VAR => "allowdesktopsync", |
|
142 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
143 | 143 | |
144 | - SYNC_PROVISION_MAXCALAGEFILTER => array ( self::STREAMER_VAR => "maxcalagefilter", |
|
145 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,4,5,6,7) )), |
|
144 | + SYNC_PROVISION_MAXCALAGEFILTER => array(self::STREAMER_VAR => "maxcalagefilter", |
|
145 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 4, 5, 6, 7))), |
|
146 | 146 | |
147 | - SYNC_PROVISION_ALLOWHTMLEMAIL => array ( self::STREAMER_VAR => "allowhtmlemail", |
|
148 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
147 | + SYNC_PROVISION_ALLOWHTMLEMAIL => array(self::STREAMER_VAR => "allowhtmlemail", |
|
148 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
149 | 149 | |
150 | - SYNC_PROVISION_MAXEMAILAGEFILTER => array ( self::STREAMER_VAR => "maxemailagefilter", |
|
151 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1, |
|
152 | - self::STREAMER_CHECK_CMPLOWER => 6 )), |
|
150 | + SYNC_PROVISION_MAXEMAILAGEFILTER => array(self::STREAMER_VAR => "maxemailagefilter", |
|
151 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1, |
|
152 | + self::STREAMER_CHECK_CMPLOWER => 6)), |
|
153 | 153 | |
154 | - SYNC_PROVISION_MAXEMAILBODYTRUNCSIZE => array ( self::STREAMER_VAR => "maxemailbodytruncsize", |
|
155 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
154 | + SYNC_PROVISION_MAXEMAILBODYTRUNCSIZE => array(self::STREAMER_VAR => "maxemailbodytruncsize", |
|
155 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -2)), |
|
156 | 156 | |
157 | - SYNC_PROVISION_MAXEMAILHTMLBODYTRUNCSIZE => array ( self::STREAMER_VAR => "maxemailhtmlbodytruncsize", |
|
158 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -2 )), |
|
157 | + SYNC_PROVISION_MAXEMAILHTMLBODYTRUNCSIZE => array(self::STREAMER_VAR => "maxemailhtmlbodytruncsize", |
|
158 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -2)), |
|
159 | 159 | |
160 | - SYNC_PROVISION_REQSIGNEDSMIMEMESSAGES => array ( self::STREAMER_VAR => "reqsignedsmimemessages", |
|
161 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
160 | + SYNC_PROVISION_REQSIGNEDSMIMEMESSAGES => array(self::STREAMER_VAR => "reqsignedsmimemessages", |
|
161 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
162 | 162 | |
163 | - SYNC_PROVISION_REQENCSMIMEMESSAGES => array ( self::STREAMER_VAR => "reqencsmimemessages", |
|
164 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
163 | + SYNC_PROVISION_REQENCSMIMEMESSAGES => array(self::STREAMER_VAR => "reqencsmimemessages", |
|
164 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
165 | 165 | |
166 | - SYNC_PROVISION_REQSIGNEDSMIMEALGORITHM => array ( self::STREAMER_VAR => "reqsignedsmimealgorithm", |
|
167 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
166 | + SYNC_PROVISION_REQSIGNEDSMIMEALGORITHM => array(self::STREAMER_VAR => "reqsignedsmimealgorithm", |
|
167 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
168 | 168 | |
169 | - SYNC_PROVISION_REQENCSMIMEALGORITHM => array ( self::STREAMER_VAR => "reqencsmimealgorithm", |
|
170 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) )), |
|
169 | + SYNC_PROVISION_REQENCSMIMEALGORITHM => array(self::STREAMER_VAR => "reqencsmimealgorithm", |
|
170 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3, 4))), |
|
171 | 171 | |
172 | - SYNC_PROVISION_ALLOWSMIMEENCALGORITHNEG => array ( self::STREAMER_VAR => "allowsmimeencalgneg", |
|
173 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2) )), |
|
172 | + SYNC_PROVISION_ALLOWSMIMEENCALGORITHNEG => array(self::STREAMER_VAR => "allowsmimeencalgneg", |
|
173 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2))), |
|
174 | 174 | |
175 | - SYNC_PROVISION_ALLOWSMIMESOFTCERTS => array ( self::STREAMER_VAR => "allowsmimesoftcerts", |
|
176 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
175 | + SYNC_PROVISION_ALLOWSMIMESOFTCERTS => array(self::STREAMER_VAR => "allowsmimesoftcerts", |
|
176 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
177 | 177 | |
178 | - SYNC_PROVISION_ALLOWBROWSER => array ( self::STREAMER_VAR => "allowbrowser", |
|
179 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
178 | + SYNC_PROVISION_ALLOWBROWSER => array(self::STREAMER_VAR => "allowbrowser", |
|
179 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
180 | 180 | |
181 | - SYNC_PROVISION_ALLOWCONSUMEREMAIL => array ( self::STREAMER_VAR => "allowconsumeremail", |
|
182 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
181 | + SYNC_PROVISION_ALLOWCONSUMEREMAIL => array(self::STREAMER_VAR => "allowconsumeremail", |
|
182 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
183 | 183 | |
184 | - SYNC_PROVISION_ALLOWREMOTEDESKTOP => array ( self::STREAMER_VAR => "allowremotedesk", |
|
185 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
184 | + SYNC_PROVISION_ALLOWREMOTEDESKTOP => array(self::STREAMER_VAR => "allowremotedesk", |
|
185 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
186 | 186 | |
187 | - SYNC_PROVISION_ALLOWINTERNETSHARING => array ( self::STREAMER_VAR => "allowinternetsharing", |
|
188 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1) )), |
|
187 | + SYNC_PROVISION_ALLOWINTERNETSHARING => array(self::STREAMER_VAR => "allowinternetsharing", |
|
188 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1))), |
|
189 | 189 | |
190 | - SYNC_PROVISION_UNAPPROVEDINROMAPPLIST => array ( self::STREAMER_VAR => "unapprovedinromapplist", |
|
190 | + SYNC_PROVISION_UNAPPROVEDINROMAPPLIST => array(self::STREAMER_VAR => "unapprovedinromapplist", |
|
191 | 191 | self::STREAMER_PROP => self::STREAMER_TYPE_SEND_EMPTY, |
192 | - self::STREAMER_ARRAY => SYNC_PROVISION_APPNAME), //TODO check |
|
192 | + self::STREAMER_ARRAY => SYNC_PROVISION_APPNAME), //TODO check |
|
193 | 193 | |
194 | - SYNC_PROVISION_APPROVEDAPPLIST => array ( self::STREAMER_VAR => "approvedapplist", |
|
194 | + SYNC_PROVISION_APPROVEDAPPLIST => array(self::STREAMER_VAR => "approvedapplist", |
|
195 | 195 | self::STREAMER_PROP => self::STREAMER_TYPE_SEND_EMPTY, |
196 | 196 | self::STREAMER_ARRAY => SYNC_PROVISION_HASH), //TODO check |
197 | 197 | ); |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | 5 => "Meeting canceled", |
148 | 148 | 7 => "Meeting canceled and received", |
149 | 149 | 9 => "Meeting", |
150 | - 11 => "Meeting received", |
|
151 | - 13 => "Meeting canceled", |
|
152 | - 15 => "Meeting canceled and received",)), |
|
150 | + 11 => "Meeting received", |
|
151 | + 13 => "Meeting canceled", |
|
152 | + 15 => "Meeting canceled and received",)), |
|
153 | 153 | |
154 | 154 | SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees", |
155 | 155 | self::STREAMER_TYPE => "SyncAttendee", |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | self::STREAMER_TYPE => "SyncBaseBody", |
179 | 179 | self::STREAMER_RONOTIFY => true, |
180 | 180 | self::STREAMER_PRIVATE => true |
181 | - ); |
|
181 | + ); |
|
182 | 182 | |
183 | 183 | $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array ( self::STREAMER_VAR => "nativebodytype"); |
184 | 184 |
@@ -49,38 +49,38 @@ discard block |
||
49 | 49 | |
50 | 50 | function __construct() { |
51 | 51 | $mapping = array( |
52 | - SYNC_POOMCAL_TIMEZONE => array ( self::STREAMER_VAR => "timezone", |
|
52 | + SYNC_POOMCAL_TIMEZONE => array(self::STREAMER_VAR => "timezone", |
|
53 | 53 | self::STREAMER_RONOTIFY => true), |
54 | 54 | |
55 | - SYNC_POOMCAL_DTSTAMP => array ( self::STREAMER_VAR => "dtstamp", |
|
55 | + SYNC_POOMCAL_DTSTAMP => array(self::STREAMER_VAR => "dtstamp", |
|
56 | 56 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
57 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO)), |
|
57 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETZERO)), |
|
58 | 58 | |
59 | - SYNC_POOMCAL_STARTTIME => array ( self::STREAMER_VAR => "starttime", |
|
59 | + SYNC_POOMCAL_STARTTIME => array(self::STREAMER_VAR => "starttime", |
|
60 | 60 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
61 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME ), |
|
62 | - self::STREAMER_RONOTIFY => true ), |
|
61 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPLOWER => SYNC_POOMCAL_ENDTIME), |
|
62 | + self::STREAMER_RONOTIFY => true), |
|
63 | 63 | |
64 | 64 | |
65 | - SYNC_POOMCAL_SUBJECT => array ( self::STREAMER_VAR => "subject", |
|
66 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY), |
|
65 | + SYNC_POOMCAL_SUBJECT => array(self::STREAMER_VAR => "subject", |
|
66 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETEMPTY), |
|
67 | 67 | self::STREAMER_RONOTIFY => true, |
68 | - self::STREAMER_PRIVATE => self::STRIP_PRIVATE_SUBSTITUTE ), |
|
69 | - |
|
70 | - SYNC_POOMCAL_UID => array ( self::STREAMER_VAR => "uid"), |
|
71 | - SYNC_POOMCAL_ORGANIZERNAME => array ( self::STREAMER_VAR => "organizername", // verified below |
|
72 | - self::STREAMER_PRIVATE => 'Undisclosed Organizer' ), |
|
73 | - SYNC_POOMCAL_ORGANIZEREMAIL => array ( self::STREAMER_VAR => "organizeremail", // verified below |
|
74 | - self::STREAMER_PRIVATE => 'undisclosed@localhost' ), |
|
75 | - SYNC_POOMCAL_LOCATION => array ( self::STREAMER_VAR => "location", |
|
68 | + self::STREAMER_PRIVATE => self::STRIP_PRIVATE_SUBSTITUTE), |
|
69 | + |
|
70 | + SYNC_POOMCAL_UID => array(self::STREAMER_VAR => "uid"), |
|
71 | + SYNC_POOMCAL_ORGANIZERNAME => array(self::STREAMER_VAR => "organizername", // verified below |
|
72 | + self::STREAMER_PRIVATE => 'Undisclosed Organizer'), |
|
73 | + SYNC_POOMCAL_ORGANIZEREMAIL => array(self::STREAMER_VAR => "organizeremail", // verified below |
|
74 | + self::STREAMER_PRIVATE => 'undisclosed@localhost'), |
|
75 | + SYNC_POOMCAL_LOCATION => array(self::STREAMER_VAR => "location", |
|
76 | 76 | self::STREAMER_RONOTIFY => true, |
77 | 77 | self::STREAMER_PRIVATE => true), |
78 | - SYNC_POOMCAL_ENDTIME => array ( self::STREAMER_VAR => "endtime", |
|
78 | + SYNC_POOMCAL_ENDTIME => array(self::STREAMER_VAR => "endtime", |
|
79 | 79 | self::STREAMER_TYPE => self::STREAMER_TYPE_DATE, |
80 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME ), |
|
81 | - self::STREAMER_RONOTIFY => true ), |
|
80 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => SYNC_POOMCAL_STARTTIME), |
|
81 | + self::STREAMER_RONOTIFY => true), |
|
82 | 82 | |
83 | - SYNC_POOMCAL_RECURRENCE => array ( self::STREAMER_VAR => "recurrence", |
|
83 | + SYNC_POOMCAL_RECURRENCE => array(self::STREAMER_VAR => "recurrence", |
|
84 | 84 | self::STREAMER_TYPE => "SyncRecurrence", |
85 | 85 | self::STREAMER_RONOTIFY => true), |
86 | 86 | |
@@ -89,10 +89,10 @@ discard block |
||
89 | 89 | // 1 = Personal |
90 | 90 | // 2 = Private |
91 | 91 | // 3 = Confident |
92 | - SYNC_POOMCAL_SENSITIVITY => array ( self::STREAMER_VAR => "sensitivity", |
|
93 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3) ), |
|
92 | + SYNC_POOMCAL_SENSITIVITY => array(self::STREAMER_VAR => "sensitivity", |
|
93 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3)), |
|
94 | 94 | self::STREAMER_RONOTIFY => true, |
95 | - self::STREAMER_VALUEMAP => array( 0 => "Normal", |
|
95 | + self::STREAMER_VALUEMAP => array(0 => "Normal", |
|
96 | 96 | 1 => "Personal", |
97 | 97 | 2 => "Private", |
98 | 98 | 3 => "Confident")), |
@@ -103,29 +103,29 @@ discard block |
||
103 | 103 | // 2 = Busy |
104 | 104 | // 3 = Out of office |
105 | 105 | // 4 = Working Elsewhere |
106 | - SYNC_POOMCAL_BUSYSTATUS => array ( self::STREAMER_VAR => "busystatus", |
|
107 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
|
108 | - self::STREAMER_CHECK_ONEVALUEOF => array(0,1,2,3,4) ), |
|
106 | + SYNC_POOMCAL_BUSYSTATUS => array(self::STREAMER_VAR => "busystatus", |
|
107 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_REQUIRED => self::STREAMER_CHECK_SETTWO, |
|
108 | + self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 2, 3, 4)), |
|
109 | 109 | self::STREAMER_RONOTIFY => true, |
110 | - self::STREAMER_PRIVATE => 2, // if private is stripped, value will be set to 2 (busy) |
|
111 | - self::STREAMER_VALUEMAP => array( 0 => "Free", |
|
110 | + self::STREAMER_PRIVATE => 2, // if private is stripped, value will be set to 2 (busy) |
|
111 | + self::STREAMER_VALUEMAP => array(0 => "Free", |
|
112 | 112 | 1 => "Tentative", |
113 | 113 | 2 => "Busy", |
114 | 114 | 3 => "Out of office", |
115 | 115 | 4 => "Working Elsewhere")), |
116 | 116 | |
117 | - SYNC_POOMCAL_ALLDAYEVENT => array ( self::STREAMER_VAR => "alldayevent", |
|
118 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO), |
|
117 | + SYNC_POOMCAL_ALLDAYEVENT => array(self::STREAMER_VAR => "alldayevent", |
|
118 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ZEROORONE => self::STREAMER_CHECK_SETZERO), |
|
119 | 119 | self::STREAMER_RONOTIFY => true, |
120 | - self::STREAMER_VALUEMAP => array( 0 => "No", |
|
120 | + self::STREAMER_VALUEMAP => array(0 => "No", |
|
121 | 121 | 1 => "Yes")), |
122 | 122 | |
123 | - SYNC_POOMCAL_REMINDER => array ( self::STREAMER_VAR => "reminder", |
|
124 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_CMPHIGHER => -1), |
|
123 | + SYNC_POOMCAL_REMINDER => array(self::STREAMER_VAR => "reminder", |
|
124 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_CMPHIGHER => -1), |
|
125 | 125 | self::STREAMER_RONOTIFY => true, |
126 | - self::STREAMER_PRIVATE => true ), // if private is stripped, value will be unset (no reminder) |
|
126 | + self::STREAMER_PRIVATE => true), // if private is stripped, value will be unset (no reminder) |
|
127 | 127 | |
128 | - SYNC_POOMCAL_RTF => array ( self::STREAMER_VAR => "rtf", |
|
128 | + SYNC_POOMCAL_RTF => array(self::STREAMER_VAR => "rtf", |
|
129 | 129 | self::STREAMER_PRIVATE => true), |
130 | 130 | |
131 | 131 | // Meetingstatus values |
@@ -138,10 +138,10 @@ discard block |
||
138 | 138 | // 11 = as 3 |
139 | 139 | // 13 = as 5 |
140 | 140 | // 15 = as 7 |
141 | - SYNC_POOMCAL_MEETINGSTATUS => array ( self::STREAMER_VAR => "meetingstatus", |
|
142 | - self::STREAMER_CHECKS => array( self::STREAMER_CHECK_ONEVALUEOF => array(0,1,3,5,7,9,11,13,15) ), |
|
141 | + SYNC_POOMCAL_MEETINGSTATUS => array(self::STREAMER_VAR => "meetingstatus", |
|
142 | + self::STREAMER_CHECKS => array(self::STREAMER_CHECK_ONEVALUEOF => array(0, 1, 3, 5, 7, 9, 11, 13, 15)), |
|
143 | 143 | self::STREAMER_RONOTIFY => true, |
144 | - self::STREAMER_VALUEMAP => array( 0 => "Not a meeting", |
|
144 | + self::STREAMER_VALUEMAP => array(0 => "Not a meeting", |
|
145 | 145 | 1 => "Meeting", |
146 | 146 | 3 => "Meeting received", |
147 | 147 | 5 => "Meeting canceled", |
@@ -151,55 +151,55 @@ discard block |
||
151 | 151 | 13 => "Meeting canceled", |
152 | 152 | 15 => "Meeting canceled and received",)), |
153 | 153 | |
154 | - SYNC_POOMCAL_ATTENDEES => array ( self::STREAMER_VAR => "attendees", |
|
154 | + SYNC_POOMCAL_ATTENDEES => array(self::STREAMER_VAR => "attendees", |
|
155 | 155 | self::STREAMER_TYPE => "SyncAttendee", |
156 | 156 | self::STREAMER_ARRAY => SYNC_POOMCAL_ATTENDEE, |
157 | 157 | self::STREAMER_RONOTIFY => true, |
158 | 158 | self::STREAMER_PRIVATE => true), |
159 | 159 | |
160 | - SYNC_POOMCAL_BODY => array ( self::STREAMER_VAR => "body", |
|
160 | + SYNC_POOMCAL_BODY => array(self::STREAMER_VAR => "body", |
|
161 | 161 | self::STREAMER_RONOTIFY => true, |
162 | 162 | self::STREAMER_PRIVATE => true), |
163 | - SYNC_POOMCAL_BODYTRUNCATED => array ( self::STREAMER_VAR => "bodytruncated", |
|
163 | + SYNC_POOMCAL_BODYTRUNCATED => array(self::STREAMER_VAR => "bodytruncated", |
|
164 | 164 | self::STREAMER_PRIVATE => true), |
165 | - SYNC_POOMCAL_EXCEPTIONS => array ( self::STREAMER_VAR => "exceptions", |
|
165 | + SYNC_POOMCAL_EXCEPTIONS => array(self::STREAMER_VAR => "exceptions", |
|
166 | 166 | self::STREAMER_TYPE => "SyncAppointmentException", |
167 | 167 | self::STREAMER_ARRAY => SYNC_POOMCAL_EXCEPTION, |
168 | 168 | self::STREAMER_RONOTIFY => true), |
169 | 169 | |
170 | - SYNC_POOMCAL_CATEGORIES => array ( self::STREAMER_VAR => "categories", |
|
170 | + SYNC_POOMCAL_CATEGORIES => array(self::STREAMER_VAR => "categories", |
|
171 | 171 | self::STREAMER_ARRAY => SYNC_POOMCAL_CATEGORY, |
172 | 172 | self::STREAMER_RONOTIFY => true, |
173 | 173 | self::STREAMER_PRIVATE => true), |
174 | 174 | ); |
175 | 175 | |
176 | 176 | if (Request::GetProtocolVersion() >= 12.0) { |
177 | - $mapping[SYNC_AIRSYNCBASE_BODY] = array ( self::STREAMER_VAR => "asbody", |
|
177 | + $mapping[SYNC_AIRSYNCBASE_BODY] = array(self::STREAMER_VAR => "asbody", |
|
178 | 178 | self::STREAMER_TYPE => "SyncBaseBody", |
179 | 179 | self::STREAMER_RONOTIFY => true, |
180 | 180 | self::STREAMER_PRIVATE => true |
181 | 181 | ); |
182 | 182 | |
183 | - $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array ( self::STREAMER_VAR => "nativebodytype"); |
|
183 | + $mapping[SYNC_AIRSYNCBASE_NATIVEBODYTYPE] = array(self::STREAMER_VAR => "nativebodytype"); |
|
184 | 184 | |
185 | 185 | //unset these properties because airsyncbase body and attachments will be used instead |
186 | 186 | unset($mapping[SYNC_POOMCAL_BODY], $mapping[SYNC_POOMCAL_BODYTRUNCATED]); |
187 | 187 | } |
188 | 188 | |
189 | - if(Request::GetProtocolVersion() >= 14.0) { |
|
190 | - $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = array ( self::STREAMER_VAR => "disallownewtimeprop", |
|
189 | + if (Request::GetProtocolVersion() >= 14.0) { |
|
190 | + $mapping[SYNC_POOMCAL_DISALLOWNEWTIMEPROPOSAL] = array(self::STREAMER_VAR => "disallownewtimeprop", |
|
191 | 191 | self::STREAMER_RONOTIFY => true, |
192 | 192 | self::STREAMER_PRIVATE => 1); // don't permit new time proposal |
193 | - $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = array ( self::STREAMER_VAR => "responserequested", |
|
193 | + $mapping[SYNC_POOMCAL_RESPONSEREQUESTED] = array(self::STREAMER_VAR => "responserequested", |
|
194 | 194 | self::STREAMER_RONOTIFY => true); |
195 | - $mapping[SYNC_POOMCAL_RESPONSETYPE] = array ( self::STREAMER_VAR => "responsetype", |
|
195 | + $mapping[SYNC_POOMCAL_RESPONSETYPE] = array(self::STREAMER_VAR => "responsetype", |
|
196 | 196 | self::STREAMER_RONOTIFY => true); |
197 | 197 | } |
198 | 198 | |
199 | - if(Request::GetProtocolVersion() >= 14.1) { |
|
200 | - $mapping[SYNC_POOMCAL_ONLINEMEETINGCONFLINK] = array ( self::STREAMER_VAR => "onlineMeetingConfLink", |
|
199 | + if (Request::GetProtocolVersion() >= 14.1) { |
|
200 | + $mapping[SYNC_POOMCAL_ONLINEMEETINGCONFLINK] = array(self::STREAMER_VAR => "onlineMeetingConfLink", |
|
201 | 201 | self::STREAMER_RONOTIFY => true); |
202 | - $mapping[SYNC_POOMCAL_ONLINEMEETINGEXTERNALLINK] = array ( self::STREAMER_VAR => "onlineMeetingExternalLink", |
|
202 | + $mapping[SYNC_POOMCAL_ONLINEMEETINGEXTERNALLINK] = array(self::STREAMER_VAR => "onlineMeetingExternalLink", |
|
203 | 203 | self::STREAMER_RONOTIFY => true); |
204 | 204 | } |
205 | 205 |
@@ -260,11 +260,13 @@ |
||
260 | 260 | $ret = parent::Check($logAsDebug); |
261 | 261 | |
262 | 262 | // semantic checks general "turn off switch" |
263 | - if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) |
|
264 | - return $ret; |
|
263 | + if (defined("DO_SEMANTIC_CHECKS") && DO_SEMANTIC_CHECKS === false) { |
|
264 | + return $ret; |
|
265 | + } |
|
265 | 266 | |
266 | - if (!$ret) |
|
267 | - return false; |
|
267 | + if (!$ret) { |
|
268 | + return false; |
|
269 | + } |
|
268 | 270 | |
269 | 271 | if ($this->meetingstatus > 0) { |
270 | 272 | if (!isset($this->organizername) || !isset($this->organizeremail)) { |
@@ -201,7 +201,7 @@ |
||
201 | 201 | * @return boolean |
202 | 202 | */ |
203 | 203 | public function IsDeleted($id) { |
204 | - return !((array_search(array(self::DELETION, $id), $this->changes) === false) && (array_search(array(self::SOFTDELETION, $id), $this->changes) === false)); |
|
204 | + return !((array_search(array(self::DELETION, $id), $this->changes) === false) && (array_search(array(self::SOFTDELETION, $id), $this->changes) === false)); |
|
205 | 205 | } |
206 | 206 | |
207 | 207 | /** |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | |
50 | 50 | // we should never forward this changes to a backend |
51 | 51 | if (!isset($this->destinationImporter)) { |
52 | - foreach($state as $addKey => $addFolder) { |
|
52 | + foreach ($state as $addKey => $addFolder) { |
|
53 | 53 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : process folder '%s'", $addFolder->displayname)); |
54 | 54 | if (isset($addFolder->NoBackendFolder) && $addFolder->NoBackendFolder == true) { |
55 | 55 | // check rights for readonly access only |
56 | 56 | $hasRights = ZPush::GetBackend()->Setup($addFolder->Store, true, $addFolder->BackendId, true); |
57 | 57 | // delete the folder on the device |
58 | - if (! $hasRights) { |
|
58 | + if (!$hasRights) { |
|
59 | 59 | // delete the folder only if it was an additional folder before, else ignore it |
60 | 60 | $synchedfolder = $this->GetFolder($addFolder->serverid); |
61 | 61 | if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | /** |
125 | 125 | * Implement interfaces which are never used |
126 | 126 | */ |
127 | - public function GetState() { return false;} |
|
127 | + public function GetState() { return false; } |
|
128 | 128 | public function LoadConflicts($contentparameters, $state) { return true; } |
129 | 129 | public function ConfigContentParameters($contentparameters) { return true; } |
130 | 130 | public function ImportMessageReadFlag($id, $flags, $categories = array()) { return true; } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | if (isset($this->destinationImporter)) { |
219 | 219 | // normally the $folder->type is not set, but we need this value to check if the change operation is permitted |
220 | 220 | // e.g. system folders can normally not be changed - set the type from cache and let the destinationImporter decide |
221 | - if (!isset($folder->type) || ! $folder->type) { |
|
221 | + if (!isset($folder->type) || !$folder->type) { |
|
222 | 222 | $cacheFolder = $this->GetFolder($folder->serverid); |
223 | 223 | $folder->type = $cacheFolder->type; |
224 | 224 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("ChangesMemoryWrapper->ImportFolderChange(): Set foldertype for folder '%s' from cache as it was not sent: '%s'", $folder->displayname, $folder->type)); |
@@ -358,12 +358,12 @@ discard block |
||
358 | 358 | * @return array |
359 | 359 | */ |
360 | 360 | public function Synchronize() { |
361 | - if($this->step < count($this->changes) && isset($this->exportImporter)) { |
|
361 | + if ($this->step < count($this->changes) && isset($this->exportImporter)) { |
|
362 | 362 | |
363 | 363 | $change = $this->changes[$this->step]; |
364 | 364 | |
365 | 365 | if ($change[0] == self::CHANGE) { |
366 | - if (! $this->GetFolder($change[1]->serverid, true)) |
|
366 | + if (!$this->GetFolder($change[1]->serverid, true)) |
|
367 | 367 | $change[1]->flags = SYNC_NEWMESSAGE; |
368 | 368 | |
369 | 369 | $this->exportImporter->ImportFolderChange($change[1]); |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | if (! $hasRights) { |
59 | 59 | // delete the folder only if it was an additional folder before, else ignore it |
60 | 60 | $synchedfolder = $this->GetFolder($addFolder->serverid); |
61 | - if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) |
|
62 | - $this->ImportFolderDeletion($addFolder); |
|
61 | + if (isset($synchedfolder->NoBackendFolder) && $synchedfolder->NoBackendFolder == true) { |
|
62 | + $this->ImportFolderDeletion($addFolder); |
|
63 | + } |
|
63 | 64 | continue; |
64 | 65 | } |
65 | 66 | } |
@@ -85,8 +86,7 @@ discard block |
||
85 | 86 | ZLog::Write(LOGLEVEL_INFO, sprintf("ChangesMemoryWrapper->Config(AdditionalFolders) : previously synchronized folder '%s' is not to be synched anymore. Sending delete to mobile.", $folder->displayname)); |
86 | 87 | $this->ImportFolderDeletion($folder); |
87 | 88 | } |
88 | - } |
|
89 | - else { |
|
89 | + } else { |
|
90 | 90 | $folderIdsOnClient[] = $sid; |
91 | 91 | } |
92 | 92 | } |
@@ -173,8 +173,7 @@ discard block |
||
173 | 173 | public function ImportMessageDeletion($id, $asSoftDelete = false) { |
174 | 174 | if ($asSoftDelete === true) { |
175 | 175 | $this->changes[] = array(self::SOFTDELETION, $id); |
176 | - } |
|
177 | - else { |
|
176 | + } else { |
|
178 | 177 | $this->changes[] = array(self::DELETION, $id); |
179 | 178 | } |
180 | 179 | return true; |
@@ -303,12 +302,12 @@ discard block |
||
303 | 302 | $ret = $this->destinationImporter->ImportFolderDeletion($folder); |
304 | 303 | |
305 | 304 | // if the operation was successful, update the HierarchyCache |
306 | - if ($ret) |
|
307 | - $this->DelFolder($id); |
|
305 | + if ($ret) { |
|
306 | + $this->DelFolder($id); |
|
307 | + } |
|
308 | 308 | |
309 | 309 | return $ret; |
310 | - } |
|
311 | - else { |
|
310 | + } else { |
|
312 | 311 | // if this folder is not in the cache, the change does not need to be streamed to the mobile |
313 | 312 | if ($this->GetFolder($id)) { |
314 | 313 | |
@@ -363,8 +362,9 @@ discard block |
||
363 | 362 | $change = $this->changes[$this->step]; |
364 | 363 | |
365 | 364 | if ($change[0] == self::CHANGE) { |
366 | - if (! $this->GetFolder($change[1]->serverid, true)) |
|
367 | - $change[1]->flags = SYNC_NEWMESSAGE; |
|
365 | + if (! $this->GetFolder($change[1]->serverid, true)) { |
|
366 | + $change[1]->flags = SYNC_NEWMESSAGE; |
|
367 | + } |
|
368 | 368 | |
369 | 369 | $this->exportImporter->ImportFolderChange($change[1]); |
370 | 370 | } |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | |
377 | 377 | // return progress array |
378 | 378 | return array("steps" => count($this->changes), "progress" => $this->step); |
379 | + } else { |
|
380 | + return false; |
|
379 | 381 | } |
380 | - else |
|
381 | - return false; |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -163,16 +163,16 @@ discard block |
||
163 | 163 | * @access protected |
164 | 164 | * @return boolean |
165 | 165 | */ |
166 | - protected function setData($data, $id = 2, $ttl=-1) { |
|
166 | + protected function setData($data, $id = 2, $ttl = -1) { |
|
167 | 167 | return $this->ipcProvider ? $this->ipcProvider->setKey($id, json_encode($data), $ttl) : false; |
168 | 168 | } |
169 | 169 | |
170 | 170 | |
171 | - protected function setDeviceUserData($key, $data, $devid, $user, $subkey=-1, $doCas=false, $rawdata = false) { |
|
171 | + protected function setDeviceUserData($key, $data, $devid, $user, $subkey = -1, $doCas = false, $rawdata = false) { |
|
172 | 172 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
173 | 173 | |
174 | 174 | // overwrite |
175 | - if (! $doCas) { |
|
175 | + if (!$doCas) { |
|
176 | 176 | $ok = ($this->ipcProvider->get()->hset($key, $compKey, json_encode($data)) !== false); |
177 | 177 | } |
178 | 178 | // merge data and do CAS on the $compKey |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | $ok = false; |
181 | 181 | $okCount = 0; |
182 | 182 | // TODO: make this configurable (retrycount)? |
183 | - while(! $ok && $okCount < 5) { |
|
183 | + while (!$ok && $okCount < 5) { |
|
184 | 184 | $newData = $data; |
185 | 185 | // step 1: get current data |
186 | 186 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | $ok = false; |
215 | 215 | $okCount = 0; |
216 | 216 | // TODO: make this configurable (retrycount)? |
217 | - while(! $ok && $okCount < 5) { |
|
217 | + while (!$ok && $okCount < 5) { |
|
218 | 218 | // step 1: get current data |
219 | 219 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
220 | 220 | $newData = json_decode($_rawdata, true); |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | break; |
224 | 224 | } |
225 | 225 | // step 2: if data exists, delete the keys of $data from it |
226 | - foreach($data as $delKey) { |
|
226 | + foreach ($data as $delKey) { |
|
227 | 227 | unset($newData[$delKey]); |
228 | 228 | } |
229 | 229 | $rawNewData = json_encode($newData); |
@@ -245,7 +245,7 @@ discard block |
||
245 | 245 | return $ok; |
246 | 246 | } |
247 | 247 | |
248 | - protected function getDeviceUserData($key, $devid, $user, $subkey=-1, $returnRaw=false) { |
|
248 | + protected function getDeviceUserData($key, $devid, $user, $subkey = -1, $returnRaw = false) { |
|
249 | 249 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
250 | 250 | $_rawdata = $this->ipcProvider->get()->hget($key, $compKey); |
251 | 251 | if ($returnRaw) { |
@@ -266,7 +266,7 @@ discard block |
||
266 | 266 | } |
267 | 267 | } |
268 | 268 | |
269 | - protected function delDeviceUserData($key, $devid, $user, $subkey=-1) { |
|
269 | + protected function delDeviceUserData($key, $devid, $user, $subkey = -1) { |
|
270 | 270 | $compKey = $this->getComposedKey($devid, $user, $subkey); |
271 | 271 | return $this->ipcProvider->get()->hdel($key, $compKey); |
272 | 272 | } |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $_data[$devid][$user] = $_data; |
285 | 285 | } |
286 | 286 | else { |
287 | - if (!isset($_data[$devid][$user])){ |
|
287 | + if (!isset($_data[$devid][$user])) { |
|
288 | 288 | $_data[$devid][$user] = array(); |
289 | 289 | } |
290 | 290 | $_data[$devid][$user][$subkey] = $_linedata; |
@@ -297,14 +297,14 @@ discard block |
||
297 | 297 | return $this->ipcProvider->get()->hGetAll($key); |
298 | 298 | } |
299 | 299 | |
300 | - protected function getComposedKey($key1, $key2, $key3=-1) { |
|
300 | + protected function getComposedKey($key1, $key2, $key3 = -1) { |
|
301 | 301 | $_k = $key1; |
302 | 302 | if ($key2 > -1) { |
303 | - $_k .="|-|". $key2; |
|
303 | + $_k .= "|-|".$key2; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | if ($key3 > -1) { |
307 | - $_k .="|-|". $key3; |
|
307 | + $_k .= "|-|".$key3; |
|
308 | 308 | } |
309 | 309 | return $_k; |
310 | 310 | } |
@@ -29,16 +29,16 @@ discard block |
||
29 | 29 | * @access public |
30 | 30 | */ |
31 | 31 | public function __construct() { |
32 | - if (!isset($this->type) || !isset($this->allocate)) |
|
33 | - throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this))); |
|
32 | + if (!isset($this->type) || !isset($this->allocate)) { |
|
33 | + throw new FatalNotImplementedException(sprintf("Class InterProcessData can not be initialized. Subclass %s did not initialize type and allocable memory.", get_class($this))); |
|
34 | + } |
|
34 | 35 | |
35 | 36 | try { |
36 | 37 | // ZP-987: use an own mutex + storage key for each device on non-shared-memory IPC |
37 | 38 | // this method is not suitable for the TopCollector atm |
38 | 39 | $type = Request::GetDeviceID(); |
39 | 40 | $this->ipcProvider = ZPush::GetRedis(); |
40 | - } |
|
41 | - catch (Exception $e) { |
|
41 | + } catch (Exception $e) { |
|
42 | 42 | // ipcProvider could not initialise |
43 | 43 | ZLog::Write(LOGLEVEL_ERROR, sprintf("%s could not initialise IPC Redis provider: %s", get_class($this), $e->getMessage())); |
44 | 44 | } |
@@ -204,8 +204,7 @@ discard block |
||
204 | 204 | elseif ($doCas == "replace") { |
205 | 205 | if (!$rawdata) { |
206 | 206 | $ok = ($this->ipcProvider->get()->hset($key, $compKey, json_encode($data)) !== false); |
207 | - } |
|
208 | - else { |
|
207 | + } else { |
|
209 | 208 | $ok = $this->ipcProvider->CASHash($key, $compKey, $rawdata, json_encode($data)); |
210 | 209 | } |
211 | 210 | } |
@@ -251,16 +250,13 @@ discard block |
||
251 | 250 | if ($returnRaw) { |
252 | 251 | if ($_rawdata) { |
253 | 252 | return array(json_decode($_rawdata, true), $_rawdata); |
254 | - } |
|
255 | - else { |
|
253 | + } else { |
|
256 | 254 | return array(array(), false); |
257 | 255 | } |
258 | - } |
|
259 | - else { |
|
256 | + } else { |
|
260 | 257 | if ($_rawdata) { |
261 | 258 | return json_decode($_rawdata, true); |
262 | - } |
|
263 | - else { |
|
259 | + } else { |
|
264 | 260 | return array(); |
265 | 261 | } |
266 | 262 | } |
@@ -282,8 +278,7 @@ discard block |
||
282 | 278 | } |
283 | 279 | if (!$subkey) { |
284 | 280 | $_data[$devid][$user] = $_data; |
285 | - } |
|
286 | - else { |
|
281 | + } else { |
|
287 | 282 | if (!isset($_data[$devid][$user])){ |
288 | 283 | $_data[$devid][$user] = array(); |
289 | 284 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | * @return boolean |
338 | 338 | * @throws FatalNotImplementedException |
339 | 339 | */ |
340 | - private function isValidType($options) { |
|
341 | - if ($options !== self::DEFAULTOPTIONS && |
|
340 | + private function isValidType($options) { |
|
341 | + if ($options !== self::DEFAULTOPTIONS && |
|
342 | 342 | $options !== self::EMAILOPTIONS && |
343 | 343 | $options !== self::CALENDAROPTIONS && |
344 | 344 | $options !== self::CONTACTOPTIONS && |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @return string |
361 | 361 | * @throws FatalNotImplementedException |
362 | 362 | */ |
363 | - private function normalizeType($options) { |
|
363 | + private function normalizeType($options) { |
|
364 | 364 | // return the requested CPO as it is defined |
365 | 365 | if (isset($this->contentParameters[$options])) |
366 | 366 | return $options; |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | */ |
294 | 294 | public function IsExporterRunRequired($currentFolderStat, $doLog = false) { |
295 | 295 | // if the backend returned false as folderstat, we have to run the exporter |
296 | - if ($currentFolderStat === false || $this->confirmationChanged) { |
|
296 | + if ($currentFolderStat === false || $this->confirmationChanged) { |
|
297 | 297 | $run = true; |
298 | 298 | } |
299 | 299 | else { |
300 | 300 | // check if the folderstat differs from the saved one or expired |
301 | - $run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); |
|
301 | + $run = !($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); |
|
302 | 302 | } |
303 | 303 | if ($doLog) { |
304 | 304 | $expDate = ($this->HasFolderStatTimeout()) ? date('Y-m-d H:i:s', $this->GetFolderStatTimeout()) : "not set"; |
@@ -404,8 +404,8 @@ discard block |
||
404 | 404 | */ |
405 | 405 | public function __call($name, $arguments) { |
406 | 406 | $lowname = strtolower($name); |
407 | - $operator = substr($lowname, 0,3); |
|
408 | - $var = substr($lowname,3); |
|
407 | + $operator = substr($lowname, 0, 3); |
|
408 | + $var = substr($lowname, 3); |
|
409 | 409 | |
410 | 410 | if (array_key_exists($var, $this->unsetdata)) { |
411 | 411 | return parent::__call($name, $arguments); |
@@ -67,8 +67,9 @@ discard block |
||
67 | 67 | * @return string/boolean false if no uuid/counter available |
68 | 68 | */ |
69 | 69 | public function GetSyncKey() { |
70 | - if (isset($this->uuid) && isset($this->uuidCounter)) |
|
71 | - return StateManager::BuildStateKey($this->uuid, $this->uuidCounter); |
|
70 | + if (isset($this->uuid) && isset($this->uuidCounter)) { |
|
71 | + return StateManager::BuildStateKey($this->uuid, $this->uuidCounter); |
|
72 | + } |
|
72 | 73 | |
73 | 74 | return false; |
74 | 75 | } |
@@ -124,9 +125,9 @@ discard block |
||
124 | 125 | if (!$this->HasSyncKey()) { |
125 | 126 | $this->uuid = $uuid; |
126 | 127 | $this->uuidCounter = $uuidNewCounter; |
128 | + } else if ($uuid !== $this->uuid) { |
|
129 | + throw new FatalException("SyncParameters->SetNewSyncKey(): new SyncKey must have the same UUID as current SyncKey"); |
|
127 | 130 | } |
128 | - else if ($uuid !== $this->uuid) |
|
129 | - throw new FatalException("SyncParameters->SetNewSyncKey(): new SyncKey must have the same UUID as current SyncKey"); |
|
130 | 131 | |
131 | 132 | $this->uuidNewCounter = $uuidNewCounter; |
132 | 133 | $this->counterconfirmed = false; |
@@ -142,8 +143,9 @@ discard block |
||
142 | 143 | * @return string/boolean returns false if uuid or counter are not available |
143 | 144 | */ |
144 | 145 | public function GetNewSyncKey() { |
145 | - if (isset($this->uuid) && isset($this->uuidNewCounter)) |
|
146 | - return StateManager::BuildStateKey($this->uuid, $this->uuidNewCounter); |
|
146 | + if (isset($this->uuid) && isset($this->uuidNewCounter)) { |
|
147 | + return StateManager::BuildStateKey($this->uuid, $this->uuidNewCounter); |
|
148 | + } |
|
147 | 149 | |
148 | 150 | return false; |
149 | 151 | } |
@@ -186,14 +188,17 @@ discard block |
||
186 | 188 | * @return boolean |
187 | 189 | */ |
188 | 190 | public function RemoveSyncKey() { |
189 | - if (isset($this->uuid)) |
|
190 | - unset($this->uuid); |
|
191 | + if (isset($this->uuid)) { |
|
192 | + unset($this->uuid); |
|
193 | + } |
|
191 | 194 | |
192 | - if (isset($this->uuidCounter)) |
|
193 | - unset($this->uuidCounter); |
|
195 | + if (isset($this->uuidCounter)) { |
|
196 | + unset($this->uuidCounter); |
|
197 | + } |
|
194 | 198 | |
195 | - if (isset($this->uuidNewCounter)) |
|
196 | - unset($this->uuidNewCounter); |
|
199 | + if (isset($this->uuidNewCounter)) { |
|
200 | + unset($this->uuidNewCounter); |
|
201 | + } |
|
197 | 202 | |
198 | 203 | ZLog::Write(LOGLEVEL_DEBUG, "SyncParameters->RemoveSyncKey(): saved sync key removed"); |
199 | 204 | return true; |
@@ -208,8 +213,7 @@ discard block |
||
208 | 213 | public function GetBackendFolderId() { |
209 | 214 | if ($this->backendfolderid) { |
210 | 215 | return $this->backendfolderid; |
211 | - } |
|
212 | - else { |
|
216 | + } else { |
|
213 | 217 | return $this->GetFolderId(); |
214 | 218 | } |
215 | 219 | } |
@@ -295,8 +299,7 @@ discard block |
||
295 | 299 | // if the backend returned false as folderstat, we have to run the exporter |
296 | 300 | if ($currentFolderStat === false || $this->confirmationChanged) { |
297 | 301 | $run = true; |
298 | - } |
|
299 | - else { |
|
302 | + } else { |
|
300 | 303 | // check if the folderstat differs from the saved one or expired |
301 | 304 | $run = ! ($this->HasFolderStat() && $currentFolderStat === $this->GetFolderStat() && time() < $this->GetFolderStatTimeout()); |
302 | 305 | } |
@@ -344,8 +347,9 @@ discard block |
||
344 | 347 | $options !== self::CONTACTOPTIONS && |
345 | 348 | $options !== self::NOTEOPTIONS && |
346 | 349 | $options !== self::TASKOPTIONS && |
347 | - $options !== self::SMSOPTIONS) |
|
348 | - throw new FatalNotImplementedException(sprintf("SyncParameters->isAllowedType('%s') ContentParameters is invalid. Such type is not available.", $options)); |
|
350 | + $options !== self::SMSOPTIONS) { |
|
351 | + throw new FatalNotImplementedException(sprintf("SyncParameters->isAllowedType('%s') ContentParameters is invalid. Such type is not available.", $options)); |
|
352 | + } |
|
349 | 353 | |
350 | 354 | return true; |
351 | 355 | } |
@@ -362,23 +366,25 @@ discard block |
||
362 | 366 | */ |
363 | 367 | private function normalizeType($options) { |
364 | 368 | // return the requested CPO as it is defined |
365 | - if (isset($this->contentParameters[$options])) |
|
366 | - return $options; |
|
369 | + if (isset($this->contentParameters[$options])) { |
|
370 | + return $options; |
|
371 | + } |
|
367 | 372 | |
368 | 373 | $returnCPO = $options; |
369 | 374 | // return email, calendar, contact or note CPO as default CPO if there no explicit default CPO defined |
370 | 375 | if ($options == self::DEFAULTOPTIONS && !isset($this->contentParameters[self::DEFAULTOPTIONS])) { |
371 | 376 | |
372 | - if (isset($this->contentParameters[self::EMAILOPTIONS])) |
|
373 | - $returnCPO = self::EMAILOPTIONS; |
|
374 | - elseif (isset($this->contentParameters[self::CALENDAROPTIONS])) |
|
375 | - $returnCPO = self::CALENDAROPTIONS; |
|
376 | - elseif (isset($this->contentParameters[self::CONTACTOPTIONS])) |
|
377 | - $returnCPO = self::CONTACTOPTIONS; |
|
378 | - elseif (isset($this->contentParameters[self::NOTEOPTIONS])) |
|
379 | - $returnCPO = self::NOTEOPTIONS; |
|
380 | - elseif (isset($this->contentParameters[self::TASKOPTIONS])) |
|
381 | - $returnCPO = self::TASKOPTIONS; |
|
377 | + if (isset($this->contentParameters[self::EMAILOPTIONS])) { |
|
378 | + $returnCPO = self::EMAILOPTIONS; |
|
379 | + } elseif (isset($this->contentParameters[self::CALENDAROPTIONS])) { |
|
380 | + $returnCPO = self::CALENDAROPTIONS; |
|
381 | + } elseif (isset($this->contentParameters[self::CONTACTOPTIONS])) { |
|
382 | + $returnCPO = self::CONTACTOPTIONS; |
|
383 | + } elseif (isset($this->contentParameters[self::NOTEOPTIONS])) { |
|
384 | + $returnCPO = self::NOTEOPTIONS; |
|
385 | + } elseif (isset($this->contentParameters[self::TASKOPTIONS])) { |
|
386 | + $returnCPO = self::TASKOPTIONS; |
|
387 | + } |
|
382 | 388 | |
383 | 389 | return $returnCPO; |
384 | 390 | } |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | * @access private |
647 | 647 | * @return boolean indicating if changes were found or not |
648 | 648 | */ |
649 | - private function CountChange($folderid) { |
|
649 | + private function CountChange($folderid) { |
|
650 | 650 | $spa = $this->GetCollection($folderid); |
651 | 651 | |
652 | 652 | if (!$spa) { |
@@ -690,62 +690,62 @@ discard block |
||
690 | 690 | $this->changes[$folderid] = $changecount; |
691 | 691 | |
692 | 692 | return ($changecount > 0); |
693 | - } |
|
694 | - |
|
695 | - /** |
|
696 | - * Checks the hierarchy for changes. |
|
697 | - * |
|
698 | - * @param boolean export changes, default: false |
|
699 | - * |
|
700 | - * @access private |
|
701 | - * @return boolean indicating if changes were found or not |
|
702 | - */ |
|
703 | - private function countHierarchyChange($exportChanges = false) { |
|
704 | - $folderid = false; |
|
705 | - |
|
706 | - // Check with device manager if the hierarchy should be reloaded. |
|
707 | - // New additional folders are loaded here. |
|
708 | - if (ZPush::GetDeviceManager()->IsHierarchySyncRequired()) { |
|
709 | - ZLog::Write(LOGLEVEL_DEBUG, "SyncCollections->countHierarchyChange(): DeviceManager says HierarchySync is required."); |
|
710 | - return true; |
|
711 | - } |
|
712 | - |
|
713 | - $changecount = false; |
|
714 | - if ($exportChanges || $this->hierarchyExporterChecked === false) { |
|
715 | - try { |
|
716 | - // if this is a validation (not first run), make sure to load the hierarchy data again |
|
717 | - if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false)) |
|
718 | - throw new StatusException("Invalid states found while re-loading hierarchy data."); |
|
719 | - |
|
720 | - |
|
721 | - $changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper(); |
|
722 | - // the hierarchyCache should now fully be initialized - check for changes in the additional folders |
|
723 | - $changesMem->Config(ZPush::GetAdditionalSyncFolders(false)); |
|
724 | - |
|
725 | - // reset backend to the main store |
|
726 | - ZPush::GetBackend()->Setup(false); |
|
727 | - $exporter = ZPush::GetBackend()->GetExporter(); |
|
728 | - if ($exporter !== false && isset($this->addparms[$folderid]["state"])) { |
|
729 | - $exporter->Config($this->addparms[$folderid]["state"]); |
|
730 | - $ret = $exporter->InitializeExporter($changesMem); |
|
731 | - while(is_array($exporter->Synchronize())); |
|
732 | - |
|
733 | - if ($ret !== false) |
|
734 | - $changecount = $changesMem->GetChangeCount(); |
|
735 | - |
|
736 | - $this->hierarchyExporterChecked = true; |
|
737 | - } |
|
738 | - } |
|
739 | - catch (StatusException $ste) { |
|
740 | - throw new StatusException("SyncCollections->countHierarchyChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN); |
|
741 | - } |
|
742 | - |
|
743 | - // start over if exporter can not be configured atm |
|
744 | - if ($changecount === false ) |
|
745 | - ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
|
746 | - } |
|
747 | - return ($changecount > 0); |
|
748 | - } |
|
693 | + } |
|
694 | + |
|
695 | + /** |
|
696 | + * Checks the hierarchy for changes. |
|
697 | + * |
|
698 | + * @param boolean export changes, default: false |
|
699 | + * |
|
700 | + * @access private |
|
701 | + * @return boolean indicating if changes were found or not |
|
702 | + */ |
|
703 | + private function countHierarchyChange($exportChanges = false) { |
|
704 | + $folderid = false; |
|
705 | + |
|
706 | + // Check with device manager if the hierarchy should be reloaded. |
|
707 | + // New additional folders are loaded here. |
|
708 | + if (ZPush::GetDeviceManager()->IsHierarchySyncRequired()) { |
|
709 | + ZLog::Write(LOGLEVEL_DEBUG, "SyncCollections->countHierarchyChange(): DeviceManager says HierarchySync is required."); |
|
710 | + return true; |
|
711 | + } |
|
712 | + |
|
713 | + $changecount = false; |
|
714 | + if ($exportChanges || $this->hierarchyExporterChecked === false) { |
|
715 | + try { |
|
716 | + // if this is a validation (not first run), make sure to load the hierarchy data again |
|
717 | + if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false)) |
|
718 | + throw new StatusException("Invalid states found while re-loading hierarchy data."); |
|
719 | + |
|
720 | + |
|
721 | + $changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper(); |
|
722 | + // the hierarchyCache should now fully be initialized - check for changes in the additional folders |
|
723 | + $changesMem->Config(ZPush::GetAdditionalSyncFolders(false)); |
|
724 | + |
|
725 | + // reset backend to the main store |
|
726 | + ZPush::GetBackend()->Setup(false); |
|
727 | + $exporter = ZPush::GetBackend()->GetExporter(); |
|
728 | + if ($exporter !== false && isset($this->addparms[$folderid]["state"])) { |
|
729 | + $exporter->Config($this->addparms[$folderid]["state"]); |
|
730 | + $ret = $exporter->InitializeExporter($changesMem); |
|
731 | + while(is_array($exporter->Synchronize())); |
|
732 | + |
|
733 | + if ($ret !== false) |
|
734 | + $changecount = $changesMem->GetChangeCount(); |
|
735 | + |
|
736 | + $this->hierarchyExporterChecked = true; |
|
737 | + } |
|
738 | + } |
|
739 | + catch (StatusException $ste) { |
|
740 | + throw new StatusException("SyncCollections->countHierarchyChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN); |
|
741 | + } |
|
742 | + |
|
743 | + // start over if exporter can not be configured atm |
|
744 | + if ($changecount === false ) |
|
745 | + ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
|
746 | + } |
|
747 | + return ($changecount > 0); |
|
748 | + } |
|
749 | 749 | |
750 | 750 | /** |
751 | 751 | * Returns an array with all folderid and the amount of changes found |
@@ -873,26 +873,26 @@ discard block |
||
873 | 873 | * @access private |
874 | 874 | * @return |
875 | 875 | */ |
876 | - private function loadStateManager() { |
|
877 | - if (!isset($this->stateManager)) |
|
876 | + private function loadStateManager() { |
|
877 | + if (!isset($this->stateManager)) |
|
878 | 878 | $this->stateManager = ZPush::GetDeviceManager()->GetStateManager(); |
879 | - } |
|
880 | - |
|
881 | - /** |
|
882 | - * Remove folder statistics from a SyncParameter object. |
|
883 | - * |
|
884 | - * @param SyncParameters $spa |
|
885 | - * |
|
886 | - * @access public |
|
887 | - * @return |
|
888 | - */ |
|
889 | - private function invalidateFolderStat($spa) { |
|
890 | - if($spa->HasFolderStat()) { |
|
891 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->invalidateFolderStat(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId())); |
|
892 | - $spa->DelFolderStat(); |
|
893 | - $this->SaveCollection($spa); |
|
894 | - return true; |
|
895 | - } |
|
896 | - return false; |
|
897 | - } |
|
879 | + } |
|
880 | + |
|
881 | + /** |
|
882 | + * Remove folder statistics from a SyncParameter object. |
|
883 | + * |
|
884 | + * @param SyncParameters $spa |
|
885 | + * |
|
886 | + * @access public |
|
887 | + * @return |
|
888 | + */ |
|
889 | + private function invalidateFolderStat($spa) { |
|
890 | + if($spa->HasFolderStat()) { |
|
891 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->invalidateFolderStat(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId())); |
|
892 | + $spa->DelFolderStat(); |
|
893 | + $this->SaveCollection($spa); |
|
894 | + return true; |
|
895 | + } |
|
896 | + return false; |
|
897 | + } |
|
898 | 898 | } |
@@ -108,12 +108,12 @@ discard block |
||
108 | 108 | $this->stateManager->DoNotDeleteOldStates(); |
109 | 109 | |
110 | 110 | $invalidStates = false; |
111 | - foreach($this->stateManager->GetSynchedFolders() as $folderid) { |
|
111 | + foreach ($this->stateManager->GetSynchedFolders() as $folderid) { |
|
112 | 112 | if ($overwriteLoaded === false && isset($this->collections[$folderid])) |
113 | 113 | continue; |
114 | 114 | |
115 | 115 | // Load Collection! |
116 | - if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) |
|
116 | + if (!$this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) |
|
117 | 117 | $invalidStates = true; |
118 | 118 | } |
119 | 119 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | |
152 | 152 | // TODO remove resync of folders |
153 | 153 | // this forces a resync of all states |
154 | - if (! $spa instanceof SyncParameters) { |
|
154 | + if (!$spa instanceof SyncParameters) { |
|
155 | 155 | throw new StateInvalidException("Saved state are not of type SyncParameters"); |
156 | 156 | } |
157 | 157 | |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | // if this is an additional folder the backend has to be setup correctly |
178 | - if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
178 | + if ($checkPermissions === true && !ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
179 | 179 | throw new StatusException(sprintf("SyncCollections->LoadCollection(): could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), self::ERROR_WRONG_HIERARCHY); |
180 | 180 | |
181 | 181 | // add collection to object |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | * @return boolean |
212 | 212 | */ |
213 | 213 | public function SaveCollection($spa) { |
214 | - if (! $this->saveData || !$spa->HasFolderId()) |
|
214 | + if (!$this->saveData || !$spa->HasFolderId()) |
|
215 | 215 | return false; |
216 | 216 | |
217 | 217 | if ($spa->IsDataChanged()) { |
@@ -240,7 +240,7 @@ discard block |
||
240 | 240 | * @return boolean |
241 | 241 | */ |
242 | 242 | public function AddCollection($spa) { |
243 | - if (! $spa->HasFolderId()) |
|
243 | + if (!$spa->HasFolderId()) |
|
244 | 244 | return false; |
245 | 245 | |
246 | 246 | $this->collections[$spa->GetFolderId()] = $spa; |
@@ -285,7 +285,7 @@ discard block |
||
285 | 285 | * @return boolean |
286 | 286 | */ |
287 | 287 | public function HasCollections() { |
288 | - return ! empty($this->collections); |
|
288 | + return !empty($this->collections); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
@@ -451,8 +451,8 @@ discard block |
||
451 | 451 | */ |
452 | 452 | public function CheckForChanges($lifetime = 600, $interval = 30, $onlyPingable = false) { |
453 | 453 | $classes = array(); |
454 | - foreach ($this->collections as $folderid => $spa){ |
|
455 | - if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid) |
|
454 | + foreach ($this->collections as $folderid => $spa) { |
|
455 | + if ($onlyPingable && $spa->GetPingableFlag() !== true || !$folderid) |
|
456 | 456 | continue; |
457 | 457 | |
458 | 458 | $class = $this->getPingClass($spa); |
@@ -465,7 +465,7 @@ discard block |
||
465 | 465 | $checkClasses = "policies only"; |
466 | 466 | else if (array_sum($classes) > 4) { |
467 | 467 | $checkClasses = ""; |
468 | - foreach($classes as $class=>$count) { |
|
468 | + foreach ($classes as $class=>$count) { |
|
469 | 469 | if ($count == 1) |
470 | 470 | $checkClasses .= sprintf("%s ", $class); |
471 | 471 | else |
@@ -480,7 +480,7 @@ discard block |
||
480 | 480 | |
481 | 481 | ZPush::GetDeviceManager()->AnnounceProcessAsPush(); |
482 | 482 | ZPush::GetTopCollector()->AnnounceInformation(sprintf("lifetime %ds", $lifetime), true); |
483 | - ZLog::Write(LOGLEVEL_INFO, sprintf("SyncCollections->CheckForChanges(): Waiting for %s changes... (lifetime %d seconds)", (empty($classes))?'policy':'store', $lifetime)); |
|
483 | + ZLog::Write(LOGLEVEL_INFO, sprintf("SyncCollections->CheckForChanges(): Waiting for %s changes... (lifetime %d seconds)", (empty($classes)) ? 'policy' : 'store', $lifetime)); |
|
484 | 484 | |
485 | 485 | // use changes sink where available |
486 | 486 | $changesSink = ZPush::GetBackend()->HasChangesSink(); |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | if (!empty($classes)) { |
490 | 490 | // initialize all possible folders |
491 | 491 | foreach ($this->collections as $folderid => $spa) { |
492 | - if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid) |
|
492 | + if (($onlyPingable && $spa->GetPingableFlag() !== true) || !$folderid) |
|
493 | 493 | continue; |
494 | 494 | |
495 | 495 | $backendFolderId = $spa->GetBackendFolderId(); |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | // initialize sink if no immediate changes were found so far |
501 | 501 | if ($changesSink && empty($this->changes)) { |
502 | 502 | ZPush::GetBackend()->Setup($store); |
503 | - if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) |
|
503 | + if (!ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) |
|
504 | 504 | throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY); |
505 | 505 | } |
506 | 506 | |
@@ -527,9 +527,9 @@ discard block |
||
527 | 527 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("refpolkey:'%s', sent polkey:'%s'", $policyKey, Request::GetPolicyKey())); |
528 | 528 | $policyKey = Request::GetPolicyKey(); |
529 | 529 | } |
530 | - while(($now = time()) < $endat) { |
|
530 | + while (($now = time()) < $endat) { |
|
531 | 531 | // how long are we waiting for changes |
532 | - $this->waitingTime = $now-$started; |
|
532 | + $this->waitingTime = $now - $started; |
|
533 | 533 | |
534 | 534 | $nextInterval = $interval; |
535 | 535 | // we should not block longer than the lifetime |
@@ -554,18 +554,18 @@ discard block |
||
554 | 554 | |
555 | 555 | // more than 60 secs to go? |
556 | 556 | if (($now + 60) < $endat) { |
557 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Forced timeout after %ds", ($now-$started)), true); |
|
558 | - throw new StatusException(sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now-$started), $lifetime), self::OBSOLETE_CONNECTION); |
|
557 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Forced timeout after %ds", ($now - $started)), true); |
|
558 | + throw new StatusException(sprintf("SyncCollections->CheckForChanges(): Timeout forced after %ss from %ss due to other process", ($now - $started), $lifetime), self::OBSOLETE_CONNECTION); |
|
559 | 559 | } |
560 | 560 | } |
561 | 561 | |
562 | 562 | // Use changes sink if available |
563 | 563 | if ($changesSink) { |
564 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now-$started), $lifetime, $checkClasses)); |
|
564 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Sink %d/%ds on %s", ($now - $started), $lifetime, $checkClasses)); |
|
565 | 565 | $notifications = ZPush::GetBackend()->ChangesSink($nextInterval); |
566 | 566 | |
567 | 567 | // how long are we waiting for changes |
568 | - $this->waitingTime = time()-$started; |
|
568 | + $this->waitingTime = time() - $started; |
|
569 | 569 | |
570 | 570 | $validNotifications = false; |
571 | 571 | foreach ($notifications as $backendFolderId) { |
@@ -586,7 +586,7 @@ discard block |
||
586 | 586 | if ($this->CountChange($folderid)) { |
587 | 587 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s'", $folderid)); |
588 | 588 | $validNotifications = true; |
589 | - $this->waitingTime = time()-$started; |
|
589 | + $this->waitingTime = time() - $started; |
|
590 | 590 | } |
591 | 591 | else { |
592 | 592 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s', but it is not relevant", $folderid)); |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | } |
599 | 599 | // use polling mechanism |
600 | 600 | else { |
601 | - ZPush::GetTopCollector()->AnnounceInformation(sprintf("Polling %d/%ds on %s", ($now-$started), $lifetime, $checkClasses)); |
|
601 | + ZPush::GetTopCollector()->AnnounceInformation(sprintf("Polling %d/%ds on %s", ($now - $started), $lifetime, $checkClasses)); |
|
602 | 602 | if ($this->CountChanges($onlyPingable)) { |
603 | 603 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Found changes polling")); |
604 | 604 | return true; |
@@ -728,7 +728,7 @@ discard block |
||
728 | 728 | if ($exporter !== false && isset($this->addparms[$folderid]["state"])) { |
729 | 729 | $exporter->Config($this->addparms[$folderid]["state"]); |
730 | 730 | $ret = $exporter->InitializeExporter($changesMem); |
731 | - while(is_array($exporter->Synchronize())); |
|
731 | + while (is_array($exporter->Synchronize())); |
|
732 | 732 | |
733 | 733 | if ($ret !== false) |
734 | 734 | $changecount = $changesMem->GetChangeCount(); |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | } |
742 | 742 | |
743 | 743 | // start over if exporter can not be configured atm |
744 | - if ($changecount === false ) |
|
744 | + if ($changecount === false) |
|
745 | 745 | ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
746 | 746 | } |
747 | 747 | return ($changecount > 0); |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | * @return |
888 | 888 | */ |
889 | 889 | private function invalidateFolderStat($spa) { |
890 | - if($spa->HasFolderStat()) { |
|
890 | + if ($spa->HasFolderStat()) { |
|
891 | 891 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->invalidateFolderStat(): removing folder stat '%s' for folderid '%s'", $spa->GetFolderStat(), $spa->GetFolderId())); |
892 | 892 | $spa->DelFolderStat(); |
893 | 893 | $this->SaveCollection($spa); |
@@ -60,8 +60,7 @@ discard block |
||
60 | 60 | } |
61 | 61 | } |
62 | 62 | return true; |
63 | - } |
|
64 | - catch (ZPushException $e) {} |
|
63 | + } catch (ZPushException $e) {} |
|
65 | 64 | return false; |
66 | 65 | } |
67 | 66 | |
@@ -109,20 +108,24 @@ discard block |
||
109 | 108 | |
110 | 109 | $invalidStates = false; |
111 | 110 | foreach($this->stateManager->GetSynchedFolders() as $folderid) { |
112 | - if ($overwriteLoaded === false && isset($this->collections[$folderid])) |
|
113 | - continue; |
|
111 | + if ($overwriteLoaded === false && isset($this->collections[$folderid])) { |
|
112 | + continue; |
|
113 | + } |
|
114 | 114 | |
115 | 115 | // Load Collection! |
116 | - if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) |
|
117 | - $invalidStates = true; |
|
116 | + if (! $this->LoadCollection($folderid, $loadState, $checkPermissions, $confirmedOnly)) { |
|
117 | + $invalidStates = true; |
|
118 | + } |
|
118 | 119 | } |
119 | 120 | |
120 | 121 | // load the hierarchy data - there are no permissions to verify so we just set it to false |
121 | - if ($loadHierarchy && !$this->LoadCollection(false, $loadState, false, false)) |
|
122 | - throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync"); |
|
122 | + if ($loadHierarchy && !$this->LoadCollection(false, $loadState, false, false)) { |
|
123 | + throw new StatusException("Invalid states found while loading hierarchy data. Forcing hierarchy sync"); |
|
124 | + } |
|
123 | 125 | |
124 | - if ($invalidStates) |
|
125 | - throw new StateInvalidException("Invalid states found while loading collections. Forcing sync"); |
|
126 | + if ($invalidStates) { |
|
127 | + throw new StateInvalidException("Invalid states found while loading collections. Forcing sync"); |
|
128 | + } |
|
126 | 129 | |
127 | 130 | return true; |
128 | 131 | } |
@@ -159,8 +162,7 @@ discard block |
||
159 | 162 | ZLog::Write(LOGLEVEL_DEBUG, "SyncCollections->LoadCollection(): Found collection with move state only, ignoring."); |
160 | 163 | return true; |
161 | 164 | } |
162 | - } |
|
163 | - catch (StateInvalidException $sive) { |
|
165 | + } catch (StateInvalidException $sive) { |
|
164 | 166 | // in case there is something wrong with the state, just stop here |
165 | 167 | // later when trying to retrieve the SyncParameters nothing will be found |
166 | 168 | |
@@ -175,8 +177,9 @@ discard block |
||
175 | 177 | } |
176 | 178 | |
177 | 179 | // if this is an additional folder the backend has to be setup correctly |
178 | - if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) |
|
179 | - throw new StatusException(sprintf("SyncCollections->LoadCollection(): could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), self::ERROR_WRONG_HIERARCHY); |
|
180 | + if ($checkPermissions === true && ! ZPush::GetBackend()->Setup(ZPush::GetAdditionalSyncFolderStore($spa->GetBackendFolderId()))) { |
|
181 | + throw new StatusException(sprintf("SyncCollections->LoadCollection(): could not Setup() the backend for folder id %s/%s", $spa->GetFolderId(), $spa->GetBackendFolderId()), self::ERROR_WRONG_HIERARCHY); |
|
182 | + } |
|
180 | 183 | |
181 | 184 | // add collection to object |
182 | 185 | $addStatus = $this->AddCollection($spa); |
@@ -186,8 +189,7 @@ discard block |
||
186 | 189 | try { |
187 | 190 | // make sure the hierarchy cache is loaded when we are loading hierarchy states |
188 | 191 | $this->addparms[$folderid]["state"] = $this->stateManager->GetSyncState($spa->GetLatestSyncKey($confirmedOnly), ($folderid === false)); |
189 | - } |
|
190 | - catch (StateNotFoundException $snfe) { |
|
192 | + } catch (StateNotFoundException $snfe) { |
|
191 | 193 | // if we can't find the state, first we should try a sync of that folder, so |
192 | 194 | // we generate a fake change, so a sync on this folder is triggered |
193 | 195 | $this->changes[$folderid] = 1; |
@@ -211,20 +213,23 @@ discard block |
||
211 | 213 | * @return boolean |
212 | 214 | */ |
213 | 215 | public function SaveCollection($spa) { |
214 | - if (! $this->saveData || !$spa->HasFolderId()) |
|
215 | - return false; |
|
216 | + if (! $this->saveData || !$spa->HasFolderId()) { |
|
217 | + return false; |
|
218 | + } |
|
216 | 219 | |
217 | 220 | if ($spa->IsDataChanged()) { |
218 | 221 | $this->loadStateManager(); |
219 | 222 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->SaveCollection(): Data of folder '%s' changed", $spa->GetFolderId())); |
220 | 223 | |
221 | 224 | // save new windowsize |
222 | - if (isset($this->globalWindowSize)) |
|
223 | - $spa->SetWindowSize($this->globalWindowSize); |
|
225 | + if (isset($this->globalWindowSize)) { |
|
226 | + $spa->SetWindowSize($this->globalWindowSize); |
|
227 | + } |
|
224 | 228 | |
225 | 229 | // update latest lifetime |
226 | - if (isset($this->refLifetime)) |
|
227 | - $spa->SetReferenceLifetime($this->refLifetime); |
|
230 | + if (isset($this->refLifetime)) { |
|
231 | + $spa->SetReferenceLifetime($this->refLifetime); |
|
232 | + } |
|
228 | 233 | |
229 | 234 | return $this->stateManager->SetSynchedFolderState($spa); |
230 | 235 | } |
@@ -240,8 +245,9 @@ discard block |
||
240 | 245 | * @return boolean |
241 | 246 | */ |
242 | 247 | public function AddCollection($spa) { |
243 | - if (! $spa->HasFolderId()) |
|
244 | - return false; |
|
248 | + if (! $spa->HasFolderId()) { |
|
249 | + return false; |
|
250 | + } |
|
245 | 251 | |
246 | 252 | $this->collections[$spa->GetFolderId()] = $spa; |
247 | 253 | |
@@ -250,12 +256,14 @@ discard block |
||
250 | 256 | $this->lastSyncTime = $spa->GetLastSyncTime(); |
251 | 257 | |
252 | 258 | // use SyncParameters PolicyKey as reference if available |
253 | - if ($spa->HasReferencePolicyKey()) |
|
254 | - $this->refPolicyKey = $spa->GetReferencePolicyKey(); |
|
259 | + if ($spa->HasReferencePolicyKey()) { |
|
260 | + $this->refPolicyKey = $spa->GetReferencePolicyKey(); |
|
261 | + } |
|
255 | 262 | |
256 | 263 | // use SyncParameters LifeTime as reference if available |
257 | - if ($spa->HasReferenceLifetime()) |
|
258 | - $this->refLifetime = $spa->GetReferenceLifetime(); |
|
264 | + if ($spa->HasReferenceLifetime()) { |
|
265 | + $this->refLifetime = $spa->GetReferenceLifetime(); |
|
266 | + } |
|
259 | 267 | |
260 | 268 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->AddCollection(): Updated reference PolicyKey '%s', reference Lifetime '%s', Last sync at '%s'", $this->refPolicyKey, $this->refLifetime, $this->lastSyncTime)); |
261 | 269 | } |
@@ -272,10 +280,11 @@ discard block |
||
272 | 280 | * @return SyncParameters / boolean false if no SyncParameters object is found for folderid |
273 | 281 | */ |
274 | 282 | public function GetCollection($folderid) { |
275 | - if (isset($this->collections[$folderid])) |
|
276 | - return $this->collections[$folderid]; |
|
277 | - else |
|
278 | - return false; |
|
283 | + if (isset($this->collections[$folderid])) { |
|
284 | + return $this->collections[$folderid]; |
|
285 | + } else { |
|
286 | + return false; |
|
287 | + } |
|
279 | 288 | } |
280 | 289 | |
281 | 290 | /** |
@@ -309,12 +318,14 @@ discard block |
||
309 | 318 | * @return boolean |
310 | 319 | */ |
311 | 320 | public function AddParameter($spa, $key, $value) { |
312 | - if (!$spa->HasFolderId()) |
|
313 | - return false; |
|
321 | + if (!$spa->HasFolderId()) { |
|
322 | + return false; |
|
323 | + } |
|
314 | 324 | |
315 | 325 | $folderid = $spa->GetFolderId(); |
316 | - if (!isset($this->addparms[$folderid])) |
|
317 | - $this->addparms[$folderid] = array(); |
|
326 | + if (!isset($this->addparms[$folderid])) { |
|
327 | + $this->addparms[$folderid] = array(); |
|
328 | + } |
|
318 | 329 | |
319 | 330 | $this->addparms[$folderid][$key] = $value; |
320 | 331 | return true; |
@@ -330,13 +341,15 @@ discard block |
||
330 | 341 | * @return mixed returns 'null' if nothing set |
331 | 342 | */ |
332 | 343 | public function GetParameter($spa, $key) { |
333 | - if (!$spa->HasFolderId()) |
|
334 | - return null; |
|
344 | + if (!$spa->HasFolderId()) { |
|
345 | + return null; |
|
346 | + } |
|
335 | 347 | |
336 | - if (isset($this->addparms[$spa->GetFolderId()]) && isset($this->addparms[$spa->GetFolderId()][$key])) |
|
337 | - return $this->addparms[$spa->GetFolderId()][$key]; |
|
338 | - else |
|
339 | - return null; |
|
348 | + if (isset($this->addparms[$spa->GetFolderId()]) && isset($this->addparms[$spa->GetFolderId()][$key])) { |
|
349 | + return $this->addparms[$spa->GetFolderId()][$key]; |
|
350 | + } else { |
|
351 | + return null; |
|
352 | + } |
|
340 | 353 | } |
341 | 354 | |
342 | 355 | /** |
@@ -375,8 +388,7 @@ discard block |
||
375 | 388 | // take the requested global windowsize or the max 512 if not defined |
376 | 389 | if (isset($this->globalWindowSize)) { |
377 | 390 | $globalWindowSize = $this->globalWindowSize; |
378 | - } |
|
379 | - else { |
|
391 | + } else { |
|
380 | 392 | $globalWindowSize = WINDOW_SIZE_MAX; // 512 by default |
381 | 393 | } |
382 | 394 | |
@@ -452,28 +464,31 @@ discard block |
||
452 | 464 | public function CheckForChanges($lifetime = 600, $interval = 30, $onlyPingable = false) { |
453 | 465 | $classes = array(); |
454 | 466 | foreach ($this->collections as $folderid => $spa){ |
455 | - if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid) |
|
456 | - continue; |
|
467 | + if ($onlyPingable && $spa->GetPingableFlag() !== true || ! $folderid) { |
|
468 | + continue; |
|
469 | + } |
|
457 | 470 | |
458 | 471 | $class = $this->getPingClass($spa); |
459 | 472 | |
460 | - if (!isset($classes[$class])) |
|
461 | - $classes[$class] = 0; |
|
473 | + if (!isset($classes[$class])) { |
|
474 | + $classes[$class] = 0; |
|
475 | + } |
|
462 | 476 | $classes[$class] += 1; |
463 | 477 | } |
464 | - if (empty($classes)) |
|
465 | - $checkClasses = "policies only"; |
|
466 | - else if (array_sum($classes) > 4) { |
|
478 | + if (empty($classes)) { |
|
479 | + $checkClasses = "policies only"; |
|
480 | + } else if (array_sum($classes) > 4) { |
|
467 | 481 | $checkClasses = ""; |
468 | 482 | foreach($classes as $class=>$count) { |
469 | - if ($count == 1) |
|
470 | - $checkClasses .= sprintf("%s ", $class); |
|
471 | - else |
|
472 | - $checkClasses .= sprintf("%s(%d) ", $class, $count); |
|
483 | + if ($count == 1) { |
|
484 | + $checkClasses .= sprintf("%s ", $class); |
|
485 | + } else { |
|
486 | + $checkClasses .= sprintf("%s(%d) ", $class, $count); |
|
487 | + } |
|
473 | 488 | } |
489 | + } else { |
|
490 | + $checkClasses = implode(" ", array_keys($classes)); |
|
474 | 491 | } |
475 | - else |
|
476 | - $checkClasses = implode(" ", array_keys($classes)); |
|
477 | 492 | |
478 | 493 | $pingTracking = new PingTracking(); |
479 | 494 | $this->changes = array(); |
@@ -489,8 +504,9 @@ discard block |
||
489 | 504 | if (!empty($classes)) { |
490 | 505 | // initialize all possible folders |
491 | 506 | foreach ($this->collections as $folderid => $spa) { |
492 | - if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid) |
|
493 | - continue; |
|
507 | + if (($onlyPingable && $spa->GetPingableFlag() !== true) || ! $folderid) { |
|
508 | + continue; |
|
509 | + } |
|
494 | 510 | |
495 | 511 | $backendFolderId = $spa->GetBackendFolderId(); |
496 | 512 | |
@@ -500,8 +516,9 @@ discard block |
||
500 | 516 | // initialize sink if no immediate changes were found so far |
501 | 517 | if ($changesSink && empty($this->changes)) { |
502 | 518 | ZPush::GetBackend()->Setup($store); |
503 | - if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) |
|
504 | - throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY); |
|
519 | + if (! ZPush::GetBackend()->ChangesSinkInitialize($backendFolderId)) { |
|
520 | + throw new StatusException(sprintf("Error initializing ChangesSink for folder id %s/%s", $folderid, $backendFolderId), self::ERROR_WRONG_HIERARCHY); |
|
521 | + } |
|
505 | 522 | } |
506 | 523 | |
507 | 524 | // check if the folder stat changed since the last sync, if so generate a change for it (only on first run) |
@@ -533,18 +550,21 @@ discard block |
||
533 | 550 | |
534 | 551 | $nextInterval = $interval; |
535 | 552 | // we should not block longer than the lifetime |
536 | - if ($endat - $now < $nextInterval) |
|
537 | - $nextInterval = $endat - $now; |
|
553 | + if ($endat - $now < $nextInterval) { |
|
554 | + $nextInterval = $endat - $now; |
|
555 | + } |
|
538 | 556 | |
539 | 557 | // Check if provisioning is necessary |
540 | 558 | // if a PolicyKey was sent use it. If not, compare with the ReferencePolicyKey |
541 | - if (PROVISIONING === true && $policyKey !== false && ZPush::GetProvisioningManager()->ProvisioningRequired($policyKey, true, false)) |
|
542 | - // the hierarchysync forces provisioning |
|
559 | + if (PROVISIONING === true && $policyKey !== false && ZPush::GetProvisioningManager()->ProvisioningRequired($policyKey, true, false)) { |
|
560 | + // the hierarchysync forces provisioning |
|
543 | 561 | throw new StatusException("SyncCollections->CheckForChanges(): Policies or PolicyKey changed. Provisioning required.", self::ERROR_WRONG_HIERARCHY); |
562 | + } |
|
544 | 563 | |
545 | 564 | // Check if a hierarchy sync is necessary |
546 | - if ($this->countHierarchyChange()) |
|
547 | - throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED); |
|
565 | + if ($this->countHierarchyChange()) { |
|
566 | + throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED); |
|
567 | + } |
|
548 | 568 | |
549 | 569 | // Check if there are newer requests |
550 | 570 | // If so, this process should be terminated if more than 60 secs to go |
@@ -577,8 +597,7 @@ discard block |
||
577 | 597 | if ($this->countHierarchyChange(true)) { |
578 | 598 | throw new StatusException("SyncCollections->CheckForChanges(): HierarchySync required.", self::HIERARCHY_CHANGED); |
579 | 599 | } |
580 | - } |
|
581 | - else { |
|
600 | + } else { |
|
582 | 601 | // the backend will notify on the backend folderid |
583 | 602 | $folderid = ZPush::GetDeviceManager()->GetFolderIdForBackendId($backendFolderId); |
584 | 603 | |
@@ -587,14 +606,14 @@ discard block |
||
587 | 606 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s'", $folderid)); |
588 | 607 | $validNotifications = true; |
589 | 608 | $this->waitingTime = time()-$started; |
590 | - } |
|
591 | - else { |
|
609 | + } else { |
|
592 | 610 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Notification received on folder '%s', but it is not relevant", $folderid)); |
593 | 611 | } |
594 | 612 | } |
595 | 613 | } |
596 | - if ($validNotifications) |
|
597 | - return true; |
|
614 | + if ($validNotifications) { |
|
615 | + return true; |
|
616 | + } |
|
598 | 617 | } |
599 | 618 | // use polling mechanism |
600 | 619 | else { |
@@ -602,8 +621,7 @@ discard block |
||
602 | 621 | if ($this->CountChanges($onlyPingable)) { |
603 | 622 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("SyncCollections->CheckForChanges(): Found changes polling")); |
604 | 623 | return true; |
605 | - } |
|
606 | - else { |
|
624 | + } else { |
|
607 | 625 | sleep($nextInterval); |
608 | 626 | } |
609 | 627 | } // end polling |
@@ -625,14 +643,17 @@ discard block |
||
625 | 643 | public function CountChanges($onlyPingable = false) { |
626 | 644 | $changesAvailable = false; |
627 | 645 | foreach ($this->collections as $folderid => $spa) { |
628 | - if ($onlyPingable && $spa->GetPingableFlag() !== true) |
|
629 | - continue; |
|
646 | + if ($onlyPingable && $spa->GetPingableFlag() !== true) { |
|
647 | + continue; |
|
648 | + } |
|
630 | 649 | |
631 | - if (isset($this->addparms[$spa->GetFolderId()]["status"]) && $this->addparms[$spa->GetFolderId()]["status"] != SYNC_STATUS_SUCCESS) |
|
632 | - continue; |
|
650 | + if (isset($this->addparms[$spa->GetFolderId()]["status"]) && $this->addparms[$spa->GetFolderId()]["status"] != SYNC_STATUS_SUCCESS) { |
|
651 | + continue; |
|
652 | + } |
|
633 | 653 | |
634 | - if ($this->CountChange($folderid)) |
|
635 | - $changesAvailable = true; |
|
654 | + if ($this->CountChange($folderid)) { |
|
655 | + $changesAvailable = true; |
|
656 | + } |
|
636 | 657 | } |
637 | 658 | |
638 | 659 | return $changesAvailable; |
@@ -667,11 +688,11 @@ discard block |
||
667 | 688 | $exporter->ConfigContentParameters($spa->GetCPO()); |
668 | 689 | $ret = $exporter->InitializeExporter($importer); |
669 | 690 | |
670 | - if ($ret !== false) |
|
671 | - $changecount = $exporter->GetChangeCount(); |
|
691 | + if ($ret !== false) { |
|
692 | + $changecount = $exporter->GetChangeCount(); |
|
693 | + } |
|
672 | 694 | } |
673 | - } |
|
674 | - catch (StatusException $ste) { |
|
695 | + } catch (StatusException $ste) { |
|
675 | 696 | if ($ste->getCode() == SYNC_STATUS_FOLDERHIERARCHYCHANGED) { |
676 | 697 | ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): exporter can not be re-configured due to state error, emulating change in folder to force Sync."); |
677 | 698 | $this->changes[$folderid] = 1; |
@@ -684,8 +705,9 @@ discard block |
||
684 | 705 | } |
685 | 706 | |
686 | 707 | // start over if exporter can not be configured atm |
687 | - if ($changecount === false) |
|
688 | - ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): no changes received from Exporter."); |
|
708 | + if ($changecount === false) { |
|
709 | + ZLog::Write(LOGLEVEL_WARN, "SyncCollections->CountChange(): no changes received from Exporter."); |
|
710 | + } |
|
689 | 711 | |
690 | 712 | $this->changes[$folderid] = $changecount; |
691 | 713 | |
@@ -714,8 +736,9 @@ discard block |
||
714 | 736 | if ($exportChanges || $this->hierarchyExporterChecked === false) { |
715 | 737 | try { |
716 | 738 | // if this is a validation (not first run), make sure to load the hierarchy data again |
717 | - if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false)) |
|
718 | - throw new StatusException("Invalid states found while re-loading hierarchy data."); |
|
739 | + if ($this->hierarchyExporterChecked === true && !$this->LoadCollection(false, true, false)) { |
|
740 | + throw new StatusException("Invalid states found while re-loading hierarchy data."); |
|
741 | + } |
|
719 | 742 | |
720 | 743 | |
721 | 744 | $changesMem = ZPush::GetDeviceManager()->GetHierarchyChangesWrapper(); |
@@ -730,19 +753,20 @@ discard block |
||
730 | 753 | $ret = $exporter->InitializeExporter($changesMem); |
731 | 754 | while(is_array($exporter->Synchronize())); |
732 | 755 | |
733 | - if ($ret !== false) |
|
734 | - $changecount = $changesMem->GetChangeCount(); |
|
756 | + if ($ret !== false) { |
|
757 | + $changecount = $changesMem->GetChangeCount(); |
|
758 | + } |
|
735 | 759 | |
736 | 760 | $this->hierarchyExporterChecked = true; |
737 | 761 | } |
738 | - } |
|
739 | - catch (StatusException $ste) { |
|
762 | + } catch (StatusException $ste) { |
|
740 | 763 | throw new StatusException("SyncCollections->countHierarchyChange(): exporter can not be re-configured.", self::ERROR_WRONG_HIERARCHY, null, LOGLEVEL_WARN); |
741 | 764 | } |
742 | 765 | |
743 | 766 | // start over if exporter can not be configured atm |
744 | - if ($changecount === false ) |
|
745 | - ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
|
767 | + if ($changecount === false ) { |
|
768 | + ZLog::Write(LOGLEVEL_WARN, "SyncCollections->countHierarchyChange(): no changes received from Exporter."); |
|
769 | + } |
|
746 | 770 | } |
747 | 771 | return ($changecount > 0); |
748 | 772 | } |
@@ -874,8 +898,9 @@ discard block |
||
874 | 898 | * @return |
875 | 899 | */ |
876 | 900 | private function loadStateManager() { |
877 | - if (!isset($this->stateManager)) |
|
878 | - $this->stateManager = ZPush::GetDeviceManager()->GetStateManager(); |
|
901 | + if (!isset($this->stateManager)) { |
|
902 | + $this->stateManager = ZPush::GetDeviceManager()->GetStateManager(); |
|
903 | + } |
|
879 | 904 | } |
880 | 905 | |
881 | 906 | /** |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | // truncate messages longer than 10 KB |
60 | 60 | $messagesize = strlen($message); |
61 | 61 | if ($truncate && $messagesize > 10240) |
62 | - $message = substr($message, 0, 10240) . sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
62 | + $message = substr($message, 0, 10240).sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
63 | 63 | |
64 | 64 | self::$lastLogs[$loglevel] = $message; |
65 | 65 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | if ($loglevel & LOGLEVEL_WBXMLSTACK) { |
75 | - self::$wbxmlDebug .= $message . PHP_EOL; |
|
75 | + self::$wbxmlDebug .= $message.PHP_EOL; |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 | |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @return string/false returns false if there was no message logged in that level |
96 | 96 | */ |
97 | 97 | static public function GetLastMessage($loglevel) { |
98 | - return (isset(self::$lastLogs[$loglevel]))?self::$lastLogs[$loglevel]:false; |
|
98 | + return (isset(self::$lastLogs[$loglevel])) ?self::$lastLogs[$loglevel] : false; |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | /** |
@@ -173,19 +173,19 @@ discard block |
||
173 | 173 | case E_NOTICE: |
174 | 174 | case E_WARNING: |
175 | 175 | // TODO check if there is a better way to avoid these messages |
176 | - if (stripos($errfile,'interprocessdata') !== false && stripos($errstr,'shm_get_var()') !== false) |
|
176 | + if (stripos($errfile, 'interprocessdata') !== false && stripos($errstr, 'shm_get_var()') !== false) |
|
177 | 177 | break; |
178 | 178 | ZLog::Write(LOGLEVEL_WARN, "$errfile:$errline $errstr ($errno)"); |
179 | 179 | break; |
180 | 180 | |
181 | 181 | default: |
182 | 182 | $bt = debug_backtrace(); |
183 | - ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ". (count($bt)-1) . " steps"); |
|
184 | - for($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { |
|
183 | + ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ".(count($bt) - 1)." steps"); |
|
184 | + for ($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { |
|
185 | 185 | $file = $line = "unknown"; |
186 | 186 | if (isset($bt[$i]['file'])) $file = $bt[$i]['file']; |
187 | 187 | if (isset($bt[$i]['line'])) $line = $bt[$i]['line']; |
188 | - ZLog::Write(LOGLEVEL_ERROR, "trace: $i:". $file . ":" . $line. " - " . ((isset($bt[$i]['class']))? $bt[$i]['class'] . $bt[$i]['type']:""). $bt[$i]['function']. "()"); |
|
188 | + ZLog::Write(LOGLEVEL_ERROR, "trace: $i:".$file.":".$line." - ".((isset($bt[$i]['class'])) ? $bt[$i]['class'].$bt[$i]['type'] : "").$bt[$i]['function']."()"); |
|
189 | 189 | } |
190 | 190 | //throw new Exception("An error occurred."); |
191 | 191 | break; |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | |
205 | 205 | $error = error_get_last(); |
206 | 206 | |
207 | - if( $error !== null) { |
|
207 | + if ($error !== null) { |
|
208 | 208 | $errno = $error["type"]; |
209 | 209 | $errfile = $error["file"]; |
210 | 210 | $errline = $error["line"]; |
@@ -24,11 +24,13 @@ discard block |
||
24 | 24 | */ |
25 | 25 | static public function Initialize() { |
26 | 26 | // define some constants for the logging |
27 | - if (!defined('LOGUSERLEVEL')) |
|
28 | - define('LOGUSERLEVEL', LOGLEVEL_OFF); |
|
27 | + if (!defined('LOGUSERLEVEL')) { |
|
28 | + define('LOGUSERLEVEL', LOGLEVEL_OFF); |
|
29 | + } |
|
29 | 30 | |
30 | - if (!defined('LOGLEVEL')) |
|
31 | - define('LOGLEVEL', LOGLEVEL_OFF); |
|
31 | + if (!defined('LOGLEVEL')) { |
|
32 | + define('LOGLEVEL', LOGLEVEL_OFF); |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $logger = self::getLogger(); |
34 | 36 | |
@@ -58,15 +60,15 @@ discard block |
||
58 | 60 | static public function Write($loglevel, $message, $truncate = true) { |
59 | 61 | // truncate messages longer than 10 KB |
60 | 62 | $messagesize = strlen($message); |
61 | - if ($truncate && $messagesize > 10240) |
|
62 | - $message = substr($message, 0, 10240) . sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
63 | + if ($truncate && $messagesize > 10240) { |
|
64 | + $message = substr($message, 0, 10240) . sprintf(" <log message with %d bytes truncated>", $messagesize); |
|
65 | + } |
|
63 | 66 | |
64 | 67 | self::$lastLogs[$loglevel] = $message; |
65 | 68 | |
66 | 69 | try { |
67 | 70 | self::getLogger()->Log($loglevel, $message); |
68 | - } |
|
69 | - catch (\Exception $e) { |
|
71 | + } catch (\Exception $e) { |
|
70 | 72 | //@TODO How should we handle logging error ? |
71 | 73 | // Ignore any error. |
72 | 74 | } |
@@ -132,8 +134,7 @@ discard block |
||
132 | 134 | // if there is an impersonated user it's used instead of the GET user |
133 | 135 | if (Request::GetImpersonatedUser()) { |
134 | 136 | $user = Request::GetImpersonatedUser(); |
135 | - } |
|
136 | - else { |
|
137 | + } else { |
|
137 | 138 | list($user) = Utils::SplitDomainUser(strtolower(Request::GetGETUser())); |
138 | 139 | } |
139 | 140 | |
@@ -159,7 +160,9 @@ discard block |
||
159 | 160 | |
160 | 161 | // TODO review error handler |
161 | 162 | function zpush_error_handler($errno, $errstr, $errfile, $errline) { |
162 | - if (defined('LOG_ERROR_MASK')) $errno &= LOG_ERROR_MASK; |
|
163 | + if (defined('LOG_ERROR_MASK')) { |
|
164 | + $errno &= LOG_ERROR_MASK; |
|
165 | + } |
|
163 | 166 | |
164 | 167 | switch ($errno) { |
165 | 168 | case 0: |
@@ -173,8 +176,9 @@ discard block |
||
173 | 176 | case E_NOTICE: |
174 | 177 | case E_WARNING: |
175 | 178 | // TODO check if there is a better way to avoid these messages |
176 | - if (stripos($errfile,'interprocessdata') !== false && stripos($errstr,'shm_get_var()') !== false) |
|
177 | - break; |
|
179 | + if (stripos($errfile,'interprocessdata') !== false && stripos($errstr,'shm_get_var()') !== false) { |
|
180 | + break; |
|
181 | + } |
|
178 | 182 | ZLog::Write(LOGLEVEL_WARN, "$errfile:$errline $errstr ($errno)"); |
179 | 183 | break; |
180 | 184 | |
@@ -183,8 +187,12 @@ discard block |
||
183 | 187 | ZLog::Write(LOGLEVEL_ERROR, "trace error: $errfile:$errline $errstr ($errno) - backtrace: ". (count($bt)-1) . " steps"); |
184 | 188 | for($i = 1, $bt_length = count($bt); $i < $bt_length; $i++) { |
185 | 189 | $file = $line = "unknown"; |
186 | - if (isset($bt[$i]['file'])) $file = $bt[$i]['file']; |
|
187 | - if (isset($bt[$i]['line'])) $line = $bt[$i]['line']; |
|
190 | + if (isset($bt[$i]['file'])) { |
|
191 | + $file = $bt[$i]['file']; |
|
192 | + } |
|
193 | + if (isset($bt[$i]['line'])) { |
|
194 | + $line = $bt[$i]['line']; |
|
195 | + } |
|
188 | 196 | ZLog::Write(LOGLEVEL_ERROR, "trace: $i:". $file . ":" . $line. " - " . ((isset($bt[$i]['class']))? $bt[$i]['class'] . $bt[$i]['type']:""). $bt[$i]['function']. "()"); |
189 | 197 | } |
190 | 198 | //throw new Exception("An error occurred."); |
@@ -257,8 +257,8 @@ |
||
257 | 257 | } |
258 | 258 | else { |
259 | 259 | if(strlen($element) == 0) |
260 | - // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true); |
|
261 | - ; |
|
260 | + // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true); |
|
261 | + ; |
|
262 | 262 | else { |
263 | 263 | $encoder->startTag($map[self::STREAMER_ARRAY]); |
264 | 264 | $encoder->content($element); |
@@ -69,11 +69,11 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function Decode(&$decoder) { |
71 | 71 | WBXMLDecoder::ResetInWhile("decodeMain"); |
72 | - while(WBXMLDecoder::InWhile("decodeMain")) { |
|
72 | + while (WBXMLDecoder::InWhile("decodeMain")) { |
|
73 | 73 | $entity = $decoder->getElement(); |
74 | 74 | |
75 | - if($entity[EN_TYPE] == EN_TYPE_STARTTAG) { |
|
76 | - if(! ($entity[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
75 | + if ($entity[EN_TYPE] == EN_TYPE_STARTTAG) { |
|
76 | + if (!($entity[EN_FLAGS] & EN_FLAGS_CONTENT)) { |
|
77 | 77 | $map = $this->mapping[$entity[EN_TAG]]; |
78 | 78 | if (isset($map[self::STREAMER_ARRAY])) { |
79 | 79 | $this->{$map[self::STREAMER_VAR]} = array(); |
@@ -81,16 +81,16 @@ discard block |
||
81 | 81 | else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
82 | 82 | $this->{$map[self::STREAMER_VAR]} = "1"; |
83 | 83 | } |
84 | - else if(!isset($map[self::STREAMER_TYPE])) { |
|
84 | + else if (!isset($map[self::STREAMER_TYPE])) { |
|
85 | 85 | $this->{$map[self::STREAMER_VAR]} = ""; |
86 | 86 | } |
87 | - else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) { |
|
87 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
88 | 88 | $this->{$map[self::STREAMER_VAR]} = ""; |
89 | 89 | } |
90 | 90 | continue; |
91 | 91 | } |
92 | 92 | // Found a start tag |
93 | - if(!isset($this->mapping[$entity[EN_TAG]])) { |
|
93 | + if (!isset($this->mapping[$entity[EN_TAG]])) { |
|
94 | 94 | // This tag shouldn't be here, abort |
95 | 95 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Tag '%s' unexpected in type XML type '%s'", $entity[EN_TAG], get_class($this))); |
96 | 96 | return false; |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | $map = $this->mapping[$entity[EN_TAG]]; |
100 | 100 | |
101 | 101 | // Handle an array |
102 | - if(isset($map[self::STREAMER_ARRAY])) { |
|
102 | + if (isset($map[self::STREAMER_ARRAY])) { |
|
103 | 103 | WBXMLDecoder::ResetInWhile("decodeArray"); |
104 | - while(WBXMLDecoder::InWhile("decodeArray")) { |
|
104 | + while (WBXMLDecoder::InWhile("decodeArray")) { |
|
105 | 105 | //do not get start tag for an array without a container |
106 | 106 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
107 | - if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) |
|
107 | + if (!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) |
|
108 | 108 | break; |
109 | 109 | } |
110 | - if(isset($map[self::STREAMER_TYPE])) { |
|
110 | + if (isset($map[self::STREAMER_TYPE])) { |
|
111 | 111 | $decoded = new $map[self::STREAMER_TYPE]; |
112 | 112 | |
113 | 113 | $decoded->Decode($decoder); |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | $decoded = $decoder->getElementContent(); |
117 | 117 | } |
118 | 118 | |
119 | - if(!isset($this->{$map[self::STREAMER_VAR]})) |
|
119 | + if (!isset($this->{$map[self::STREAMER_VAR]})) |
|
120 | 120 | $this->{$map[self::STREAMER_VAR]} = array($decoded); |
121 | 121 | else |
122 | 122 | array_push($this->{$map[self::STREAMER_VAR]}, $decoded); |
123 | 123 | |
124 | - if(!$decoder->getElementEndTag()) //end tag of a container element |
|
124 | + if (!$decoder->getElementEndTag()) //end tag of a container element |
|
125 | 125 | return false; |
126 | 126 | |
127 | 127 | if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER) { |
@@ -139,43 +139,43 @@ discard block |
||
139 | 139 | } |
140 | 140 | //do not get end tag for an array without a container |
141 | 141 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
142 | - if(!$decoder->getElementEndTag()) //end tag of container |
|
142 | + if (!$decoder->getElementEndTag()) //end tag of container |
|
143 | 143 | return false; |
144 | 144 | } |
145 | 145 | } |
146 | 146 | else { // Handle single value |
147 | - if(isset($map[self::STREAMER_TYPE])) { |
|
147 | + if (isset($map[self::STREAMER_TYPE])) { |
|
148 | 148 | // Complex type, decode recursively |
149 | - if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
149 | + if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
|
150 | 150 | $decoded = $this->parseDate($decoder->getElementContent()); |
151 | - if(!$decoder->getElementEndTag()) |
|
151 | + if (!$decoder->getElementEndTag()) |
|
152 | 152 | return false; |
153 | 153 | } |
154 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
154 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
155 | 155 | $decoded = hex2bin($decoder->getElementContent()); |
156 | - if(!$decoder->getElementEndTag()) |
|
156 | + if (!$decoder->getElementEndTag()) |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | // explode comma or semicolon strings into arrays |
160 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) { |
|
161 | - $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
|
160 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) { |
|
161 | + $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED) ? ", " : "; "; |
|
162 | 162 | $decoded = explode($glue, $decoder->getElementContent()); |
163 | - if(!$decoder->getElementEndTag()) |
|
163 | + if (!$decoder->getElementEndTag()) |
|
164 | 164 | return false; |
165 | 165 | } |
166 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
166 | + else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
167 | 167 | $decoded = StringStreamWrapper::Open($decoder->getElementContent()); |
168 | - if(!$decoder->getElementEndTag()) |
|
168 | + if (!$decoder->getElementEndTag()) |
|
169 | 169 | return false; |
170 | 170 | } |
171 | 171 | else { |
172 | 172 | $subdecoder = new $map[self::STREAMER_TYPE](); |
173 | - if($subdecoder->Decode($decoder) === false) |
|
173 | + if ($subdecoder->Decode($decoder) === false) |
|
174 | 174 | return false; |
175 | 175 | |
176 | 176 | $decoded = $subdecoder; |
177 | 177 | |
178 | - if(!$decoder->getElementEndTag()) { |
|
178 | + if (!$decoder->getElementEndTag()) { |
|
179 | 179 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("No end tag for '%s'", $entity[EN_TAG])); |
180 | 180 | return false; |
181 | 181 | } |
@@ -185,13 +185,13 @@ discard block |
||
185 | 185 | // Simple type, just get content |
186 | 186 | $decoded = $decoder->getElementContent(); |
187 | 187 | |
188 | - if($decoded === false) { |
|
188 | + if ($decoded === false) { |
|
189 | 189 | // the tag is declared to have content, but no content is available. |
190 | 190 | // set an empty content |
191 | 191 | $decoded = ""; |
192 | 192 | } |
193 | 193 | |
194 | - if(!$decoder->getElementEndTag()) { |
|
194 | + if (!$decoder->getElementEndTag()) { |
|
195 | 195 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Unable to get end tag for '%s'", $entity[EN_TAG])); |
196 | 196 | return false; |
197 | 197 | } |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | } |
202 | 202 | } |
203 | 203 | } |
204 | - else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
204 | + else if ($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
205 | 205 | $decoder->ungetElement($entity); |
206 | 206 | break; |
207 | 207 | } |
@@ -222,10 +222,10 @@ discard block |
||
222 | 222 | public function Encode(&$encoder) { |
223 | 223 | // A return value if anything was streamed. We need for empty tags. |
224 | 224 | $streamed = false; |
225 | - foreach($this->mapping as $tag => $map) { |
|
226 | - if(isset($this->{$map[self::STREAMER_VAR]})) { |
|
225 | + foreach ($this->mapping as $tag => $map) { |
|
226 | + if (isset($this->{$map[self::STREAMER_VAR]})) { |
|
227 | 227 | // Variable is available |
228 | - if(is_object($this->{$map[self::STREAMER_VAR]})) { |
|
228 | + if (is_object($this->{$map[self::STREAMER_VAR]})) { |
|
229 | 229 | // Subobjects can do their own encoding |
230 | 230 | if ($this->{$map[self::STREAMER_VAR]} instanceof Streamer) { |
231 | 231 | $encoder->startTag($tag); |
@@ -239,7 +239,7 @@ discard block |
||
239 | 239 | ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this))); |
240 | 240 | } |
241 | 241 | // Array of objects |
242 | - else if(isset($map[self::STREAMER_ARRAY])) { |
|
242 | + else if (isset($map[self::STREAMER_ARRAY])) { |
|
243 | 243 | if (empty($this->{$map[self::STREAMER_VAR]}) && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
244 | 244 | $encoder->startTag($tag, false, true); |
245 | 245 | } |
@@ -250,13 +250,13 @@ discard block |
||
250 | 250 | $encoder->startTag($tag); |
251 | 251 | |
252 | 252 | foreach ($this->{$map[self::STREAMER_VAR]} as $element) { |
253 | - if(is_object($element)) { |
|
253 | + if (is_object($element)) { |
|
254 | 254 | $encoder->startTag($map[self::STREAMER_ARRAY]); // Outputs object container (eg Attachment) |
255 | 255 | $element->Encode($encoder); |
256 | 256 | $encoder->endTag(); |
257 | 257 | } |
258 | 258 | else { |
259 | - if(strlen($element) == 0) |
|
259 | + if (strlen($element) == 0) |
|
260 | 260 | // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true); |
261 | 261 | ; |
262 | 262 | else { |
@@ -268,12 +268,12 @@ discard block |
||
268 | 268 | } |
269 | 269 | } |
270 | 270 | |
271 | - if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
271 | + if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
272 | 272 | $encoder->endTag(); |
273 | 273 | } |
274 | 274 | } |
275 | 275 | else { |
276 | - if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) { |
|
276 | + if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) { |
|
277 | 277 | continue; |
278 | 278 | } |
279 | 279 | |
@@ -286,7 +286,7 @@ discard block |
||
286 | 286 | } |
287 | 287 | |
288 | 288 | // Simple type |
289 | - if(!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) { |
|
289 | + if (!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) { |
|
290 | 290 | // send empty tags |
291 | 291 | if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) |
292 | 292 | $encoder->startTag($tag, false, true); |
@@ -296,23 +296,23 @@ discard block |
||
296 | 296 | } else |
297 | 297 | $encoder->startTag($tag); |
298 | 298 | |
299 | - if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) { |
|
300 | - if($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970 |
|
299 | + if (isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) { |
|
300 | + if ($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970 |
|
301 | 301 | $encoder->content($this->formatDate($this->{$map[self::STREAMER_VAR]}, $map[self::STREAMER_TYPE])); |
302 | 302 | } |
303 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
303 | + else if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
304 | 304 | $encoder->content(strtoupper(bin2hex($this->{$map[self::STREAMER_VAR]}))); |
305 | 305 | } |
306 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
306 | + else if (isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
307 | 307 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, false); |
308 | 308 | } |
309 | - else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
309 | + else if (isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
310 | 310 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, true); |
311 | 311 | } |
312 | 312 | // implode comma or semicolon arrays into a string |
313 | - else if(isset($map[self::STREAMER_TYPE]) && is_array($this->{$map[self::STREAMER_VAR]}) && |
|
313 | + else if (isset($map[self::STREAMER_TYPE]) && is_array($this->{$map[self::STREAMER_VAR]}) && |
|
314 | 314 | ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED)) { |
315 | - $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
|
315 | + $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED) ? ", " : "; "; |
|
316 | 316 | $encoder->content(implode($glue, $this->{$map[self::STREAMER_VAR]})); |
317 | 317 | } |
318 | 318 | else { |
@@ -324,7 +324,7 @@ discard block |
||
324 | 324 | } |
325 | 325 | } |
326 | 326 | // Output our own content |
327 | - if(isset($this->content)) |
|
327 | + if (isset($this->content)) |
|
328 | 328 | $encoder->content($this->content); |
329 | 329 | |
330 | 330 | return $streamed; |
@@ -339,12 +339,12 @@ discard block |
||
339 | 339 | public function StripData($flags = 0) { |
340 | 340 | foreach ($this->mapping as $k=>$v) { |
341 | 341 | if (isset($this->{$v[self::STREAMER_VAR]})) { |
342 | - if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData") ) { |
|
342 | + if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData")) { |
|
343 | 343 | $this->{$v[self::STREAMER_VAR]}->StripData($flags); |
344 | 344 | } |
345 | 345 | else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) { |
346 | 346 | foreach ($this->{$v[self::STREAMER_VAR]} as $element) { |
347 | - if (is_object($element) && method_exists($element, "StripData") ) { |
|
347 | + if (is_object($element) && method_exists($element, "StripData")) { |
|
348 | 348 | $element->StripData($flags); |
349 | 349 | } |
350 | 350 | elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * @return void |
419 | 419 | */ |
420 | 420 | public function jsonDeserialize($stdObj) { |
421 | - foreach($stdObj->data as $k => $v) { |
|
421 | + foreach ($stdObj->data as $k => $v) { |
|
422 | 422 | if (is_object($v) && isset($v->gsSyncStateClass)) { |
423 | 423 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Streamer->jsonDeserialize(): top class '%s'", $v->gsSyncStateClass)); |
424 | 424 | $this->$k = new $v->gsSyncStateClass; |
@@ -448,9 +448,9 @@ discard block |
||
448 | 448 | * @return string |
449 | 449 | */ |
450 | 450 | private function formatDate($ts, $type) { |
451 | - if($type == self::STREAMER_TYPE_DATE) |
|
451 | + if ($type == self::STREAMER_TYPE_DATE) |
|
452 | 452 | return gmstrftime("%Y%m%dT%H%M%SZ", $ts); |
453 | - else if($type == self::STREAMER_TYPE_DATE_DASHES) |
|
453 | + else if ($type == self::STREAMER_TYPE_DATE_DASHES) |
|
454 | 454 | return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
455 | 455 | // fallback to dashes (should never be reached) |
456 | 456 | return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
@@ -465,8 +465,8 @@ discard block |
||
465 | 465 | * @return long |
466 | 466 | */ |
467 | 467 | function parseDate($ts) { |
468 | - if(preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) { |
|
469 | - if ($matches[1] >= 2038){ |
|
468 | + if (preg_match("/(\d{4})[^0-9]*(\d{2})[^0-9]*(\d{2})(T(\d{2})[^0-9]*(\d{2})[^0-9]*(\d{2})(.\d+)?Z){0,1}$/", $ts, $matches)) { |
|
469 | + if ($matches[1] >= 2038) { |
|
470 | 470 | $matches[1] = 2038; |
471 | 471 | $matches[2] = 1; |
472 | 472 | $matches[3] = 18; |
@@ -77,14 +77,11 @@ discard block |
||
77 | 77 | $map = $this->mapping[$entity[EN_TAG]]; |
78 | 78 | if (isset($map[self::STREAMER_ARRAY])) { |
79 | 79 | $this->{$map[self::STREAMER_VAR]} = array(); |
80 | - } |
|
81 | - else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
|
80 | + } else if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
|
82 | 81 | $this->{$map[self::STREAMER_VAR]} = "1"; |
83 | - } |
|
84 | - else if(!isset($map[self::STREAMER_TYPE])) { |
|
82 | + } else if(!isset($map[self::STREAMER_TYPE])) { |
|
85 | 83 | $this->{$map[self::STREAMER_VAR]} = ""; |
86 | - } |
|
87 | - else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) { |
|
84 | + } else if ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES ) { |
|
88 | 85 | $this->{$map[self::STREAMER_VAR]} = ""; |
89 | 86 | } |
90 | 87 | continue; |
@@ -94,8 +91,7 @@ discard block |
||
94 | 91 | // This tag shouldn't be here, abort |
95 | 92 | ZLog::Write(LOGLEVEL_WBXMLSTACK, sprintf("Tag '%s' unexpected in type XML type '%s'", $entity[EN_TAG], get_class($this))); |
96 | 93 | return false; |
97 | - } |
|
98 | - else { |
|
94 | + } else { |
|
99 | 95 | $map = $this->mapping[$entity[EN_TAG]]; |
100 | 96 | |
101 | 97 | // Handle an array |
@@ -104,25 +100,28 @@ discard block |
||
104 | 100 | while(WBXMLDecoder::InWhile("decodeArray")) { |
105 | 101 | //do not get start tag for an array without a container |
106 | 102 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
107 | - if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) |
|
108 | - break; |
|
103 | + if(!$decoder->getElementStartTag($map[self::STREAMER_ARRAY])) { |
|
104 | + break; |
|
105 | + } |
|
109 | 106 | } |
110 | 107 | if(isset($map[self::STREAMER_TYPE])) { |
111 | 108 | $decoded = new $map[self::STREAMER_TYPE]; |
112 | 109 | |
113 | 110 | $decoded->Decode($decoder); |
114 | - } |
|
115 | - else { |
|
111 | + } else { |
|
116 | 112 | $decoded = $decoder->getElementContent(); |
117 | 113 | } |
118 | 114 | |
119 | - if(!isset($this->{$map[self::STREAMER_VAR]})) |
|
120 | - $this->{$map[self::STREAMER_VAR]} = array($decoded); |
|
121 | - else |
|
122 | - array_push($this->{$map[self::STREAMER_VAR]}, $decoded); |
|
115 | + if(!isset($this->{$map[self::STREAMER_VAR]})) { |
|
116 | + $this->{$map[self::STREAMER_VAR]} = array($decoded); |
|
117 | + } else { |
|
118 | + array_push($this->{$map[self::STREAMER_VAR]}, $decoded); |
|
119 | + } |
|
123 | 120 | |
124 | - if(!$decoder->getElementEndTag()) //end tag of a container element |
|
121 | + if(!$decoder->getElementEndTag()) { |
|
122 | + //end tag of a container element |
|
125 | 123 | return false; |
124 | + } |
|
126 | 125 | |
127 | 126 | if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER) { |
128 | 127 | $e = $decoder->peek(); |
@@ -131,47 +130,52 @@ discard block |
||
131 | 130 | continue 2; |
132 | 131 | } |
133 | 132 | //break on end tag because no container elements block end is reached |
134 | - if ($e[EN_TYPE] == EN_TYPE_ENDTAG) |
|
135 | - break; |
|
136 | - if (empty($e)) |
|
137 | - break; |
|
133 | + if ($e[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
134 | + break; |
|
135 | + } |
|
136 | + if (empty($e)) { |
|
137 | + break; |
|
138 | + } |
|
138 | 139 | } |
139 | 140 | } |
140 | 141 | //do not get end tag for an array without a container |
141 | 142 | if (!(isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_NO_CONTAINER)) { |
142 | - if(!$decoder->getElementEndTag()) //end tag of container |
|
143 | + if(!$decoder->getElementEndTag()) { |
|
144 | + //end tag of container |
|
143 | 145 | return false; |
146 | + } |
|
144 | 147 | } |
145 | - } |
|
146 | - else { // Handle single value |
|
148 | + } else { // Handle single value |
|
147 | 149 | if(isset($map[self::STREAMER_TYPE])) { |
148 | 150 | // Complex type, decode recursively |
149 | 151 | if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES) { |
150 | 152 | $decoded = $this->parseDate($decoder->getElementContent()); |
151 | - if(!$decoder->getElementEndTag()) |
|
152 | - return false; |
|
153 | - } |
|
154 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
153 | + if(!$decoder->getElementEndTag()) { |
|
154 | + return false; |
|
155 | + } |
|
156 | + } else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
155 | 157 | $decoded = hex2bin($decoder->getElementContent()); |
156 | - if(!$decoder->getElementEndTag()) |
|
157 | - return false; |
|
158 | + if(!$decoder->getElementEndTag()) { |
|
159 | + return false; |
|
160 | + } |
|
158 | 161 | } |
159 | 162 | // explode comma or semicolon strings into arrays |
160 | 163 | else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED) { |
161 | 164 | $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
162 | 165 | $decoded = explode($glue, $decoder->getElementContent()); |
163 | - if(!$decoder->getElementEndTag()) |
|
164 | - return false; |
|
165 | - } |
|
166 | - else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
166 | + if(!$decoder->getElementEndTag()) { |
|
167 | + return false; |
|
168 | + } |
|
169 | + } else if($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
167 | 170 | $decoded = StringStreamWrapper::Open($decoder->getElementContent()); |
168 | - if(!$decoder->getElementEndTag()) |
|
169 | - return false; |
|
170 | - } |
|
171 | - else { |
|
171 | + if(!$decoder->getElementEndTag()) { |
|
172 | + return false; |
|
173 | + } |
|
174 | + } else { |
|
172 | 175 | $subdecoder = new $map[self::STREAMER_TYPE](); |
173 | - if($subdecoder->Decode($decoder) === false) |
|
174 | - return false; |
|
176 | + if($subdecoder->Decode($decoder) === false) { |
|
177 | + return false; |
|
178 | + } |
|
175 | 179 | |
176 | 180 | $decoded = $subdecoder; |
177 | 181 | |
@@ -180,8 +184,7 @@ discard block |
||
180 | 184 | return false; |
181 | 185 | } |
182 | 186 | } |
183 | - } |
|
184 | - else { |
|
187 | + } else { |
|
185 | 188 | // Simple type, just get content |
186 | 189 | $decoded = $decoder->getElementContent(); |
187 | 190 | |
@@ -200,12 +203,10 @@ discard block |
||
200 | 203 | $this->{$map[self::STREAMER_VAR]} = $decoded; |
201 | 204 | } |
202 | 205 | } |
203 | - } |
|
204 | - else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
206 | + } else if($entity[EN_TYPE] == EN_TYPE_ENDTAG) { |
|
205 | 207 | $decoder->ungetElement($entity); |
206 | 208 | break; |
207 | - } |
|
208 | - else { |
|
209 | + } else { |
|
209 | 210 | ZLog::Write(LOGLEVEL_WBXMLSTACK, "Unexpected content in type"); |
210 | 211 | break; |
211 | 212 | } |
@@ -232,30 +233,30 @@ discard block |
||
232 | 233 | $res = $this->{$map[self::STREAMER_VAR]}->Encode($encoder); |
233 | 234 | $encoder->endTag(); |
234 | 235 | // nothing was streamed in previous encode but it should be streamed empty anyway |
235 | - if (!$res && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) |
|
236 | - $encoder->startTag($tag, false, true); |
|
236 | + if (!$res && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
|
237 | + $encoder->startTag($tag, false, true); |
|
238 | + } |
|
239 | + } else { |
|
240 | + ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this))); |
|
237 | 241 | } |
238 | - else |
|
239 | - ZLog::Write(LOGLEVEL_ERROR, sprintf("Streamer->Encode(): parameter '%s' of object %s is not of type Streamer", $map[self::STREAMER_VAR], get_class($this))); |
|
240 | 242 | } |
241 | 243 | // Array of objects |
242 | 244 | else if(isset($map[self::STREAMER_ARRAY])) { |
243 | 245 | if (empty($this->{$map[self::STREAMER_VAR]}) && isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
244 | 246 | $encoder->startTag($tag, false, true); |
245 | - } |
|
246 | - else { |
|
247 | + } else { |
|
247 | 248 | // Outputs array container (eg Attachments) |
248 | 249 | // Do not output start and end tag when type is STREAMER_TYPE_NO_CONTAINER |
249 | - if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
250 | - $encoder->startTag($tag); |
|
250 | + if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) { |
|
251 | + $encoder->startTag($tag); |
|
252 | + } |
|
251 | 253 | |
252 | 254 | foreach ($this->{$map[self::STREAMER_VAR]} as $element) { |
253 | 255 | if(is_object($element)) { |
254 | 256 | $encoder->startTag($map[self::STREAMER_ARRAY]); // Outputs object container (eg Attachment) |
255 | 257 | $element->Encode($encoder); |
256 | 258 | $encoder->endTag(); |
257 | - } |
|
258 | - else { |
|
259 | + } else { |
|
259 | 260 | if(strlen($element) == 0) |
260 | 261 | // Do not output empty items. Not sure if we should output an empty tag with $encoder->startTag($map[self::STREAMER_ARRAY], false, true); |
261 | 262 | ; |
@@ -268,11 +269,11 @@ discard block |
||
268 | 269 | } |
269 | 270 | } |
270 | 271 | |
271 | - if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) |
|
272 | - $encoder->endTag(); |
|
272 | + if (!isset($map[self::STREAMER_PROP]) || $map[self::STREAMER_PROP] != self::STREAMER_TYPE_NO_CONTAINER) { |
|
273 | + $encoder->endTag(); |
|
274 | + } |
|
273 | 275 | } |
274 | - } |
|
275 | - else { |
|
276 | + } else { |
|
276 | 277 | if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_IGNORE) { |
277 | 278 | continue; |
278 | 279 | } |
@@ -288,25 +289,26 @@ discard block |
||
288 | 289 | // Simple type |
289 | 290 | if(!isset($map[self::STREAMER_TYPE]) && strlen($this->{$map[self::STREAMER_VAR]}) == 0) { |
290 | 291 | // send empty tags |
291 | - if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) |
|
292 | - $encoder->startTag($tag, false, true); |
|
292 | + if (isset($map[self::STREAMER_PROP]) && $map[self::STREAMER_PROP] == self::STREAMER_TYPE_SEND_EMPTY) { |
|
293 | + $encoder->startTag($tag, false, true); |
|
294 | + } |
|
293 | 295 | |
294 | 296 | // Do not output empty items. See above: $encoder->startTag($tag, false, true); |
295 | 297 | continue; |
296 | - } else |
|
297 | - $encoder->startTag($tag); |
|
298 | + } else { |
|
299 | + $encoder->startTag($tag); |
|
300 | + } |
|
298 | 301 | |
299 | 302 | if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_DATE_DASHES)) { |
300 | - if($this->{$map[self::STREAMER_VAR]} != 0) // don't output 1-1-1970 |
|
303 | + if($this->{$map[self::STREAMER_VAR]} != 0) { |
|
304 | + // don't output 1-1-1970 |
|
301 | 305 | $encoder->content($this->formatDate($this->{$map[self::STREAMER_VAR]}, $map[self::STREAMER_TYPE])); |
302 | - } |
|
303 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
306 | + } |
|
307 | + } else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_HEX) { |
|
304 | 308 | $encoder->content(strtoupper(bin2hex($this->{$map[self::STREAMER_VAR]}))); |
305 | - } |
|
306 | - else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
309 | + } else if(isset($map[self::STREAMER_TYPE]) && $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASPLAIN) { |
|
307 | 310 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, false); |
308 | - } |
|
309 | - else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
311 | + } else if(isset($map[self::STREAMER_TYPE]) && ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM_ASBASE64 || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_STREAM)) { |
|
310 | 312 | $encoder->contentStream($this->{$map[self::STREAMER_VAR]}, true); |
311 | 313 | } |
312 | 314 | // implode comma or semicolon arrays into a string |
@@ -314,8 +316,7 @@ discard block |
||
314 | 316 | ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED || $map[self::STREAMER_TYPE] == self::STREAMER_TYPE_SEMICOLON_SEPARATED)) { |
315 | 317 | $glue = ($map[self::STREAMER_TYPE] == self::STREAMER_TYPE_COMMA_SEPARATED)?", ":"; "; |
316 | 318 | $encoder->content(implode($glue, $this->{$map[self::STREAMER_VAR]})); |
317 | - } |
|
318 | - else { |
|
319 | + } else { |
|
319 | 320 | $encoder->content($this->{$map[self::STREAMER_VAR]}); |
320 | 321 | } |
321 | 322 | $encoder->endTag(); |
@@ -324,8 +325,9 @@ discard block |
||
324 | 325 | } |
325 | 326 | } |
326 | 327 | // Output our own content |
327 | - if(isset($this->content)) |
|
328 | - $encoder->content($this->content); |
|
328 | + if(isset($this->content)) { |
|
329 | + $encoder->content($this->content); |
|
330 | + } |
|
329 | 331 | |
330 | 332 | return $streamed; |
331 | 333 | } |
@@ -341,27 +343,22 @@ discard block |
||
341 | 343 | if (isset($this->{$v[self::STREAMER_VAR]})) { |
342 | 344 | if (is_object($this->{$v[self::STREAMER_VAR]}) && method_exists($this->{$v[self::STREAMER_VAR]}, "StripData") ) { |
343 | 345 | $this->{$v[self::STREAMER_VAR]}->StripData($flags); |
344 | - } |
|
345 | - else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) { |
|
346 | + } else if (isset($v[self::STREAMER_ARRAY]) && !empty($this->{$v[self::STREAMER_VAR]})) { |
|
346 | 347 | foreach ($this->{$v[self::STREAMER_VAR]} as $element) { |
347 | 348 | if (is_object($element) && method_exists($element, "StripData") ) { |
348 | 349 | $element->StripData($flags); |
349 | - } |
|
350 | - elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
|
350 | + } elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
|
351 | 351 | if ($v[self::STREAMER_PRIVATE] !== true) { |
352 | 352 | $this->{$v[self::STREAMER_VAR]} = $v[self::STREAMER_PRIVATE]; |
353 | - } |
|
354 | - else { |
|
353 | + } else { |
|
355 | 354 | unset($this->{$v[self::STREAMER_VAR]}); |
356 | 355 | } |
357 | 356 | } |
358 | 357 | } |
359 | - } |
|
360 | - elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
|
358 | + } elseif ($flags === Streamer::STRIP_PRIVATE_DATA && isset($v[self::STREAMER_PRIVATE])) { |
|
361 | 359 | if ($v[self::STREAMER_PRIVATE] !== true) { |
362 | 360 | $this->{$v[self::STREAMER_VAR]} = $v[self::STREAMER_PRIVATE]; |
363 | - } |
|
364 | - else { |
|
361 | + } else { |
|
365 | 362 | unset($this->{$v[self::STREAMER_VAR]}); |
366 | 363 | } |
367 | 364 | } |
@@ -423,8 +420,7 @@ discard block |
||
423 | 420 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("Streamer->jsonDeserialize(): top class '%s'", $v->gsSyncStateClass)); |
424 | 421 | $this->$k = new $v->gsSyncStateClass; |
425 | 422 | $this->$k->jsonDeserialize($v); |
426 | - } |
|
427 | - else { |
|
423 | + } else { |
|
428 | 424 | $this->$k = $v; |
429 | 425 | } |
430 | 426 | } |
@@ -448,10 +444,11 @@ discard block |
||
448 | 444 | * @return string |
449 | 445 | */ |
450 | 446 | private function formatDate($ts, $type) { |
451 | - if($type == self::STREAMER_TYPE_DATE) |
|
452 | - return gmstrftime("%Y%m%dT%H%M%SZ", $ts); |
|
453 | - else if($type == self::STREAMER_TYPE_DATE_DASHES) |
|
454 | - return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
|
447 | + if($type == self::STREAMER_TYPE_DATE) { |
|
448 | + return gmstrftime("%Y%m%dT%H%M%SZ", $ts); |
|
449 | + } else if($type == self::STREAMER_TYPE_DATE_DASHES) { |
|
450 | + return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
|
451 | + } |
|
455 | 452 | // fallback to dashes (should never be reached) |
456 | 453 | return gmstrftime("%Y-%m-%dT%H:%M:%S.000Z", $ts); |
457 | 454 | } |
@@ -473,9 +470,15 @@ discard block |
||
473 | 470 | $matches[5] = $matches[6] = $matches[7] = 0; |
474 | 471 | } |
475 | 472 | |
476 | - if (!isset($matches[5])) $matches[5] = 0; |
|
477 | - if (!isset($matches[6])) $matches[6] = 0; |
|
478 | - if (!isset($matches[7])) $matches[7] = 0; |
|
473 | + if (!isset($matches[5])) { |
|
474 | + $matches[5] = 0; |
|
475 | + } |
|
476 | + if (!isset($matches[6])) { |
|
477 | + $matches[6] = 0; |
|
478 | + } |
|
479 | + if (!isset($matches[7])) { |
|
480 | + $matches[7] = 0; |
|
481 | + } |
|
479 | 482 | |
480 | 483 | return gmmktime($matches[5], $matches[6], $matches[7], $matches[2], $matches[3], $matches[1]); |
481 | 484 | } |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return boolean |
127 | 127 | */ |
128 | 128 | public function ProcessLoopDetectionAddStatus($folderid, $status) { |
129 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionAddStatus: '%s' with status %d", $folderid?$folderid:'hierarchy', $status)); |
|
129 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionAddStatus: '%s' with status %d", $folderid ? $folderid : 'hierarchy', $status)); |
|
130 | 130 | // generate entry if not already there |
131 | 131 | self::GetProcessEntry(); |
132 | 132 | |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | |
182 | 182 | $lookback = self::$start - 600; // look at the last 5 min |
183 | 183 | foreach ($this->getProcessStack() as $se) { |
184 | - if ($se['time'] > $lookback && $se['time'] < (self::$start-1)) { |
|
184 | + if ($se['time'] > $lookback && $se['time'] < (self::$start - 1)) { |
|
185 | 185 | // look for sync command |
186 | 186 | if (isset($se['stat']) && ($se['cc'] == ZPush::COMMAND_SYNC || $se['cc'] == ZPush::COMMAND_PING)) { |
187 | - foreach($se['stat'] as $key => $value) { |
|
187 | + foreach ($se['stat'] as $key => $value) { |
|
188 | 188 | // we only care about hierarchy errors of this folder |
189 | 189 | if ($se['cc'] == ZPush::COMMAND_SYNC) { |
190 | 190 | if ($value == SYNC_STATUS_FOLDERHIERARCHYCHANGED) { |
191 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): seen Sync command with Exception or folderid '%s' and code '%s'", $key, $value )); |
|
191 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): seen Sync command with Exception or folderid '%s' and code '%s'", $key, $value)); |
|
192 | 192 | } |
193 | 193 | } |
194 | 194 | if (!isset($loopingFolders[$key])) { |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | } |
215 | 215 | // Sync is executed, but a foldersync should be executed (hierarchy errors) |
216 | 216 | if (isset($data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED]) && |
217 | - $data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED] > 3 ) { |
|
217 | + $data[ZPush::COMMAND_SYNC][SYNC_STATUS_FOLDERHIERARCHYCHANGED] > 3) { |
|
218 | 218 | ZLog::Write(LOGLEVEL_INFO, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchySyncAdvised(): Sync(with error)/Ping loop of folderid '%s' detected.", $fid)); |
219 | 219 | return true; |
220 | 220 | } |
@@ -248,19 +248,19 @@ discard block |
||
248 | 248 | |
249 | 249 | $lookback = self::$start - 600; // look at the last 5 min |
250 | 250 | foreach ($this->getProcessStack() as $se) { |
251 | - if ($se['time'] > $lookback && $se['time'] < (self::$start-1)) { |
|
251 | + if ($se['time'] > $lookback && $se['time'] < (self::$start - 1)) { |
|
252 | 252 | // look for sync command |
253 | 253 | if (isset($se['stat']) && ($se['cc'] == ZPush::COMMAND_SYNC || $se['cc'] == ZPush::COMMAND_PING)) { |
254 | - foreach($se['stat'] as $key => $value) { |
|
254 | + foreach ($se['stat'] as $key => $value) { |
|
255 | 255 | // don't count PING with changes on a folder or sync with success |
256 | 256 | if (($se['cc'] == ZPush::COMMAND_PING && $value == SYNC_PINGSTATUS_CHANGES) || |
257 | - ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS) ) { |
|
257 | + ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS)) { |
|
258 | 258 | continue; |
259 | 259 | } |
260 | 260 | if (!isset($seenFailed[$key])) |
261 | 261 | $seenFailed[$key] = 0; |
262 | 262 | $seenFailed[$key]++; |
263 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value )); |
|
263 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value)); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | // look for FolderSync command with previous failed commands |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | $filtered = array(); |
283 | 283 | foreach ($seenFailed as $k => $count) { |
284 | - if ($count>1) |
|
284 | + if ($count > 1) |
|
285 | 285 | $filtered[] = $k; |
286 | 286 | } |
287 | 287 | |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | $errors = false; |
308 | 308 | if (count($stack) > 1) { |
309 | 309 | $se = $stack[0]; |
310 | - if (!isset($se['end']) && $se['cc'] != ZPush::COMMAND_PING && !isset($se['push']) ) { |
|
310 | + if (!isset($se['end']) && $se['cc'] != ZPush::COMMAND_PING && !isset($se['push'])) { |
|
311 | 311 | // there is no end time |
312 | 312 | ZLog::Write(LOGLEVEL_ERROR, sprintf("LoopDetection->ProcessLoopDetectionPreviousConnectionFailed(): Command '%s' at %s with pid '%d' terminated unexpectedly or is still running.", Utils::GetCommandFromCode($se['cc']), Utils::GetFormattedTime($se['time']), $se['pid'])); |
313 | 313 | ZLog::Write(LOGLEVEL_ERROR, "Please check your logs for this PID and errors like PHP-Fatals or Apache segmentation faults and report your results to the grommunio dev team."); |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | |
350 | 350 | $ok = false; |
351 | 351 | $tryCount = 1; |
352 | - while(! $ok && $tryCount < 5) { |
|
352 | + while (!$ok && $tryCount < 5) { |
|
353 | 353 | list($stack, $stackRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, self::INTERPROCESSLD, true); |
354 | 354 | |
355 | 355 | // insert/update current process entry |
@@ -374,7 +374,7 @@ discard block |
||
374 | 374 | $nstack = array_slice($nstack, -10, 10); |
375 | 375 | |
376 | 376 | // update loop data |
377 | - $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas="replace", $stackRaw); |
|
377 | + $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas = "replace", $stackRaw); |
|
378 | 378 | if (!$ok) { |
379 | 379 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->updateProcessStack(): CAS failed on try %d!", $tryCount)); |
380 | 380 | usleep(100000); |
@@ -422,19 +422,19 @@ discard block |
||
422 | 422 | return false; |
423 | 423 | |
424 | 424 | $ok = false; |
425 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
425 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
426 | 426 | |
427 | 427 | // initialize params |
428 | 428 | $this->initializeParams(); |
429 | 429 | $tryCount = 1; |
430 | - while(! $ok && $tryCount < 5) { |
|
430 | + while (!$ok && $tryCount < 5) { |
|
431 | 431 | list($brokenmsgs, $brokenmsgsRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey, true); |
432 | 432 | |
433 | 433 | $brokenmsgs[$id] = array('uuid' => $this->broken_message_uuid, 'counter' => $this->broken_message_counter); |
434 | 434 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->SetBrokenMessage('%s', '%s'): tracking broken message", $folderid, $id)); |
435 | 435 | |
436 | 436 | // update data |
437 | - $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw); |
|
437 | + $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas = "replace", $brokenmsgsRaw); |
|
438 | 438 | if (!$ok) { |
439 | 439 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->SetBrokenMessage(): CAS failed on try %d!", $tryCount)); |
440 | 440 | usleep(100000); |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) |
460 | 460 | return array(); |
461 | 461 | |
462 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
462 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
463 | 463 | $removeIds = array(); |
464 | 464 | $okIds = array(); |
465 | 465 | |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | |
469 | 469 | $ok = false; |
470 | 470 | $tryCount = 1; |
471 | - while(! $ok && $tryCount < 5) { |
|
471 | + while (!$ok && $tryCount < 5) { |
|
472 | 472 | list($brokenmsgs, $brokenmsgsRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey, true); |
473 | 473 | |
474 | 474 | if (empty($brokenmsgs)) { |
@@ -490,7 +490,7 @@ discard block |
||
490 | 490 | } |
491 | 491 | |
492 | 492 | // remove data |
493 | - foreach (array_merge($okIds,$removeIds) as $id) { |
|
493 | + foreach (array_merge($okIds, $removeIds) as $id) { |
|
494 | 494 | unset($brokenmsgs[$id]); |
495 | 495 | } |
496 | 496 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | } |
502 | 502 | else { |
503 | 503 | // update data |
504 | - $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw); |
|
504 | + $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas = "replace", $brokenmsgsRaw); |
|
505 | 505 | if (!$ok) { |
506 | 506 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->GetSyncedButBeforeIgnoredMessages(): CAS failed on try %d!", $tryCount)); |
507 | 507 | usleep(100000); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | |
535 | 535 | $ok = false; |
536 | 536 | $tryCount = 1; |
537 | - while(! $ok && $tryCount < 5) { |
|
537 | + while (!$ok && $tryCount < 5) { |
|
538 | 538 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
539 | 539 | |
540 | 540 | if (!isset($current["uuid"])) { |
@@ -551,7 +551,7 @@ discard block |
||
551 | 551 | $current["usage"] = $counter; |
552 | 552 | |
553 | 553 | // update loop data |
554 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
554 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
555 | 555 | if (!$ok) { |
556 | 556 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->SetSyncStateUsage(): CAS failed on try %d!", $tryCount)); |
557 | 557 | usleep(100000); |
@@ -595,8 +595,8 @@ discard block |
||
595 | 595 | ($current["count"] == $counter && $current["queued"] > 0) || |
596 | 596 | (isset($current["usage"]) && $current["usage"] >= $counter) |
597 | 597 | )) { |
598 | - $usage = isset($current["usage"]) ? sprintf(" - counter %d already expired",$current["usage"]) : ""; |
|
599 | - ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed". $usage); |
|
598 | + $usage = isset($current["usage"]) ? sprintf(" - counter %d already expired", $current["usage"]) : ""; |
|
599 | + ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, counter already processed".$usage); |
|
600 | 600 | $obsolete = true; |
601 | 601 | } |
602 | 602 | } |
@@ -657,20 +657,20 @@ discard block |
||
657 | 657 | |
658 | 658 | $ok = false; |
659 | 659 | $tryCount = 1; |
660 | - while(! $ok && $tryCount < 5) { |
|
660 | + while (!$ok && $tryCount < 5) { |
|
661 | 661 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
662 | 662 | |
663 | 663 | // completely new/unknown UUID |
664 | 664 | if (empty($current)) |
665 | - $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages); |
|
665 | + $current = array("uuid" => $uuid, "count" => $counter - 1, "queued" => $queuedMessages); |
|
666 | 666 | |
667 | 667 | // old UUID in cache - the device requested a new state!! |
668 | - if (isset($current['uuid']) && $current['uuid'] != $uuid ) { |
|
668 | + if (isset($current['uuid']) && $current['uuid'] != $uuid) { |
|
669 | 669 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed for folder"); |
670 | 670 | |
671 | 671 | // some devices (iPhones) may request new UUIDs after broken items were sent several times |
672 | 672 | if (isset($current['queued']) && $current['queued'] > 0 && |
673 | - (isset($current['maxCount']) && $current['count']+1 < $current['maxCount'] || $counter == 1)) { |
|
673 | + (isset($current['maxCount']) && $current['count'] + 1 < $current['maxCount'] || $counter == 1)) { |
|
674 | 674 | |
675 | 675 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed and while items where sent to device - forcing loop mode"); |
676 | 676 | $loop = true; // force loop mode |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | $current['loopcount'] = 1; |
758 | 758 | // the MaxCount is the max number of messages exported before |
759 | 759 | $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages); |
760 | - $loop = true; // loop mode!! |
|
760 | + $loop = true; // loop mode!! |
|
761 | 761 | } |
762 | 762 | } |
763 | 763 | else if ($queuedMessages == 0) { |
@@ -781,16 +781,16 @@ discard block |
||
781 | 781 | $this->ignore_messageid = $current['potential']; |
782 | 782 | } |
783 | 783 | $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages); |
784 | - $loop = true; // loop mode!! |
|
784 | + $loop = true; // loop mode!! |
|
785 | 785 | } |
786 | 786 | } |
787 | 787 | |
788 | 788 | } |
789 | 789 | if (isset($current['loopcount'])) |
790 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false'))); |
|
790 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored']) ? $current['ignored'] : 'false'))); |
|
791 | 791 | |
792 | 792 | // update loop data |
793 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
793 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
794 | 794 | if (!$ok) { |
795 | 795 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->Detect(): CAS failed on try %d!", $tryCount)); |
796 | 796 | usleep(100000); |
@@ -844,7 +844,7 @@ discard block |
||
844 | 844 | $changedData = false; |
845 | 845 | $ok = false; |
846 | 846 | $tryCount = 1; |
847 | - while(! $ok && $tryCount < 5) { |
|
847 | + while (!$ok && $tryCount < 5) { |
|
848 | 848 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
849 | 849 | |
850 | 850 | // we found our broken message! |
@@ -854,7 +854,7 @@ discard block |
||
854 | 854 | $changedData = true; |
855 | 855 | |
856 | 856 | // check if this message was broken before - here we know that it still is and remove it from the tracking |
857 | - $brokenkey = self::BROKENMSGS ."-". $folderid; |
|
857 | + $brokenkey = self::BROKENMSGS."-".$folderid; |
|
858 | 858 | // TODO: this is currently not supported here! It's in a different structure now! |
859 | 859 | // if (isset($loopdata[self::$devid][self::$user][$brokenkey]) && isset($loopdata[self::$devid][self::$user][$brokenkey][$messageid])) { |
860 | 860 | // ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IgnoreNextMessage(): previously broken message '%s' is still broken and will not be tracked anymore", $messageid)); |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | break; |
885 | 885 | } |
886 | 886 | // update loop data |
887 | - $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
|
887 | + $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas = "replace", $currentRaw); |
|
888 | 888 | if (!$ok) { |
889 | 889 | ZLog::Write(LOGLEVEL_WARN, sprintf("LoopDetection->Detect(): CAS failed on try %d!", $tryCount)); |
890 | 890 | usleep(100000); |
@@ -71,8 +71,9 @@ discard block |
||
71 | 71 | * @return string |
72 | 72 | */ |
73 | 73 | public static function GetProcessIdentifier() { |
74 | - if (!isset(self::$processident)) |
|
75 | - self::$processident = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff)); |
|
74 | + if (!isset(self::$processident)) { |
|
75 | + self::$processident = sprintf('%04x%04x', mt_rand(0, 0xffff), mt_rand(0, 0xffff)); |
|
76 | + } |
|
76 | 77 | |
77 | 78 | return self::$processident; |
78 | 79 | } |
@@ -107,8 +108,9 @@ discard block |
||
107 | 108 | // generate entry if not already there |
108 | 109 | self::GetProcessEntry(); |
109 | 110 | |
110 | - if (!isset(self::$processentry['stat'])) |
|
111 | - self::$processentry['stat'] = array(); |
|
111 | + if (!isset(self::$processentry['stat'])) { |
|
112 | + self::$processentry['stat'] = array(); |
|
113 | + } |
|
112 | 114 | |
113 | 115 | self::$processentry['stat'][get_class($exception)] = $exception->getCode(); |
114 | 116 | |
@@ -130,11 +132,13 @@ discard block |
||
130 | 132 | // generate entry if not already there |
131 | 133 | self::GetProcessEntry(); |
132 | 134 | |
133 | - if ($folderid === false) |
|
134 | - $folderid = "hierarchy"; |
|
135 | + if ($folderid === false) { |
|
136 | + $folderid = "hierarchy"; |
|
137 | + } |
|
135 | 138 | |
136 | - if (!isset(self::$processentry['stat'])) |
|
137 | - self::$processentry['stat'] = array(); |
|
139 | + if (!isset(self::$processentry['stat'])) { |
|
140 | + self::$processentry['stat'] = array(); |
|
141 | + } |
|
138 | 142 | |
139 | 143 | self::$processentry['stat'][$folderid] = $status; |
140 | 144 | |
@@ -257,8 +261,9 @@ discard block |
||
257 | 261 | ($se['cc'] == ZPush::COMMAND_SYNC && $value == SYNC_STATUS_SUCCESS) ) { |
258 | 262 | continue; |
259 | 263 | } |
260 | - if (!isset($seenFailed[$key])) |
|
261 | - $seenFailed[$key] = 0; |
|
264 | + if (!isset($seenFailed[$key])) { |
|
265 | + $seenFailed[$key] = 0; |
|
266 | + } |
|
262 | 267 | $seenFailed[$key]++; |
263 | 268 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen command with Exception or folderid '%s' and code '%s'", $key, $value )); |
264 | 269 | } |
@@ -269,11 +274,11 @@ discard block |
||
269 | 274 | if (isset($se['stat']) && isset($se['stat']['hierarchy']) && $se['stat']['hierarchy'] == SYNC_FSSTATUS_SYNCKEYERROR) { |
270 | 275 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): a full FolderReSync was already requested. Resetting fail counter."); |
271 | 276 | $seenFailed = array(); |
272 | - } |
|
273 | - else { |
|
277 | + } else { |
|
274 | 278 | $seenFolderSync = true; |
275 | - if (!empty($seenFailed)) |
|
276 | - ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen FolderSync after other failing command"); |
|
279 | + if (!empty($seenFailed)) { |
|
280 | + ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->ProcessLoopDetectionIsHierarchyResyncRequired(): seen FolderSync after other failing command"); |
|
281 | + } |
|
277 | 282 | } |
278 | 283 | } |
279 | 284 | } |
@@ -281,8 +286,9 @@ discard block |
||
281 | 286 | |
282 | 287 | $filtered = array(); |
283 | 288 | foreach ($seenFailed as $k => $count) { |
284 | - if ($count>1) |
|
285 | - $filtered[] = $k; |
|
289 | + if ($count>1) { |
|
290 | + $filtered[] = $k; |
|
291 | + } |
|
286 | 292 | } |
287 | 293 | |
288 | 294 | if ($seenFolderSync && !empty($filtered)) { |
@@ -360,18 +366,19 @@ discard block |
||
360 | 366 | foreach ($stack as $entry) { |
361 | 367 | if ($entry['id'] != $updateentry['id']) { |
362 | 368 | $nstack[] = $entry; |
363 | - } |
|
364 | - else { |
|
369 | + } else { |
|
365 | 370 | $nstack[] = $updateentry; |
366 | 371 | $found = true; |
367 | 372 | } |
368 | 373 | } |
369 | 374 | |
370 | - if (!$found) |
|
371 | - $nstack[] = $updateentry; |
|
375 | + if (!$found) { |
|
376 | + $nstack[] = $updateentry; |
|
377 | + } |
|
372 | 378 | |
373 | - if (count($nstack) > 10) |
|
374 | - $nstack = array_slice($nstack, -10, 10); |
|
379 | + if (count($nstack) > 10) { |
|
380 | + $nstack = array_slice($nstack, -10, 10); |
|
381 | + } |
|
375 | 382 | |
376 | 383 | // update loop data |
377 | 384 | $ok = $this->setDeviceUserData($this->type, $nstack, parent::$devid, parent::$user, self::INTERPROCESSLD, $doCas="replace", $stackRaw); |
@@ -418,8 +425,9 @@ discard block |
||
418 | 425 | * @return boolean |
419 | 426 | */ |
420 | 427 | public function SetBrokenMessage($folderid, $id) { |
421 | - if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) |
|
422 | - return false; |
|
428 | + if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) { |
|
429 | + return false; |
|
430 | + } |
|
423 | 431 | |
424 | 432 | $ok = false; |
425 | 433 | $brokenkey = self::BROKENMSGS ."-". $folderid; |
@@ -456,8 +464,9 @@ discard block |
||
456 | 464 | * @return array |
457 | 465 | */ |
458 | 466 | public function GetSyncedButBeforeIgnoredMessages($folderid) { |
459 | - if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) |
|
460 | - return array(); |
|
467 | + if ($folderid == false || !isset($this->broken_message_uuid) || !isset($this->broken_message_counter) || $this->broken_message_uuid == false || $this->broken_message_counter == false) { |
|
468 | + return array(); |
|
469 | + } |
|
461 | 470 | |
462 | 471 | $brokenkey = self::BROKENMSGS ."-". $folderid; |
463 | 472 | $removeIds = array(); |
@@ -473,8 +482,7 @@ discard block |
||
473 | 482 | |
474 | 483 | if (empty($brokenmsgs)) { |
475 | 484 | break; |
476 | - } |
|
477 | - else { |
|
485 | + } else { |
|
478 | 486 | foreach ($brokenmsgs as $id => $data) { |
479 | 487 | // previously broken message was successfully synced! |
480 | 488 | if ($data['uuid'] == $this->broken_message_uuid && $data['counter'] < $this->broken_message_counter) { |
@@ -498,8 +506,7 @@ discard block |
||
498 | 506 | $this->delDeviceUserData($this->type, parent::$devid, parent::$user, $brokenkey); |
499 | 507 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->GetSyncedButBeforeIgnoredMessages('%s'): removed folder from tracking of ignored messages", $folderid)); |
500 | 508 | break; |
501 | - } |
|
502 | - else { |
|
509 | + } else { |
|
503 | 510 | // update data |
504 | 511 | $ok = $this->setDeviceUserData($this->type, $brokenmsgs, parent::$devid, parent::$user, $brokenkey, $doCas="replace", $brokenmsgsRaw); |
505 | 512 | if (!$ok) { |
@@ -585,8 +592,7 @@ discard block |
||
585 | 592 | if (!isset($current["uuid"]) || $current["uuid"] != $uuid) { |
586 | 593 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->IsSyncStateObsolete(): yes, uuid changed or not set"); |
587 | 594 | $obsolete = true; |
588 | - } |
|
589 | - else { |
|
595 | + } else { |
|
590 | 596 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - last counter: %d with %d queued", |
591 | 597 | $folderid, $uuid, $counter, $current["count"], $current["queued"])); |
592 | 598 | |
@@ -600,8 +606,7 @@ discard block |
||
600 | 606 | $obsolete = true; |
601 | 607 | } |
602 | 608 | } |
603 | - } |
|
604 | - else { |
|
609 | + } else { |
|
605 | 610 | ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->IsSyncStateObsolete(): check folderid: '%s' uuid '%s' counter: %d - no data found: not obsolete", $folderid, $uuid, $counter)); |
606 | 611 | } |
607 | 612 | |
@@ -661,8 +666,9 @@ discard block |
||
661 | 666 | list($current, $currentRaw) = $this->getDeviceUserData($this->type, parent::$devid, parent::$user, $folderid, true); |
662 | 667 | |
663 | 668 | // completely new/unknown UUID |
664 | - if (empty($current)) |
|
665 | - $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages); |
|
669 | + if (empty($current)) { |
|
670 | + $current = array("uuid" => $uuid, "count" => $counter-1, "queued" => $queuedMessages); |
|
671 | + } |
|
666 | 672 | |
667 | 673 | // old UUID in cache - the device requested a new state!! |
668 | 674 | if (isset($current['uuid']) && $current['uuid'] != $uuid ) { |
@@ -675,8 +681,7 @@ discard block |
||
675 | 681 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): UUID changed and while items where sent to device - forcing loop mode"); |
676 | 682 | $loop = true; // force loop mode |
677 | 683 | $current['queued'] = $queuedMessages; |
678 | - } |
|
679 | - else { |
|
684 | + } else { |
|
680 | 685 | $current['queued'] = 0; |
681 | 686 | } |
682 | 687 | |
@@ -700,8 +705,9 @@ discard block |
||
700 | 705 | // case 1.1 |
701 | 706 | $current['count'] = $counter; |
702 | 707 | $current['queued'] = $queuedMessages; |
703 | - if (isset($current["usage"]) && $current["usage"] < $current['count']) |
|
704 | - unset($current["usage"]); |
|
708 | + if (isset($current["usage"]) && $current["usage"] < $current['count']) { |
|
709 | + unset($current["usage"]); |
|
710 | + } |
|
705 | 711 | |
706 | 712 | // case 1.2 |
707 | 713 | if (isset($current['maxCount'])) { |
@@ -729,8 +735,9 @@ discard block |
||
729 | 735 | // case 2 - same counter, but there were no changes before and are there now |
730 | 736 | else if ($current['count'] == $counter && $current['queued'] == 0 && $queuedMessages > 0) { |
731 | 737 | $current['queued'] = $queuedMessages; |
732 | - if (isset($current["usage"]) && $current["usage"] < $current['count']) |
|
733 | - unset($current["usage"]); |
|
738 | + if (isset($current["usage"]) && $current["usage"] < $current['count']) { |
|
739 | + unset($current["usage"]); |
|
740 | + } |
|
734 | 741 | } |
735 | 742 | |
736 | 743 | // case 3 - same counter, changes sent before, hanging loop and ignoring |
@@ -746,8 +753,7 @@ discard block |
||
746 | 753 | // return suggested new window size |
747 | 754 | $current['windowLimit'] = 25; |
748 | 755 | $loop = $current['windowLimit']; |
749 | - } |
|
750 | - else { |
|
756 | + } else { |
|
751 | 757 | // case 3.1) we have just encountered a loop! |
752 | 758 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.1 detected - loop detected, init loop mode"); |
753 | 759 | if (isset($current['windowLimit'])) { |
@@ -759,8 +765,7 @@ discard block |
||
759 | 765 | $current['maxCount'] = $counter + (($maxItems < $queuedMessages) ? $maxItems : $queuedMessages); |
760 | 766 | $loop = true; // loop mode!! |
761 | 767 | } |
762 | - } |
|
763 | - else if ($queuedMessages == 0) { |
|
768 | + } else if ($queuedMessages == 0) { |
|
764 | 769 | // case 3.2) there was a loop before but now the changes are GONE |
765 | 770 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.2 detected - changes gone - clearing loop data"); |
766 | 771 | $current['queued'] = 0; |
@@ -769,8 +774,7 @@ discard block |
||
769 | 774 | unset($current['maxCount']); |
770 | 775 | unset($current['potential']); |
771 | 776 | unset($current['windowLimit']); |
772 | - } |
|
773 | - else { |
|
777 | + } else { |
|
774 | 778 | // case 3.3) still looping the same message! Increase counter |
775 | 779 | ZLog::Write(LOGLEVEL_DEBUG, "LoopDetection->Detect(): case 3.3 detected - in loop mode, increase loop counter"); |
776 | 780 | $current['loopcount']++; |
@@ -786,8 +790,9 @@ discard block |
||
786 | 790 | } |
787 | 791 | |
788 | 792 | } |
789 | - if (isset($current['loopcount'])) |
|
790 | - ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false'))); |
|
793 | + if (isset($current['loopcount'])) { |
|
794 | + ZLog::Write(LOGLEVEL_DEBUG, sprintf("LoopDetection->Detect(): loop data: loopcount(%d), maxCount(%d), queued(%d), ignored(%s)", $current['loopcount'], $current['maxCount'], $current['queued'], (isset($current['ignored'])?$current['ignored']:'false'))); |
|
795 | + } |
|
791 | 796 | |
792 | 797 | // update loop data |
793 | 798 | $ok = $this->setDeviceUserData($this->type, $current, parent::$devid, parent::$user, $folderid, $doCas="replace", $currentRaw); |
@@ -824,11 +829,13 @@ discard block |
||
824 | 829 | |
825 | 830 | $potentialBroken = false; |
826 | 831 | $realBroken = false; |
827 | - if (Request::GetCommandCode() == ZPush::COMMAND_SYNC && $this->ignore_messageid !== false) |
|
828 | - $potentialBroken = true; |
|
832 | + if (Request::GetCommandCode() == ZPush::COMMAND_SYNC && $this->ignore_messageid !== false) { |
|
833 | + $potentialBroken = true; |
|
834 | + } |
|
829 | 835 | |
830 | - if ($messageid !== false && $this->ignore_messageid == $messageid) |
|
831 | - $realBroken = true; |
|
836 | + if ($messageid !== false && $this->ignore_messageid == $messageid) { |
|
837 | + $realBroken = true; |
|
838 | + } |
|
832 | 839 | |
833 | 840 | // this call is just to know what should be happening |
834 | 841 | // no further actions necessary |
@@ -892,8 +899,9 @@ discard block |
||
892 | 899 | } |
893 | 900 | } |
894 | 901 | |
895 | - if ($realBroken) |
|
896 | - ZPush::GetTopCollector()->AnnounceInformation("Broken message ignored", true); |
|
902 | + if ($realBroken) { |
|
903 | + ZPush::GetTopCollector()->AnnounceInformation("Broken message ignored", true); |
|
904 | + } |
|
897 | 905 | |
898 | 906 | return $realBroken; |
899 | 907 | } |
@@ -915,19 +923,20 @@ discard block |
||
915 | 923 | if ($this->blockMutex()) { |
916 | 924 | $loopdata = ($this->hasData()) ? $this->getData() : array(); |
917 | 925 | |
918 | - if ($user == false && $devid == false) |
|
919 | - $loopdata = array(); |
|
920 | - elseif ($user == false && $devid != false) |
|
921 | - $loopdata[$devid] = array(); |
|
922 | - elseif ($user != false && $devid != false) |
|
923 | - $loopdata[$devid][$user] = array(); |
|
924 | - elseif ($user != false && $devid == false) { |
|
926 | + if ($user == false && $devid == false) { |
|
927 | + $loopdata = array(); |
|
928 | + } elseif ($user == false && $devid != false) { |
|
929 | + $loopdata[$devid] = array(); |
|
930 | + } elseif ($user != false && $devid != false) { |
|
931 | + $loopdata[$devid][$user] = array(); |
|
932 | + } elseif ($user != false && $devid == false) { |
|
925 | 933 | ZLog::Write(LOGLEVEL_WARN, sprintf("Not possible to reset loop detection data for user '%s' without a specifying a device id", $user)); |
926 | 934 | $stat = false; |
927 | 935 | } |
928 | 936 | |
929 | - if ($stat) |
|
930 | - $ok = $this->setData($loopdata); |
|
937 | + if ($stat) { |
|
938 | + $ok = $this->setData($loopdata); |
|
939 | + } |
|
931 | 940 | |
932 | 941 | $this->releaseMutex(); |
933 | 942 | } |
@@ -955,8 +964,9 @@ discard block |
||
955 | 964 | $this->releaseMutex(); |
956 | 965 | } |
957 | 966 | // end exclusive block |
958 | - if (isset($loopdata) && isset($loopdata[$devid]) && isset($loopdata[$devid][$user])) |
|
959 | - return $loopdata[$devid][$user]; |
|
967 | + if (isset($loopdata) && isset($loopdata[$devid]) && isset($loopdata[$devid][$user])) { |
|
968 | + return $loopdata[$devid][$user]; |
|
969 | + } |
|
960 | 970 | |
961 | 971 | return false; |
962 | 972 | } |