Overview

Packages

  • Auth
  • Core
  • Horde
    • Imsp
  • None
  • Notification

Classes

  • Horde
  • Horde_Config
  • Horde_Config_Form
  • Horde_Core_ActiveSync_Connector
  • Horde_Core_ActiveSync_Driver
  • Horde_Core_Ajax_Application
  • Horde_Core_Ajax_Imple
  • Horde_Core_Ajax_Imple_AutoCompleter
  • Horde_Core_Ajax_Imple_Geocoder_Geonames
  • Horde_Core_Ajax_Imple_SpellChecker
  • Horde_Core_Alarm_Handler_Notify
  • Horde_Core_Auth_Application
  • Horde_Core_Auth_Composite
  • Horde_Core_Auth_Ldap
  • Horde_Core_Auth_Msad
  • Horde_Core_Auth_Shibboleth
  • Horde_Core_Auth_Signup_Base
  • Horde_Core_Auth_Signup_Form
  • Horde_Core_Auth_Signup_Null
  • Horde_Core_Auth_Signup_Sql
  • Horde_Core_Auth_Signup_SqlObject
  • Horde_Core_Autoloader_Callback_Mime
  • Horde_Core_Autoloader_Callback_Nls
  • Horde_Core_Block
  • Horde_Core_Block_Collection
  • Horde_Core_Block_Layout
  • Horde_Core_Block_Layout_Manager
  • Horde_Core_Block_Layout_View
  • Horde_Core_Block_Upgrade
  • Horde_Core_Browser
  • Horde_Core_Bundle
  • Horde_Core_Cli
  • Horde_Core_Controller_NotFound
  • Horde_Core_Controller_RequestConfiguration
  • Horde_Core_Controller_RequestMapper
  • Horde_Core_Controller_SettingsFinder
  • Horde_Core_Db_Migration
  • Horde_Core_Factory_ActiveSyncBackend
  • Horde_Core_Factory_ActiveSyncServer
  • Horde_Core_Factory_ActiveSyncState
  • Horde_Core_Factory_Ajax
  • Horde_Core_Factory_Alarm
  • Horde_Core_Factory_Auth
  • Horde_Core_Factory_AuthSignup
  • Horde_Core_Factory_Base
  • Horde_Core_Factory_BlockCollection
  • Horde_Core_Factory_Browser
  • Horde_Core_Factory_Cache
  • Horde_Core_Factory_Crypt
  • Horde_Core_Factory_Data
  • Horde_Core_Factory_Db
  • Horde_Core_Factory_DbBase
  • Horde_Core_Factory_DbPear
  • Horde_Core_Factory_Dns
  • Horde_Core_Factory_Editor
  • Horde_Core_Factory_Facebook
  • Horde_Core_Factory_Group
  • Horde_Core_Factory_History
  • Horde_Core_Factory_HttpClient
  • Horde_Core_Factory_Identity
  • Horde_Core_Factory_Image
  • Horde_Core_Factory_Imple
  • Horde_Core_Factory_Imsp
  • Horde_Core_Factory_ImspAuth
  • Horde_Core_Factory_Injector
  • Horde_Core_Factory_KolabServer
  • Horde_Core_Factory_KolabSession
  • Horde_Core_Factory_KolabStorage
  • Horde_Core_Factory_Ldap
  • Horde_Core_Factory_Lock
  • Horde_Core_Factory_Logger
  • Horde_Core_Factory_LoginTasks
  • Horde_Core_Factory_Mail
  • Horde_Core_Factory_Mapper
  • Horde_Core_Factory_Matcher
  • Horde_Core_Factory_Memcache
  • Horde_Core_Factory_MimeViewer
  • Horde_Core_Factory_Notification
  • Horde_Core_Factory_Perms
  • Horde_Core_Factory_PermsCore
  • Horde_Core_Factory_Prefs
  • Horde_Core_Factory_Request
  • Horde_Core_Factory_Secret
  • Horde_Core_Factory_SessionHandler
  • Horde_Core_Factory_Share
  • Horde_Core_Factory_ShareBase
  • Horde_Core_Factory_Template
  • Horde_Core_Factory_TextFilter
  • Horde_Core_Factory_ThemesCache
  • Horde_Core_Factory_Token
  • Horde_Core_Factory_Tree
  • Horde_Core_Factory_Twitter
  • Horde_Core_Factory_UrlShortener
  • Horde_Core_Factory_Vfs
  • Horde_Core_Factory_View
  • Horde_Core_Factory_Weather
  • Horde_Core_Group_Ldap
  • Horde_Core_Log_Logger
  • Horde_Core_LoginTasks
  • Horde_Core_LoginTasks_Backend_Horde
  • Horde_Core_LoginTasks_SystemTask_Upgrade
  • Horde_Core_Mime_Viewer_Syntaxhighlighter
  • Horde_Core_Mime_Viewer_Vcard
  • Horde_Core_Notification_Event_Status
  • Horde_Core_Notification_Handler_Decorator_Hordelog
  • Horde_Core_Notification_Storage_Session
  • Horde_Core_Perms
  • Horde_Core_Perms_Ui
  • Horde_Core_Prefs_Cache_Session
  • Horde_Core_Prefs_Identity
  • Horde_Core_Prefs_Storage_Configuration
  • Horde_Core_Prefs_Storage_Hooks
  • Horde_Core_Prefs_Storage_Upgrade
  • Horde_Core_Prefs_Ui
  • Horde_Core_Prefs_Ui_Widgets
  • Horde_Core_Share_Driver
  • Horde_Core_Share_FactoryCallback
  • Horde_Core_Sidebar
  • Horde_Core_Text_Filter_Bbcode
  • Horde_Core_Text_Filter_Emails
  • Horde_Core_Text_Filter_Emoticons
  • Horde_Core_Text_Filter_Highlightquotes
  • Horde_Core_Translation
  • Horde_Core_Tree_Html
  • Horde_Core_Tree_Javascript
  • Horde_Core_Tree_Simplehtml
  • Horde_Core_Ui_FlagImage
  • Horde_Core_Ui_JsCalendar
  • Horde_Core_Ui_Language
  • Horde_Core_Ui_Layout
  • Horde_Core_Ui_ModalFormRenderer
  • Horde_Core_Ui_Pager
  • Horde_Core_Ui_Tabs
  • Horde_Core_Ui_TagCloud
  • Horde_Core_Ui_VarRenderer
  • Horde_Core_Ui_VarRenderer_Html
  • Horde_Core_Ui_VarRenderer_TablesetHtml
  • Horde_Core_Ui_Widget
  • Horde_ErrorHandler
  • Horde_Help
  • Horde_Menu
  • Horde_Registry
  • Horde_Registry_Api
  • Horde_Registry_Application
  • Horde_Registry_Caller
  • Horde_Registry_Nlsconfig
  • Horde_Script_Files
  • Horde_Session
  • Horde_Session_Null
  • Horde_Themes
  • Horde_Themes_Cache
  • Horde_Themes_Css
  • Horde_Themes_Element
  • Horde_Themes_Image
  • Horde_Themes_Sound

