Overview

Packages

  • IMP
  • None

Classes

  • IMP
  • IMP_Ajax_Application
  • IMP_Ajax_Imple_ContactAutoCompleter
  • IMP_Ajax_Imple_PassphraseDialog
  • IMP_Ajax_Queue
  • IMP_Api
  • IMP_Auth
  • IMP_Block_Newmail
  • IMP_Block_Summary
  • IMP_Compose
  • IMP_Compose_Exception
  • IMP_Compose_Stationery
  • IMP_Contents
  • IMP_Crypt_Pgp
  • IMP_Crypt_Smime
  • IMP_Dimp
  • IMP_Exception
  • IMP_Factory_AuthImap
  • IMP_Factory_Compose
  • IMP_Factory_Contents
  • IMP_Factory_Flags
  • IMP_Factory_Identity
  • IMP_Factory_Imap
  • IMP_Factory_Imaptree
  • IMP_Factory_Mail
  • IMP_Factory_Mailbox
  • IMP_Factory_MailboxList
  • IMP_Factory_MimeViewer
  • IMP_Factory_Pgp
  • IMP_Factory_Quota
  • IMP_Factory_Search
  • IMP_Factory_Sentmail
  • IMP_Factory_Smime
  • IMP_Filter
  • IMP_Flag_Base
  • IMP_Flag_Imap
  • IMP_Flag_Imap_Answered
  • IMP_Flag_Imap_Deleted
  • IMP_Flag_Imap_Draft
  • IMP_Flag_Imap_Flagged
  • IMP_Flag_Imap_Forwarded
  • IMP_Flag_Imap_Junk
  • IMP_Flag_Imap_NotJunk
  • IMP_Flag_Imap_Seen
  • IMP_Flag_System_Attachment
  • IMP_Flag_System_Encrypted
  • IMP_Flag_System_HighPriority
  • IMP_Flag_System_List
  • IMP_Flag_System_LowPriority
  • IMP_Flag_System_Match_Address
  • IMP_Flag_System_Match_Flag
  • IMP_Flag_System_Match_Header
  • IMP_Flag_System_Personal
  • IMP_Flag_System_Signed
  • IMP_Flag_System_Unseen
  • IMP_Flag_User
  • IMP_Flags
  • IMP_Imap
  • IMP_Imap_Acl
  • IMP_Imap_Exception
  • IMP_Imap_PermanentFlags
  • IMP_Imap_Thread
  • IMP_Imap_Tree
  • IMP_Indices
  • IMP_Indices_Form
  • IMP_LoginTasks_SystemTask_GarbageCollection
  • IMP_LoginTasks_SystemTask_Upgrade
  • IMP_LoginTasks_SystemTask_UpgradeAuth
  • IMP_LoginTasks_Task_Autocreate
  • IMP_LoginTasks_Task_DeleteAttachmentsMonthly
  • IMP_LoginTasks_Task_DeleteSentmailMonthly
  • IMP_LoginTasks_Task_FilterOnLogin
  • IMP_LoginTasks_Task_PurgeSentmail
  • IMP_LoginTasks_Task_PurgeSpam
  • IMP_LoginTasks_Task_PurgeTrash
  • IMP_LoginTasks_Task_RecoverDraft
  • IMP_LoginTasks_Task_RenameSentmailMonthly
  • IMP_Mailbox
  • IMP_Mailbox_List
  • IMP_Mailbox_List_Track
  • IMP_Maillog
  • IMP_Menu_Dimp
  • IMP_Message
  • IMP_Mime_Status
  • IMP_Mime_Viewer_Alternative
  • IMP_Mime_Viewer_Appledouble
  • IMP_Mime_Viewer_Audio
  • IMP_Mime_Viewer_Enriched
  • IMP_Mime_Viewer_Externalbody
  • IMP_Mime_Viewer_Html
  • IMP_Mime_Viewer_Images
  • IMP_Mime_Viewer_Itip
  • IMP_Mime_Viewer_Mdn
  • IMP_Mime_Viewer_Partial
  • IMP_Mime_Viewer_Pdf
  • IMP_Mime_Viewer_Pgp
  • IMP_Mime_Viewer_Plain
  • IMP_Mime_Viewer_Related
  • IMP_Mime_Viewer_Rfc822
  • IMP_Mime_Viewer_Smil
  • IMP_Mime_Viewer_Smime
  • IMP_Mime_Viewer_Status
  • IMP_Mime_Viewer_Vcard
  • IMP_Mime_Viewer_Video
  • IMP_Mime_Viewer_Zip
  • IMP_Notification_Event_Status
  • IMP_Notification_Handler_Decorator_ImapAlerts
  • IMP_Notification_Handler_Decorator_NewmailNotify
  • IMP_Notification_Listener_AjaxStatus
  • Imp_Prefs_Identity
  • IMP_Prefs_Ui
  • IMP_Quota
  • IMP_Quota_Base
  • IMP_Quota_Command
  • IMP_Quota_Hook
  • IMP_Quota_Imap
  • IMP_Quota_Maildir
  • IMP_Quota_Mdaemon
  • IMP_Quota_Mercury32
  • IMP_Quota_Null
  • IMP_Quota_Sql
  • IMP_Search
  • IMP_Search_Element
  • IMP_Search_Element_Attachment
  • IMP_Search_Element_Autogenerated
  • IMP_Search_Element_Bulk
  • IMP_Search_Element_Contacts
  • IMP_Search_Element_Date
  • IMP_Search_Element_Flag
  • IMP_Search_Element_Header
  • IMP_Search_Element_Mailinglist
  • IMP_Search_Element_Or
  • IMP_Search_Element_Personal
  • IMP_Search_Element_Recipient
  • IMP_Search_Element_Size
  • IMP_Search_Element_Text
  • IMP_Search_Element_Within
  • IMP_Search_Filter
  • IMP_Search_Filter_Attachment
  • IMP_Search_Filter_Autogenerated
  • IMP_Search_Filter_Builtin
  • IMP_Search_Filter_Bulk
  • IMP_Search_Filter_Contacts
  • IMP_Search_Filter_Mailinglist
  • IMP_Search_Filter_Personal
  • IMP_Search_Query
  • IMP_Search_Vfolder
  • IMP_Search_Vfolder_Builtin
  • IMP_Search_Vfolder_Vinbox
  • IMP_Search_Vfolder_Vtrash
  • IMP_Sentmail
  • IMP_Sentmail_Base
  • IMP_Sentmail_Null
  • IMP_Sentmail_Sql
  • IMP_Spam
  • IMP_Test
  • IMP_Tree_Flist
  • IMP_Tree_Jquerymobile
  • IMP_Tree_Simplehtml
  • IMP_Ui_Compose
  • IMP_Ui_Editor
  • IMP_Ui_Folder
  • IMP_Ui_Headers
  • IMP_Ui_Imageview
  • IMP_Ui_Mailbox
  • IMP_Ui_Message
  • IMP_Ui_Mimp
  • IMP_Ui_Search
  • IMP_Views_Compose
  • IMP_Views_ListMessages
  • IMP_Views_ShowMessage
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * This class provides an IMP-specific interface to all identities a
  4:  * user might have. Its methods take care of any site-specific
  5:  * restrictions configured in prefs.php and conf.php.
  6:  *
  7:  * Copyright 2001-2012 Horde LLC (http://www.horde.org/)
  8:  *
  9:  * See the enclosed file COPYING for license information (GPL). If you
 10:  * did not receive this file, see http://www.horde.org/licenses/gpl.
 11:  *
 12:  * @author   Jan Schneider <jan@horde.org>
 13:  * @author   Chuck Hagenbuch <chuck@horde.org>
 14:  * @category Horde
 15:  * @license  http://www.horde.org/licenses/gpl GPL
 16:  * @package  IMP
 17:  */
 18: class Imp_Prefs_Identity extends Horde_Core_Prefs_Identity
 19: {
 20:     /**
 21:      * Cached data.
 22:      *
 23:      * @var array
 24:      */
 25:     protected $_cached = array(
 26:         'aliases' => array(),
 27:         'fromList' => array(),
 28:         'froms' => array(),
 29:         'names' => array(),
 30:         // 'own_addresses'
 31:         'signatures' => array()
 32:         // 'tie_addresses'
 33:     );
 34: 
 35:     /**
 36:      * Identity preferences added by IMP.
 37:      *
 38:      * @var array
 39:      */
 40:     protected $_impPrefs = array(
 41:         'replyto_addr', 'alias_addr', 'tieto_addr', 'bcc_addr', 'signature',
 42:         'signature_html', 'sig_first', 'sig_dashes', 'save_sent_mail',
 43:         'sent_mail_folder'
 44:     );
 45: 
 46:     /**
 47:      * Reads all the user's identities from the prefs object or builds
 48:      * a new identity from the standard values given in prefs.php.
 49:      *
 50:      * @see __construct()
 51:      */
 52:     public function __construct($params)
 53:     {
 54:         $this->_prefnames['properties'] = array_merge(
 55:             $this->_prefnames['properties'],
 56:             $this->_impPrefs
 57:         );
 58: 
 59:         parent::__construct($params);
 60:     }
 61: 
 62:     /**
 63:      * Verifies and sanitizes all identity properties.
 64:      *
 65:      * @param integer $identity  The identity to verify.
 66:      *
 67:      * @throws Horde_Exception
 68:      */
 69:     public function verify($identity = null)
 70:     {
 71:         if (!isset($identity)) {
 72:             $identity = $this->_default;
 73:         }
 74: 
 75:         /* Fill missing IMP preferences with default values. */
 76:         foreach ($this->_impPrefs as $pref) {
 77:             if (!isset($this->_identities[$identity][$pref])) {
 78:                 $this->_identities[$identity][$pref] = $this->_prefs->getValue($pref);
 79:             }
 80:         }
 81: 
 82:         parent::verify($identity);
 83: 
 84:         /* Prepare email validator */
 85:         require_once 'Horde/Form.php';
 86:         $email = new Horde_Form_Type_email();
 87:         $vars = new Horde_Variables();
 88:         $var = new Horde_Form_Variable('', 'replyto_addr', $email, false);
 89: 
 90:         /* Verify Reply-to address. */
 91:         if (!$email->isValid($var, $vars, $this->getValue('replyto_addr', $identity), $error_message)) {
 92:             throw new Horde_Exception($error_message);
 93:         }
 94: 
 95:         /* Clean up Alias, Tie-to, and BCC addresses. */
 96:         foreach (array('alias_addr', 'tieto_addr', 'bcc_addr') as $val) {
 97:             $data = $this->getValue($val, $identity);
 98:             if (is_array($data)) {
 99:                 $data = implode("\n", $data);
100:             }
101:             $data = trim($data);
102:             $data = (empty($data)) ? array() : Horde_Array::prepareAddressList(preg_split("/[\n\r]+/", $data));
103: 
104:             /* Validate addresses */
105:             foreach ($data as $address) {
106:                 if (!$email->isValid($var, $vars, $address, $error_message)) {
107:                     throw new Horde_Exception($error_message);
108:                 }
109:             }
110: 
111:             $this->setValue($val, $data, $identity);
112:         }
113:     }
114: 
115:     /**
116:      * Returns a complete From: header based on all relevant factors (fullname,
117:      * from address, input fields, locks etc.)
118:      *
119:      * @param integer $ident        The identity to retrieve the values from.
120:      * @param string $from_address  A default from address to use if no
121:      *                              identity is selected and the from_addr
122:      *                              preference is locked.
123:      *
124:      * @return string  A full From: header in the format
125:      *                 'Fullname <user@example.com>'.
126:      * @throws Horde_Exception
127:      */
128:     public function getFromLine($ident = null, $from_address = '')
129:     {
130:         if (isset($this->_cached['froms'][$ident])) {
131:             return $this->_cached['froms'][$ident];
132:         }
133: 
134:         if (!isset($ident)) {
135:             $address = $from_address;
136:         }
137: 
138:         if (empty($address) || $this->_prefs->isLocked($this->_prefnames['from_addr'])) {
139:             $address = $this->getFromAddress($ident);
140:             $name = $this->getFullname($ident);
141:         }
142: 
143:         try {
144:             $ob = $this->_getAddrList($address);
145:         } catch (Horde_Mime_Exception $e) {
146:             throw new Horde_Exception (_("Your From address is not a valid email address. This can be fixed in your Personal Information preferences page."));
147:         }
148: 
149:         if (empty($name)) {
150:             $name = empty($ob[0]['personal'])
151:                 ? $this->getFullname($ident)
152:                 : $ob[0]['personal'];
153:         }
154: 
155:         $from = Horde_Mime_Address::writeAddress($ob[0]['mailbox'], $ob[0]['host'], $name);
156: 
157:         $this->_cached['froms'][$ident] = $from;
158: 
159:         return $from;
160:     }
161: 
162:     /**
163:      * Returns an array with From: headers from all identities
164:      *
165:      * @return array  The From: headers from all identities
166:      */
167:     public function getAllFromLines()
168:     {
169:         foreach (array_keys($this->_identities) as $ident) {
170:             $list[$ident] = $this->getFromAddress($ident);
171:         }
172:         return $list;
173:     }
174: 
175:     /**
176:      * Returns an array with the necessary values for the identity select
177:      * box in the IMP compose window.
178:      *
179:      * @return array  The array with the necessary strings
180:      */
181:     public function getSelectList()
182:     {
183:         $ids = $this->getAll($this->_prefnames['id']);
184:         foreach ($ids as $key => $id) {
185:             $list[$key] = $this->getFromAddress($key) . ' (' . $id . ')';
186:         }
187:         return $list;
188:     }
189: 
190:     /**
191:      * Returns true if the given address belongs to one of the identities.
192:      * This function will search aliases for an identity automatically.
193:      *
194:      * @param string $address  The address to search for in the identities.
195:      *
196:      * @return boolean  True if the address was found.
197:      */
198:     public function hasAddress($address)
199:     {
200:         $list = $this->getAllFromAddresses(true);
201:         return isset($list[Horde_String::lower($address)]);
202:     }
203: 
204:     /**
205:      * Returns the from address based on the chosen identity. If no
206:      * address can be found it is built from the current user name and
207:      * the specified maildomain.
208:      *
209:      * @param integer $ident  The identity to retrieve the address from.
210:      *
211:      * @return string  A valid from address.
212:      */
213:     public function getFromAddress($ident = null)
214:     {
215:         if (!isset($this->_cached['fromList'][$ident])) {
216:             $val = $this->getValue($this->_prefnames['from_addr'], $ident);
217:             if (empty($val)) {
218:                 $val = $GLOBALS['registry']->getAuth();
219:             }
220: 
221:             if (!strstr($val, '@')) {
222:                 $val .= '@' . $GLOBALS['session']->get('imp', 'maildomain');
223:             }
224: 
225:             $this->_cached['fromList'][$ident] = $val;
226:         }
227: 
228:         return $this->_cached['fromList'][$ident];
229:     }
230: 
231:     /**
232:      * Returns all aliases based on the chosen identity.
233:      *
234:      * @param integer $ident  The identity to retrieve the aliases from.
235:      *
236:      * @return array  Aliases for the identity.
237:      */
238:     public function getAliasAddress($ident)
239:     {
240:         if (!isset($this->_cached['aliases'][$ident])) {
241:             $this->_cached['aliases'][$ident] = @array_merge(
242:                 (array)$this->getValue('alias_addr', $ident),
243:                 array($this->getValue('replyto_addr', $ident))
244:             );
245:         }
246: 
247:         return $this->_cached['aliases'][$ident];
248:     }
249: 
250:     /**
251:      * Returns an array with all identities' from addresses.
252:      *
253:      * @param boolean $alias  Include aliases?
254:      *
255:      * @return array  The array with
256:      *                KEY - address
257:      *                VAL - identity number
258:      */
259:     public function getAllFromAddresses($alias = false)
260:     {
261:         $list = array();
262: 
263:         foreach ($this->_identitiesWithDefaultLast() as $key => $identity) {
264:             /* Get From Addresses. */
265:             $list[Horde_String::lower($this->getFromAddress($key))] = $key;
266: 
267:             /* Get Aliases. */
268:             if ($alias) {
269:                 $addrs = $this->getAliasAddress($key);
270:                 if (!empty($addrs)) {
271:                     foreach (array_filter($addrs) as $val) {
272:                         $list[Horde_String::lower($val)] = $key;
273:                     }
274:                 }
275:             }
276:         }
277: 
278:         return $list;
279:     }
280: 
281:     /**
282:      * Get all 'tie to' address/identity pairs.
283:      *
284:      * @return array  The array with
285:      *                KEY - address
286:      *                VAL - identity number
287:      */
288:     public function getAllTieAddresses()
289:     {
290:         $list = array();
291: 
292:         foreach ($this->_identitiesWithDefaultLast() as $key => $identity) {
293:             $tieaddr = $this->getValue('tieto_addr', $key);
294:             if (!empty($tieaddr)) {
295:                 foreach ($tieaddr as $val) {
296:                     $list[$val] = $key;
297:                 }
298:             }
299:         }
300: 
301:         return $list;
302:     }
303: 
304:     /**
305:      * Returns a list of all e-mail addresses from all identities, including
306:      * both from addresses and tie addreses.
307:      *
308:      * @return array  A list of e-mail addresses.
309:      */
310:     public function getAllIdentityAddresses()
311:     {
312:         /* Combine the keys (which contain the e-mail addresses). */
313:         return array_merge(
314:             array_keys($this->getAllFromAddresses(true)),
315:             array_keys($this->getAllTieAddresses())
316:         );
317:     }
318: 
319:     /**
320:      * Returns the list of identities with the default identity positioned
321:      * last.
322:      *
323:      * @return array  The identities list with the default identity last.
324:      */
325:     protected function _identitiesWithDefaultLast()
326:     {
327:         $ids = $this->_identities;
328:         $default = $this->getDefault();
329:         $tmp = $ids[$default];
330:         unset($ids[$default]);
331:         $ids[$default] = $tmp;
332:         return $ids;
333:     }
334: 
335:     /**
336:      * Returns the BCC addresses for a given identity.
337:      *
338:      * @param integer $ident  The identity to retrieve the Bcc addresses from.
339:      *
340:      * @return array  The array of objects (IMAP addresses).
341:      */
342:     public function getBccAddresses($ident = null)
343:     {
344:         $bcc = $this->getValue('bcc_addr', $ident);
345:         if (empty($bcc)) {
346:             return array();
347:         } else {
348:             if (!is_array($bcc)) {
349:                 $bcc = array($bcc);
350:             }
351:             try {
352:                 return $this->_getAddrList(implode(', ', $bcc));
353:             } catch (Horde_Mime_Exception $e) {
354:                 return array();
355:             }
356:         }
357:     }
358: 
359:     /**
360:      * Returns the identity's id that matches the passed addresses.
361:      *
362:      * @param mixed $addresses     Either an array or a single string or a
363:      *                             comma-separated list of email addresses.
364:      * @param boolean $search_own  Search for a matching identity in own
365:      *                             addresses also?
366:      *
367:      * @return integer  The id of the first identity that from or alias
368:      *                  addresses match (one of) the passed addresses or
369:      *                  null if none matches.
370:      */
371:     public function getMatchingIdentity($addresses, $search_own = true)
372:     {
373:         if (!isset($this->_cached['tie_addresses'])) {
374:             $this->_cached['tie_addresses'] = $this->getAllTieAddresses();
375:             $this->_cached['own_addresses'] = $this->getAllFromAddresses(true);
376:         }
377: 
378:         /* Normalize address list. */
379:         $addresses = is_array($addresses)
380:             ? array_filter($addresses)
381:             : array($addresses);
382: 
383:         try {
384:             $addr_list = $this->_getAddrList(implode(', ', $addresses));
385:         } catch (Horde_Mime_Exception $e) {
386:             return null;
387:         }
388: 
389:         foreach ($addr_list as $address) {
390:             if (empty($address['mailbox'])) {
391:                 continue;
392:             }
393: 
394:             $find_address = $address['mailbox'];
395:             if (!empty($address['host'])) {
396:                 $find_address .= '@' . $address['host'];
397:             }
398:             $find_address = Horde_String::lower($find_address);
399: 
400:             /* Search 'tieto' addresses first. */
401:             /* Check for this address explicitly. */
402:             if (isset($this->_cached['tie_addresses'][$find_address])) {
403:                 return $this->_cached['tie_addresses'][$find_address];
404:             }
405: 
406:             /* If we didn't find the address, check for the domain. */
407:             if (!empty($address['host']) &&
408:                 isset($this->_cached['tie_addresses']['@' . $address['host']])) {
409:                 return $this->_cached['tie_addresses']['@' . $address['host']];
410:             }
411: 
412:             /* Next, search all from addresses. */
413:             if ($search_own &&
414:                 isset($this->_cached['own_addresses'][$find_address])) {
415:                 return $this->_cached['own_addresses'][$find_address];
416:             }
417:         }
418: 
419:         return null;
420:     }
421: 
422:     /**
423:      * Returns the user's full name.
424:      *
425:      * @param integer $ident  The identity to retrieve the name from.
426:      *
427:      * @return string  The user's full name.
428:      */
429:     public function getFullname($ident = null)
430:     {
431:         if (isset($this->_cached['names'][$ident])) {
432:             return $this->_cached['names'][$ident];
433:         }
434: 
435:         $this->_cached['names'][$ident] = $this->getValue($this->_prefnames['fullname'], $ident);
436: 
437:         return $this->_cached['names'][$ident];
438:     }
439: 
440:     /**
441:      * Returns the full signature based on the current settings for the
442:      * signature itself, the dashes and the position.
443:      *
444:      * @param string $type    Either 'text' or 'html'.
445:      * @param integer $ident  The identity to retrieve the signature from.
446:      *
447:      * @return string  The full signature.
448:      * @throws Horde_Exception
449:      */
450:     public function getSignature($type = 'text', $ident = null)
451:     {
452:         $convert = false;
453:         $key = $ident . '|' . $type;
454:         $val = null;
455: 
456:         if (isset($this->_cached['signatures'][$key])) {
457:             return $this->_cached['signatures'][$key];
458:         }
459: 
460:         if ($type == 'html') {
461:             $val = $this->getValue('signature_html', $ident);
462:             if (!strlen($val)) {
463:                 $convert = true;
464:                 $val = null;
465:             }
466:         }
467: 
468:         if (is_null($val)) {
469:             $val = $this->getValue('signature', $ident);
470: 
471:             if (!empty($val) && ($type == 'text')) {
472:                 $sig_first = $this->getValue('sig_first', $ident);
473:                 $sig_dashes = $this->getValue('sig_dashes', $ident);
474: 
475:                 $val = str_replace("\r\n", "\n", $val);
476: 
477:                 if ($sig_dashes) {
478:                     $val = "-- \n" . $val . "\n";
479:                 } else {
480:                     $val = "\n" . $val;
481:                 }
482: 
483:                 if ($sig_first) {
484:                     $val .= "\n\n\n";
485:                 }
486:             }
487:         }
488: 
489:         if ($val && ($type == 'html')) {
490:             if ($convert) {
491:                 $val = IMP_Compose::text2html(trim($val));
492:             }
493: 
494:             $val = '<p>&nbsp;</p><div class="impComposeSignature">' . $val . '</div>';
495:         }
496: 
497:         try {
498:             $val = Horde::callHook('signature', array($val), 'imp');
499:         } catch (Horde_Exception_HookNotSet $e) {}
500: 
501:         $this->_cached['signatures'][$key] = $val;
502: 
503:         return $val;
504:     }
505: 
506:     /**
507:      * Returns an array with the signatures from all identities
508:      *
509:      * @param string $type  Either 'text' or 'html'.
510:      *
511:      * @return array  The array with all the signatures.
512:      */
513:     public function getAllSignatures($type = 'text')
514:     {
515:         foreach ($this->_identities as $key => $identity) {
516:             $list[$key] = $this->getSignature($type, $key);
517:         }
518: 
519:         return $list;
520:     }
521: 
522:     /**
523:      * Returns a property from one of the identities.
524:      *
525:      * @see getValue()
526:      */
527:     public function getValue($key, $identity = null)
528:     {
529:         $val = parent::getValue($key, $identity);
530: 
531:         switch ($key) {
532:         case 'sent_mail_folder':
533:             return (is_string($val) && strlen($val))
534:                 ? IMP_Mailbox::get(IMP_Mailbox::prefFrom($val))
535:                 : null;
536: 
537:         default:
538:             return $val;
539:         }
540:     }
541: 
542:     /**
543:      * Sets a property with a specified value.
544:      *
545:      * @see setValue()
546:      */
547:     public function setValue($key, $val, $identity = null)
548:     {
549:         if ($key == 'sent_mail_folder') {
550:             if ($val) {
551:                 $val->expire(IMP_Mailbox::CACHE_SPECIALMBOXES);
552:             } else {
553:                 IMP_Mailbox::get('INBOX')->expire(IMP_Mailbox::CACHE_SPECIALMBOXES);
554:             }
555:             $val = IMP_Mailbox::prefTo($val);
556:         }
557:         return parent::setValue($key, $val, $identity);
558:     }
559: 
560:     /**
561:      * Returns an array with the sent-mail folder names from all the
562:      * identities.
563:      *
564:      * @return array  The array with the sent-mail objects.
565:      */
566:     public function getAllSentmailFolders()
567:     {
568:         $list = array();
569: 
570:         foreach (array_keys($this->_identities) as $key) {
571:             if ($folder = $this->getValue('sent_mail_folder', $key)) {
572:                 $list[strval($folder)] = 1;
573:             }
574:         }
575: 
576:         return IMP_Mailbox::get(array_keys($list));
577:     }
578: 
579:     /**
580:      * Returns true if the mail should be saved and the user is allowed to.
581:      *
582:      * @param integer $ident  The identity to retrieve the setting from.
583:      *
584:      * @return boolean  True if the sent mail should be saved.
585:      */
586:     public function saveSentmail($ident = null)
587:     {
588:         return $GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->access(IMP_Imap::ACCESS_FOLDERS)
589:             ? $this->getValue('save_sent_mail', $ident)
590:             : false;
591:     }
592: 
593:     /**
594:      * Return a domain-appropriate address list.
595:      *
596:      * @param string $in  The input string.
597:      *
598:      * @return array  See Horde_Mime_Address::parseAddressList().
599:      */
600:     protected function _getAddrList($in)
601:     {
602:         return Horde_Mime_Address::parseAddressList($in, array(
603:             'defserver' => $GLOBALS['session']->get('imp', 'maildomain')
604:         ));
605:     }
606: 
607: }
608: 
API documentation generated by ApiGen