本文整理汇总了PHP中CRM_Core_SelectValues::ufVisibility方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_SelectValues::ufVisibility方法的具体用法?PHP CRM_Core_SelectValues::ufVisibility怎么用?PHP CRM_Core_SelectValues::ufVisibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_SelectValues
的用法示例。
在下文中一共展示了CRM_Core_SelectValues::ufVisibility方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
public function buildQuickForm()
{
$this->add('text', 'title', ts('Find'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'));
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
$config = CRM_Core_Config::singleton();
if ($config->userFramework == 'Joomla') {
unset($groupTypes['Access Control']);
}
$this->addCheckBox('group_type', ts('Type'), $groupTypes, NULL, NULL, NULL, NULL, ' ');
$this->add('select', 'visibility', ts('Visibility'), array('' => ts('- any visibility -')) + CRM_Core_SelectValues::ufVisibility(TRUE));
$groupStatuses = array(ts('Enabled') => 1, ts('Disabled') => 2);
$this->addCheckBox('group_status', ts('Status'), $groupStatuses, NULL, NULL, NULL, NULL, ' ');
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => TRUE)));
parent::buildQuickForm();
$this->assign('suppressForm', TRUE);
}
示例2: buildQuickForm
public function buildQuickForm()
{
$this->add('text', 'title', ts('Find'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'));
require_once 'CRM/Core/OptionGroup.php';
$groupTypes = CRM_Core_OptionGroup::values('group_type', true);
$config =& CRM_Core_Config::singleton();
if ($config->userFramework == 'Joomla') {
unset($groupTypes['Access Control']);
}
$this->addCheckBox('group_type', ts('Type'), $groupTypes, null, null, null, null, ' ');
$this->add('select', 'visibility', ts('Visibility'), array('' => ts('- any visibility -')) + CRM_Core_SelectValues::ufVisibility(true));
$this->addElement('checkbox', 'active_status', ts('Enabled'));
$this->addElement('checkbox', 'inactive_status', ts('Disabled'));
$this->addButtons(array(array('type' => 'refresh', 'name' => ts('Search'), 'isDefault' => true)));
parent::buildQuickForm();
}
示例3: getGroupList
/**
* This function to get list of groups.
*
* @param array $params
* Associated array for params.
*
* @return array
*/
public static function getGroupList(&$params)
{
$config = CRM_Core_Config::singleton();
$whereClause = self::whereClause($params, FALSE);
//$this->pagerAToZ( $whereClause, $params );
if (!empty($params['rowCount']) && $params['rowCount'] > 0) {
$limit = " LIMIT {$params['offset']}, {$params['rowCount']} ";
}
$orderBy = ' ORDER BY groups.title asc';
if (!empty($params['sort'])) {
$orderBy = ' ORDER BY ' . CRM_Utils_Type::escape($params['sort'], 'String');
// CRM-16905 - Sort by count cannot be done with sql
if (strpos($params['sort'], 'count') === 0) {
$orderBy = $limit = '';
}
}
$select = $from = $where = "";
$groupOrg = FALSE;
if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
$select = ", contact.display_name as org_name, contact.id as org_id";
$from = " LEFT JOIN civicrm_group_organization gOrg\n ON gOrg.group_id = groups.id\n LEFT JOIN civicrm_contact contact\n ON contact.id = gOrg.organization_id ";
//get the Organization ID
$orgID = CRM_Utils_Request::retrieve('oid', 'Positive', CRM_Core_DAO::$_nullObject);
if ($orgID) {
$where = " AND gOrg.organization_id = {$orgID}";
}
$groupOrg = TRUE;
}
$query = "\n SELECT groups.*, createdBy.sort_name as created_by {$select}\n FROM civicrm_group groups\n LEFT JOIN civicrm_contact createdBy\n ON createdBy.id = groups.created_id\n {$from}\n WHERE {$whereClause} {$where}\n GROUP BY groups.id\n {$orderBy}\n {$limit}";
$object = CRM_Core_DAO::executeQuery($query, $params, TRUE, 'CRM_Contact_DAO_Group');
//FIXME CRM-4418, now we are handling delete separately
//if we introduce 'delete for group' make sure to handle here.
$groupPermissions = array(CRM_Core_Permission::VIEW);
if (CRM_Core_Permission::check('edit groups')) {
$groupPermissions[] = CRM_Core_Permission::EDIT;
$groupPermissions[] = CRM_Core_Permission::DELETE;
}
// CRM-9936
$reservedPermission = CRM_Core_Permission::check('administer reserved groups');
$links = self::actionLinks();
$allTypes = CRM_Core_OptionGroup::values('group_type');
$values = $groupsToCount = array();
$visibility = CRM_Core_SelectValues::ufVisibility();
while ($object->fetch()) {
$permission = CRM_Contact_BAO_Group::checkPermission($object->id, $object->title);
//@todo CRM-12209 introduced an ACL check in the whereClause function
// it may be that this checking is now obsolete - or that what remains
// should be removed to the whereClause (which is also accessed by getCount)
if ($permission) {
$newLinks = $links;
$values[$object->id] = array('class' => array(), 'count' => '0');
CRM_Core_DAO::storeValues($object, $values[$object->id]);
// Wrap with crm-editable. Not an ideal solution.
if (in_array(CRM_Core_Permission::EDIT, $groupPermissions)) {
$values[$object->id]['title'] = '<span class="crm-editable crmf-title">' . $values[$object->id]['title'] . '</span>';
}
if ($object->saved_search_id) {
$values[$object->id]['title'] .= ' (' . ts('Smart Group') . ')';
// check if custom search, if so fix view link
$customSearchID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_SavedSearch', $object->saved_search_id, 'search_custom_id');
if ($customSearchID) {
$newLinks[CRM_Core_Action::VIEW]['url'] = 'civicrm/contact/search/custom';
$newLinks[CRM_Core_Action::VIEW]['qs'] = "reset=1&force=1&ssID={$object->saved_search_id}";
}
}
$action = array_sum(array_keys($newLinks));
// CRM-9936
if (array_key_exists('is_reserved', $object)) {
//if group is reserved and I don't have reserved permission, suppress delete/edit
if ($object->is_reserved && !$reservedPermission) {
$action -= CRM_Core_Action::DELETE;
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
}
}
if (array_key_exists('is_active', $object)) {
if ($object->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$values[$object->id]['class'][] = 'disabled';
$action -= CRM_Core_Action::VIEW;
$action -= CRM_Core_Action::DISABLE;
}
}
$action = $action & CRM_Core_Action::mask($groupPermissions);
$values[$object->id]['visibility'] = $visibility[$values[$object->id]['visibility']];
$groupsToCount[$object->saved_search_id ? 'civicrm_group_contact_cache' : 'civicrm_group_contact'][] = $object->id;
if (isset($values[$object->id]['group_type'])) {
$groupTypes = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($values[$object->id]['group_type'], 1, -1));
$types = array();
foreach ($groupTypes as $type) {
$types[] = CRM_Utils_Array::value($type, $allTypes);
//.........这里部分代码省略.........
示例4: buildQuickForm
//.........这里部分代码省略.........
$phoneTypes = CRM_Core_PseudoConstant::phoneType();
ksort($phoneTypes);
foreach ($sel1 as $k => $sel) {
if ($k) {
foreach ($this->_location_types as $key => $value) {
$sel4[$k]['phone'][$key] =& $phoneTypes;
}
}
}
foreach ($sel1 as $k => $sel) {
if ($k) {
if (is_array($this->_mapperFields[$k])) {
foreach ($this->_mapperFields[$k] as $key => $value) {
if ($hasLocationTypes[$k][$key]) {
$sel3[$k][$key] = $this->_location_types;
} else {
$sel3[$key] = null;
}
}
}
}
}
$this->_defaults = array();
$js = "<script type='text/javascript'>\n";
$formName = "document.{$this->_name}";
$alreadyMixProfile = false;
if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
$alreadyMixProfile = true;
}
$this->assign('alreadyMixProfile', $alreadyMixProfile);
$attributes = array('onclick' => "showLabel();mixProfile();", 'onblur' => 'showLabel();mixProfile();');
$sel =& $this->addElement('hierselect', "field_name", ts('Field Name'), $attributes);
$formValues = array();
$formValues = $this->exportValues();
if (empty($formValues)) {
for ($k = 1; $k < 4; $k++) {
if (!$defaults['field_name'][$k]) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
} else {
if (!empty($formValues['field_name'])) {
foreach ($formValues['field_name'] as $value) {
for ($k = 1; $k < 4; $k++) {
if (!isset($formValues['field_name'][$k]) || !$formValues['field_name'][$k]) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
} else {
$js .= "{$formName}['field_name[{$k}]'].style.display = '';\n";
}
}
}
} else {
for ($k = 1; $k < 4; $k++) {
if (!isset($defaults['field_name'][$k])) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
}
}
foreach ($sel2 as $k => $v) {
if (is_array($sel2[$k])) {
asort($sel2[$k]);
}
}
$sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
$js .= "</script>\n";
$this->assign('initHideBoxes', $js);
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), true, array("onChange" => "showHideSeletorSearch(this.value);"));
//CRM-4363
$js = array('onclick' => "mixProfile();");
// should the field appear in selectors (as a column)?
$this->add('checkbox', 'in_selector', ts('Results Column?'), null, null, $js);
$this->add('checkbox', 'is_searchable', ts('Searchable?'), null, null, $js);
// weight
$this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'weight'), true);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
$this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'help_post'));
// listings title
$this->add('text', 'listings_title', ts('Listings Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'listings_title'));
$this->addRule('listings_title', ts('Please enter a valid title for this field when displayed in user listings.'), 'title');
$this->add('checkbox', 'is_required', ts('Required?'));
$this->add('checkbox', 'is_active', ts('Active?'));
$this->add('checkbox', 'is_view', ts('View Only?'));
// $this->add( 'checkbox', 'is_registration', ts( 'Display in Registration Form?' ) );
//$this->add( 'checkbox', 'is_match' , ts( 'Key to Match Contacts?' ) );
$this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'label'));
$js = null;
if ($this->_hasSearchableORInSelector) {
$js = array('onclick' => "return verify( );");
}
// add buttons
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true, 'js' => $js), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $js), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_UF_Form_Field', 'formRule'), $this);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"));
}
$this->setDefaults($defaults);
}
示例5: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_action == CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Group'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'title', ts('Name') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE);
$this->add('textarea', 'description', ts('Description') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
$config = CRM_Core_Config::singleton();
if (isset($this->_id) && CRM_Utils_Array::value('saved_search_id', $this->_groupValues)) {
unset($groupTypes['Access Control']);
}
if (!empty($groupTypes)) {
$this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' ');
}
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(TRUE), TRUE);
$groupNames = CRM_Core_PseudoConstant::group();
$parentGroups = $parentGroupElements = array();
if (isset($this->_id) && CRM_Utils_Array::value('parents', $this->_groupValues)) {
$parentGroupIds = explode(',', $this->_groupValues['parents']);
foreach ($parentGroupIds as $parentGroupId) {
$parentGroups[$parentGroupId] = $groupNames[$parentGroupId];
if (array_key_exists($parentGroupId, $groupNames)) {
$parentGroupElements[$parentGroupId] = $groupNames[$parentGroupId];
$this->addElement('checkbox', "remove_parent_group_{$parentGroupId}", $groupNames[$parentGroupId]);
}
}
}
$this->assign_by_ref('parent_groups', $parentGroupElements);
if (isset($this->_id)) {
$potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($this->_id, $groupNames);
} else {
$potentialParentGroupIds = array_keys($groupNames);
}
$parentGroupSelectValues = array('' => '- ' . ts('select') . ' -');
foreach ($potentialParentGroupIds as $potentialParentGroupId) {
if (array_key_exists($potentialParentGroupId, $groupNames)) {
$parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
}
}
if (count($parentGroupSelectValues) > 1) {
if (CRM_Core_Permission::isMultisiteEnabled()) {
$required = empty($parentGroups) ? TRUE : FALSE;
$required = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) || !isset($this->_id) ? FALSE : $required;
} else {
$required = FALSE;
}
$this->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required);
}
if (CRM_Core_Permission::check('administer Multiple Organizations') && CRM_Core_Permission::isMultisiteEnabled()) {
//group organization Element
$groupOrgDataURL = CRM_Utils_System::url('civicrm/ajax/search', 'org=1', FALSE, NULL, FALSE);
$this->assign('groupOrgDataURL', $groupOrgDataURL);
$this->addElement('text', 'organization', ts('Organization'), '');
$this->addElement('hidden', 'organization_id', '', array('id' => 'organization_id'));
}
// is_reserved property CRM-9936
$this->addElement('checkbox', 'is_reserved', ts('Reserved Group?'));
if (!CRM_Core_Permission::check('administer reserved groups')) {
$this->freeze('is_reserved');
}
//build custom data
CRM_Custom_Form_CustomData::buildQuickForm($this);
$this->addButtons(array(array('type' => 'upload', 'name' => $this->_action == CRM_Core_Action::ADD ? ts('Continue') : ts('Save'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
$doParentCheck = FALSE;
if (CRM_Core_Permission::isMultisiteEnabled()) {
$doParentCheck = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? FALSE : TRUE;
}
$options = array('selfObj' => $this, 'parentGroups' => $parentGroups, 'doParentCheck' => $doParentCheck);
$this->addFormRule(array('CRM_Group_Form_Edit', 'formRule'), $options);
}
示例6: buildQuickForm
//.........这里部分代码省略.........
}
foreach ($fields as $key => $value) {
foreach ($value as $key1 => $value1) {
$this->_mapperFields[$key][$key1] = $value1['title'];
$hasLocationTypes[$key][$key1] = $value1['hasLocationType'];
}
}
require_once 'CRM/Core/BAO/LocationType.php';
$this->_location_types =& CRM_Core_PseudoConstant::locationType();
$defaultLocationType =& CRM_Core_BAO_LocationType::getDefault();
/* FIXME: dirty hack to make the default option show up first. This
* avoids a mozilla browser bug with defaults on dynamically constructed
* selector widgets. */
if ($defaultLocationType) {
$defaultLocation = $this->_location_types[$defaultLocationType->id];
unset($this->_location_types[$defaultLocationType->id]);
$this->_location_types = array($defaultLocationType->id => $defaultLocation) + $this->_location_types;
}
$sel1 = array('' => '-select-') + CRM_Core_SelectValues::contactType();
if (!empty($contribFields)) {
$sel1['Contribution'] = 'Contributions';
}
foreach ($sel1 as $key => $sel) {
if ($key) {
$sel2[$key] = $this->_mapperFields[$key];
}
}
$sel3[''] = null;
$phoneTypes = CRM_Core_SelectValues::phoneType();
foreach ($sel1 as $k => $sel) {
if ($k) {
foreach ($this->_location_types as $key => $value) {
$sel4[$k]['phone'][$key] =& $phoneTypes;
}
}
}
foreach ($sel1 as $k => $sel) {
if ($k) {
foreach ($this->_mapperFields[$k] as $key => $value) {
if ($hasLocationTypes[$k][$key]) {
$sel3[$k][$key] = $this->_location_types;
} else {
$sel3[$key] = null;
}
}
}
}
$this->_defaults = array();
$js = "<script type='text/javascript'>\n";
$formName = "document.{$this->_name}";
$sel =& $this->addElement('hierselect', "field_name", ts('Field Name'), 'onclick="showLabel();"');
$formValues = array();
//$formValues = $this->controller->exportValues( $this->_name );
$formValues = $_POST;
// using $_POST since export values don't give values on first submit
if (empty($formValues)) {
for ($k = 1; $k < 4; $k++) {
if (!$defaults['field_name'][$k]) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
} else {
foreach ($formValues['field_name'] as $value) {
for ($k = 1; $k < 4; $k++) {
if (!$formValues['field_name'][$k]) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
}
}
$sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
$js .= "</script>\n";
$this->assign('initHideBoxes', $js);
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), true);
// should the field appear in selector?
$this->add('checkbox', 'in_selector', ts('In Selector?'));
// weight
$this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'weight'), true);
$this->addRule('weight', ts(' is a numeric field'), 'numeric');
$this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'help_post'));
// listings title
$this->add('text', 'listings_title', ts('Listings Title'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'listings_title'));
$this->addRule('listings_title', ts('Please enter a valid title for this field when displayed in user listings.'), 'title');
$this->add('checkbox', 'is_required', ts('Required?'));
$this->add('checkbox', 'is_active', ts('Active?'));
$this->add('checkbox', 'is_searchable', ts('Searchable?'));
$this->add('checkbox', 'is_view', ts('View Only?'));
// $this->add( 'checkbox', 'is_registration', ts( 'Display in Registration Form?' ) );
//$this->add( 'checkbox', 'is_match' , ts( 'Key to Match Contacts?' ) );
$this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField', 'label'));
// add buttons
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_UF_Form_Field', 'formRule'));
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_CORE_ACTION_VIEW) {
$this->freeze();
$this->addElement('button', 'done', ts('Done'), array('onClick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"));
}
$this->setDefaults($defaults);
}
示例7: buildQuickForm
//.........这里部分代码省略.........
if ($k) {
foreach ($this->_location_types as $key => $value) {
$sel4[$k]['phone'][$key] =& $phoneTypes;
$sel4[$k]['phone_and_ext'][$key] =& $phoneTypes;
}
}
}
foreach ($sel1 as $k => $sel) {
if ($k) {
if (is_array($this->_mapperFields[$k])) {
foreach ($this->_mapperFields[$k] as $key => $value) {
if ($hasLocationTypes[$k][$key]) {
$sel3[$k][$key] = $this->_location_types;
} elseif ($hasWebsiteTypes[$k][$key]) {
$sel3[$k][$key] = $this->_website_types;
} else {
$sel3[$key] = NULL;
}
}
}
}
}
$this->_defaults = array();
$js = "<script type='text/javascript'>\n";
$formName = "document.{$this->_name}";
$alreadyMixProfile = FALSE;
if (CRM_Core_BAO_UFField::checkProfileType($this->_gid)) {
$alreadyMixProfile = TRUE;
}
$this->assign('alreadyMixProfile', $alreadyMixProfile);
$sel =& $this->addElement('hierselect', 'field_name', ts('Field Name'));
$formValues = $this->exportValues();
if (empty($formValues)) {
for ($k = 1; $k < 4; $k++) {
if (!isset($defaults['field_name'][$k])) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
} else {
if (!empty($formValues['field_name'])) {
for ($key = 1; $key < 4; $key++) {
if (!isset($formValues['field_name'][$key])) {
$js .= "{$formName}['field_name[{$key}]'].style.display = 'none';\n";
} else {
$js .= "{$formName}['field_name[{$key}]'].style.display = '';\n";
}
}
} else {
for ($k = 1; $k < 4; $k++) {
if (!isset($defaults['field_name'][$k])) {
$js .= "{$formName}['field_name[{$k}]'].style.display = 'none';\n";
}
}
}
}
foreach ($sel2 as $k => $v) {
if (is_array($sel2[$k])) {
asort($sel2[$k]);
}
}
$sel->setOptions(array($sel1, $sel2, $sel3, $sel4));
// proper interpretation of spec in CRM-8732
if (!isset($this->_id) && in_array('Search Profile', $otherModules)) {
$defaults['visibility'] = 'Public Pages and Listings';
}
$js .= "</script>\n";
$this->assign('initHideBoxes', $js);
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), TRUE, array('onChange' => "showHideSeletorSearch(this.value);"));
//CRM-4363
$js = array('onChange' => "mixProfile();");
// should the field appear in selectors (as a column)?
$this->add('checkbox', 'in_selector', ts('Results Column?'), NULL, NULL, $js);
$this->add('checkbox', 'is_searchable', ts('Searchable?'), NULL, NULL, $js);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_UFField');
// weight
$this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE);
$this->addRule('weight', ts('is a numeric field'), 'numeric');
$this->add('textarea', 'help_pre', ts('Field Pre Help'), $attributes['help_pre']);
$this->add('textarea', 'help_post', ts('Field Post Help'), $attributes['help_post']);
$this->add('checkbox', 'is_required', ts('Required?'));
$this->add('checkbox', 'is_multi_summary', ts('Include in multi-record listing?'));
$this->add('checkbox', 'is_active', ts('Active?'));
$this->add('checkbox', 'is_view', ts('View Only?'));
// $this->add( 'checkbox', 'is_registration', ts( 'Display in Registration Form?' ) );
//$this->add( 'checkbox', 'is_match' , ts( 'Key to Match Contacts?' ) );
$this->add('text', 'label', ts('Field Label'), $attributes['label']);
$js = NULL;
if ($this->_hasSearchableORInSelector) {
$js = array('onclick' => "return verify( );");
}
// add buttons
$this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE, 'js' => $js), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new', 'js' => $js), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->addFormRule(array('CRM_UF_Form_Field', 'formRule'), $this);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->freeze();
$this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='civicrm/admin/uf/group/field?reset=1&action=browse&gid=" . $this->_gid . "'"));
}
$this->setDefaults($defaults);
}
示例8: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_action == CRM_Core_Action::DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Group'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'title', ts('Name') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), true);
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title'));
$this->add('textarea', 'description', ts('Description') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
require_once 'CRM/Core/OptionGroup.php';
$groupTypes = CRM_Core_OptionGroup::values('group_type', true);
$config =& CRM_Core_Config::singleton();
if (isset($this->_id) && CRM_Utils_Array::value('saved_search_id', $this->_groupValues) || $config->userFramework == 'Joomla') {
unset($groupTypes['Access Control']);
}
if (!CRM_Core_Permission::access('CiviMail')) {
unset($groupTypes['Mailing List']);
}
if (!empty($groupTypes)) {
$this->addCheckBox('group_type', ts('Group Type'), $groupTypes, null, null, null, null, ' ');
}
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(true), true);
$groupNames =& CRM_Core_PseudoConstant::group();
$parentGroups = array();
if (isset($this->_id) && CRM_Utils_Array::value('parents', $this->_groupValues)) {
$parentGroupIds = explode(',', $this->_groupValues['parents']);
foreach ($parentGroupIds as $parentGroupId) {
$parentGroups[$parentGroupId] = $groupNames[$parentGroupId];
$this->addElement('checkbox', "remove_parent_group_{$parentGroupId}", $groupNames[$parentGroupId]);
}
}
$this->assign_by_ref('parent_groups', $parentGroups);
if (isset($this->_id)) {
require_once 'CRM/Contact/BAO/GroupNestingCache.php';
$potentialParentGroupIds = CRM_Contact_BAO_GroupNestingCache::getPotentialCandidates($this->_id, $groupNames);
} else {
$potentialParentGroupIds = array_keys($groupNames);
}
$parentGroupSelectValues = array('' => '- ' . ts('select') . ' -');
foreach ($potentialParentGroupIds as $potentialParentGroupId) {
if (array_key_exists($potentialParentGroupId, $groupNames)) {
$parentGroupSelectValues[$potentialParentGroupId] = $groupNames[$potentialParentGroupId];
}
}
if (count($parentGroupSelectValues) > 1) {
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
$required = empty($parentGroups) ? true : false;
$required = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? false : $required;
} else {
$required = false;
}
$this->add('select', 'parents', ts('Add Parent'), $parentGroupSelectValues, $required);
}
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE && CRM_Core_Permission::check('administer Multiple Organizations')) {
//group organization Element
$groupOrgDataURL = CRM_Utils_System::url('civicrm/ajax/search', 'org=1', false, null, false);
$this->assign('groupOrgDataURL', $groupOrgDataURL);
$this->addElement('text', 'organization', ts('Organization'), '');
$this->addElement('hidden', 'organization_id', '', array('id' => 'organization_id'));
}
//build custom data
CRM_Custom_Form_Customdata::buildQuickForm($this);
$this->addButtons(array(array('type' => 'upload', 'name' => $this->_action == CRM_Core_Action::ADD ? ts('Continue') : ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
if (defined('CIVICRM_MULTISITE') && CIVICRM_MULTISITE) {
$doParentCheck = $this->_id && CRM_Core_BAO_Domain::isDomainGroup($this->_id) ? false : true;
} else {
$doParentCheck = false;
}
if ($doParentCheck) {
$this->addFormRule(array('CRM_Group_Form_Edit', 'formRule'), $parentGroups);
}
}
示例9: browse
/**
* Browse all CiviCRM Profile group fields.
*
* @return void
*/
public function browse()
{
$resourceManager = CRM_Core_Resources::singleton();
if (!empty($_GET['new']) && $resourceManager->ajaxPopupsEnabled) {
$resourceManager->addScriptFile('civicrm', 'js/crm.addNew.js', 999, 'html-header');
}
$ufField = array();
$ufFieldBAO = new CRM_Core_BAO_UFField();
// fkey is gid
$ufFieldBAO->uf_group_id = $this->_gid;
$ufFieldBAO->orderBy('weight', 'field_name');
$ufFieldBAO->find();
$otherModules = CRM_Core_BAO_UFGroup::getUFJoinRecord($this->_gid);
$this->assign('otherModules', $otherModules);
$isGroupReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $this->_gid, 'is_reserved');
$this->assign('isGroupReserved', $isGroupReserved);
$profileType = CRM_Core_BAO_UFField::getProfileType($this->_gid);
if ($profileType == 'Contribution' || $profileType == 'Membership' || $profileType == 'Activity' || $profileType == 'Participant') {
$this->assign('skipCreate', TRUE);
}
$locationType = array();
$locationType = CRM_Core_PseudoConstant::get('CRM_Core_DAO_Address', 'location_type_id');
$fields = CRM_Contact_BAO_Contact::exportableFields('All', FALSE, TRUE);
$fields = array_merge(CRM_Contribute_BAO_Contribution::getContributionFields(), $fields);
$select = array();
foreach ($fields as $name => $field) {
if ($name) {
$select[$name] = $field['title'];
}
}
$select['group'] = ts('Group(s)');
$select['tag'] = ts('Tag(s)');
$visibility = CRM_Core_SelectValues::ufVisibility();
while ($ufFieldBAO->fetch()) {
$ufField[$ufFieldBAO->id] = array();
$phoneType = $locType = '';
CRM_Core_DAO::storeValues($ufFieldBAO, $ufField[$ufFieldBAO->id]);
$ufField[$ufFieldBAO->id]['visibility_display'] = $visibility[$ufFieldBAO->visibility];
$ufField[$ufFieldBAO->id]['label'] = $ufFieldBAO->label;
$action = array_sum(array_keys($this->actionLinks()));
if ($ufFieldBAO->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
if ($ufFieldBAO->is_reserved) {
$action -= CRM_Core_Action::UPDATE;
$action -= CRM_Core_Action::DISABLE;
$action -= CRM_Core_Action::DELETE;
}
$ufField[$ufFieldBAO->id]['order'] = $ufField[$ufFieldBAO->id]['weight'];
$ufField[$ufFieldBAO->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $ufFieldBAO->id, 'gid' => $this->_gid), ts('more'), FALSE, 'ufField.row.actions', 'UFField', $ufFieldBAO->id);
}
$returnURL = CRM_Utils_System::url('civicrm/admin/uf/group/field', "reset=1&action=browse&gid={$this->_gid}");
$filter = "uf_group_id = {$this->_gid}";
CRM_Utils_Weight::addOrder($ufField, 'CRM_Core_DAO_UFField', 'id', $returnURL, $filter);
$this->assign('ufField', $ufField);
// retrieve showBestResult from session
$session = CRM_Core_Session::singleton();
$showBestResult = $session->get('showBestResult');
$this->assign('showBestResult', $showBestResult);
$session->set('showBestResult', 0);
}
示例10: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
$this->addElement('checkbox', 'override_verp', ts('Track Replies?'));
$defaults['override_verp'] = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MAILING_PREFERENCES_NAME, 'track_civimail_replies', NULL, FALSE);
$this->add('checkbox', 'forward_replies', ts('Forward Replies?'));
$defaults['forward_replies'] = FALSE;
$this->add('checkbox', 'url_tracking', ts('Track Click-throughs?'));
$defaults['url_tracking'] = TRUE;
$this->add('checkbox', 'open_tracking', ts('Track Opens?'));
$defaults['open_tracking'] = TRUE;
$this->add('checkbox', 'auto_responder', ts('Auto-respond to Replies?'));
$defaults['auto_responder'] = FALSE;
$this->add('select', 'visibility', ts('Mailing Visibility'), CRM_Core_SelectValues::ufVisibility(TRUE), TRUE);
$this->add('select', 'reply_id', ts('Auto-responder'), CRM_Mailing_PseudoConstant::component('Reply'), TRUE);
$this->add('select', 'unsubscribe_id', ts('Unsubscribe Message'), CRM_Mailing_PseudoConstant::component('Unsubscribe'), TRUE);
$this->add('select', 'resubscribe_id', ts('Resubscribe Message'), CRM_Mailing_PseudoConstant::component('Resubscribe'), TRUE);
$this->add('select', 'optout_id', ts('Opt-out Message'), CRM_Mailing_PseudoConstant::component('OptOut'), TRUE);
$buttons = array(array('type' => 'back', 'name' => ts('<< Previous')), array('type' => 'next', 'name' => ts('Next >>'), 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'submit', 'name' => ts('Save & Continue Later')), array('type' => 'cancel', 'name' => ts('Cancel')));
$this->addButtons($buttons);
$this->setDefaults($defaults);
}
示例11: buildQuickForm
/**
* Function to actually build the form
*
* @return None
* @access public
*/
function buildQuickForm()
{
if ($this->_action == CRM_CORE_ACTION_DELETE) {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Delete Group'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
} else {
$this->applyFilter('__ALL__', 'trim');
$this->add('text', 'title', ts('Name:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'));
$this->addRule('title', ts('Group name is required.'), 'required');
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $this->_id, 'title'));
$this->add('text', 'description', ts('Description:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
$this->add('select', 'visibility', ts('Visibility'), CRM_Core_SelectValues::ufVisibility(), true);
$this->addButtons(array(array('type' => 'next', 'name' => $this->_action == CRM_CORE_ACTION_ADD ? ts('Continue') : ts('Save'), 'isDefault' => true), array('type' => 'cancel', 'name' => ts('Cancel'))));
$this->_groupTree =& CRM_Core_BAO_CustomGroup::getTree('Group', $this->_id, 0);
CRM_Core_BAO_CustomGroup::buildQuickForm($this, $this->_groupTree, 'showBlocks1', 'hideBlocks1');
}
}