本文整理汇总了PHP中CRM_Core_BAO_Tag类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Tag类的具体用法?PHP CRM_Core_BAO_Tag怎么用?PHP CRM_Core_BAO_Tag使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_BAO_Tag类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
* @return void
*/
public function buildQuickForm()
{
// get categories for the contact id
$entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
$this->assign('tagged', $entityTag);
// get the list of all the categories
$allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
// need to append the array with the " checked " if contact is tagged with the tag
foreach ($allTag as $tagID => $varValue) {
if (in_array($tagID, $entityTag)) {
$tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
} else {
$tagAttribute = array('id' => "tag_{$tagID}");
}
$tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
}
$this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree($this->_entityTable, TRUE);
// let's not load jstree if there are not children. This also fixes blank
// display at the beginning of checkboxes
$loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
$this->assign('loadjsTree', FALSE);
if (!empty($loadJsTree)) {
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
$this->assign('loadjsTree', TRUE);
}
$this->assign('tree', $tree);
$this->assign('tag', $allTag);
//build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
}
开发者ID:kidaa30,项目名称:yes,代码行数:38,代码来源:Tag.php
示例2: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
// get categories for the contact id
$entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
$this->assign('tagged', $entityTag);
// get the list of all the categories
$allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
// need to append the array with the " checked " if contact is tagged with the tag
foreach ($allTag as $tagID => $varValue) {
if (in_array($tagID, $entityTag)) {
$tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'checked' => 'checked', 'id' => "tag_{$tagID}");
} else {
$tagAttribute = array('onclick' => "return changeRowColor(\"rowidtag_{$tagID}\")", 'id' => "tag_{$tagID}");
}
$tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
}
$this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree($this->_entityTable, TRUE);
$this->assign('tree', $tree);
$this->assign('tag', $allTag);
//build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
if ($this->_action & CRM_Core_Action::BROWSE) {
$this->freeze();
} else {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:36,代码来源:Tag.php
示例3: buildQuickForm
/**
* Function to build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
// get categories for the contact id
$entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
$this->assign('tagged', $entityTag);
// get the list of all the categories
$allTag = CRM_Core_BAO_Tag::getTagsUsedFor($this->_entityTable);
// need to append the array with the " checked " if contact is tagged with the tag
foreach ($allTag as $tagID => $varValue) {
if (in_array($tagID, $entityTag)) {
$tagAttribute = array('checked' => 'checked', 'id' => "tag_{$tagID}");
} else {
$tagAttribute = array('id' => "tag_{$tagID}");
}
$tagChk[$tagID] = $this->createElement('checkbox', $tagID, '', '', $tagAttribute);
}
$this->addGroup($tagChk, 'tagList', NULL, NULL, TRUE);
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree($this->_entityTable, TRUE);
$this->assign('tree', $tree);
$this->assign('tag', $allTag);
//build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, $this->_entityTable, $this->_entityID);
if ($this->_action & CRM_Core_Action::BROWSE) {
$this->freeze();
} else {
$this->addButtons(array(array('type' => 'next', 'name' => ts('Update Tags'), 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
}
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:37,代码来源:Tag.php
示例4: getTags
/**
* Method to get groups
*
* @return array
* @access protected
*/
protected function getTags()
{
$tags = CRM_Core_BAO_Tag::getTagsUsedFor();
$options = array();
foreach ($tags as $tag_id => $tag) {
$options[$tag_id] = $tag;
}
return $options;
}
开发者ID:alejandro-ixiam,项目名称:org.civicoop.civirules,代码行数:15,代码来源:TagId.php
示例5: crm_delete_tag
/**
* Deletes an existing Tag
*
* @param object $tag valid tag object
* @return NULL | error if delete successfull then NULL otherwise object of CRM_Core_Error
* @access public
*/
function crm_delete_tag(&$tag)
{
require_once 'CRM/Core/BAO/Tag.php';
if (!isset($tag->id)) {
return _crm_error('Invalid Tag object passed in');
}
if (CRM_Core_BAO_Tag::del($tag->id)) {
return null;
} else {
return _crm_error('Error while deleting Tag object');
}
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:19,代码来源:Tag.php
示例6: postProcess
/**
* Function to process the form
*
* @access public
* @return None
*/
function postProcess()
{
$params = $ids = array();
// store the submitted values in an array
$params = $this->exportValues();
$ids['tag'] = $this->_id;
if ($this->_action == CRM_CORE_ACTION_DELETE) {
if ($this->_id > 0) {
CRM_Core_BAO_Tag::del($this->_id);
}
} else {
CRM_Core_BAO_Tag::add($params, $ids);
}
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:20,代码来源:Tag.php
示例7: civicrm_api3_tag_create
/**
* Add a Tag. Tags are used to classify CRM entities (including Contacts, Groups and Actions).
*
* Allowed @params array keys are:
*
* {@example TagCreate.php}
*
* @return array of newly created tag property values.
* {@getfields tag_create}
* @access public
*/
function civicrm_api3_tag_create($params)
{
$ids = array('tag' => CRM_Utils_Array::value('tag', $params));
if (CRM_Utils_Array::value('tag', $params)) {
$ids['tag'] = $params['tag'];
}
if (CRM_Utils_Array::value('id', $params)) {
$ids['tag'] = $params['id'];
}
$tagBAO = CRM_Core_BAO_Tag::add($params, $ids);
$values = array();
_civicrm_api3_object_to_array($tagBAO, $values[$tagBAO->id]);
return civicrm_api3_create_success($values, $params, 'tag', 'create', $tagBAO);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:25,代码来源:Tag.php
示例8: addTag
function addTag($param)
{
if (array_key_exists($param['name'], $this->tags)) {
echo "\n- exists already: " . $param['name'];
return;
}
$key = array('tag' => '');
if ($param['parent']) {
if (array_key_exists($param['parent'], $this->tags)) {
$param['parent_id'] = $this->tags[$param['parent']];
} else {
$param['parent_id'] = $this->addTag(array(parent => '', name => $param['parent']));
}
$tag = CRM_Core_BAO_Tag::add($param, $key);
echo "\n" . $tag->id . ": create " . $param['name'] . " below " . $param['parent'];
} else {
$tag = CRM_Core_BAO_Tag::add($param, $key);
echo "\n" . $tag->id . ": create " . $param['name'] . " (root)";
}
$this->tags[$param['name']] = $tag->id;
return $tag->id;
}
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:22,代码来源:ImportTags.php
示例9: buildQuickForm
/**
* Function to build the form
*
* @return None
* @access public
*/
public function buildQuickForm()
{
if ($this->_batchStatusId == 2) {
$this->add('submit', 'export_batch', ts('Export Batch'));
}
// do not build rest of form unless it is open batch
if ($this->_batchStatusId != 1) {
return;
}
parent::buildQuickForm();
$this->add('submit', 'close_batch', ts('Close Batch'));
$this->add('submit', 'export_batch', ts('Close & Export Batch'));
// text for sort_name
$this->addElement('text', 'sort_name', ts('Contributor Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
$this->_group = CRM_Core_PseudoConstant::group();
// multiselect for groups
if ($this->_group) {
$this->add('select', 'group', ts('Groups'), $this->_group, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'title' => ts('- select -')));
}
CRM_Contribute_BAO_Query::buildSearchForm($this);
$this->addElement('checkbox', 'toggleSelects', NULL, NULL);
$this->add('select', 'trans_remove', ts('Task'), array('' => ts('- actions -')) + array('Remove' => ts('Remove from Batch')));
$this->add('submit', 'rSubmit', ts('Go'), array('class' => 'form-submit', 'id' => 'GoRemove'));
self::$_entityID = CRM_Utils_Request::retrieve('bid', 'Positive');
$this->addButtons(array(array('type' => 'submit', 'name' => ts('Search'), 'isDefault' => TRUE)));
$this->addElement('checkbox', 'toggleSelect', NULL, NULL);
$this->add('select', 'trans_assign', ts('Task'), array('' => ts('- actions -')) + array('Assign' => ts('Assign to Batch')));
$this->add('submit', 'submit', ts('Go'), array('class' => 'form-submit', 'id' => 'Go'));
$this->applyFilter('__ALL__', 'trim');
$this->addElement('hidden', 'batch_id', self::$_entityID);
$this->add('text', 'name', ts('Batch Name'));
}
开发者ID:hguru,项目名称:224Civi,代码行数:42,代码来源:BatchTransaction.php
示例10: buildAttachment
static function buildAttachment(&$form, $entityTable, $entityID = NULL, $numAttachments = NULL, $ajaxDelete = FALSE)
{
if (!$numAttachments) {
$numAttachments = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'max_attachments');
}
// Assign maxAttachments count to template for help message
$form->assign('maxAttachments', $numAttachments);
$config = CRM_Core_Config::singleton();
// set default max file size as 2MB
$maxFileSize = $config->maxFileSize ? $config->maxFileSize : 2;
$currentAttachmentInfo = self::getEntityFile($entityTable, $entityID, TRUE);
$totalAttachments = 0;
if ($currentAttachmentInfo) {
$totalAttachments = count($currentAttachmentInfo);
$form->add('checkbox', 'is_delete_attachment', ts('Delete All Attachment(s)'));
$form->assign('currentAttachmentInfo', $currentAttachmentInfo);
} else {
$form->assign('currentAttachmentInfo', NULL);
}
if ($totalAttachments) {
if ($totalAttachments >= $numAttachments) {
$numAttachments = 0;
} else {
$numAttachments -= $totalAttachments;
}
}
$form->assign('numAttachments', $numAttachments);
$tags = CRM_Core_BAO_Tag::getTags('civicrm_file');
// get tagset info
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_file');
// add attachments
for ($i = 1; $i <= $numAttachments; $i++) {
$form->addElement('file', "attachFile_{$i}", ts('Attach File'), 'size=30 maxlength=60');
$form->addUploadElement("attachFile_{$i}");
$form->setMaxFileSize($maxFileSize * 1024 * 1024);
$form->addRule("attachFile_{$i}", ts('File size should be less than %1 MByte(s)', array(1 => $maxFileSize)), 'maxfilesize', $maxFileSize * 1024 * 1024);
$form->addElement('text', "attachDesc_{$i}", ts('Description'), 'size=40 maxlength=255');
if (!empty($tags)) {
$form->add('select', "tag_{$i}", ts('Tags'), $tags, FALSE, array('id' => "tags_{$i}", 'multiple' => 'multiple', 'title' => ts('- select -')));
}
}
// build tagset widget
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_file', NULL, TRUE, TRUE, FALSE);
}
开发者ID:hguru,项目名称:224Civi,代码行数:44,代码来源:File.php
示例11: buildQuickForm
public function buildQuickForm()
{
if ($this->_action & (CRM_Core_Action::DELETE | CRM_Core_Action::RENEW)) {
//enable form element (ActivityLinks sets this true)
$this->assign('suppressForm', FALSE);
$button = ts('Delete');
if ($this->_action & CRM_Core_Action::RENEW) {
$button = ts('Restore');
}
$this->addButtons(array(array('type' => 'next', 'name' => $button, 'spacing' => ' ', 'isDefault' => TRUE), array('type' => 'cancel', 'name' => ts('Cancel'))));
return;
}
// Build other activity links.
CRM_Activity_Form_ActivityLinks::commonBuildQuickForm($this);
// Enable form element (ActivityLinks sets this true).
$this->assign('suppressForm', FALSE);
$element =& $this->add('select', 'activity_type_id', ts('Activity Type'), array('' => '- ' . ts('select') . ' -') + $this->_fields['followup_activity_type_id']['attributes'], FALSE, array('onchange' => "CRM.buildCustomData( 'Activity', this.value );", 'class' => 'crm-select2 required'));
// Freeze for update mode.
if ($this->_action & CRM_Core_Action::UPDATE) {
$element->freeze();
}
// Call to RecurringEntity buildQuickForm for add/update mode.
if ($this->_action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
CRM_Core_Form_RecurringEntity::buildQuickForm($this);
}
foreach ($this->_fields as $field => $values) {
if (!empty($this->_fields[$field])) {
$attribute = CRM_Utils_Array::value('attributes', $values);
$required = !empty($values['required']);
if ($values['type'] == 'select' && empty($attribute)) {
$this->addSelect($field, array('entity' => 'activity'), $required);
} elseif ($values['type'] == 'entityRef') {
$this->addEntityRef($field, $values['label'], $attribute, $required);
} else {
$this->add($values['type'], $field, $values['label'], $attribute, $required, CRM_Utils_Array::value('extra', $values));
}
}
}
// CRM-7362 --add campaigns.
CRM_Campaign_BAO_Campaign::addCampaign($this, CRM_Utils_Array::value('campaign_id', $this->_values));
// Add engagement level CRM-7775
$buildEngagementLevel = FALSE;
if (CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$buildEngagementLevel = TRUE;
$this->addSelect('engagement_level', array('entity' => 'activity'));
$this->addRule('engagement_level', ts('Please enter the engagement index as a number (integers only).'), 'positiveInteger');
}
$this->assign('buildEngagementLevel', $buildEngagementLevel);
// check for survey activity
$this->_isSurveyActivity = FALSE;
if ($this->_activityId && CRM_Campaign_BAO_Campaign::isCampaignEnable() && CRM_Campaign_BAO_Campaign::accessCampaign()) {
$this->_isSurveyActivity = CRM_Campaign_BAO_Survey::isSurveyActivity($this->_activityId);
if ($this->_isSurveyActivity) {
$surveyId = CRM_Core_DAO::getFieldValue('CRM_Activity_DAO_Activity', $this->_activityId, 'source_record_id');
$responseOptions = CRM_Campaign_BAO_Survey::getResponsesOptions($surveyId);
if ($responseOptions) {
$this->add('select', 'result', ts('Result'), array('' => ts('- select -')) + array_combine($responseOptions, $responseOptions));
}
$surveyTitle = NULL;
if ($surveyId) {
$surveyTitle = CRM_Core_DAO::getFieldValue('CRM_Campaign_DAO_Survey', $surveyId, 'title');
}
$this->assign('surveyTitle', $surveyTitle);
}
}
$this->assign('surveyActivity', $this->_isSurveyActivity);
// this option should be available only during add mode
if ($this->_action != CRM_Core_Action::UPDATE) {
$this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
}
$this->addRule('duration', ts('Please enter the duration as number of minutes (integers only).'), 'positiveInteger');
$this->addDateTime('activity_date_time', ts('Date'), TRUE, array('formatType' => 'activityDateTime'));
// Add followup date.
$this->addDateTime('followup_date', ts('in'), FALSE, array('formatType' => 'activityDateTime'));
// Only admins and case-workers can change the activity source
if (!CRM_Core_Permission::check('administer CiviCRM') && $this->_context != 'caseActivity') {
$this->getElement('source_contact_id')->freeze();
}
//need to assign custom data type and subtype to the template
$this->assign('customDataType', 'Activity');
$this->assign('customDataSubType', $this->_activityTypeId);
$this->assign('entityID', $this->_activityId);
CRM_Core_BAO_Tag::getTags('civicrm_activity', $tags, NULL, ' ', TRUE);
if (!empty($tags)) {
$this->add('select', 'tag', ts('Tags'), $tags, FALSE, array('id' => 'tags', 'multiple' => 'multiple', 'class' => 'crm-select2 huge'));
}
// we need to hide activity tagset for special activities
$specialActivities = array('Open Case');
if (!in_array($this->_activityTypeName, $specialActivities)) {
// build tag widget
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_activity');
CRM_Core_Form_Tag::buildQuickForm($this, $parentNames, 'civicrm_activity', $this->_activityId);
}
// if we're viewing, we're assigning different buttons than for adding/editing
if ($this->_action & CRM_Core_Action::VIEW) {
if (isset($this->_groupTree)) {
CRM_Core_BAO_CustomGroup::buildCustomDataView($this, $this->_groupTree);
}
// form should be frozen for view mode
$this->freeze();
//.........这里部分代码省略.........
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:101,代码来源:Activity.php
示例12: buildTagFilter
/**
* Build the tag filter field to display on the filters tab.
*/
public function buildTagFilter()
{
$contactTags = CRM_Core_BAO_Tag::getTags($this->_tagFilterTable);
if (!empty($contactTags)) {
$this->_columns['civicrm_tag'] = array('dao' => 'CRM_Core_DAO_Tag', 'filters' => array('tagid' => array('name' => 'tag_id', 'title' => ts('Tag'), 'tag' => TRUE, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $contactTags)));
}
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:10,代码来源:Form.php
示例13: buildSearchForm
/**
* Add all the elements shared between case search and advanaced search.
*
*
* @param CRM_Core_Form $form
*
* @return void
*/
public static function buildSearchForm(&$form)
{
$config = CRM_Core_Config::singleton();
//validate case configuration.
$configured = CRM_Case_BAO_Case::isCaseConfigured();
$form->assign('notConfigured', !$configured['configured']);
$form->add('select', 'case_type_id', ts('Case Type'), CRM_Case_PseudoConstant::caseType('title', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
$form->add('select', 'case_status_id', ts('Case Status'), CRM_Case_PseudoConstant::caseStatus('label', FALSE), FALSE, array('class' => 'crm-select2', 'multiple' => 'multiple'));
CRM_Core_Form_Date::buildDateRange($form, 'case_from', 1, '_start_date_low', '_start_date_high', ts('From'), FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'case_to', 1, '_end_date_low', '_end_date_high', ts('From'), FALSE);
$form->assign('validCiviCase', TRUE);
//give options when all cases are accessible.
$accessAllCases = FALSE;
if (CRM_Core_Permission::check('access all cases and activities')) {
$accessAllCases = TRUE;
$caseOwner = array(1 => ts('Search All Cases'), 2 => ts('Only My Cases'));
$form->addRadio('case_owner', ts('Cases'), $caseOwner);
}
$form->assign('accessAllCases', $accessAllCases);
$caseTags = CRM_Core_BAO_Tag::getTags('civicrm_case');
if ($caseTags) {
foreach ($caseTags as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "case_tags[{$tagID}]", NULL, $tagName);
}
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_case');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_case', NULL, TRUE, FALSE);
if (CRM_Core_Permission::check('administer CiviCRM')) {
$form->addElement('checkbox', 'case_deleted', ts('Deleted Cases'));
}
// add all the custom searchable fields
$extends = array('Case');
$groupDetails = CRM_Core_BAO_CustomGroup::getGroupDetail(NULL, TRUE, $extends);
if ($groupDetails) {
$form->assign('caseGroupTree', $groupDetails);
foreach ($groupDetails as $group) {
foreach ($group['fields'] as $field) {
$fieldId = $field['id'];
$elementName = 'custom_' . $fieldId;
CRM_Core_BAO_CustomField::addQuickFormElement($form, $elementName, $fieldId, FALSE, FALSE, TRUE);
}
}
}
$form->setDefaults(array('case_owner' => 1));
}
开发者ID:scardinius,项目名称:civicrm-core-api-mailing,代码行数:53,代码来源:Query.php
示例14: buildQuickForm
/**
* build form elements.
* params object $form object of the form
*
* @param CRM_Core_Form $form
* The form object that we are operating on.
* @param int $contactId
* Contact id.
* @param int $type
* What components are we interested in.
* @param bool $visibility
* Visibility of the field.
* @param null $isRequired
* @param string $groupName
* If used for building group block.
* @param string $tagName
* If used for building tag block.
* @param string $fieldName
* This is used in batch profile(i.e to build multiple blocks).
*
* @param string $groupElementType
*
*/
public static function buildQuickForm(&$form, $contactId = 0, $type = self::ALL, $visibility = FALSE, $isRequired = NULL, $groupName = 'Group(s)', $tagName = 'Tag(s)', $fieldName = NULL, $groupElementType = 'checkbox')
{
if (!isset($form->_tagGroup)) {
$form->_tagGroup = array();
}
// NYSS 5670
if (!$contactId && !empty($form->_contactId)) {
$contactId = $form->_contactId;
}
$type = (int) $type;
if ($type & self::GROUP) {
$fName = 'group';
if ($fieldName) {
$fName = $fieldName;
}
$groupID = isset($form->_grid) ? $form->_grid : NULL;
if ($groupID && $visibility) {
$ids = array($groupID => $groupID);
} else {
if ($visibility) {
$group = CRM_Core_PseudoConstant::allGroup();
} else {
$group = CRM_Core_PseudoConstant::group();
}
$ids = $group;
}
if ($groupID || !empty($group)) {
$groups = CRM_Contact_BAO_Group::getGroupsHierarchy($ids);
$attributes['skiplabel'] = TRUE;
$elements = array();
$groupsOptions = array();
foreach ($groups as $id => $group) {
// make sure that this group has public visibility
if ($visibility && $group['visibility'] == 'User and User Admin Only') {
continue;
}
if ($groupElementType == 'select') {
$groupsOptions[$id] = $group['title'];
} else {
$form->_tagGroup[$fName][$id]['description'] = $group['description'];
$elements[] =& $form->addElement('advcheckbox', $id, NULL, $group['title'], $attributes);
}
}
if ($groupElementType == 'select' && !empty($groupsOptions)) {
$form->add('select', $fName, $groupName, $groupsOptions, FALSE, array('id' => $fName, 'multiple' => 'multiple', 'class' => 'crm-select2'));
$form->assign('groupCount', count($groupsOptions));
}
if ($groupElementType == 'checkbox' && !empty($elements)) {
$form->addGroup($elements, $fName, $groupName, ' <br />');
$form->assign('groupCount', count($elements));
if ($isRequired) {
$form->addRule($fName, ts('%1 is a required field.', array(1 => $groupName)), 'required');
}
}
$form->assign('groupElementType', $groupElementType);
}
}
if ($type & self::TAG) {
$fName = 'tag';
if ($fieldName) {
$fName = $fieldName;
}
$form->_tagGroup[$fName] = 1;
// get the list of all the categories
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree('civicrm_contact', TRUE);
// let's not load jstree if there are not children. This also fixes blank
// display at the beginning of checkboxes
$loadJsTree = CRM_Utils_Array::retrieveValueRecursive($tree, 'children');
$form->assign('loadjsTree', FALSE);
if (!empty($loadJsTree)) {
// CODE FROM CRM/Tag/Form/Tag.php //
CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
$form->assign('loadjsTree', TRUE);
}
$elements = array();
self::climbtree($form, $tree, $elements);
//.........这里部分代码省略.........
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:101,代码来源:TagsAndGroups.php
示例15: _tagImportedContactsWithNewTag
private function _tagImportedContactsWithNewTag($contactIds, $newTagName, $newTagDesc)
{
$newTagId = NULL;
if ($newTagName) {
/* Create a new Tag */
$tagParams = array('name' => $newTagName, 'title' => $newTagName, 'description' => $newTagDesc, 'is_selectable' => TRUE, 'used_for' => 'civicrm_contact');
$id = array();
$addedTag = CRM_Core_BAO_Tag::add($tagParams, $id);
$this->_tag[$addedTag->id] = 1;
}
//add Tag to Import
if (is_array($this->_tag)) {
$tagAdditions = array();
foreach ($this->_tag as $tagId => $val) {
$addTagCount = CRM_Core_BAO_EntityTag::addEntitiesToTag($contactIds, $tagId);
$totalTagCount = $addTagCount[1];
if (isset($addedTag) && $tagId == $addedTag->id) {
$tagName = $newTagName;
$new = TRUE;
} else {
$tagName = $this->_allTags[$tagId];
$new = FALSE;
}
$tagAdditions[] = array('url' => CRM_Utils_System::url('civicrm/contact/search', 'reset=1&force=1&context=smog&id=' . $tagId), 'name' => $tagName, 'added' => $totalTagCount, 'notAdded' => $addTagCount[2], 'new' => $new);
}
return $tagAdditions;
}
return FALSE;
}
开发者ID:hguru,项目名称:224Civi,代码行数:29,代码来源:ImportJob.php
示例16: basic
static function basic(&$form)
{
$form->addElement('hidden', 'hidden_basic', 1);
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
$contact_type = array();
require_once 'CRM/Contact/BAO/ContactType.php';
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements();
foreach ($contactTypes as $k => $v) {
if (!empty($k)) {
$contact_type[] = HTML_QuickForm::createElement('checkbox', $k, null, $v);
}
}
$form->addGroup($contact_type, 'contact_type', ts('Contact Type(s)'), '<br />');
}
if ($form->_searchOptions['groups']) {
// checkboxes for groups
foreach ($form->_group as $groupID => $group) {
$form->_groupElement =& $form->addElement('checkbox', "group[{$groupID}]", null, $group);
}
}
if ($form->_searchOptions['tags']) {
// checkboxes for categories
require_once 'CRM/Core/BAO/Tag.php';
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree();
$form->assign('tree', $tags->getTree());
foreach ($form->_tag as $tagID => $tagName) {
$form->_tagElement =& $form->addElement('checkbox', "tag[{$tagID}]", null, $tagName);
}
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name, street name, city
$form->add('text', 'email', ts('Contact Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
//added contact source
$form->add('text', 'contact_source', ts('Contact Source'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'source'));
// add checkbox for cms users only
if (CIVICRM_UF != 'Standalone') {
$form->addYesNo('uf_user', ts('CMS User?'));
}
// add search profiles
require_once 'CRM/Core/BAO/UFGroup.php';
// FIXME: This is probably a part of profiles - need to be
// FIXME: eradicated from here when profiles are reworked.
$types = array('Participant', 'Contribution', 'Membership');
// get component profiles
$componentProfiles = array();
$componentProfiles = CRM_Core_BAO_UFGroup::getProfiles($types);
$ufGroups =& CRM_Core_BAO_UFGroup::getModuleUFGroup('Search Profile', 1);
$accessibleUfGroups = CRM_Core_Permission::ufGroup(CRM_Core_Permission::VIEW);
$searchProfiles = array();
foreach ($ufGroups as $key => $var) {
if (!array_key_exists($key, $componentProfiles) && in_array($key, $accessibleUfGroups)) {
$searchProfiles[$key] = $var['title'];
}
}
$form->addElement('select', 'uf_group_id', ts('Search Views'), array('0' => ts('- default view -')) + $searchProfiles);
// checkboxes for DO NOT phone, email, mail
// we take labels from SelectValues
$t = CRM_Core_SelectValues::privacy();
$t['do_not_toggle'] = ts('Include contacts who have these privacy option(s).');
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_phone', null, $t['do_not_phone']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_email', null, $t['do_not_email']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_mail', null, $t['do_not_mail']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_sms', null, $t['do_not_sms']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_trade', null, $t['do_not_trade']);
$privacy[] = HTML_QuickForm::createElement('advcheckbox', 'do_not_toggle', null, $t['do_not_toggle']);
$form->addGroup($privacy, 'privacy', ts('Privacy'), array(' ', ' ', ' ', '<br/>'));
// preferred communication method
require_once 'CRM/Core/PseudoConstant.php';
$comm = CRM_Core_PseudoConstant::pcm();
$commPreff = array();
foreach ($comm as $k => $v) {
$commPreff[] = HTML_QuickForm::createElement('advcheckbox', $k, null, $v);
}
$form->addGroup($commPreff, 'preferred_communication_method', ts('Preferred Communication Method'));
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:78,代码来源:Criteria.php
示例17: processTags
static function processTags()
{
$skipTagCreate = $skipEntityAction = $entityId = NULL;
$action = CRM_Utils_Type::escape($_POST['action'], 'String');
$parentId = CRM_Utils_Type::escape($_POST['parentId'], 'Integer');
if ($_POST['entityId']) {
$entityId = CRM_Utils_Type::escape($_POST['entityId'], 'Integer');
}
$entityTable = CRM_Utils_Type::escape($_POST['entityTable'], 'String');
if ($_POST['skipTagCreate']) {
$skipTagCreate = CRM_Utils_Type::escape($_POST['skipTagCreate'], 'Integer');
}
if ($_POST['skipEntityAction']) {
$skipEntityAction = CRM_Utils_Type::escape($_POST['skipEntityAction'], 'Integer');
}
// check if user has selected existing tag or is creating new tag
// this is done to allow numeric tags etc.
$tagValue = explode(':::', $_POST['tagID']);
$createNewTag = FALSE;
$tagID = $tagValue[0];
if (isset($tagValue[1]) && $tagValue[1] == 'value') {
$createNewTag = TRUE;
}
$tagInfo = array();
// if action is select
if ($action == 'select') {
// check the value of tagID
// if numeric that means existing tag
// else create new tag
if (!$skipTagCreate && $createNewTag) {
$params = array('name' => $tagID, 'parent_id' => $parentId);
$tagObject = CRM_Core_BAO_Tag::add($params, CRM_Core_DAO::$_nullArray);
$tagInfo = array('name' => $tagID, 'id' => $tagObject->id, 'action' => $action);
$tagID = $tagObject->id;
}
if (!$skipEntityAction && $entityId) {
// save this tag to contact
$params = array('entity_table' => $entityTable, 'entity_id' => $entityId, 'tag_id' => $tagID);
CRM_Core_BAO_EntityTag::add($params);
}
// if action is delete
} elseif ($action == 'delete') {
if (!is_numeric($tagID)) {
$tagID = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Tag', $tagID, 'id', 'name');
}
if (!$skipEntityAction && $entityId) {
// delete this tag entry for the entity
$params = array('entity_table' => $entityTable, 'entity_id' => $entityId, 'tag_id' => $tagID);
CRM_Core_BAO_EntityTag::del($params);
}
$tagInfo = array('id' => $tagID, 'action' => $action);
}
CRM_Utils_JSON::output($tagInfo);
}
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:54,代码来源:AJAX.php
示例18: basic
/**
* @param CRM_Core_Form $form
*/
public static function basic(&$form)
{
$form->addElement('hidden', 'hidden_basic', 1);
if ($form->_searchOptions['contactType']) {
// add checkboxes for contact type
//@todo FIXME - using the CRM_Core_DAO::VALUE_SEPARATOR creates invalid html - if you can find the form
// this is loaded onto then replace with something like '__' & test
$separator = CRM_Core_DAO::VALUE_SEPARATOR;
$contactTypes = CRM_Contact_BAO_ContactType::getSelectElements(FALSE, TRUE, $separator);
if ($contactTypes) {
$form->add('select', 'contact_type', ts('Contact Type(s)'), $contactTypes, FALSE, array('id' => 'contact_type', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
}
}
if ($form->_searchOptions['groups']) {
// multiselect for groups
if ($form->_group) {
// Arrange groups into hierarchical listing (child groups follow their parents and have indentation spacing in title)
$groupHierarchy = CRM_Contact_BAO_Group::getGroupsHierarchy($form->_group, NULL, ' ', TRUE);
$form->add('select', 'group', ts('Groups'), $groupHierarchy, FALSE, array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$groupOptions = CRM_Core_BAO_OptionValue::getOptionValuesAssocArrayFromName('group_type');
$form->add('select', 'group_type', ts('Group Types'), $groupOptions, FALSE, array('id' => 'group_type', 'multiple' => 'multiple', 'class' => 'crm-select2'));
$form->add('hidden', 'group_search_selected', 'group');
}
}
if ($form->_searchOptions['tags']) {
// multiselect for categories
$contactTags = CRM_Core_BAO_Tag::getTags();
if ($contactTags) {
$form->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE, array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2', 'style' => 'width: 100%;'));
}
$parentNames = CRM_Core_BAO_Tag::getTagSet('civicrm_contact');
CRM_Core_Form_Tag::buildQuickForm($form, $parentNames, 'civicrm_contact', NULL, TRUE, FALSE);
$used_for = CRM_Core_OptionGroup::values('tag_used_for');
$tagsTypes = array();
$showAllTagTypes = FALSE;
foreach ($used_for as $key => $value) {
//check tags for every type and find if there are any defined
$tags = CRM_Core_BAO_Tag::getTagsUsedFor($key, FALSE, TRUE, NULL);
// check if there are tags other than contact type, if no - keep checkbox hidden on adv search
// we will hide searching contact by attachments tags until it will be implemented in core
if (count($tags) && $key != 'civicrm_file' && $key != 'civicrm_contact') {
//if tags exists then add type to display in adv search form help text
$tagsTypes[] = ts($value);
$showAllTagTypes = TRUE;
}
}
$tagTypesText = implode(" or ", $tagsTypes);
if ($showAllTagTypes) {
$form->add('checkbox', 'all_tag_types', ts('Include tags used for %1', array(1 => $tagTypesText)));
$form->add('hidden', 'tag_types_text', $tagTypesText);
}
}
// add text box for last name, first name, street name, city
$form->addElement('text', 'sort_name', ts('Find...'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
// add text box for last name, first name,
|
请发表评论