本文整理汇总了PHP中CRM_Core_PseudoConstant::mailProtocol方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::mailProtocol方法的具体用法?PHP CRM_Core_PseudoConstant::mailProtocol怎么用?PHP CRM_Core_PseudoConstant::mailProtocol使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_PseudoConstant
的用法示例。
在下文中一共展示了CRM_Core_PseudoConstant::mailProtocol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getStore
/**
* Return the proper mail store implementation, based on config settings
*
* @param string $name name of the settings set from civimail_mail_settings to use (null for default)
* @return object mail store implementation for processing CiviMail-bound emails
*/
function getStore($name = null)
{
$dao = new CRM_Core_DAO_MailSettings();
$dao->domain_id = CRM_Core_Config::domainID();
$name ? $dao->name = $name : ($dao->is_default = 1);
if (!$dao->find(true)) {
throw new Exception("Could not find entry named {$name} in civicrm_mail_settings");
}
$protocols =& CRM_Core_PseudoConstant::mailProtocol();
switch ($protocols[$dao->protocol]) {
case 'IMAP':
require_once 'CRM/Mailing/MailStore/Imap.php';
return new CRM_Mailing_MailStore_Imap($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl, $dao->source);
case 'POP3':
require_once 'CRM/Mailing/MailStore/Pop3.php';
return new CRM_Mailing_MailStore_Pop3($dao->server, $dao->username, $dao->password, (bool) $dao->is_ssl);
case 'Maildir':
require_once 'CRM/Mailing/MailStore/Maildir.php';
return new CRM_Mailing_MailStore_Maildir($dao->source);
case 'Localdir':
require_once 'CRM/Mailing/MailStore/Localdir.php';
return new CRM_Mailing_MailStore_Localdir($dao->source);
// DO NOT USE the mbox transport for anything other than testing
// in particular, it does not clear the mbox afterwards
// DO NOT USE the mbox transport for anything other than testing
// in particular, it does not clear the mbox afterwards
case 'mbox':
require_once 'CRM/Mailing/MailStore/Mbox.php';
return new CRM_Mailing_MailStore_Mbox($dao->source);
default:
throw new Exception("Unknown protocol {$dao->protocol}");
}
}
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
parent::buildQuickForm();
if ($this->_action & CRM_Core_Action::DELETE) {
return;
}
$this->applyFilter('__ALL__', 'trim');
//get the attributes.
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_MailSettings');
//build setting form
$this->add('text', 'name', ts('Name'), $attributes['name'], TRUE);
$this->add('text', 'domain', ts('Email Domain'), $attributes['domain'], TRUE);
$this->addRule('domain', ts('Email domain must use a valid internet domain format (e.g. \'example.org\').'), 'domain');
$this->add('text', 'localpart', ts('Localpart'), $attributes['localpart']);
$this->add('text', 'return_path', ts('Return-Path'), $attributes['return_path']);
$this->addRule('return_path', ts('Return-Path must use a valid email address format.'), 'email');
$this->add('select', 'protocol', ts('Protocol'), array('' => ts('- select -')) + CRM_Core_PseudoConstant::mailProtocol(), TRUE);
$this->add('text', 'server', ts('Server'), $attributes['server']);
$this->add('text', 'username', ts('Username'), array('autocomplete' => 'off'));
$this->add('password', 'password', ts('Password'), array('autocomplete' => 'off'));
$this->add('text', 'source', ts('Source'), $attributes['source']);
$this->add('checkbox', 'is_ssl', ts('Use SSL?'));
$usedfor = array(1 => ts('Bounce Processing'), 0 => ts('Email-to-Activity Processing'));
$this->add('select', 'is_default', ts('Used For?'), $usedfor);
}
示例3: browse
/**
* Browse all mail settings.
*
* @return void
* @access public
* @static
*/
function browse()
{
//get all mail settings.
$allMailSettings = array();
$mailSetting = new CRM_Core_DAO_MailSettings();
$allProtocols = CRM_Core_PseudoConstant::mailProtocol();
//multi-domain support for mail settings. CRM-5244
$mailSetting->domain_id = CRM_Core_Config::domainID();
//find all mail settings.
$mailSetting->find();
while ($mailSetting->fetch()) {
//replace protocol value with name
$mailSetting->protocol = CRM_Utils_Array::value($mailSetting->protocol, $allProtocols);
CRM_Core_DAO::storeValues($mailSetting, $allMailSettings[$mailSetting->id]);
//form all action links
$action = array_sum(array_keys($this->links()));
// disallow the DELETE action for the default set of settings
if ($mailSetting->is_default) {
$action &= ~CRM_Core_Action::DELETE;
}
//add action links.
$allMailSettings[$mailSetting->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $mailSetting->id));
}
$this->assign('rows', $allMailSettings);
}
示例4:
/**
* Get the all Mail Protocols from database.
*
* The static array mailProtocol is returned, and if it's
* called the first time, the DAO is used
* to get all the Mail Protocol.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all Mail Protocols.
*/
public static function &mailProtocol()
{
if (!self::$mailProtocol) {
require_once 'CRM/Core/OptionGroup.php';
self::$mailProtocol = CRM_Core_OptionGroup::values('mail_protocol');
}
return self::$mailProtocol;
}
示例5:
/**
* Get the all Mail Protocols from database.
*
* The static array mailProtocol is returned, and if it's
* called the first time, the DAO is used
* to get all the Mail Protocol.
*
* Note: any database errors will be trapped by the DAO.
*
* @access public
* @static
*
* @return array - array reference of all Mail Protocols.
*/
public static function &mailProtocol()
{
if (!self::$mailProtocol) {
self::$mailProtocol = CRM_Core_OptionGroup::values('mail_protocol');
}
return self::$mailProtocol;
}