本文整理汇总了PHP中CRM_Core_DAO_UFGroup类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_UFGroup类的具体用法?PHP CRM_Core_DAO_UFGroup怎么用?PHP CRM_Core_DAO_UFGroup使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Core_DAO_UFGroup类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: buildQuickForm
public function buildQuickForm()
{
// CRM_Event_Form_Task_Batch::buildQuickForm() gets ufGroupId
// from the form, so set it here to the id of the reserved profile
$dao = new CRM_Core_DAO_UFGroup();
$dao->name = 'participant_status';
$dao->find(TRUE);
$this->set('ufGroupId', $dao->id);
$statuses = CRM_Event_PseudoConstant::participantStatus(NULL, NULL, 'label');
asort($statuses, SORT_STRING);
$this->add('select', 'status_change', ts('Change All Statuses'), array('' => ts('- select status -')) + $statuses);
$this->assign('context', 'statusChange');
# CRM-4321: display info on users being notified if any of the below statuses is enabled
parent::assignToTemplate();
parent::buildQuickForm();
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:16,代码来源:ParticipantStatus.php
示例2: buildQuickForm
/**
* Build form for honoree contact / on behalf of organization.
*
* @param CRM_Core_Form $form
*
*/
public static function buildQuickForm(&$form)
{
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $form->_honoreeProfileId;
if (!$ufGroup->find(TRUE)) {
CRM_Core_Error::fatal(ts('Chosen honoree profile for this contribution is disabled'));
}
$prefix = 'honor';
$honoreeProfileFields = CRM_Core_BAO_UFGroup::getFields($form->_honoreeProfileId, FALSE, NULL, NULL, NULL, FALSE, NULL, TRUE, NULL, CRM_Core_Permission::CREATE);
$form->addElement('hidden', 'honoree_profile_id', $form->_honoreeProfileId);
$form->assign('honoreeProfileFields', $honoreeProfileFields);
// add the form elements
foreach ($honoreeProfileFields as $name => $field) {
// If soft credit type is not chosen then make omit requiredness from honoree profile fields
if (count($form->_submitValues) && empty($form->_submitValues['soft_credit_type_id']) && !empty($field['is_required'])) {
$field['is_required'] = FALSE;
}
CRM_Core_BAO_UFGroup::buildProfile($form, $field, CRM_Profile_Form::MODE_CREATE, NULL, FALSE, FALSE, NULL, $prefix);
}
}
开发者ID:nganivet,项目名称:civicrm-core,代码行数:26,代码来源:ProfileContact.php
示例3: buildQuickForm
function buildQuickForm()
{
// CRM_Event_Form_Task_Batch::buildQuickForm() gets ufGroupId
// from the form, so set it here to the id of the reserved profile
require_once 'CRM/Core/DAO/UFGroup.php';
$dao = new CRM_Core_DAO_UFGroup();
$dao->name = 'participant_status';
$dao->find(true);
$this->set('ufGroupId', $dao->id);
require_once 'CRM/Event/PseudoConstant.php';
$statuses =& CRM_Event_PseudoConstant::participantStatus();
asort($statuses, SORT_STRING);
$this->add('select', 'status_change', ts('Change All Statuses'), array('' => ts('- select status -')) + $statuses, null, array('onchange' => "if (this.value) setStatusesTo(this.value);"));
$this->assign('context', 'statusChange');
# CRM-4321: display info on users being notified if any of the below statuses is enabled
require_once 'CRM/Event/PseudoConstant.php';
$notifyingStatuses = array(ts('Pending from waitlist'), ts('Pending from approval'), ts('Expired'), ts('Cancelled'));
$notifyingStatuses = array_intersect($notifyingStatuses, CRM_Event_PseudoConstant::participantStatus());
$this->assign('notifyingStatuses', implode(', ', $notifyingStatuses));
parent::buildQuickForm();
}
开发者ID:ksecor,项目名称:civicrm,代码行数:21,代码来源:ParticipantStatus.php
示例4: setDefaultValues
/**
* Set default values for the form. Note that in edit/view mode
* the default values are retrieved from the database
*
*
* @return void
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
$soft_credit_types = CRM_Core_OptionGroup::values('soft_credit_type', TRUE, FALSE, FALSE, NULL, 'name');
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Title and Settings') . " ({$title})");
$ufJoinParams = array('module' => 'OnBehalf', 'entity_table' => 'civicrm_contribution_page', 'entity_id' => $this->_id);
$onBehalfIDs = CRM_Core_BAO_UFJoin::getUFGroupIds($ufJoinParams);
if ($onBehalfIDs) {
// get the first one only
$defaults['onbehalf_profile_id'] = $onBehalfIDs[0];
}
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = 'soft_credit';
$ufJoinDAO->entity_id = $this->_id;
if ($ufJoinDAO->find(TRUE)) {
$defaults['honoree_profile'] = $ufJoinDAO->uf_group_id;
$jsonData = CRM_Contribute_BAO_ContributionPage::formatMultilingualHonorParams($ufJoinDAO->module_data, TRUE);
$defaults = array_merge($defaults, $jsonData);
$defaults['honor_block_is_active'] = $ufJoinDAO->is_active;
} else {
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'honoree_individual';
if ($ufGroupDAO->find(TRUE)) {
$defaults['honoree_profile'] = $ufGroupDAO->id;
}
$defaults['soft_credit_types'] = array(CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types));
}
} else {
CRM_Utils_System::setTitle(ts('Title and Settings'));
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'honoree_individual';
if ($ufGroupDAO->find(TRUE)) {
$defaults['honoree_profile'] = $ufGroupDAO->id;
}
$defaults['soft_credit_types'] = array(CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types));
}
return $defaults;
}
开发者ID:rajeshrhino,项目名称:civicrm-core,代码行数:47,代码来源:Settings.php
示例5: run
/**
* run this page (figure out the action needed and perform it).
*
* @return void
*/
function run()
{
$this->preProcess();
$this->assign('recentlyViewed', FALSE);
$this->assign('ufGroupName', 'unknown');
// override later (if possible)
if ($this->_gid) {
$ufgroupDAO = new CRM_Core_DAO_UFGroup();
$ufgroupDAO->id = $this->_gid;
if (!$ufgroupDAO->find(TRUE)) {
CRM_Core_Error::fatal();
}
}
if ($this->_gid) {
// set the title of the page
if ($ufgroupDAO->title) {
CRM_Utils_System::setTitle($ufgroupDAO->title);
}
if ($ufgroupDAO->name) {
$this->assign('ufGroupName', $ufgroupDAO->name);
}
}
$this->assign('isReset', TRUE);
$formController = new CRM_Core_Controller_Simple('CRM_Profile_Form_Search', ts('Search Profile'), CRM_Core_Action::ADD);
$formController->setEmbedded(TRUE);
$formController->set('gid', $this->_gid);
$formController->process();
$searchError = FALSE;
// check if there is a POST
if (!empty($_POST)) {
if ($formController->validate() !== TRUE) {
$searchError = TRUE;
}
}
// also get the search tpl name
$this->assign('searchTPL', $formController->getHookedTemplateFileName());
$this->assign('search', $this->_search);
// search if search returned a form error?
if ((empty($_GET['reset']) || !empty($_GET['force'])) && !$searchError) {
$this->assign('isReset', FALSE);
$gidString = $this->_gid;
if (empty($this->_profileIds)) {
$gids = $this->_gid;
} else {
$gids = $this->_profileIds;
$gidString = implode(',', $this->_profileIds);
}
$map = 0;
$linkToUF = 0;
$editLink = FALSE;
if ($this->_gid) {
$map = $ufgroupDAO->is_map;
$linkToUF = $ufgroupDAO->is_uf_link;
$editLink = $ufgroupDAO->is_edit_link;
}
if ($map) {
$this->assign('mapURL', CRM_Utils_System::url('civicrm/profile/map', "map=1&gid={$gidString}&reset=1"));
}
if (!empty($this->_params['group'])) {
foreach ($this->_params['group'] as $key => $val) {
if (!$val) {
unset($this->_params['group'][$key]);
}
}
}
// the selector will override this if the user does have
// edit permissions as determined by the mask, CRM-4341
// do not allow edit for anon users in joomla frontend, CRM-4668
$config = CRM_Core_Config::singleton();
if (!CRM_Core_Permission::check('access CiviCRM') || $config->userFrameworkFrontend == 1) {
$editLink = FALSE;
}
$selector = new CRM_Profile_Selector_Listings($this->_params, $this->_customFields, $gids, $map, $editLink, $linkToUF);
$controller = new CRM_Core_Selector_Controller($selector, $this->get(CRM_Utils_Pager::PAGE_ID), $this->get(CRM_Utils_Sort::SORT_ID), CRM_Core_Action::VIEW, $this, CRM_Core_Selector_Controller::TEMPLATE);
$controller->setEmbedded(TRUE);
$controller->run();
}
//CRM-6862 -run form cotroller after
//selector, since it erase $_POST
$formController->run();
return parent::run();
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:87,代码来源:Listings.php
示例6: addDisplayEnums
/**
* adds $value['foo_display'] for each $value['foo'] enum from civicrm_uf_group
*
* @param array $values (reference) the array up for enhancing
* @return void
*/
function addDisplayEnums(&$values)
{
$enumFields =& CRM_Core_DAO_UFGroup::getEnums();
foreach ($enumFields as $enum) {
if (isset($values[$enum])) {
$values[$enum . '_display'] = CRM_Core_DAO_UFGroup::tsEnum($enum, $values[$enum]);
}
}
}
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:15,代码来源:UFGroup.php
示例7: migrateHonoreeInfo
/**
* Migrate honoree information to uf_join.module_data as honoree columns (text and title) will be dropped
* on DB upgrade
*
* @param CRM_Queue_TaskContext $ctx
*
* @return bool
* TRUE for success
*/
public static function migrateHonoreeInfo(CRM_Queue_TaskContext $ctx)
{
$query = "ALTER TABLE `civicrm_uf_join`\n ADD COLUMN `module_data` longtext COMMENT 'Json serialized array of data used by the ufjoin.module'";
CRM_Core_DAO::executeQuery($query);
$honorTypes = array_keys(CRM_Core_OptionGroup::values('honor_type'));
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'new_individual';
$ufGroupDAO->find(TRUE);
$query = "SELECT * FROM civicrm_contribution_page";
$dao = CRM_Core_DAO::executeQuery($query);
if ($dao->N) {
$domain = new CRM_Core_DAO_Domain();
$domain->find(TRUE);
while ($dao->fetch()) {
$honorParams = array('soft_credit' => array('soft_credit_types' => $honorTypes));
if ($domain->locales) {
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
foreach ($locales as $locale) {
$honor_block_title = "honor_block_title_{$locale}";
$honor_block_text = "honor_block_text_{$locale}";
$honorParams['soft_credit'] += array($locale => array('honor_block_title' => $dao->{$honor_block_title}, 'honor_block_text' => $dao->{$honor_block_text}));
}
} else {
$honorParams['soft_credit'] += array('default' => array('honor_block_title' => $dao->honor_block_title, 'honor_block_text' => $dao->honor_block_text));
}
$ufJoinParam = array('module' => 'soft_credit', 'entity_table' => 'civicrm_contribution_page', 'is_active' => $dao->honor_block_is_active, 'entity_id' => $dao->id, 'uf_group_id' => $ufGroupDAO->id, 'module_data' => json_encode($honorParams));
CRM_Core_BAO_UFJoin::create($ufJoinParam);
}
}
return TRUE;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:40,代码来源:FourFive.php
示例8: preProcess
/**
* pre processing work done here.
*
* gets session variables for table name, id of entity in table, type of entity and stores them.
*
* @param
* @return void
*
* @access public
*/
function preProcess()
{
require_once 'CRM/Core/BAO/UFGroup.php';
require_once "CRM/Core/BAO/UFField.php";
$this->_id = $this->get('id');
$this->_gid = $this->get('gid');
$this->_grid = CRM_Utils_Request::retrieve('grid', 'Integer', $this);
$this->_context = CRM_Utils_Request::retrieve('context', 'String', $this);
$this->_duplicateButtonName = $this->getButtonName('upload', 'duplicate');
if (!$this->_gid) {
$this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive', $this, false, 0, 'GET');
}
//get values for captch and dupe update.
if ($this->_gid) {
$dao = new CRM_Core_DAO_UFGroup();
$dao->id = $this->_gid;
if ($dao->find(true)) {
$this->_isUpdateDupe = $dao->is_update_dupe;
$this->_isAddCaptcha = $dao->add_captcha;
}
$dao->free();
}
// if we dont have a gid use the default, else just use that specific gid
if (($this->_mode == self::MODE_REGISTER || $this->_mode == self::MODE_CREATE) && !$this->_gid) {
$this->_ctype = CRM_Utils_Request::retrieve('ctype', 'String', $this, false, 'Individual', 'REQUEST');
$this->_fields = CRM_Core_BAO_UFGroup::getRegistrationFields($this->_action, $this->_mode, $this->_ctype);
} else {
if ($this->_mode == self::MODE_SEARCH) {
$this->_fields = CRM_Core_BAO_UFGroup::getListingFields($this->_action, CRM_Core_BAO_UFGroup::PUBLIC_VISIBILITY | CRM_Core_BAO_UFGroup::LISTINGS_VISIBILITY, false, $this->_gid, true, null, $this->_skipPermission, CRM_Core_Permission::SEARCH);
} else {
$this->_fields = CRM_Core_BAO_UFGroup::getFields($this->_gid, false, null, null, null, false, null, $this->_skipPermission, null, $this->_action == CRM_Core_Action::ADD ? CRM_Core_Permission::CREATE : CRM_Core_Permission::EDIT);
///is profile double-opt process configurablem, key
///should be present in civicrm.settting.php file
$config =& CRM_Core_Config::singleton();
if ($config->profileDoubleOptIn && CRM_Utils_Array::value('group', $this->_fields)) {
$emailField = false;
foreach ($this->_fields as $name => $values) {
if (substr($name, 0, 6) == 'email-') {
$emailField = true;
}
}
if (!$emailField) {
$session =& CRM_Core_Session::singleton();
$status = ts("Email field should be included in profile if you want to use Group(s) when Profile double-opt in process is enabled.");
$session->setStatus($status);
}
}
}
}
if (!is_array($this->_fields)) {
$session =& CRM_Core_Session::singleton();
CRM_Core_Session::setStatus(ts('This feature is not currently available.'));
return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm', 'reset=1'));
}
if ($this->_mode != self::MODE_SEARCH) {
CRM_Core_BAO_UFGroup::setRegisterDefaults($this->_fields, $defaults);
$this->setDefaults($defaults);
}
$this->setDefaultsValues();
}
开发者ID:bhirsch,项目名称:civicrm,代码行数:70,代码来源:Form.php
示例9: testcreateAndGetHonorContact
/**
* Create honor-contact method
*/
public function testcreateAndGetHonorContact()
{
$firstName = 'John_' . substr(sha1(rand()), 0, 7);
$lastName = 'Smith_' . substr(sha1(rand()), 0, 7);
$email = "{$firstName}.{$lastName}@example.com";
//Get profile id of name honoree_individual used to create profileContact
$honoreeProfileId = NULL;
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'honoree_individual';
if ($ufGroupDAO->find(TRUE)) {
$honoreeProfileId = $ufGroupDAO->id;
}
$params = array('prefix_id' => 3, 'first_name' => $firstName, 'last_name' => $lastName, 'email-1' => $email);
$softParam = array('soft_credit_type_id' => 1);
$honoreeContactId = CRM_Contact_BAO_Contact::createProfileContact($params, CRM_Core_DAO::$_nullArray, NULL, NULL, $honoreeProfileId);
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $honoreeContactId, 'first_name', 'id', $firstName, 'Database check for created honor contact record.');
//create contribution on behalf of honary.
$contactId = Contact::createIndividual();
$softParam['contact_id'] = $honoreeContactId;
$ids = array('contribution' => NULL);
$param = array('contact_id' => $contactId, 'currency' => 'USD', 'financial_type_id' => 4, 'contribution_status_id' => 1, 'receive_date' => date('Ymd'), 'total_amount' => 66);
$contribution = CRM_Contribute_BAO_Contribution::create($param, $ids);
$id = $contribution->id;
$softParam['contribution_id'] = $id;
$softParam['currency'] = $contribution->currency;
$softParam['amount'] = $contribution->total_amount;
//Create Soft Contribution for honoree contact
CRM_Contribute_BAO_ContributionSoft::add($softParam);
$this->assertDBCompareValue('CRM_Contribute_DAO_ContributionSoft', $id, 'contact_id', 'contribution_id', $honoreeContactId, 'Check DB for honor contact of the contribution');
//get honorary information
$getHonorContact = CRM_Contribute_BAO_Contribution::getHonorContacts($honoreeContactId);
$this->assertEquals(array($id => array('honor_type' => 'In Honor of', 'honorId' => $id, 'display_name' => 'John Doe', 'type' => 'Event Fee', 'type_id' => '4', 'amount' => '$ 66.00', 'source' => NULL, 'receive_date' => date('Y-m-d 00:00:00'), 'contribution_status' => 'Completed')), $getHonorContact);
$this->assertDBCompareValue('CRM_Contact_DAO_Contact', $honoreeContactId, 'first_name', 'id', $firstName, 'Database check for created honor contact record.');
//get annual contribution information
$annual = CRM_Contribute_BAO_Contribution::annual($contactId);
$config = CRM_Core_Config::singleton();
$currencySymbol = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_Currency', $config->defaultCurrency, 'symbol', 'name');
$this->assertDBCompareValue('CRM_Contribute_DAO_Contribution', $id, 'total_amount', 'id', ltrim($annual[2], $currencySymbol), 'Check DB for total amount of the contribution');
//Delete honor contact
Contact::delete($honoreeContactId);
//Delete Contribution record
$this->contributionDelete($contribution->id);
//Delete contributor contact
Contact::delete($contactId);
}
开发者ID:konadave,项目名称:civicrm-core,代码行数:48,代码来源:ContributionTest.php
示例10: getProfileType
/**
* Get the profile type (eg: individual/organization/household)
*
* @param int $ufGroupId
* Uf group id.
* @param bool $returnMixType
* This is true, then field type of mix profile field is returned.
* @param bool $onlyPure
* True if only pure profiles are required.
*
* @param bool $skipComponentType
*
* @return string
* profile group_type
*
*/
public static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE)
{
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $ufGroupId;
$ufGroup->is_active = 1;
$ufGroup->find(TRUE);
return self::calculateProfileType($ufGroup->group_type, $returnMixType, $onlyPure, $skipComponentType);
}
开发者ID:kidaa30,项目名称:yes,代码行数:24,代码来源:UFField.php
示例11: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
// add the hidden field to redirect the postProcess from
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $this->_gid;
if (!$ufGroup->find(TRUE)) {
CRM_Core_Error::fatal();
}
// set the title
if ($this->_multiRecord && $this->_customGroupTitle) {
$groupTitle = $this->_multiRecord & CRM_Core_Action::UPDATE ? 'Edit ' . $this->_customGroupTitle . ' Record' : $this->_customGroupTitle;
} else {
$groupTitle = $ufGroup->title;
}
CRM_Utils_System::setTitle($groupTitle);
$this->assign('recentlyViewed', FALSE);
if ($this->_context != 'dialog') {
$this->_postURL = CRM_Utils_Array::value('postURL', $_POST);
$this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
if (!$this->_postURL) {
$this->_postURL = $ufGroup->post_URL;
}
if (!$this->_postURL) {
if ($this->_context == 'Search') {
$this->_postURL = CRM_Utils_System::url('civicrm/contact/search');
} elseif ($this->_id && $this->_gid) {
$urlParams = "reset=1&id={$this->_id}&gid={$gidString}";
if ($this->_isContactActivityProfile && $this->_activityId) {
$urlParams .= "&aid={$this->_activityId}";
}
// get checksum if present
if ($this->get('cs')) {
$urlParams .= "&cs=" . $this->get('cs');
}
$this->_postURL = CRM_Utils_System::url('civicrm/profile/view', $urlParams);
}
}
if (!$this->_cancelURL) {
if ($ufGroup->cancel_URL) {
$this->_cancelURL = $ufGroup->cancel_URL;
} else {
$this->_cancelURL = CRM_Utils_System::url('civicrm/profile', "reset=1&gid={$gidString}");
}
}
if ($this->_multiRecordProfile) {
$urlParams = "reset=1&id={$this->_id}&gid={$gidString}";
// get checksum if present
if ($this->get('cs')) {
$urlParams .= "&cs=" . $this->get('cs');
}
$this->_postURL = CRM_Utils_System::url('civicrm/profile/edit', $urlParams);
$this->_cancelURL = CRM_Utils_System::url('civicrm/profile/edit', $urlParams);
//passing the post url to template so the popup form does
//proper redirection and proccess form errors if any
if (!isset($this->_onPopupClose) || $this->_onPopupClose == 'redirectToProfile') {
$popupRedirect = CRM_Utils_System::url('civicrm/profile/edit', $urlParams, FALSE, NULL, FALSE);
} elseif ($this->_onPopupClose == 'redirectToTab') {
$popupRedirect = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_id}&selectedChild=custom_{$this->_customGroupId}", FALSE, NULL, FALSE);
}
$this->assign('urlParams', $urlParams);
$this->assign('postUrl', $popupRedirect);
}
// we do this gross hack since qf also does entity replacement
$this->_postURL = str_replace('&', '&', $this->_postURL);
$this->_cancelURL = str_replace('&', '&', $this->_cancelURL);
$this->addElement('hidden', 'postURL', $this->_postURL);
if ($this->_cancelURL) {
$this->addElement('hidden', 'cancelURL', $this->_cancelURL);
}
// also retain error URL if set
$this->_errorURL = CRM_Utils_Array::value('errorURL', $_POST);
if ($this->_errorURL) {
// we do this gross hack since qf also does entity replacement
$this->_errorURL = str_replace('&', '&', $this->_errorURL);
$this->addElement('hidden', 'errorURL', $this->_errorURL);
}
// replace the session stack in case user cancels (and we dont go into postProcess)
$session = CRM_Core_Session::singleton();
$session->replaceUserContext($this->_postURL);
}
parent::buildQuickForm();
if ($this->_multiRecord & CRM_Core_Action::DELETE && $this->_recordExists) {
$this->_deleteButtonName = $this->getButtonName('upload', 'delete');
$this->addElement('submit', $this->_deleteButtonName, ts('Delete'));
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'), 'isDefault' => TRUE);
$this->addButtons($buttons);
return;
}
//get the value from session, this is set if there is any file
//upload field
//.........这里部分代码省略.........
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:101,代码来源:Edit.php
示例12: buildQuickForm
/**
* Function to actually build the form
*
* @return void
* @access public
*/
public function buildQuickForm()
{
// add the hidden field to redirect the postProcess from
require_once 'CRM/UF/Form/Group.php';
require_once 'CRM/Core/DAO/UFGroup.php';
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $this->_gid;
if (!$ufGroup->find(true)) {
CRM_Core_Error::fatal();
}
// set the title
CRM_Utils_System::setTitle($ufGroup->title);
$this->assign('recentlyViewed', false);
if ($this->_context != 'dialog') {
$this->_postURL = CRM_Utils_Array::value('postURL', $_POST);
$this->_cancelURL = CRM_Utils_Array::value('cancelURL', $_POST);
$gidString = $this->_gid;
if (!empty($this->_profileIds)) {
$gidString = implode(',', $this->_profileIds);
}
if (!$this->_postURL) {
$this->_postURL = $ufGroup->post_URL;
}
if (!$this->_postURL) {
if ($this->_context == 'Search') {
$this->_postURL = CRM_Utils_System::url('civicrm/contact/search');
} elseif ($this->_id && $this->_gid) {
$this->_postURL = CRM_Utils_System::url('civicrm/profile/view', "reset=1&id={$this->_id}&gid={$gidString}");
}
}
if (!$this->_cancelURL) {
if ($ufGroup->cancel_URL) {
$this->_cancelURL = $ufGroup->cancel_URL;
} else {
$this->_cancelURL = CRM_Utils_System::url('civicrm/profile', "reset=1&gid={$gidString}");
}
}
// we do this gross hack since qf also does entity replacement
$this->_postURL = str_replace('&', '&', $this->_postURL);
$this->_cancelURL = str_replace('&', '&', $this->_cancelURL);
$this->addElement('hidden', 'postURL', $this->_postURL);
if ($this->_cancelURL) {
$this->addElement('hidden', 'cancelURL', $this->_cancelURL);
}
// also retain error URL if set
$this->_errorURL = CRM_Utils_Array::value('errorURL', $_POST);
if ($this->_errorURL) {
// we do this gross hack since qf also does entity replacement
$this->_errorURL = str_replace('&', '&', $this->_errorURL);
$this->addElement('hidden', 'errorURL', $this->_errorURL);
}
// replace the session stack in case user cancels (and we dont go into postProcess)
$session = CRM_Core_Session::singleton();
$session->replaceUserContext($this->_postURL);
}
parent::buildQuickForm();
//get the value from session, this is set if there is any file
//upload field
$uploadNames = $this->get('uploadNames');
if (!empty($uploadNames)) {
$buttonName = 'upload';
} else {
$buttonName = 'next';
}
$buttons[] = array('type' => $buttonName, 'name' => ts('Save'), 'isDefault' => true);
if ($this->_context != 'dialog') {
$buttons[] = array('type' => 'cancel', 'name' => ts('Cancel'), 'isDefault' => true);
}
$this->addButtons($buttons);
$this->addFormRule(array('CRM_Profile_Form', 'formRule'), $this);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:77,代码来源:Edit.php
示例13: getProfileType
/**
* function to get the profile type (eg: individual/organization/household)
*
* @param int $ufGroupId uf group id
* @param boolean $returnMixType this is true, then field type of mix profile field is returned
* @param boolean $onlyPure true if only pure profiles are required
*
* @return profile group_type
* @acess public
* @static
*/
static function getProfileType($ufGroupId, $returnMixType = TRUE, $onlyPure = FALSE, $skipComponentType = FALSE)
{
// profile types
$contactTypes = array('Contact', 'Individual', 'Household', 'Organization');
$subTypes = CRM_Contact_BAO_ContactType::subTypes();
$components = array('Contribution', 'Participant', 'Membership', 'Activity');
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->id = $ufGroupId;
$ufGroup->is_active = 1;
$ufGroup->find(TRUE);
$profileTypes = array();
if ($ufGroup->group_type) {
$typeParts = explode(CRM_Core_DAO::VALUE_SEPARATOR, $ufGroup->group_type);
$profileTypes = explode(',', $typeParts[0]);
}
if ($onlyPure) {
if (count($profileTypes) == 1) {
return $profileTypes[0];
} else {
return NULL;
}
}
//we need to unset Contact
if (count($profileTypes) > 1) {
$index = array_search('Contact', $profileTypes);
if ($index !== FALSE) {
unset($profileTypes[$index]);
}
}
$profileType = $mixProfileType = NULL;
// this case handles pure profile
if (count($profileTypes) == 1) {
$profileType = array_pop($profileTypes);
} else {
//check the there are any components include in profile
$componentCount = array();
foreach ($components as $value) {
if (in_array($value, $profileTypes)) {
$componentCount[] = $value;
}
}
//check contact type included in profile
$contactTypeCount = array();
foreach ($contactTypes as $value) {
if (in_array($value, $profileTypes)) {
$contactTypeCount[] = $value;
}
}
// subtype counter
$subTypeCount = array();
foreach ($subTypes as $value) {
if (in_array($value, $profileTypes)) {
$subTypeCount[] = $value;
}
}
if (!$skipComponentType && count($componentCount) == 1) {
$profileType = $componentCount[0];
} elseif (count($componentCount) > 1) {
$mixProfileType = $componentCount[1];
} elseif (count($subTypeCount) == 1) {
$profileType = $subTypeCount[0];
} elseif (count($contactTypeCount) == 1) {
$profileType = $contactTypeCount[0];
} elseif (count($subTypeCount) > 1) {
// this is mix subtype profiles
$mixProfileType = $subTypeCount[1];
} elseif (count($contactTypeCount) > 1) {
// this is mix contact profiles
$mixProfileType = $contactTypeCount[1];
}
}
if ($mixProfileType) {
if ($returnMixType) {
return $mixProfileType;
} else {
return 'Mixed';
}
} else {
return $profileType;
}
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:92,代码来源:UFField.php
示例14: checkProfileGroupType
/**
* function to check for mix profiles groups (eg: individual + other contact types)
*
* @return true for mix profile group else false
* @acess public
* @static
*/
static function checkProfileGroupType($ctype)
{
$ufGroup = new CRM_Core_DAO_UFGroup();
$query = "\nSELECT ufg.id as id\n FROM civicrm_uf_group as ufg, civicrm_uf_join as ufj\n WHERE ufg.id = ufj.uf_group_id\n AND ufj.module = 'User Registration'\n AND ufg.is_active = 1 ";
$ufGroup =& CRM_Core_DAO::executeQuery($query);
$fields = array();
$validProfiles = array('Individual', 'Organization', 'Household', 'Contribution');
while ($ufGroup->fetch()) {
$profileType = self::getProfileType($ufGroup->id);
if (in_array($profileType, $validProfiles)) {
continue;
} else {
if ($profileType) {
return false;
}
}
}
return true;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:26,代码来源:UFField.php
示例15: setDefaultValues
/**
* Set default values for the form.
*/
public function setDefaultValues()
{
$defaults = parent::setDefaultValues();
$soft_credit_types = CRM_Core_OptionGroup::values('soft_credit_type', TRUE, FALSE, FALSE, NULL, 'name');
if ($this->_id) {
$title = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionPage', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Title and Settings') . " ({$title})");
foreach (array('on_behalf', 'soft_credit') as $module) {
$ufJoinDAO = new CRM_Core_DAO_UFJoin();
$ufJoinDAO->module = $module;
$ufJoinDAO->entity_id = $this->_id;
if ($ufJoinDAO->find(TRUE)) {
$jsonData = CRM_Contribute_BAO_ContributionPage::formatModuleData($ufJoinDAO->module_data, TRUE, $module);
if ($module == 'soft_credit') {
$defaults['honoree_profile'] = $ufJoinDAO->uf_group_id;
$defaults = array_merge($defaults, $jsonData);
$defaults['honor_block_is_active'] = $ufJoinDAO->is_active;
} else {
$defaults['onbehalf_profile_id'] = $ufJoinDAO->uf_group_id;
$defaults = array_merge($defaults, $jsonData);
$defaults['is_organization'] = $ufJoinDAO->is_active;
}
} else {
if ($module == 'soft_credit') {
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'honoree_individual';
if ($ufGroupDAO->find(TRUE)) {
$defaults['honoree_profile'] = $ufGroupDAO->id;
}
$defaults['soft_credit_types'] = array(CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types));
} else {
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'on_behalf_organization';
if ($ufGroupDAO->find(TRUE)) {
$defaults['onbehalf_profile_id'] = $ufGroupDAO->id;
}
$defaults['for_organization'] = ts('I am contributing on behalf of an organization.');
$defaults['is_for_organization'] = 1;
}
}
}
} else {
$ufGroupDAO = new CRM_Core_DAO_UFGroup();
$ufGroupDAO->name = 'honoree_individual';
if ($ufGroupDAO->find(TRUE)) {
$defaults['honoree_profile'] = $ufGroupDAO->id;
}
$defaults['soft_credit_types'] = array(CRM_Utils_Array::value('in_honor_of', $soft_credit_types), CRM_Utils_Array::value('in_memory_of', $soft_credit_types));
}
return $defaults;
}
开发者ID:rollox,项目名称:civicrm-core,代码行数:54,代码来源:Settings.php
示例16: upgrade_3_3_alpha1
function upgrade_3_3_alpha1($rev)
{
$config = CRM_Core_Config::singleton();
if ($config->userSystem->is_drupal) {
// CRM-6426 - make civicrm profiles permissioned on drupal my account
$config->userSystem->updateCategories();
}
// CRM-6846
// insert name column for custom field table.
// make sure name for custom field, group and
// profile should be unique and properly munged.
$colQuery = 'ALTER TABLE `civicrm_custom_field` ADD `name` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL AFTER `custom_group_id` ';
CRM_Core_DAO::executeQuery($colQuery, CRM_Core_DAO::$_nullArray, TRUE, NULL, FALSE, FALSE);
$customFldCntQuery = 'select count(*) from civicrm_custom_field where name like %1 and id != %2';
$customField = new CRM_Core_DAO_CustomField();
$customField->selectAdd();
$customField->selectAdd('id, label');
$customField->find();
while ($customField->fetch()) {
$name = CRM_Utils_String::munge($customField->label, '_', 64);
$fldCnt = CRM_Core_DAO::singleValueQuery($customFldCntQuery, array(1 => array($name, 'String'), 2 => array($customField->id, 'Integer')), TRUE, FALSE);
if ($fldCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
$customFieldQuery = "\nUpdate `civicrm_custom_field`\nSET `name` = %1\nWHERE id = %2\n";
$customFieldParams = array(1 => array($name, 'String'), 2 => array($customField->id, 'Integer'));
CRM_Core_DAO::executeQuery($customFieldQuery, $customFieldParams, TRUE, NULL, FALSE, FALSE);
}
$customField->free();
$customGrpCntQuery = 'select count(*) from civicrm_custom_group where name like %1 and id != %2';
$customGroup = new CRM_Core_DAO_CustomGroup();
$customGroup->selectAdd();
$customGroup->selectAdd('id, title');
$customGroup->find();
while ($customGroup->fetch()) {
$name = CRM_Utils_String::munge($customGroup->title, '_', 64);
$grpCnt = CRM_Core_DAO::singleValueQuery($customGrpCntQuery, array(1 => array($name, 'String'), 2 => array($customGroup->id, 'Integer')));
if ($grpCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_CustomGroup', $customGroup->id, 'name', $name);
}
$customGroup->free();
$ufGrpCntQuery = 'select count(*) from civicrm_uf_group where name like %1 and id != %2';
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->selectAdd();
$ufGroup->selectAdd('id, title');
$ufGroup->find();
while ($ufGroup->fetch()) {
$name = CRM_Utils_String::munge($ufGroup->title, '_', 64);
$ufGrpCnt = CRM_Core_DAO::singleValueQuery($ufGrpCntQuery, array(1 => array($name, 'String'), 2 => array($ufGroup->id, 'Integer')));
if ($ufGrpCnt) {
$name = CRM_Utils_String::munge("{$name}_" . rand(), '_', 64);
}
CRM_Core_DAO::setFieldValue('CRM_Core_DAO_UFGroup', $ufGroup->id, 'name', $name);
}
$ufGroup->free();
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// now modify the config so that the directories are stored in option group/value
// CRM-6914
// require_once 'CRM/Core/BAO/ConfigSetting.php';
// $params = array( );
// CRM_Core_BAO_ConfigSetting::add( $parambs );
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:65,代码来源:ThreeThree.php
示例17: add
/**
* Add the UF Group.
*
* @param array $params
* Reference array contains the values submitted by the form.
* @param array $ids
* Reference array contains the id.
*
*
* @return object
*/
public static function add(&$params, $ids = array())
{
$fields = array('is_active', 'add_captcha', 'is_map', 'is_update_dupe', 'is_edit_link', 'is_uf_link', 'is_cms_user');
foreach ($fields as $field) {
$params[$field] = CRM_Utils_Array::value($field, $params, FALSE);
}
$params['limit_listings_group_id'] = CRM_Utils_Array::value('group', $params);
$params['add_to_group_id'] = CRM_Utils_Array::value('add_contact_to_group', $params);
//CRM-15427
if (!empty($params['group_type']) && is_array($params['group_type'])) {
$params['group_type'] = implode(',', $params['group_type']);
}
$ufGroup = new CRM_Core_DAO_UFGroup();
$ufGroup->copyValues($params);
$ufGroupID = CRM_Utils_Array::value('ufgroup', $ids, CRM_Utils_Array::value('id', $params));
if (!$ufGroupID) {
$ufGroup->name = CRM_Utils_String::munge($ufGroup->title, '_', 56);
}
$ufGroup->id = $ufGroupID;
$ufGroup->save();
if (!$ufGroupID) {
$ufGroup->name = $ufGroup->name . "_{$ufGroup->id}";
$ufGroup->save();
|
请发表评论