本文整理汇总了PHP中IMP_Mailbox::getPref方法的典型用法代码示例。如果您正苦于以下问题:PHP IMP_Mailbox::getPref方法的具体用法?PHP IMP_Mailbox::getPref怎么用?PHP IMP_Mailbox::getPref使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMP_Mailbox
的用法示例。
在下文中一共展示了IMP_Mailbox::getPref方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updateSpecialMboxes
/**
* Update special mailbox preferences.
*
* @param string $pref The pref name to update.
* @param IMP_Mailbox $form The form data.
* @param string $new The new mailbox name.
* @param string $type Special use attribute (RFC 6154).
* @param Horde_Core_Prefs_Ui $ui The UI object.
*
* @return boolean True if preferences were updated.
*/
protected function _updateSpecialMboxes($pref, $form, $new, $type, Horde_Core_Prefs_Ui $ui)
{
global $injector, $prefs;
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if (!$imp_imap->access(IMP_Imap::ACCESS_FOLDERS) || $prefs->isLocked($pref)) {
return false;
}
$cache = $injector->getInstance('IMP_Mailbox_SessionCache');
if ($mbox_ob = IMP_Mailbox::getPref($pref)) {
$cache->expire(array(IMP_Mailbox_SessionCache::CACHE_DISPLAY, IMP_Mailbox_SessionCache::CACHE_LABEL, IMP_Mailbox_SessionCache::CACHE_SPECIALMBOXES), $mbox_ob);
}
if ($form == self::PREF_NO_MBOX) {
return $prefs->setValue($pref, '');
}
if (strpos($form, self::PREF_SPECIALUSE) === 0) {
$mbox = IMP_Mailbox::get(substr($form, strlen(self::PREF_SPECIALUSE)));
} elseif (!empty($new)) {
$mbox = IMP_Mailbox::get($new)->namespace_append;
$opts = is_null($type) ? array() : array('special_use' => array($type));
if (!$mbox->create($opts)) {
$mbox = null;
}
} else {
$mbox = $form;
}
if (!$mbox) {
return false;
}
$cache->expire(array(IMP_Mailbox_SessionCache::CACHE_DISPLAY, IMP_Mailbox_SessionCache::CACHE_LABEL), $mbox);
return $prefs->setValue($pref, $mbox->pref_to);
}
示例2: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $injector, $page_output;
$page_output->addScriptFile('prefs/folder.js');
$page_output->addInlineJsVars(array('ImpFolderPrefs.mboxes.drafts' => _("Enter the name for your new drafts mailbox.")));
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
$view->addHelper('Horde_Core_View_Helper_Label');
$iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
$iterator->add(array($iterator::NONIMAP, $iterator::REMOTE));
$iterator->mboxes = array('INBOX');
$view->flist = new IMP_Ftree_Select(array('basename' => true, 'iterator' => $iterator, 'new_mbox' => true, 'selected' => IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS)));
$view->nombox = IMP_Mailbox::formTo(self::PREF_NO_MBOX);
$view->special_use = $this->_getSpecialUse(Horde_Imap_Client::SPECIALUSE_DRAFTS);
return $view->render('drafts');
}
示例3: display
/**
*/
public function display(Horde_Core_Prefs_Ui $ui)
{
global $injector, $page_output, $prefs;
if ($prefs->isLocked(IMP_Mailbox::MBOX_TEMPLATES)) {
return '';
}
$page_output->addScriptFile('prefs/folder.js');
$page_output->addInlineJsVars(array('ImpFolderPrefs.mboxes.templates' => _("Enter the name for your new compose templates mailbox.")));
$view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/prefs'));
$view->addHelper('Horde_Core_View_Helper_Label');
$iterator = new IMP_Ftree_IteratorFilter($injector->getInstance('IMP_Ftree'));
$iterator->add(array($iterator::NONIMAP, $iterator::REMOTE));
$iterator->mboxes = array('INBOX');
$view->mbox_flist = new IMP_Ftree_Select(array('iterator' => $iterator, 'new_mbox' => true, 'selected' => IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TEMPLATES)));
$view->mbox_nomailbox = IMP_Mailbox::formTo(self::PREF_NO_MBOX);
return $view->render('composetemplates');
}
示例4: update
/**
*/
public function update(Horde_Core_Prefs_Ui $ui)
{
global $injector, $prefs;
$imp_search = $injector->getInstance('IMP_Search');
$curr_vtrash = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH)->vtrash;
$trash = IMP_Mailbox::formFrom($ui->vars->trash);
if (!$prefs->isLocked('vfolder')) {
$vtrash = $imp_search['vtrash'];
$vtrash->enabled = $trash->vtrash;
$imp_search['vtrash'] = $vtrash;
}
if (!$this->_updateSpecialMboxes(IMP_Mailbox::MBOX_TRASH, $trash, $ui->vars->trash_new, Horde_Imap_Client::SPECIALUSE_TRASH, $ui)) {
return false;
}
$injector->getInstance('IMP_Factory_Imap')->create()->updateFetchIgnore();
/* Switching to/from Virtual Trash requires us to expire all currently
* cached mailbox lists (hide deleted status may have changed). */
if ($curr_vtrash || $trash->vtrash) {
$injector->getInstance('IMP_Factory_MailboxList')->expireAll();
}
return true;
}
示例5: _init
/**
* URL Parameters:
* - a: (string) The action ID.
* - action: (string) The action ID (used on redirect page).
* - bcc: (string) BCC address(es).
* - bcc_expand_[1-5]: (string) Expand matches for BCC addresses.
* - cc: (string) CC address(es).
* - cc_expand_[1-5]: (string) Expand matches for BCC addresses.
* - composeCache: (string) Compose object cache ID.
* - from: (string) From address to use.
* - identity: (integer) The identity to use for composing.
* - message: (string) Message text.
* - subject: (string) Message subject.
* - to: (string) To address(es).
* - to_expand_[1-5]: (string) Expand matches for To addresses.
* - u: (string) Unique ID (cache buster).
*/
protected function _init()
{
global $injector, $notification, $prefs, $registry;
/* The message text and headers. */
$expand = array();
$header = array('to' => '', 'cc' => '', 'bcc' => '');
$msg = '';
$this->title = _("Compose Message");
/* Get the list of headers to display. */
$display_hdrs = array('to' => _("To: "), 'cc' => _("Cc: "), 'bcc' => "Bcc: ");
/* Set the current identity. */
$identity = $injector->getInstance('IMP_Identity');
if (!$prefs->isLocked('default_identity') && isset($this->vars->identity)) {
$identity->setDefault($this->vars->identity);
}
/* Determine if mailboxes are readonly. */
$drafts = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS);
$readonly_drafts = $drafts && $drafts->readonly;
$sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
$save_sent_mail = !$sent_mail || $sent_mail->readonly ? false : $prefs->getValue('save_sent_mail');
/* Determine if compose mode is disabled. */
$compose_disable = !IMP_Compose::canCompose();
/* Initialize objects. */
$imp_compose = $injector->getInstance('IMP_Factory_Compose')->create($this->vars->composeCache);
/* Are attachments allowed? */
$attach_upload = $imp_compose->canUploadAttachment();
foreach (array_keys($display_hdrs) as $val) {
$header[$val] = $this->vars->{$val};
/* If we are reloading the screen, check for expand matches. */
if ($this->vars->composeCache) {
$expanded = array();
for ($i = 0; $i < 5; ++$i) {
if ($tmp = $this->vars->get($val . '_expand_' . $i)) {
$expanded[] = $tmp;
}
}
if (!empty($expanded)) {
$header['to'] = strlen($header['to']) ? implode(', ', $expanded) . ', ' . $header['to'] : implode(', ', $expanded);
}
}
}
/* Add attachment. */
if ($attach_upload && isset($_FILES['upload_1']) && strlen($_FILES['upload_1']['name'])) {
try {
$atc_ob = $imp_compose->addAttachmentFromUpload('upload_1');
if ($atc_ob[0] instanceof IMP_Compose_Exception) {
throw $atc_ob[0];
}
if ($this->vars->a == _("Expand Names")) {
$notification->push(sprintf(_("Added \"%s\" as an attachment."), $atc_ob[0]->getPart()->getName()), 'horde.success');
}
} catch (IMP_Compose_Exception $e) {
$this->vars->a = null;
$notification->push($e, 'horde.error');
}
}
/* Run through the action handlers. */
switch ($this->vars->a) {
// 'd' = draft
// 'en' = edit as new
// 't' = template
case 'd':
case 'en':
case 't':
try {
switch ($this->vars->a) {
case 'd':
$result = $imp_compose->resumeDraft($this->indices, array('format' => 'text'));
$this->view->resume = true;
break;
case 'en':
$result = $imp_compose->editAsNew($this->indices, array('format' => 'text'));
break;
case 't':
$result = $imp_compose->useTemplate($this->indices, array('format' => 'text'));
break;
}
$msg = $result['body'];
$header = array_merge($header, $this->_convertToHeader($result));
if (!is_null($result['identity']) && $result['identity'] != $identity->getDefault() && !$prefs->isLocked('default_identity')) {
$identity->setDefault($result['identity']);
$sent_mail = $identity->getValue(IMP_Mailbox::MBOX_SENT);
}
//.........这里部分代码省略.........
示例6: emptyMailbox
/**
* Empties the entire mailbox.
*/
public function emptyMailbox()
{
global $notification, $prefs;
if (!$this->access_empty) {
$notification->push(sprintf(_("Could not delete messages from %s. This mailbox is read-only."), $this->display), 'horde.error');
return;
}
if ($this->vtrash) {
foreach (IMP_Mailbox::get($this->getSearchOb()->mboxes) as $val) {
$val->expunge();
}
$notification->push(_("Emptied all messages from Virtual Trash Folder."), 'horde.success');
return;
}
/* Make sure there is at least 1 message before attempting to
* delete. */
try {
$imp_imap = $this->imp_imap;
$status = $imp_imap->status($this, Horde_Imap_Client::STATUS_MESSAGES);
if (empty($status['messages'])) {
$notification->push(sprintf(_("The mailbox %s is already empty."), $this->display), 'horde.message');
return;
}
$trash = $prefs->getValue('use_trash') ? IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH) : null;
if (!$trash || $trash == $this) {
$imp_imap->store($this, array('add' => array(Horde_Imap_Client::FLAG_DELETED)));
$this->expunge();
} else {
$ret = $imp_imap->search($this);
$this->getIndicesOb($ret['match'])->delete();
}
$notification->push(sprintf(_("Emptied all messages from %s."), $this->display), 'horde.success');
} catch (IMP_Imap_Exception $e) {
}
}
示例7: getSpecialMailboxes
/**
* Return the list of special mailboxes.
*
* @return array A list of mailboxes, with the SPECIAL_* constants
* as keys and values containing the IMP_Mailbox objects or
* null if the mailbox doesn't exist (SPECIAL_SENT
* contains an array of objects).
*/
public function getSpecialMailboxes()
{
global $injector, $prefs;
if (!isset($this->_temp[self::CACHE_SPECIALMBOXES])) {
$sm = array(IMP_Mailbox::SPECIAL_COMPOSETEMPLATES => IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TEMPLATES), IMP_Mailbox::SPECIAL_DRAFTS => IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS), IMP_Mailbox::SPECIAL_SENT => $injector->getInstance('IMP_Identity')->getAllSentmail(), IMP_Mailbox::SPECIAL_SPAM => IMP_Mailbox::getPref(IMP_Mailbox::MBOX_SPAM), IMP_Mailbox::SPECIAL_TRASH => $prefs->getValue('use_trash') ? IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH) : null, IMP_Mailbox::SPECIAL_USER => array());
foreach ($injector->getInstance('IMP_Factory_Imap')->create()->config->user_special_mboxes as $key => $val) {
$ob = IMP_Mailbox::get($key);
$ob->display = $val;
$sm[IMP_Mailbox::SPECIAL_USER][strval($key)] = $ob;
}
$this->_temp[self::CACHE_SPECIALMBOXES] = $sm;
}
return $this->_temp[self::CACHE_SPECIALMBOXES];
}
示例8: _spamMbox
/**
* Return the spam mailbox.
*
* @return IMP_Mailbox The spam mailbox, if it exists. Otherwise, false.
*/
protected function _spamMbox()
{
return ($spam = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_SPAM)) && $spam->exists ? $spam : false;
}
示例9: _initPages
/**
*/
protected function _initPages()
{
global $injector, $registry, $session;
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
$this->view->allowFolders = $imp_imap->access(IMP_Imap::ACCESS_FOLDERS);
$this->view->canInnocent = !empty($imp_imap->config->innocent_params);
$this->view->canSearch = $imp_imap->access(IMP_Imap::ACCESS_SEARCH);
$this->view->canSpam = !empty($imp_imap->config->spam_params);
if ($this->view->canCompose = IMP_Compose::canCompose()) {
/* Setting up identities. */
$identity = $injector->getInstance('IMP_Identity');
$this->view->identities = array();
foreach ($identity->getSelectList() as $id => $from) {
$this->view->identities[] = array('label' => $from, 'sel' => $id == $identity->getDefault(), 'val' => $id);
}
$this->view->user = $registry->getAuth();
$this->view->draft = $imp_imap->access(IMP_Imap::ACCESS_DRAFTS) && ($draft = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_DRAFTS)) && !$draft->readonly;
if (IMP_Compose::canUploadAttachment()) {
$this->view->attach = true;
$this->view->max_size = $session->get('imp', 'file_upload');
}
}
}
示例10: _upgradeMailboxPrefs
/**
* As of IMP 6, special mailboxes are stored in UTF-8, not UTF7-IMAP.
*/
protected function _upgradeMailboxPrefs()
{
global $injector, $prefs;
$special_mboxes = array('drafts_folder', 'spam_folder', 'trash_folder');
foreach ($special_mboxes as $val) {
if (!$prefs->isDefault($val)) {
$old_pref = strval(IMP_Mailbox::getPref($val));
if (!Horde_Mime::is8bit($old_pref)) {
$mbox = IMP_Mailbox::get(new Horde_Imap_Client_Mailbox($old_pref, true));
$prefs->setValue($val, $mbox->pref_to);
}
}
}
$imp_identity = $injector->getInstance('IMP_Identity');
foreach ($imp_identity->getAll('sent_mail_folder') as $key => $val) {
if (!is_null($val) && !Horde_Mime::is8bit($val)) {
$mbox = IMP_Mailbox::get(new Horde_Imap_Client_Mailbox($val, true));
$imp_identity->setValue(IMP_Mailbox::MBOX_SENT, $mbox, $key);
}
}
}
示例11: _upgradeMailboxPrefs
/**
* As of IMP 6, special mailboxes are stored in UTF-8, not UTF7-IMAP.
*/
protected function _upgradeMailboxPrefs()
{
global $injector, $prefs;
$special_mboxes = array('drafts_folder', 'spam_folder', 'trash_folder');
foreach ($special_mboxes as $val) {
if (!$prefs->isDefault($val)) {
$old_pref = strval(IMP_Mailbox::getPref($val));
if (!Horde_Mime::is8bit($old_pref, 'UTF-8')) {
$mbox = IMP_Mailbox::get(Horde_String::convertCharset($old_pref, 'UTF7-IMAP', 'UTF-8'));
$prefs->setValue($val, $old_pref->{$mbox}->pref_to);
}
}
}
$imp_identity = $injector->getInstance('IMP_Identity');
foreach ($imp_identity->getAll('sent_mail_folder') as $key => $val) {
if (!is_null($val) && !Horde_Mime::is8bit($val, 'UTF-8')) {
$mbox = IMP_Mailbox::get(Horde_String::convertCharset(strval($val), 'UTF7-IMAP', 'UTF-8'));
$imp_identity->setValue(IMP_Mailbox::MBOX_SENT, $mbox, $key);
}
}
}
示例12: saveTemplate
/**
* Save a template message on the IMAP server.
*
* @param array $headers List of message headers (UTF-8).
* @param mixed $message Either the message text (string) or a
* Horde_Mime_Part object that contains the text
* to save.
* @param array $opts An array of options w/the following keys:
* - html: (boolean) Is this an HTML message?
* - priority: (string) The message priority ('high', 'normal', 'low').
* - readreceipt: (boolean) Add return receipt headers?
*
* @return string Notification text on success.
*
* @throws IMP_Compose_Exception
*/
public function saveTemplate($headers, $message, array $opts = array())
{
if (!($mbox = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TEMPLATES))) {
throw new IMP_Compose_Exception(_("Saving the template failed: no template mailbox exists."));
}
/* Check for access to mailbox. */
if (!$mbox->create()) {
throw new IMP_Compose_Exception(_("Saving the template failed: could not create the templates mailbox."));
}
$append_flags = array(Horde_Imap_Client::FLAG_SEEN);
$old_uid = $this->getMetadata('template_uid_edit');
/* Add the message to the mailbox. */
try {
$mbox->imp_imap->append($mbox, array(array('data' => $this->_saveDraftMsg($headers, $message, $opts), 'flags' => $append_flags, 'verify_email' => true)));
if ($old_uid) {
$old_uid->delete(array('nuke' => true));
}
} catch (IMP_Imap_Exception $e) {
return _("The template was not successfully saved.");
}
return _("The template has been saved.");
}
示例13: menu
/**
*/
public function menu($menu)
{
global $injector, $prefs, $registry, $session;
$imp_imap = $injector->getInstance('IMP_Factory_Imap')->create();
if ($imp_imap->access(IMP_Imap::ACCESS_TRASH) && $prefs->getValue('use_trash') && $prefs->getValue('empty_trash_menu') && ($trash = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH)) && ($trash->vtrash || $trash->access_expunge)) {
$menu->addArray(array('class' => '__noselection', 'icon' => 'imp-empty-trash', 'onclick' => 'return window.confirm(' . json_encode(_("Are you sure you wish to empty your trash mailbox?")) . ')', 'text' => _("Empty _Trash"), 'url' => $trash->url('mailbox')->add(array('actionID' => 'empty_mailbox', 'token' => $session->getToken()))));
}
if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS) && $prefs->getValue('empty_spam_menu') && ($spam = IMP_Mailbox::getPref(IMP_Mailbox::MBOX_SPAM)) && $spam->access_expunge) {
$menu->addArray(array('class' => '__noselection', 'icon' => 'imp-empty-spam', 'onclick' => 'return window.confirm(' . json_encode(_("Are you sure you wish to empty your spam mailbox?")) . ')', 'text' => _("Empty _Spam"), 'url' => $spam->url('mailbox')->add(array('actionID' => 'empty_mailbox', 'token' => $session->getToken()))));
}
if ($imp_imap->access(IMP_Imap::ACCESS_FOLDERS)) {
$menu->addArray(array('icon' => 'imp-folder', 'text' => _("_Folders"), 'url' => IMP_Basic_Folders::url()));
}
if ($imp_imap->access(IMP_Imap::ACCESS_SEARCH)) {
$menu->addArray(array('icon' => 'imp-search', 'text' => _("_Search"), 'url' => IMP_Basic_Search::url()));
}
if ($prefs->getValue('filter_menuitem')) {
$menu->addArray(array('icon' => 'imp-filters', 'text' => _("Fi_lters"), 'url' => $registry->getServiceLink('prefs', 'imp')->add('group', 'filters')));
}
}
示例14: array
$ui->prefs['reply_lang']['enum'] = $enum;
});
// The list of buttons to show in CKeditor
// See http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Toolbar for
// details on configuration
$_prefs['ckeditor_buttons'] = array('value' => "[['Bold','Italic','Underline'],['Font','FontSize'],['TextColor','BGColor'],['Cut','Copy','Paste'],['Undo','Redo'],['NumberedList','BulletedList'],['Link','Unlink'],['Image','Table','Smiley','SpecialChar']]");
$_prefs['signature_expanded'] = array('value' => 0, 'type' => 'implicit');
// *** Compose Templates Preferences ***
$prefGroups['composetemplates'] = array('column' => _("Compose"), 'label' => _("Compose Templates"), 'desc' => _("Edit compose templates."), 'members' => array('composetemplates_management', 'composetemplates_new'), 'suppress' => function () {
return !$GLOBALS['injector']->getInstance('IMP_Factory_Imap')->create()->isImap();
});
// Compose templates configuration widget
$_prefs['composetemplates_management'] = array('type' => 'special', 'handler' => 'IMP_Prefs_Special_ComposeTemplates');
// Link to compose templates mailbox.
$_prefs['composetemplates_new'] = array('type' => 'link', 'xurl' => '', 'img' => 'edit.png', 'desc' => _("Create new Template"), 'suppress' => function () {
return !IMP_Mailbox::getPref('composetemplates_mbox');
}, 'on_init' => function ($ui) {
$clink = new IMP_Compose_Link();
$ui->prefs['composetemplates_new']['xurl'] = $clink->link()->add(array('actionID' => 'template_new', 'type' => 'template_new'));
});
// Compose templates mailbox
$_prefs['composetemplates_mbox'] = array('value' => 'Templates');
// *** Compose Reply Preferences ***
$prefGroups['reply'] = array('column' => _("Compose"), 'label' => _("Replies"), 'desc' => _("Configure how you reply to mail."), 'members' => array('reply_format', 'reply_charset', 'reply_headers', 'reply_quote', 'attrib_text', 'reply_strip_sig'));
$_prefs['reply_format'] = array('value' => 0, 'type' => 'checkbox', 'desc' => _("When replying, use the same format as the original message?"));
$_prefs['reply_charset'] = array('desc' => _("Use the charset of the original message when replying?"), 'advanced' => true, 'value' => 0, 'type' => 'checkbox');
$_prefs['reply_headers'] = array('desc' => _("Include a brief summary of the original message's header in a reply?"), 'value' => 0, 'type' => 'checkbox');
$_prefs['reply_quote'] = array('value' => 1, 'advanced' => true, 'type' => 'checkbox', 'desc' => _("Include original message in a reply?"));
$_prefs['attrib_text'] = array('value' => _("Quoting %f:"), 'advanced' => true, 'type' => 'text', 'desc' => _("How to attribute quoted lines in a reply?"), 'help' => 'prefs-attrib_text', 'requires' => array('reply_quote'));
$_prefs['reply_strip_sig'] = array('desc' => _("Strip the sender's signature from plaintext replies?"), 'advanced' => true, 'value' => 0, 'type' => 'checkbox', 'requires' => array('reply_quote'));
// *** Compose Forward Preferences ***
示例15: describe
/**
* Return information for the login task.
*
* @return string Description of what the operation is going to do during
* this login.
*/
public function describe()
{
return sprintf(_("All messages in your \"%s\" mailbox older than %s days will be permanently deleted."), IMP_Mailbox::getPref(IMP_Mailbox::MBOX_TRASH)->display_html, $GLOBALS['prefs']->getValue('purge_trash_keep'));
}