本文整理汇总了PHP中CRM_Core_Permission::access方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_Permission::access方法的具体用法?PHP CRM_Core_Permission::access怎么用?PHP CRM_Core_Permission::access使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_Permission
的用法示例。
在下文中一共展示了CRM_Core_Permission::access方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
/**
* Build the form object.
*
* It consists of
* - displaying the QILL (query in local language)
* - displaying elements for saving the search
*/
public function buildQuickForm()
{
// @todo sync this more with CRM_Group_Form_Edit.
$query = new CRM_Contact_BAO_Query($this->get('queryParams'));
$this->assign('qill', $query->qill());
// Values from the search form
$formValues = $this->controller->exportValues();
// the name and description are actually stored with the group and not the saved search
$this->add('text', 'title', ts('Name'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'), TRUE);
$this->addElement('textarea', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'description'));
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
unset($groupTypes['Access Control']);
if (!CRM_Core_Permission::access('CiviMail')) {
$isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
unset($groupTypes['Mailing List']);
}
}
if (!empty($groupTypes)) {
$this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' ');
}
//CRM-14190
CRM_Group_Form_Edit::buildParentGroups($this);
// get the group id for the saved search
$groupID = NULL;
if (isset($this->_id)) {
$groupID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Group', $this->_id, 'id', 'saved_search_id');
$this->addDefaultButtons(ts('Update Smart Group'));
} else {
$this->addDefaultButtons(ts('Save Smart Group'));
$this->assign('partiallySelected', $formValues['radio_ts'] != 'ts_all');
}
$this->addRule('title', ts('Name already exists in Database.'), 'objectExists', array('CRM_Contact_DAO_Group', $groupID, 'title'));
}
示例2: initTasks
static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup', 'result' => true), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup', 'result' => true), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag', 'result' => true), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag', 'result' => true), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => false), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => false), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => true), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => false), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity', 'result' => true), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => true), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => true), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => false), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => true), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => true), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => true), 21 => array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => true));
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Household');
self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold', 'result' => true);
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Organization');
self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization', 'result' => true);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[8]);
}
//show map action only if map provider and key is set
$config =& CRM_Core_Config::singleton();
if ($config->mapProvider && $config->mapAPIKey) {
self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => false);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant', 'result' => true);
}
if (CRM_Core_Permission::access('CiviMail')) {
self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => false);
}
self::$_tasks += CRM_Core_Component::taskList();
require_once 'CRM/Utils/Hook.php';
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例3: __construct
/**
* Class constructor.
*/
public function __construct()
{
// There could be multiple contacts. We not clear on which contact id to display.
// Lets hide it for now.
$this->_exposeContactID = FALSE;
// if navigated from count link of activity summary reports.
$this->_resetDateFilter = CRM_Utils_Request::retrieve('resetDateFilter', 'Boolean', CRM_Core_DAO::$_nullObject);
$config = CRM_Core_Config::singleton();
$campaignEnabled = in_array("CiviCampaign", $config->enableComponents);
$caseEnabled = in_array("CiviCase", $config->enableComponents);
if ($campaignEnabled) {
$getCampaigns = CRM_Campaign_BAO_Campaign::getPermissionedCampaigns(NULL, NULL, TRUE, FALSE, TRUE);
$this->activeCampaigns = $getCampaigns['campaigns'];
asort($this->activeCampaigns);
$this->engagementLevels = CRM_Campaign_PseudoConstant::engagementLevel();
}
$components = CRM_Core_Component::getEnabledComponents();
foreach ($components as $componentName => $componentInfo) {
// CRM-19201: Add support for reporting CiviCampaign activities
// For CiviCase, "access all cases and activities" is required here
// rather than "access my cases and activities" to prevent those with
// only the later permission from seeing a list of all cases which might
// present a privacy issue.
if (CRM_Core_Permission::access($componentName, TRUE, TRUE)) {
$accessAllowed[] = $componentInfo->componentID;
}
}
$include = '';
if (!empty($accessAllowed)) {
$include = 'OR v.component_id IN (' . implode(', ', $accessAllowed) . ')';
}
$condition = " AND ( v.component_id IS NULL {$include} )";
$this->activityTypes = CRM_Core_OptionGroup::values('activity_type', FALSE, FALSE, FALSE, $condition);
asort($this->activityTypes);
$this->_columns = array('civicrm_contact' => array('dao' => 'CRM_Contact_DAO_Contact', 'fields' => array('contact_source' => array('name' => 'sort_name', 'title' => ts('Source Name'), 'alias' => 'civicrm_contact_source', 'no_repeat' => TRUE), 'contact_assignee' => array('name' => 'sort_name', 'title' => ts('Assignee Name'), 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.sort_name", 'default' => TRUE), 'contact_target' => array('name' => 'sort_name', 'title' => ts('Target Name'), 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.sort_name", 'default' => TRUE), 'contact_source_id' => array('name' => 'id', 'alias' => 'civicrm_contact_source', 'dbAlias' => "civicrm_contact_source.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE), 'contact_assignee_id' => array('name' => 'id', 'alias' => 'civicrm_contact_assignee', 'dbAlias' => "civicrm_contact_assignee.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE), 'contact_target_id' => array('name' => 'id', 'alias' => 'civicrm_contact_target', 'dbAlias' => "civicrm_contact_target.id", 'no_display' => TRUE, 'default' => TRUE, 'required' => TRUE)), 'filters' => array('contact_source' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_source', 'title' => ts('Source Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_assignee' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_assignee', 'title' => ts('Assignee Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'contact_target' => array('name' => 'sort_name', 'alias' => 'civicrm_contact_target', 'title' => ts('Target Name'), 'operator' => 'like', 'type' => CRM_Report_Form::OP_STRING), 'current_user' => array('name' => 'current_user', 'title' => ts('Limit To Current User'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No'), '1' => ts('Yes')))), 'grouping' => 'contact-fields'), 'civicrm_email' => array('dao' => 'CRM_Core_DAO_Email', 'fields' => array('contact_source_email' => array('name' => 'email', 'title' => ts('Source Email'), 'alias' => 'civicrm_email_source'), 'contact_assignee_email' => array('name' => 'email', 'title' => ts('Assignee Email'), 'alias' => 'civicrm_email_assignee'), 'contact_target_email' => array('name' => 'email', 'title' => ts('Target Email'), 'alias' => 'civicrm_email_target')), 'order_bys' => array('source_contact_email' => array('name' => 'email', 'title' => ts('Source Email'), 'dbAlias' => 'civicrm_email_contact_source_email'))), 'civicrm_phone' => array('dao' => 'CRM_Core_DAO_Phone', 'fields' => array('contact_source_phone' => array('name' => 'phone', 'title' => ts('Source Phone'), 'alias' => 'civicrm_phone_source'), 'contact_assignee_phone' => array('name' => 'phone', 'title' => ts('Assignee Phone'), 'alias' => 'civicrm_phone_assignee'), 'contact_target_phone' => array('name' => 'phone', 'title' => ts('Target Phone'), 'alias' => 'civicrm_phone_target'))), 'civicrm_activity' => array('dao' => 'CRM_Activity_DAO_Activity', 'fields' => array('id' => array('no_display' => TRUE, 'title' => ts('Activity ID'), 'required' => TRUE), 'source_record_id' => array('no_display' => TRUE, 'required' => TRUE), 'activity_type_id' => array('title' => ts('Activity Type'), 'required' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'activity_subject' => array('title' => ts('Subject'), 'default' => TRUE), 'activity_date_time' => array('title' => ts('Activity Date'), 'required' => TRUE), 'status_id' => array('title' => ts('Activity Status'), 'default' => TRUE, 'type' => CRM_Utils_Type::T_STRING), 'duration' => array('title' => ts('Duration'), 'type' => CRM_Utils_Type::T_INT), 'details' => array('title' => ts('Activity Details'))), 'filters' => array('activity_date_time' => array('default' => 'this.month', 'operatorType' => CRM_Report_Form::OP_DATE), 'activity_subject' => array('title' => ts('Activity Subject')), 'activity_type_id' => array('title' => ts('Activity Type'), 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activityTypes), 'status_id' => array('title' => ts('Activity Status'), 'type' => CRM_Utils_Type::T_STRING, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => CRM_Core_PseudoConstant::activityStatus()), 'details' => array('title' => ts('Activity Details'), 'type' => CRM_Utils_Type::T_TEXT)), 'order_bys' => array('activity_date_time' => array('title' => ts('Activity Date'), 'default_weight' => '1', 'dbAlias' => 'civicrm_activity_activity_date_time'), 'activity_type_id' => array('title' => ts('Activity Type'), 'default_weight' => '2', 'dbAlias' => 'field(civicrm_activity_activity_type_id, ' . implode(', ', array_keys($this->activityTypes)) . ')')), 'grouping' => 'activity-fields', 'alias' => 'activity'), 'civicrm_activity_contact' => array('dao' => 'CRM_Activity_DAO_ActivityContact', 'fields' => array())) + $this->addressFields(TRUE);
if ($caseEnabled && CRM_Core_Permission::check('access all cases and activities')) {
$this->_columns['civicrm_activity']['filters']['include_case_activities'] = array('name' => 'include_case_activities', 'title' => ts('Include Case Activities'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_SELECT, 'options' => array('0' => ts('No'), '1' => ts('Yes')));
}
if ($campaignEnabled) {
// Add display column and filter for Survey Results, Campaign and Engagement Index if CiviCampaign is enabled
$this->_columns['civicrm_activity']['fields']['result'] = array('title' => ts('Survey Result'), 'default' => 'false');
$this->_columns['civicrm_activity']['filters']['result'] = array('title' => ts('Survey Result'), 'operator' => 'like', 'type' => CRM_Utils_Type::T_STRING);
if (!empty($this->activeCampaigns)) {
$this->_columns['civicrm_activity']['fields']['campaign_id'] = array('title' => ts('Campaign'), 'default' => 'false');
$this->_columns['civicrm_activity']['filters']['campaign_id'] = array('title' => ts('Campaign'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->activeCampaigns);
}
if (!empty($this->engagementLevels)) {
$this->_columns['civicrm_activity']['fields']['engagement_level'] = array('title' => ts('Engagement Index'), 'default' => 'false');
$this->_columns['civicrm_activity']['filters']['engagement_level'] = array('title' => ts('Engagement Index'), 'type' => CRM_Utils_Type::T_INT, 'operatorType' => CRM_Report_Form::OP_MULTISELECT, 'options' => $this->engagementLevels);
}
}
$this->_groupFilter = TRUE;
$this->_tagFilter = TRUE;
$this->_tagFilterTable = 'civicrm_activity';
parent::__construct();
}
示例4: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
$params = $this->exportValues();
// Process / save contact info
$params['contact_type'] = $this->_contactType;
$params['contact_id'] = $this->_contactId;
if (!empty($this->_contactSubType)) {
$params['contact_sub_type'] = $this->_contactSubType;
}
CRM_Contact_BAO_Contact::create($params);
// Saving current employer affects relationship tab, and possibly related memberships and contributions
$this->ajaxResponse['updateTabs'] = array('#tab_rel' => CRM_Contact_BAO_Contact::getCountComponent('rel', $this->_contactId));
if (CRM_Core_Permission::access('CiviContribute')) {
$this->ajaxResponse['updateTabs']['#tab_contribute'] = CRM_Contact_BAO_Contact::getCountComponent('contribution', $this->_contactId);
}
if (CRM_Core_Permission::access('CiviMember')) {
$this->ajaxResponse['updateTabs']['#tab_member'] = CRM_Contact_BAO_Contact::getCountComponent('membership', $this->_contactId);
}
$this->response();
}
示例5: initTasks
public static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Group - add contacts'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Group - remove contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag - add to contacts'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Tag - remove from contacts'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Email - send now (to 50 or less)'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Add activity'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('Smart group - create'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Smart group - update'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print selected rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing labels - print'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch update contacts via profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('PDF letters - print'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Email - unhold addresses'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Communication preferences - alter'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore contacts from trash'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
//CRM-16329, if SMS provider is configured show sms action.
$providersCount = CRM_SMS_BAO_Provider::activeProviderCount();
if ($providersCount) {
self::$_tasks[self::SMS_CONTACTS] = array('title' => ts('SMS - schedule/send'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE);
}
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('household');
self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('organization');
self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add relationship - to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
}
if (CRM_Core_Permission::check('merge duplicate contacts')) {
self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[self::DELETE_CONTACTS]);
}
//show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
// should fix this to be more flexible as providers are added ??
$config = CRM_Core_Config::singleton();
if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[self::ADD_EVENT] = array('title' => ts('Register participants for event'), 'class' => 'CRM_Event_Form_Participant');
}
if (CRM_Core_Permission::access('CiviMail') || CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Email - schedule/send via CiviMail'), 'class' => 'CRM_Mailing_Form_Task_AdhocMailing', 'result' => FALSE);
}
self::$_tasks += CRM_Core_Component::taskList();
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例6: init
/**
* The initializer code, called before the processing
*/
public function init()
{
$fields = CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, FALSE);
$fields = array_merge($fields, array('soft_credit' => array('title' => ts('Soft Credit'), 'softCredit' => TRUE, 'headerPattern' => '/Soft Credit/i')));
// add pledge fields only if its is enabled
if (CRM_Core_Permission::access('CiviPledge')) {
$pledgeFields = array('pledge_payment' => array('title' => ts('Pledge Payment'), 'headerPattern' => '/Pledge Payment/i'), 'pledge_id' => array('title' => ts('Pledge ID'), 'headerPattern' => '/Pledge ID/i'));
$fields = array_merge($fields, $pledgeFields);
}
foreach ($fields as $name => $field) {
$field['type'] = CRM_Utils_Array::value('type', $field, CRM_Utils_Type::T_INT);
$field['dataPattern'] = CRM_Utils_Array::value('dataPattern', $field, '//');
$field['headerPattern'] = CRM_Utils_Array::value('headerPattern', $field, '//');
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
}
$this->_newContributions = array();
$this->setActiveFields($this->_mapperKeys);
$this->setActiveFieldSoftCredit($this->_mapperSoftCredit);
$this->setActiveFieldSoftCreditType($this->_mapperSoftCreditType);
// FIXME: we should do this in one place together with Form/MapField.php
$this->_contactIdIndex = -1;
$this->_totalAmountIndex = -1;
$this->_contributionTypeIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
switch ($key) {
case 'contribution_contact_id':
$this->_contactIdIndex = $index;
break;
case 'total_amount':
$this->_totalAmountIndex = $index;
break;
case 'financial_type':
$this->_contributionTypeIndex = $index;
break;
}
$index++;
}
}
示例7: run
function run()
{
require_once 'CRM/Utils/Request.php';
require_once 'CRM/Core/DAO.php';
$eid = CRM_Utils_Request::retrieve('eid', 'Positive', $this, true);
$fid = CRM_Utils_Request::retrieve('fid', 'Positive', $this, false);
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this, true);
$quest = CRM_Utils_Request::retrieve('quest', 'String', $this);
$action = CRM_Utils_Request::retrieve('action', 'String', $this);
require_once 'CRM/Core/BAO/File.php';
list($path, $mimeType) = CRM_Core_BAO_File::path($id, $eid, null, $quest);
if (!$path) {
CRM_Core_Error::statusBounce('Could not retrieve the file');
}
$buffer = file_get_contents($path);
if (!$buffer) {
CRM_Core_Error::statusBounce('The file is either empty or you do not have permission to retrieve the file');
}
if ($action & CRM_Core_Action::DELETE) {
if (CRM_Utils_Request::retrieve('confirmed', 'Boolean', CRM_Core_DAO::$_nullObject)) {
CRM_Core_BAO_File::delete($id, $eid, $fid);
CRM_Core_Session::setStatus(ts('The attached file has been deleted.'));
$session =& CRM_Core_Session::singleton();
$toUrl = $session->popUserContext();
CRM_Utils_System::redirect($toUrl);
} else {
$wrapper =& new CRM_Utils_Wrapper();
return $wrapper->run('CRM_Custom_Form_DeleteFile', ts('Domain Information Page'), null);
}
} else {
if (CRM_Core_Permission::access('Gcc')) {
// hack file name for gcc
require_once 'CRM/Gcc/Form/File.php';
$path = CRM_Gcc_Form_File::getFileName($path);
}
CRM_Utils_System::download(basename($path), $mimeType, $buffer);
}
}
示例8: buildQuickForm
/**
* Build the form object.
*/
public function buildQuickForm()
{
//create radio buttons to select existing group or add a new group
$options = array(ts('Add Contact To Existing Group'), ts('Create New Group'));
if (!$this->_id) {
$this->addRadio('group_option', ts('Group Options'), $options, array('onclick' => "return showElements();"));
$this->add('text', 'title', ts('Group Name:') . ' ', CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Group', 'title'));
$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'));
$groupTypes = CRM_Core_OptionGroup::values('group_type', TRUE);
if (!CRM_Core_Permission::access('CiviMail')) {
$isWorkFlowEnabled = CRM_Mailing_Info::workflowEnabled();
if ($isWorkFlowEnabled && !CRM_Core_Permission::check('create mailings') && !CRM_Core_Permission::check('schedule mailings') && !CRM_Core_Permission::check('approve mailings')) {
unset($groupTypes['Mailing List']);
}
}
if (!empty($groupTypes)) {
$this->addCheckBox('group_type', ts('Group Type'), $groupTypes, NULL, NULL, NULL, NULL, ' ');
}
}
// add select for groups
$group = array('' => ts('- select group -')) + CRM_Core_PseudoConstant::nestedGroup();
$groupElement = $this->add('select', 'group_id', ts('Select Group'), $group, FALSE, array('class' => 'crm-select2 huge'));
$this->_title = $group[$this->_id];
if ($this->_context === 'amtg') {
$groupElement->freeze();
// also set the group title
$groupValues = array('id' => $this->_id, 'title' => $this->_title);
$this->assign_by_ref('group', $groupValues);
}
// Set dynamic page title for 'Add Members Group (confirm)'
if ($this->_id) {
CRM_Utils_System::setTitle(ts('Add Contacts: %1', array(1 => $this->_title)));
} else {
CRM_Utils_System::setTitle(ts('Add Contacts to A Group'));
}
$this->addDefaultButtons(ts('Add to Group'));
}
示例9: initTasks
static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(1 => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), 2 => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), 3 => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), 4 => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), 5 => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), 6 => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), 7 => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE), 8 => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), 11 => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity'), 13 => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), 14 => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), 15 => array('title' => ts('Print Contacts'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), 16 => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), 17 => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), 19 => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), 22 => array('title' => ts('Unhold Emails'), 'class' => 'CRM_Contact_Form_Task_Unhold'), 25 => array('title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete Permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Household');
self::$_tasks[9] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Organization');
self::$_tasks[10] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
}
if (CRM_Core_Permission::check('merge duplicate contacts')) {
self::$_tasks[21] = array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[8]);
}
//show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
// should fix this to be more flexible as providers are added ??
$config = CRM_Core_Config::singleton();
if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
self::$_tasks[12] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[18] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant');
}
if (CRM_Core_Permission::access('CiviMail')) {
self::$_tasks[20] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => FALSE);
} elseif (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
self::$_tasks[20] = array('title' => ts('Create a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test'), 'result' => FALSE);
}
self::$_tasks += CRM_Core_Component::taskList();
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例10: initTasks
static function initTasks()
{
if (!self::$_tasks) {
self::$_tasks = array(self::GROUP_CONTACTS => array('title' => ts('Add Contacts to Group'), 'class' => 'CRM_Contact_Form_Task_AddToGroup'), self::REMOVE_CONTACTS => array('title' => ts('Remove Contacts from Group'), 'class' => 'CRM_Contact_Form_Task_RemoveFromGroup'), self::TAG_CONTACTS => array('title' => ts('Tag Contacts (assign tags)'), 'class' => 'CRM_Contact_Form_Task_AddToTag'), self::REMOVE_TAGS => array('title' => ts('Untag Contacts (remove tags)'), 'class' => 'CRM_Contact_Form_Task_RemoveFromTag'), self::EXPORT_CONTACTS => array('title' => ts('Export Contacts'), 'class' => array('CRM_Export_Form_Select', 'CRM_Export_Form_Map'), 'result' => FALSE), self::EMAIL_CONTACTS => array('title' => ts('Send Email to Contacts'), 'class' => 'CRM_Contact_Form_Task_Email', 'result' => TRUE), self::SMS_CONTACTS => array('title' => ts('Send SMS to Contacts'), 'class' => 'CRM_Contact_Form_Task_SMS', 'result' => TRUE), self::DELETE_CONTACTS => array('title' => ts('Delete Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::RECORD_CONTACTS => array('title' => ts('Record Activity for Contacts'), 'class' => 'CRM_Activity_Form_Activity'), self::SAVE_SEARCH => array('title' => ts('New Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch', 'result' => TRUE), self::SAVE_SEARCH_UPDATE => array('title' => ts('Update Smart Group'), 'class' => 'CRM_Contact_Form_Task_SaveSearch_Update', 'result' => TRUE), self::PRINT_CONTACTS => array('title' => ts('Print Selected Rows'), 'class' => 'CRM_Contact_Form_Task_Print', 'result' => FALSE), self::LABEL_CONTACTS => array('title' => ts('Mailing Labels'), 'class' => 'CRM_Contact_Form_Task_Label', 'result' => TRUE), self::BATCH_UPDATE => array('title' => ts('Batch Update via Profile'), 'class' => array('CRM_Contact_Form_Task_PickProfile', 'CRM_Contact_Form_Task_Batch'), 'result' => TRUE), self::PRINT_FOR_CONTACTS => array('title' => ts('Print PDF Letter for Contacts'), 'class' => 'CRM_Contact_Form_Task_PDF', 'result' => TRUE), self::EMAIL_UNHOLD => array('title' => ts('Unhold Emails'), 'class' => 'CRM_Contact_Form_Task_Unhold'), self::COMMUNICATION_PREFS => array('title' => ts('Alter Contact Communication Preferences'), 'class' => 'CRM_Contact_Form_Task_AlterPreferences'), self::RESTORE => array('title' => ts('Restore Contacts'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE), self::DELETE_PERMANENTLY => array('title' => ts('Delete Permanently'), 'class' => 'CRM_Contact_Form_Task_Delete', 'result' => FALSE));
if (CRM_Contact_BAO_ContactType::isActive('Household')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Household');
self::$_tasks[self::HOUSEHOLD_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToHousehold');
}
if (CRM_Contact_BAO_ContactType::isActive('Organization')) {
$label = CRM_Contact_BAO_ContactType::getLabel('Organization');
self::$_tasks[self::ORGANIZATION_CONTACTS] = array('title' => ts('Add Contacts to %1', array(1 => $label)), 'class' => 'CRM_Contact_Form_Task_AddToOrganization');
}
if (CRM_Core_Permission::check('merge duplicate contacts')) {
self::$_tasks[self::MERGE_CONTACTS] = array('title' => ts('Merge Contacts'), 'class' => 'CRM_Contact_Form_Task_Merge', 'result' => TRUE);
}
//CRM-4418, check for delete
if (!CRM_Core_Permission::check('delete contacts')) {
unset(self::$_tasks[self::DELETE_CONTACTS]);
}
//show map action only if map provider and geoprovider are set (Google doesn't need geoprovider)
// should fix this to be more flexible as providers are added ??
$config = CRM_Core_Config::singleton();
if ($config->mapProvider && ($config->mapProvider == 'Google' || ($config->mapProvider == 'OpenStreetMaps' || $config->geoProvider == 'Google'))) {
self::$_tasks[self::MAP_CONTACTS] = array('title' => ts('Map Contacts'), 'class' => 'CRM_Contact_Form_Task_Map', 'result' => FALSE);
}
if (CRM_Core_Permission::access('CiviEvent')) {
self::$_tasks[self::ADD_EVENT] = array('title' => ts('Add Contacts to Event'), 'class' => 'CRM_Event_Form_Participant');
}
if (CRM_Core_Permission::access('CiviMail')) {
self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Schedule/Send a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test', 'CRM_Mailing_Form_Schedule'), 'result' => FALSE);
} elseif (CRM_Mailing_Info::workflowEnabled() && CRM_Core_Permission::check('create mailings')) {
self::$_tasks[self::CREATE_MAILING] = array('title' => ts('Create a Mass Mailing'), 'class' => array('CRM_Mailing_Form_Group', 'CRM_Mailing_Form_Settings', 'CRM_Mailing_Form_Upload', 'CRM_Mailing_Form_Test'), 'result' => FALSE);
}
self::$_tasks += CRM_Core_Component::taskList();
CRM_Utils_Hook::searchTasks('contact', self::$_tasks);
asort(self::$_tasks);
}
}
示例11: init
/**
* the initializer code, called before the processing
*
* @return void
* @access public
*/
function init()
{
require_once 'CRM/Contribute/BAO/Contribution.php';
$fields =& CRM_Contribute_BAO_Contribution::importableFields($this->_contactType, false);
$fields = array_merge($fields, array('soft_credit' => array('title' => ts('Soft Credit'), 'softCredit' => true, 'headerPattern' => '/Soft Credit/i')));
// add pledge fields only if its is enabled
if (CRM_Core_Permission::access('CiviPledge')) {
$pledgeFields = array('pledge_payment' => array('title' => ts('Pledge Payment'), 'headerPattern' => '/Pledge Payment/i'), 'pledge_id' => array('title' => ts('Pledge ID'), 'headerPattern' => '/Pledge ID/i'));
$fields = array_merge($fields, $pledgeFields);
}
foreach ($fields as $name => $field) {
$this->addField($name, $field['title'], $field['type'], $field['headerPattern'], $field['dataPattern']);
}
$this->_newContributions = array();
$this->setActiveFields($this->_mapperKeys);
$this->setActiveFieldSoftCredit($this->_mapperSoftCredit);
// FIXME: we should do this in one place together with Form/MapField.php
$this->_contactIdIndex = -1;
$this->_totalAmountIndex = -1;
$this->_contributionTypeIndex = -1;
$index = 0;
foreach ($this->_mapperKeys as $key) {
switch ($key) {
case 'contribution_contact_id':
$this->_contactIdIndex = $index;
break;
case 'total_amount':
$this->_totalAmountIndex = $index;
break;
case 'contribution_type':
$this->_contributionTypeIndex = $index;
break;
}
$index++;
}
}
示例12: setProfileDefaults
//.........这里部分代码省略.........
// type as per loc field and removed below code.
if ($locTypeId == 'Primary') {
$locTypeId = CRM_Contact_BAO_Contact::getPrimaryLocationType($contactId);
}
if (is_numeric($locTypeId)) {
//fixed for CRM-665
if ($locTypeId == CRM_Utils_Array::value('location_type_id', $value)) {
if (CRM_Utils_Array::value($fieldName, $value)) {
//to handle stateprovince and country
if ($fieldName == 'state_province') {
$defaults[$fldName] = $value['state_province_id'];
} else {
if ($fieldName == 'county') {
$defaults[$fldName] = $value['county_id'];
} else {
if ($fieldName == 'country') {
$defaults[$fldName] = $value['country_id'];
if (!isset($value['country_id']) || !$value['country_id']) {
$config =& CRM_Core_Config::singleton();
if ($config->defaultContactCountry) {
$defaults[$fldName] = $config->defaultContactCountry;
}
}
} else {
if ($fieldName == 'phone') {
if ($phoneTypeId) {
if ($value['phone'][$phoneTypeId]) {
$defaults[$fldName] = $value['phone'][$phoneTypeId];
}
} else {
$defaults[$fldName] = $value['phone'];
}
} else {
if ($fieldName == 'email') {
//adding the first email (currently we don't support multiple emails of same location type)
$defaults[$fldName] = $value['email'];
} else {
if ($fieldName == 'im') {
//adding the first im (currently we don't support multiple ims of same location type)
$defaults[$fldName] = $value['im'];
$defaults[$fldName . "-provider_id"] = $value['im_provider_id'];
} else {
$defaults[$fldName] = $value[$fieldName];
}
}
}
}
}
}
}
}
}
}
}
}
}
if (CRM_Core_Permission::access('Quest', false)) {
require_once 'CRM/Quest/BAO/Student.php';
// Checking whether the database contains quest_student table.
// Now there are two different schemas for core and quest.
// So if only core schema in use then withought following check gets the DB error.
$student = new CRM_Quest_BAO_Student();
$tableStudent = $student->getTableName();
if ($tableStudent) {
//set student defaults
CRM_Quest_BAO_Student::retrieve($details, $studentDefaults, $ids);
$studentFields = array('educational_interest', 'college_type', 'college_interest', 'test_tutoring');
foreach ($studentFields as $fld) {
if ($studentDefaults[$fld]) {
$values = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $studentDefaults[$fld]);
}
$studentDefaults[$fld] = array();
if (is_array($values)) {
foreach ($values as $v) {
$studentDefaults[$fld][$v] = 1;
}
}
}
foreach ($fields as $name => $field) {
$fldName = "field[{$contactId}][{$name}]";
if (array_key_exists($name, $studentDefaults)) {
$defaults[$fldName] = $studentDefaults[$name];
}
}
}
}
}
//Handling Contribution Part of the batch profile
if (CRM_Core_Permission::access('CiviContribute') && $component == 'Contribute') {
self::setComponentDefaults($fields, $componentId, $component, $defaults);
}
//Handling Event Participation Part of the batch profile
if (CRM_Core_Permission::access('CiviEvent') && $component == 'Event') {
self::setComponentDefaults($fields, $componentId, $component, $defaults);
}
//Handling membership Part of the batch profile
if (CRM_Core_Permission::access('CiviMember') && $component == 'Membership') {
self::setComponentDefaults($fields, $componentId, $component, $defaults);
}
}
示例13: preProcess
/**
* Set variables up before form is built.
*
* @return void
*/
public function preProcess()
{
$values = array();
$id = CRM_Utils_Request::retrieve('id', 'Positive', $this);
// Make sure context is assigned to template for condition where we come here view civicrm/membership/view
$context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->assign('context', $context);
if ($id) {
$params = array('id' => $id);
CRM_Member_BAO_Membership::retrieve($params, $values);
$membershipType = CRM_Member_BAO_MembershipType::getMembershipTypeDetails($values['membership_type_id']);
// Do the action on related Membership if needed
$relAction = CRM_Utils_Request::retrieve('relAction', 'String', $this);
if ($relAction) {
$this->relAction($relAction, $values);
}
// build associated contributions
$this->assign('accessContribution', FALSE);
if (CRM_Core_Permission::access('CiviContribute')) {
$this->assign('accessContribution', TRUE);
CRM_Member_Page_Tab::associatedContribution($values['contact_id'], $id);
}
//Provide information about membership source when it is the result of a relationship (CRM-1901)
$values['owner_membership_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $id, 'owner_membership_id');
if (isset($values['owner_membership_id'])) {
$values['owner_contact_id'] = CRM_Core_DAO::getFieldValue('CRM_Member_DAO_Membership', $values['owner_membership_id'], 'contact_id', 'id');
$values['owner_display_name'] = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $values['owner_contact_id'], 'display_name', 'id');
$direction = strrev($membershipType['relationship_direction']);
// To display relationship type in view membership page
$relTypeIds = str_replace(CRM_Core_DAO::VALUE_SEPARATOR, ",", $membershipType['relationship_type_id']);
$sql = "\nSELECT relationship_type_id,\n CASE\n WHEN contact_id_a = {$values['owner_contact_id']} AND contact_id_b = {$values['contact_id']} THEN 'b_a'\n WHEN contact_id_b = {$values['owner_contact_id']} AND contact_id_a = {$values['contact_id']} THEN 'a_b'\nEND AS 'relType'\n FROM civicrm_relationship\n WHERE relationship_type_id IN ({$relTypeIds})";
$dao = CRM_Core_DAO::executeQuery($sql);
$values['relationship'] = NULL;
while ($dao->fetch()) {
$typeId = $dao->relationship_type_id;
$direction = $dao->relType;
if ($direction && $typeId) {
if ($values['relationship']) {
$values['relationship'] .= ',';
}
$values['relationship'] .= CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', $typeId, "name_{$direction}", 'id');
}
}
}
$this->assign('has_related', FALSE);
// if membership can be granted, and we are the owner of the membership
if (!empty($membershipType['relationship_type_id']) && empty($values['owner_membership_id'])) {
// display related contacts/membership block
$this->assign('has_related', TRUE);
$this->assign('max_related', CRM_Utils_Array::value('max_related', $values, ts('Unlimited')));
// split the relations in 2 arrays based on direction
$relTypeId = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_type_id']);
$relDirection = explode(CRM_Core_DAO::VALUE_SEPARATOR, $membershipType['relationship_direction']);
foreach ($relTypeId as $rid) {
$dir = each($relDirection);
$relTypeDir[substr($dir['value'], 0, 1)][] = $rid;
}
// build query in 2 parts with a UNION if necessary
// _x and _y are replaced with _a and _b first, then vice-versa
// comment is a qualifier for the relationship - now just job_title
$select = "\nSELECT r.id, c.id as cid, c.display_name as name, c.job_title as comment,\n rt.name_x_y as relation, r.start_date, r.end_date,\n m.id as mid, ms.is_current_member, ms.label as status\n FROM civicrm_relationship r\n LEFT JOIN civicrm_relationship_type rt ON rt.id = r.relationship_type_id\n LEFT JOIN civicrm_contact c ON c.id = r.contact_id_x\n LEFT JOIN civicrm_membership m ON (m.owner_membership_id = {$values['id']}\n AND m.contact_id = r.contact_id_x AND m.is_test = 0)\n LEFT JOIN civicrm_membership_status ms ON ms.id = m.status_id\n WHERE r.contact_id_y = {$values['contact_id']} AND r.is_active = 1 AND c.is_deleted = 0";
$query = '';
foreach (array('a', 'b') as $dir) {
if (isset($relTypeDir[$dir])) {
$query .= ($query ? ' UNION ' : '') . str_replace('_y', '_' . $dir, str_replace('_x', '_' . ($dir == 'a' ? 'b' : 'a'), $select)) . ' AND r.relationship_type_id IN (' . implode(',', $relTypeDir[$dir]) . ')';
}
}
$query .= " ORDER BY is_current_member DESC";
$dao = CRM_Core_DAO::executeQuery($query);
$related = array();
$relatedRemaining = CRM_Utils_Array::value('max_related', $values, PHP_INT_MAX);
$rowElememts = array('id', 'cid', 'name', 'comment', 'relation', 'mid', 'start_date', 'end_date', 'is_current_member', 'status');
while ($dao->fetch()) {
$row = array();
foreach ($rowElememts as $field) {
$row[$field] = $dao->{$field};
}
if ($row['mid'] && $row['is_current_member'] == 1) {
$relatedRemaining--;
$row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::DELETE, array('id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'mid' => $row['mid']), ts('more'), FALSE, 'membership.relationship.action', 'Relationship', CRM_Utils_Request::retrieve('id', 'Positive', $this));
} else {
if ($relatedRemaining > 0) {
$row['action'] = CRM_Core_Action::formLink(self::links(), CRM_Core_Action::ADD, array('id' => CRM_Utils_Request::retrieve('id', 'Positive', $this), 'cid' => $row['cid'], 'rid' => $row['cid']), ts('more'), FALSE, 'membership.relationship.action', 'Relationship', CRM_Utils_Request::retrieve('id', 'Positive', $this));
}
}
$related[] = $row;
}
$this->assign('related', $related);
if ($relatedRemaining <= 0) {
$this->assign('related_text', ts('None available'));
} else {
if ($relatedRemaining < 100000) {
$this->assign('related_text', ts('%1 available', array(1 => $relatedRemaining)));
} else {
$this->assign('related_text', ts('Unlimited', array(1 => $relatedRemaining)));
//.........这里部分代码省略.........
示例14: getAvailableFields
/**
* Get a list of fields which can be added to profiles.
*
* @param int $gid : UF group ID
* @param array $defaults : Form defaults
* @return array, multidimensional; e.g. $result['FieldGroup']['field_name']['label']
*/
public static function getAvailableFields($gid = NULL, $defaults = array())
{
$fields = array('Contact' => array(), 'Individual' => CRM_Contact_BAO_Contact::importableFields('Individual', FALSE, FALSE, TRUE, TRUE, TRUE), 'Household' => CRM_Contact_BAO_Contact::importableFields('Household', FALSE, FALSE, TRUE, TRUE, TRUE), 'Organization' => CRM_Contact_BAO_Contact::importableFields('Organization', FALSE, FALSE, TRUE, TRUE, TRUE));
// include hook injected fields
$fields['Contact'] = array_merge($fields['Contact'], CRM_Contact_BAO_Query_Hook::singleton()->getFields());
// add current employer for individuals
$fields['Individual']['current_employer'] = array('name' => 'organization_name', 'title' => ts('Current Employer'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
if (!$addressOptions['county']) {
unset($fields['Individual']['county'], $fields['Household']['county'], $fields['Organization']['county']);
}
// break out common contact fields array CRM-3037.
// from a UI perspective this makes very little sense
foreach ($fields['Individual'] as $key => $value) {
if (!empty($fields['Household'][$key]) && !empty($fields['Organization'][$key])) {
$fields['Contact'][$key] = $value;
unset($fields['Individual'][$key], $fields['Household'][$key], $fields['Organization'][$key]);
}
}
// Internal field not exposed to forms
unset($fields['Contact']['contact_type']);
unset($fields['Contact']['master_id']);
// convert phone extension in to psedo-field phone + phone extension
//unset extension
unset($fields['Contact']['phone_ext']);
//add psedo field
$fields['Contact']['phone_and_ext'] = array('name' => 'phone_and_ext', 'title' => ts('Phone and Extension'), 'hasLocationType' => 1);
// include Subtypes For Profile
$subTypes = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($subTypes as $name => $val) {
//custom fields for sub type
$subTypeFields = CRM_Core_BAO_CustomField::getFieldsForImport($name, FALSE, FALSE, FALSE, TRUE, TRUE);
if (array_key_exists($val['parent'], $fields)) {
$fields[$name] = $fields[$val['parent']] + $subTypeFields;
} else {
$fields[$name] = $subTypeFields;
}
}
if (CRM_Core_Permission::access('CiviContribute')) {
$contribFields = CRM_Contribute_BAO_Contribution::getContributionFields(FALSE);
if (!empty($contribFields)) {
unset($contribFields['is_test']);
unset($contribFields['is_pay_later']);
unset($contribFields['contribution_id']);
$contribFields['contribution_note'] = array('name' => 'contribution_note', 'title' => ts('Contribution Note'));
$fields['Contribution'] = array_merge($contribFields, self::getContribBatchEntryFields());
}
}
if (CRM_Core_Permission::access('CiviEvent')) {
$participantFields = CRM_Event_BAO_Query::getParticipantFields();
if ($participantFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($participantFields, 'external_identifier', 'event_id', 'participant_contact_id', 'participant_role_id', 'participant_status_id', 'participant_is_test', 'participant_fee_level', 'participant_id', 'participant_is_pay_later', 'participant_campaign');
if (isset($participantFields['participant_campaign_id'])) {
$participantFields['participant_campaign_id']['title'] = ts('Campaign');
}
$fields['Participant'] = $participantFields;
}
}
if (CRM_Core_Permission::access('CiviMember')) {
$membershipFields = CRM_Member_BAO_Membership::getMembershipFields();
// Remove fields not supported by profiles
CRM_Utils_Array::remove($membershipFields, 'membership_id', 'membership_type_id', 'member_is_test', 'is_override', 'status_id', 'member_is_pay_later');
if ($gid && CRM_Core_DAO::getFieldValue('CRM_Core_DAO_UFGroup', $gid, 'name') == 'membership_batch_entry') {
$fields['Membership'] = array_merge($membershipFields, self::getMemberBatchEntryFields());
} else {
$fields['Membership'] = $membershipFields;
}
}
if (CRM_Core_Permission::access('CiviCase')) {
$caseFields = CRM_Case_BAO_Query::getFields(TRUE);
$caseFields = array_merge($caseFields, CRM_Core_BAO_CustomField::getFieldsForImport('Case'));
if ($caseFields) {
// Remove fields not supported by profiles
CRM_Utils_Array::remove($caseFields, 'case_id', 'case_type', 'case_start_date', 'case_end_date', 'case_role', 'case_status', 'case_deleted');
}
$fields['Case'] = $caseFields;
}
$activityFields = CRM_Activity_BAO_Activity::getProfileFields();
if ($activityFields) {
// campaign related fields.
if (isset($activityFields['activity_campaign_id'])) {
$activityFields['activity_campaign_id']['title'] = ts('Campaign');
}
$fields['Activity'] = $activityFields;
}
$fields['Formatting']['format_free_html_' . rand(1000, 9999)] = array('name' => 'free_html', 'import' => FALSE, 'export' => FALSE, 'title' => 'Free HTML');
// Sort by title
foreach ($fields as &$values) {
$values = CRM_Utils_Array::crmArraySortByField($values, 'title');
}
//group selected and unwanted fields list
$ufFields = $gid ? CRM_Core_BAO_UFGroup::getFields($gid, FALSE, NULL, NULL, NULL, TRUE, NULL, TRUE) : array();
//.........这里部分代码省略.........
示例15: getContent
/**
* Given an id creates a subject/content array
*
* @param int $id
* Id of the block.
*
* @return array
*/
public static function getContent($id)
{
// return if upgrade mode
$config = CRM_Core_Config::singleton();
if ($config->isUpgradeMode()) {
return NULL;
}
if (!self::getProperty($id, 'active')) {
return NULL;
}
if ($id == self::EVENT && CRM_Core_Permission::check('view event info')) {
// is CiviEvent enabled?
if (!CRM_Core_Permission::access('CiviEvent', FALSE)) {
return NULL;
}
// do nothing
} elseif (!CRM_Core_Permission::check('access CiviCRM') && $id != self::LANGSWITCH) {
return NULL;
} elseif ($id == self::ADD) {
$hasAccess = TRUE;
if (!CRM_Core_Permission::check('add contacts') && !CRM_Core_Permission::check('edit groups')) {
$hasAccess = FALSE;
}
//validate across edit/view - CRM-5666
if ($hasAccess) {
$hasAccess = CRM_Core_Permission::giveMeAllACLs();
}
if (!$hasAccess) {
return NULL;
}
}
self::setTemplateValues($id);
// Suppress Recent Items block if it's empty - CRM-5188
if ($id == self::RECENTLY_VIEWED) {
$recent = self::getProperty($id, 'templateValues');
if (CRM_Utils_Array::crmIsEmptyArray($recent)) {
return NULL;
}
}
// Suppress Language switcher if language is inherited from CMS - CRM-9971
$config = CRM_Core_Config::singleton();
if ($id == self::LANGSWITCH && property_exists($config, "inheritLocale") && $config->inheritLocale) {
return NULL;
}
$block = array();
$block['name'] = 'block-civicrm';
$block['id'] = $block['name'] . '_' . $id;
$block['subject'] = self::fetch($id, 'Subject.tpl', array('subject' => self::getProperty($id, 'subject')));
$block['content'] = self::fetch($id, self::getProperty($id, 'template'), self::getProperty($id, 'templateValues'));
return $block;
}