Mercurial > hg > rc2
comparison program/lib/Roundcube/rcube_vcard.php @ 22:303b85d5b561
More cleaning up php8 Warnings/deprecations
| author | Charlie Root |
|---|---|
| date | Wed, 15 Oct 2025 14:06:27 -0400 |
| parents | 73124dd49283 |
| children | bea5a38be938 |
comparison
equal
deleted
inserted
replaced
| 21:73124dd49283 | 22:303b85d5b561 |
|---|---|
| 124 $this->raw = self::charset_convert($this->raw, $detected_charset); | 124 $this->raw = self::charset_convert($this->raw, $detected_charset); |
| 125 } | 125 } |
| 126 | 126 |
| 127 // find well-known address fields | 127 // find well-known address fields |
| 128 $this->displayname = $this->raw['FN'][0][0]; | 128 $this->displayname = $this->raw['FN'][0][0]; |
| 129 $this->surname = $this->raw['N'][0][0]; | 129 if (!empty($this->raw['N'])) { |
| 130 $this->firstname = $this->raw['N'][0][1]; | 130 $this->surname = $this->raw['N'][0][0]; |
| 131 $this->middlename = $this->raw['N'][0][2]; | 131 $this->firstname = $this->raw['N'][0][1]; |
| 132 $this->middlename = $this->raw['N'][0][2]; | |
| 133 } | |
| 132 $this->nickname = empty($this->raw['NICKNAME']) ? null : $this->raw['NICKNAME'][0][0]; | 134 $this->nickname = empty($this->raw['NICKNAME']) ? null : $this->raw['NICKNAME'][0][0]; |
| 133 $this->organization = empty($this->raw['ORG']) ? null : $this->raw['ORG'][0][0]; | 135 $this->organization = empty($this->raw['ORG']) ? null : $this->raw['ORG'][0][0]; |
| 134 $this->business = ($this->raw['X-ABSHOWAS'][0][0] == 'COMPANY') || (join('', (array)$this->raw['N'][0]) == '' && !empty($this->organization)); | 136 $this->business = (isset($this->raw['X-ABSHOWAS'][0][0]) && $this->raw['X-ABSHOWAS'][0][0] == 'COMPANY') |
| 135 | 137 || (!empty($this->organization) && isset($this->raw['N'][0]) && @implode('', (array) $this->raw['N'][0]) === ''); |
| 136 foreach ((array)$this->raw['EMAIL'] as $i => $raw_email) { | 138 |
| 137 $this->email[$i] = is_array($raw_email) ? $raw_email[0] : $raw_email; | 139 if (!empty($this->raw['EMAIL'])) { |
| 140 foreach ((array) $this->raw['EMAIL'] as $i => $raw_email) { | |
| 141 $this->email[$i] = is_array($raw_email) ? $raw_email[0] : $raw_email; | |
| 142 } | |
| 138 } | 143 } |
| 139 | 144 |
| 140 // make the pref e-mail address the first entry in $this->email | 145 // make the pref e-mail address the first entry in $this->email |
| 141 $pref_index = $this->get_type_index('EMAIL', 'pref'); | 146 $pref_index = $this->get_type_index('EMAIL', 'pref'); |
| 142 if ($pref_index > 0) { | 147 if ($pref_index > 0) { |
| 166 if (!empty($this->$col) && strlen($this->$col)) { | 171 if (!empty($this->$col) && strlen($this->$col)) { |
| 167 $out[$col] = $this->$col; | 172 $out[$col] = $this->$col; |
| 168 } | 173 } |
| 169 } | 174 } |
| 170 | 175 |
| 171 if ($this->raw['N'][0][3]) | 176 if (!empty($this->raw['N'])) { |
| 177 if ($this->raw['N'][0][3]) | |
| 172 $out['prefix'] = $this->raw['N'][0][3]; | 178 $out['prefix'] = $this->raw['N'][0][3]; |
| 173 if ($this->raw['N'][0][4]) | 179 if ($this->raw['N'][0][4]) |
| 174 $out['suffix'] = $this->raw['N'][0][4]; | 180 $out['suffix'] = $this->raw['N'][0][4]; |
| 175 | 181 } |
| 176 // convert from raw vcard data into associative data for Roundcube | 182 // convert from raw vcard data into associative data for Roundcube |
| 177 foreach (array_flip(self::$fieldmap) as $tag => $col) { | 183 foreach (array_flip(self::$fieldmap) as $tag => $col) { |
| 178 if (!empty($this->raw[$tag])) { | 184 if (!empty($this->raw[$tag])) { |
| 179 foreach ((array)$this->raw[$tag] as $i => $raw) { | 185 foreach ((array)$this->raw[$tag] as $i => $raw) { |
| 180 if (is_array($raw)) { | 186 if (is_array($raw)) { |
| 184 | 190 |
| 185 if (!empty($raw['type'])) { | 191 if (!empty($raw['type'])) { |
| 186 $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); | 192 $combined = join(',', self::array_filter((array)$raw['type'], 'internet,pref', true)); |
| 187 $combined = strtoupper($combined); | 193 $combined = strtoupper($combined); |
| 188 | 194 |
| 189 if ($typemap[$combined]) { | 195 if (!empty($typemap[$combined])) { |
| 190 $subtype = $typemap[$combined]; | 196 $subtype = $typemap[$combined]; |
| 191 } | 197 } |
| 192 else if ($typemap[$raw['type'][++$k]]) { | 198 else if (!empty($typemap[$raw['type'][++$k]])) { |
| 193 $subtype = $typemap[$raw['type'][$k]]; | 199 $subtype = $typemap[$raw['type'][$k]]; |
| 194 } | 200 } |
| 195 else { | 201 else { |
| 196 $subtype = strtolower($raw['type'][$k]); | 202 $subtype = strtolower($raw['type'][$k]); |
| 197 } | 203 } |
| 198 | 204 |
| 199 while ($k < count($raw['type']) && ($subtype == 'internet' || $subtype == 'pref')) { | 205 while ($k < count($raw['type']) && ($subtype == 'interne |
| 200 $subtype = $typemap[$raw['type'][++$k]] ?: strtolower($raw['type'][$k]); | 206 t' || $subtype == 'pref')) { |
| 207 $k++; | |
| 208 if (!empty($raw['type'][$k])) { | |
| 209 if (!empty($typemap[$raw['type'][$k]])) { | |
| 210 $subtype = $typemap[$raw['type'][$k]]; | |
| 211 } | |
| 212 else { | |
| 213 $subtype = $raw['type'][$k]; | |
| 214 } | |
| 215 } | |
| 201 } | 216 } |
| 202 } | 217 } |
| 203 | |
| 204 // read vcard 2.1 subtype | 218 // read vcard 2.1 subtype |
| 205 if (!$subtype) { | 219 if (!$subtype) { |
| 206 foreach ($raw as $k => $v) { | 220 foreach ($raw as $k => $v) { |
| 207 if (!is_numeric($k) && $v === true && ($k = strtolower($k)) | 221 if (!is_numeric($k) && $v === true && ($k = strtolower($k)) |
| 208 && !in_array($k, array('pref','internet','voice','base64')) | 222 && !in_array($k, array('pref','internet','voice','base64')) |
| 239 } | 253 } |
| 240 } | 254 } |
| 241 | 255 |
| 242 // handle special IM fields as used by Apple | 256 // handle special IM fields as used by Apple |
| 243 foreach ($this->immap as $tag => $type) { | 257 foreach ($this->immap as $tag => $type) { |
| 244 foreach ((array)$this->raw[$tag] as $i => $raw) { | 258 if (!empty($this->raw[$tag])) { |
| 259 foreach ((array)$this->raw[$tag] as $i => $raw) { | |
| 245 $out['im:'.$type][] = $raw[0]; | 260 $out['im:'.$type][] = $raw[0]; |
| 246 } | 261 } |
| 262 } | |
| 247 } | 263 } |
| 248 | 264 |
| 249 // copy photo data | 265 // copy photo data |
| 250 if ($this->raw['PHOTO']) { | 266 if (!empty($this->raw['PHOTO'])) { |
| 251 $out['photo'] = $this->raw['PHOTO'][0][0]; | 267 $out['photo'] = $this->raw['PHOTO'][0][0]; |
| 252 } | 268 } |
| 253 | 269 |
| 254 return $out; | 270 return $out; |
| 255 } | 271 } |
