1
|
|
|
<?php |
2
|
|
|
//------------------------------------------------------------------------- |
3
|
|
|
// OVIDENTIA http://www.ovidentia.org |
4
|
|
|
// Ovidentia is free software; you can redistribute it and/or modify |
5
|
|
|
// it under the terms of the GNU General Public License as published by |
6
|
|
|
// the Free Software Foundation; either version 2, or (at your option) |
7
|
|
|
// any later version. |
8
|
|
|
// |
9
|
|
|
// This program is distributed in the hope that it will be useful, but |
10
|
|
|
// WITHOUT ANY WARRANTY; without even the implied warranty of |
11
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
12
|
|
|
// See the GNU General Public License for more details. |
13
|
|
|
// |
14
|
|
|
// You should have received a copy of the GNU General Public License |
15
|
|
|
// along with this program; if not, write to the Free Software |
16
|
|
|
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
17
|
|
|
// USA. |
18
|
|
|
//------------------------------------------------------------------------- |
19
|
|
|
/** |
20
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) |
21
|
|
|
* @copyright Copyright (c) 2006 by CANTICO ({@link http://www.cantico.fr}) |
22
|
|
|
*/ |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Translates the string. |
27
|
|
|
* |
28
|
|
|
* @param string $str |
29
|
|
|
* @return string |
30
|
|
|
*/ |
31
|
|
|
function caldav_translate($str) |
32
|
|
|
{ |
33
|
|
|
return bab_translate($str, 'LibCaldav'); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Parse attendee property |
40
|
|
|
* @param string $iCalPropertyName |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
function caldav_getAttendeeProp($iCalPropertyName, $iCalPropertyValue) |
44
|
|
|
{ |
45
|
4 |
|
$parameters = explode(';', $iCalPropertyName); |
46
|
4 |
|
array_shift($parameters); |
47
|
|
|
|
48
|
4 |
|
$role = null; |
49
|
4 |
|
$partstat = null; |
50
|
4 |
|
$cn = ''; |
51
|
4 |
|
$email = null; |
52
|
|
|
|
53
|
4 |
View Code Duplication |
foreach ($parameters as $parameter) { |
|
|
|
|
54
|
4 |
|
list($paramName, $paramValue) = explode('=', $parameter); |
55
|
|
|
switch ($paramName) { |
56
|
4 |
|
case 'ROLE': |
57
|
|
|
$role = $paramValue; |
58
|
|
|
break; |
59
|
4 |
|
case 'PARTSTAT': |
60
|
|
|
$partstat = $paramValue; |
61
|
|
|
break; |
62
|
4 |
|
case 'CN': |
63
|
4 |
|
$cn = trim($paramValue, '" '); |
64
|
4 |
|
break; |
65
|
|
|
} |
66
|
4 |
|
} |
67
|
4 |
|
if (stripos($iCalPropertyValue, 'MAILTO:') !== false) { |
68
|
4 |
|
list(, $email) = explode(':', $iCalPropertyValue); |
69
|
4 |
|
} |
70
|
|
|
|
71
|
|
|
return array($role, $partstat, $cn, $email); |
72
|
|
|
} |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.