Exceptions

  • Horde_Exception_HookNotSet
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * This class provides Horde-specific functions for the Horde_Prefs_Identity
  4:  * class.
  5:  *
  6:  * Copyright 2010-2012 Horde LLC (http://www.horde.org/)
  7:  *
  8:  * See the enclosed file COPYING for license information (LGPL). If you
  9:  * did not receive this file, see http://www.horde.org/licenses/lgpl21.
 10:  *
 11:  * @author   Jan Schneider <jan@horde.org>
 12:  * @author   Michael Slusarz <slusarz@horde.org>
 13:  * @category Horde
 14:  * @license  http://www.horde.org/licenses/lgpl21 LGPL 2.1
 15:  * @package  Core
 16:  */
 17: class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
 18: {
 19:     /**
 20:      * Sends a message to an email address supposed to be added to the
 21:      * identity.
 22:      * A message is send to this address containing a link to confirm that the
 23:      * address really belongs to that user.
 24:      *
 25:      * @param integer $id       The identity's ID.
 26:      * @param string $old_addr  The old From: address.
 27:      *
 28:      * @throws Horde_Mime_Exception
 29:      */
 30:     public function verifyIdentity($id, $old_addr)
 31:     {
 32:         global $conf;
 33: 
 34:         $hash = strval(new Horde_Support_Randomid());
 35: 
 36:         if (!($pref = @unserialize($this->_prefs->getValue('confirm_email')))) {
 37:             $pref = array();
 38:         }
 39:         $pref[$hash] = $this->get($id);
 40:         $this->_prefs->setValue('confirm_email', serialize($pref));
 41: 
 42:         $new_addr = $this->getValue($this->_prefnames['from_addr'], $id);
 43:         $confirm = Horde::url(Horde::getServiceLink('emailconfirm'), true)->add('h', $hash)->setRaw(true);
 44:         $message = sprintf(Horde_Core_Translation::t("You have requested to add the email address \"%s\" to the list of your personal email addresses.\n\nGo to the following link to confirm that this is really your address:\n%s\n\nIf you don't know what this message means, you can delete it."),
 45:                            $new_addr,
 46:                            $confirm);
 47: 
 48:         $msg_headers = new Horde_Mime_Headers();
 49:         $msg_headers->addMessageIdHeader();
 50:         $msg_headers->addUserAgentHeader();
 51:         $msg_headers->addHeader('Date', date('r'));
 52:         $msg_headers->addHeader('To', $new_addr);
 53:         $msg_headers->addHeader('From', $old_addr);
 54:         $msg_headers->addHeader('Subject', Horde_Core_Translation::t("Confirm new email address"));
 55: 
 56:         $body = new Horde_Mime_Part();
 57:         $body->setType('text/plain');
 58:         $body->setContents(Horde_String::wrap($message, 76));
 59:         $body->setCharset('UTF-8');
 60: 
 61:         $body->send($new_addr, $msg_headers, $GLOBALS['injector']->getInstance('Horde_Mail'));
 62: 
 63:         $GLOBALS['notification']->push(sprintf(Horde_Core_Translation::t("A message has been sent to \"%s\" to verify that this is really your address. The new email address is activated as soon as you confirm this message."), $new_addr), 'horde.message');
 64:     }
 65: 
 66:     /**
 67:      * Checks whether an identity confirmation is valid, and adds the
 68:      * validated identity.
 69:      *
 70:      * @param string $hash  The saved hash of the identity being validated.
 71:      */
 72:     public function confirmIdentity($hash)
 73:     {
 74:         global $notification;
 75: 
 76:         $confirm = $this->_prefs->getValue('confirm_email');
 77:         if (empty($confirm)) {
 78:             $notification->push(Horde_Core_Translation::t("There are no email addresses to confirm."), 'horde.message');
 79:             return;
 80:         }
 81: 
 82:         $confirm = @unserialize($confirm);
 83:         if (empty($confirm)) {
 84:             $notification->push(Horde_Core_Translation::t("There are no email addresses to confirm."), 'horde.message');
 85:             return;
 86:         } elseif (!isset($confirm[$hash])) {
 87:             $notification->push(Horde_Core_Translation::t("Email addresses to confirm not found."), 'horde.message');
 88:             return;
 89:         }
 90: 
 91:         $identity = $confirm[$hash];
 92:         $id = array_search($identity['id'], $this->getAll($this->_prefnames['id']));
 93:         if ($id === false) {
 94:             /* Adding a new identity. */
 95:             $verified = array();
 96:             foreach ($identity as $key => $value) {
 97:                 if (!$this->_prefs->isLocked($key)) {
 98:                     $verified[$key] = $value;
 99:                 }
100:             }
101:             $this->add($verified);
102:         } else {
103:             /* Updating an existing identity. */
104:             foreach ($identity as $key => $value) {
105:                 $this->setValue($key, $value, $id);
106:             }
107:         }
108:         $this->save();
109:         unset($confirm[$hash]);
110:         $this->_prefs->setValue('confirm_email', serialize($confirm));
111: 
112:         $notification->push(sprintf(Horde_Core_Translation::t("The email address %s has been added to your identities. You can close this window now."), $verified[$this->_prefnames['from_addr']]), 'horde.success');
113:     }
114: 
115:     /**
116:      * Returns the from address based on the chosen identity. If no
117:      * address can be found it is built from the current user name and
118:      * the specified maildomain.
119:      *
120:      * @param integer $ident  The identity to retrieve the address from.
121:      *
122:      * @return string  A valid from address.
123:      */
124:     public function getFromAddress($ident = null)
125:     {
126:         return $GLOBALS['prefs']->getValue('from_addr');
127:     }
128: 
129:     /**
130:      * Returns the identity's id that matches the passed addresses.
131:      *
132:      * @param mixed $addresses     Either an array or a single string or a
133:      *                             comma-separated list of email addresses.
134:      * @param boolean $search_own  Search for a matching identity in own
135:      *                             addresses also?
136:      *
137:      * @return integer  The id of the first identity that from or alias
138:      *                  addresses match (one of) the passed addresses or
139:      *                  null if none matches.
140:      */
141:     public function getMatchingIdentity($addresses, $search_own = true)
142:     {
143:         return null;
144:     }
145: 
146: }
147: 
API documentation generated by ApiGen