/usr/share/php/Horde/Icalendar/Vcard.php is in php-horde-icalendar 2.1.7-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 | <?php
/**
* Copyright 2003-2017 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl21.
*
* @author Karsten Fourmont <karsten@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
/**
* Class representing vCard entries.
*
* @author Karsten Fourmont <karsten@horde.org>
* @category Horde
* @copyright 2003-2017 Horde LLC
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Icalendar
*/
class Horde_Icalendar_Vcard extends Horde_Icalendar
{
// The following were shamelessly yoinked from Contact_Vcard_Build
// Part numbers for N components.
const N_FAMILY = 0;
const N_GIVEN = 1;
const N_ADDL = 2;
const N_PREFIX = 3;
const N_SUFFIX = 4;
// Part numbers for ADR components.
const ADR_POB = 0;
const ADR_EXTEND = 1;
const ADR_STREET = 2;
const ADR_LOCALITY = 3;
const ADR_REGION = 4;
const ADR_POSTCODE = 5;
const ADR_COUNTRY = 6;
// Part numbers for GEO components.
const GEO_LAT = 0;
const GEO_LON = 1;
/**
* The component type of this class.
*
* @var string
*/
public $type = 'vcard';
/**
* Constructor.
*/
public function __construct($version = '2.1')
{
parent::__construct($version);
}
/**
* Sets the version of this component.
*
* @see $version
* @see $oldFormat
*
* @param string A float-like version string.
*/
public function setVersion($version)
{
$this->_oldFormat = $version < 3;
$this->_version = $version;
}
/**
* Unlike vevent and vtodo, a vcard is normally not enclosed in an
* iCalendar container. (BEGIN..END)
*
* @return TODO
*/
public function exportvCalendar()
{
$requiredAttributes['VERSION'] = $this->_version;
$requiredAttributes['N'] = ';;;;;;';
if ($this->_version == '3.0') {
$requiredAttributes['FN'] = '';
}
foreach ($requiredAttributes as $name => $default_value) {
try {
$this->getAttribute($name);
} catch (Horde_Icalendar_Exception $e) {
$this->setAttribute($name, $default_value);
}
}
return $this->_exportvData('VCARD');
}
/**
* Returns the contents of the "N" tag as a printable Name:
* i.e. converts:
*
* N:Duck;Dagobert;T;Professor;Sen.
* to
* "Professor Dagobert T Duck Sen"
*
* @return string Full name of vcard "N" tag or null if no N tag.
*/
public function printableName()
{
try {
$name_parts = $this->getAttributeValues('N');
} catch (Horde_Icalendar_Exception $e) {
return null;
}
$name_arr = array();
foreach (array(self::N_PREFIX, self::N_GIVEN, self::N_ADDL, self::N_FAMILY, self::N_SUFFIX) as $val) {
if (!empty($name_parts[$val])) {
$name_arr[] = $name_parts[$val];
}
}
return implode(' ', $name_arr);
}
/**
* Static function to make a given email address rfc822 compliant.
*
* @param string $address An email address.
*
* @return string The RFC822-formatted email address.
*/
static function getBareEmail($address)
{
$ob = new Horde_Mail_Rfc822_Address($address);
return $ob->bare_address;
}
}
|