本文整理汇总了PHP中CRM_Utils_Array::collectMethod方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Array::collectMethod方法的具体用法?PHP CRM_Utils_Array::collectMethod怎么用?PHP CRM_Utils_Array::collectMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_Array
的用法示例。
在下文中一共展示了CRM_Utils_Array::collectMethod方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
parent::buildQuickForm();
$this->_mappingID = $mappingID = NULL;
$providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
//CRM-16777: Don't provide access to administer schedule reminder page, with user that does not have 'administer CiviCRM' permission
if (empty($this->_context) && !CRM_Core_Permission::check('administer CiviCRM')) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
} else {
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
if (!CRM_Event_BAO_Event::checkPermission($this->_compId, CRM_Core_Permission::EDIT)) {
CRM_Core_Error::fatal(ts('You do not have permission to access this page.'));
}
}
if ($this->_action & CRM_Core_Action::DELETE) {
$reminderName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'title');
if ($this->_context == 'event') {
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
}
$this->assign('reminderName', $reminderName);
return;
} elseif ($this->_action & CRM_Core_Action::UPDATE) {
$this->_mappingID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_ActionSchedule', $this->_id, 'mapping_id');
if ($this->_context == 'event') {
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
}
} elseif (!empty($this->_context)) {
if ($this->_context == 'event') {
$this->_compId = CRM_Utils_Request::retrieve('compId', 'Integer', $this);
$isTemplate = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_compId, 'is_template');
$mapping = CRM_Utils_Array::first(CRM_Core_BAO_ActionSchedule::getMappings(array('id' => $isTemplate ? CRM_Event_ActionMapping::EVENT_TPL_MAPPING_ID : CRM_Event_ActionMapping::EVENT_NAME_MAPPING_ID)));
if ($mapping) {
$this->_mappingID = $mapping->getId();
} else {
CRM_Core_Error::fatal('Could not find mapping for event scheduled reminders.');
}
}
}
if (!empty($_POST) && !empty($_POST['entity']) && empty($this->_context)) {
$mappingID = $_POST['entity'][0];
} elseif ($this->_mappingID) {
$mappingID = $this->_mappingID;
}
$this->add('text', 'title', ts('Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_ActionSchedule', 'title'), TRUE);
$mappings = CRM_Core_BAO_ActionSchedule::getMappings();
$selectedMapping = $mappings[$mappingID ? $mappingID : 1];
$entityRecipientLabels = $selectedMapping->getRecipientTypes() + CRM_Core_BAO_ActionSchedule::getAdditionalRecipients();
$this->assign('entityMapping', json_encode(CRM_Utils_Array::collectMethod('getEntity', $mappings)));
$this->assign('recipientMapping', json_encode(array_combine(array_keys($entityRecipientLabels), array_keys($entityRecipientLabels))));
if (empty($this->_context)) {
$sel =& $this->add('hierselect', 'entity', ts('Entity'), array('name' => 'entity[0]', 'style' => 'vertical-align: top;'));
$sel->setOptions(array(CRM_Utils_Array::collectMethod('getLabel', $mappings), CRM_Core_BAO_ActionSchedule::getAllEntityValueLabels(), CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels()));
if (is_a($sel->_elements[1], 'HTML_QuickForm_select')) {
// make second selector a multi-select -
$sel->_elements[1]->setMultiple(TRUE);
$sel->_elements[1]->setSize(5);
}
if (is_a($sel->_elements[2], 'HTML_QuickForm_select')) {
// make third selector a multi-select -
$sel->_elements[2]->setMultiple(TRUE);
$sel->_elements[2]->setSize(5);
}
} else {
// Dig deeper - this code is sublimely stupid.
$allEntityStatusLabels = CRM_Core_BAO_ActionSchedule::getAllEntityStatusLabels();
$options = $allEntityStatusLabels[$this->_mappingID][0];
$attributes = array('multiple' => 'multiple', 'class' => 'crm-select2 huge', 'placeholder' => $options[0]);
unset($options[0]);
$this->add('select', 'entity', ts('Recipient(s)'), $options, TRUE, $attributes);
$this->assign('context', $this->_context);
}
//get the frequency units.
$this->_freqUnits = CRM_Core_SelectValues::getRecurringFrequencyUnits();
$numericOptions = CRM_Core_SelectValues::getNumericOptions(0, 30);
//reminder_interval
$this->add('select', 'start_action_offset', ts('When'), $numericOptions);
$isActive = ts('Send email');
$recordActivity = ts('Record activity for automated email');
if ($providersCount) {
$this->assign('sms', $providersCount);
$isActive = ts('Send email or SMS');
$recordActivity = ts('Record activity for automated email or SMS');
$options = CRM_Core_OptionGroup::values('msg_mode');
$this->add('select', 'mode', ts('Send as'), $options);
$providers = CRM_SMS_BAO_Provider::getProviders(NULL, NULL, TRUE, 'is_default desc');
$providerSelect = array();
foreach ($providers as $provider) {
$providerSelect[$provider['id']] = $provider['title'];
}
$this->add('select', 'sms_provider_id', ts('SMS Provider'), $providerSelect, TRUE);
}
foreach ($this->_freqUnits as $val => $label) {
$freqUnitsDisplay[$val] = ts('%1(s)', array(1 => $label));
}
$this->addDate('absolute_date', ts('Start Date'), FALSE, array('formatType' => 'mailing'));
//reminder_frequency
//.........这里部分代码省略.........