Overview

Packages

  • Itip

Classes

  • Horde_Itip
  • Horde_Itip_Event_Vevent
  • Horde_Itip_Exception
  • Horde_Itip_Resource_Base
  • Horde_Itip_Resource_Identity
  • Horde_Itip_Response
  • Horde_Itip_Response_Options_Base
  • Horde_Itip_Response_Options_Horde
  • Horde_Itip_Response_Options_Kolab
  • Horde_Itip_Response_Type_Accept
  • Horde_Itip_Response_Type_Base
  • Horde_Itip_Response_Type_Decline
  • Horde_Itip_Response_Type_Tentative
  • Horde_Itip_Translation

Interfaces

  • Horde_Itip_Event
  • Horde_Itip_Resource
  • Horde_Itip_Response_Options
  • Horde_Itip_Response_Type
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Horde_Prefs_Identity based information provider for an invited resource.
  4:  *
  5:  * PHP version 5
  6:  *
  7:  * @category Horde
  8:  * @package  Itip
  9:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 10:  * @license  http://www.horde.org/licenses/lgpl21 LGPL
 11:  * @link     http://pear.horde.org/index.php?package=Itip
 12:  */
 13: 
 14: /**
 15:  * Horde_Prefs_Identity based information provider for an invited resource.
 16:  *
 17:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
 18:  *
 19:  * See the enclosed file COPYING for license information (LGPL). If you did not
 20:  * receive this file, see
 21:  * {@link http://www.horde.org/licenses/lgpl21 LGPL}.
 22:  *
 23:  * @category Horde
 24:  * @package  Itip
 25:  * @author   Gunnar Wrobel <wrobel@pardus.de>
 26:  * @license  http://www.horde.org/licenses/lgpl21 LGPL
 27:  * @link     http://pear.horde.org/index.php?package=Itip
 28:  */
 29: class Horde_Itip_Resource_Identity
 30: implements Horde_Itip_Resource
 31: {
 32:     /**
 33:      * The identity.
 34:      *
 35:      * @var IMP_Prefs_Identity
 36:      */
 37:     private $_identity;
 38: 
 39:     /**
 40:      * The selected identity for replying.
 41:      *
 42:      * @var string
 43:      */
 44:     private $_reply_to;
 45: 
 46:     /**
 47:      * Constructor.
 48:      *
 49:      * @param IMP_Prefs_Identity $identity  The IMP identity of the invited
 50:      *                                      resource.
 51:      * @param array              $attendees The attendees of the invitation.
 52:      * @param string             $reply_to  The selected identity for sending the
 53:      *                                      reply.
 54:      * @todo Parse mailto using parse_url
 55:      */
 56:     public function __construct($identity, $attendees, $reply_to)
 57:     {
 58:         $this->_identity = $identity;
 59:         if (!is_array($attendees)) {
 60:             $attendees = array($attendees);
 61:         }
 62:         foreach ($attendees as $attendee) {
 63:             $attendee = preg_replace('/mailto:/i', '', $attendee);
 64:             if (!is_null($id = $identity->getMatchingIdentity($attendee))) {
 65:                 $identity->setDefault($id);
 66:                 break;
 67:             }
 68:         }
 69:         $this->_reply_to = $reply_to;
 70:     }
 71: 
 72:     /**
 73:      * Retrieve the mail address of the resource.
 74:      *
 75:      * @return string The mail address.
 76:      */
 77:     public function getMailAddress()
 78:     {
 79:         return $this->_identity->getFromAddress();
 80:     }
 81: 
 82:     /**
 83:      * Retrieve the reply-to address for the resource.
 84:      *
 85:      * @return string The reply-to address.
 86:      */
 87:     public function getReplyTo()
 88:     {
 89:         $original = $this->_identity->getDefault();
 90:         $this->_identity->setDefault($this->_reply_to);
 91:         $reply_to = $this->_identity->getValue('replyto_addr');
 92:         $this->_identity->setDefault($original);
 93:         return $reply_to;
 94:     }
 95: 
 96:     /**
 97:      * Retrieve the common name of the resource.
 98:      *
 99:      * @return string The common name.
100:      */
101:     public function getCommonName()
102:     {
103:         return $this->_identity->getValue('fullname');
104:     }
105: 
106:     /**
107:      * Retrieve the "From" address for this resource.
108:      *
109:      * @return string The "From" address.
110:      */
111:     public function getFrom()
112:     {
113:         $cn = $this->getCommonName();
114:         if (!empty($cn)) {
115:             return sprintf("%s <%s>", $cn, $this->getMailAddress());
116:         } else {
117:             return $this->getMailAddress();
118:         }
119:     }
120: }
API documentation generated by ApiGen