1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
17: class Horde_Core_Prefs_Identity extends Horde_Prefs_Identity
18: {
19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 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: 68: 69: 70: 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:
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:
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: 117: 118: 119: 120: 121: 122: 123:
124: public function getFromAddress($ident = null)
125: {
126: return $GLOBALS['prefs']->getValue('from_addr');
127: }
128:
129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140:
141: public function getMatchingIdentity($addresses, $search_own = true)
142: {
143: return null;
144: }
145:
146: }
147: