本文整理汇总了PHP中CRM_Core_DAO_OptionGroup::find方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_DAO_OptionGroup::find方法的具体用法?PHP CRM_Core_DAO_OptionGroup::find怎么用?PHP CRM_Core_DAO_OptionGroup::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_DAO_OptionGroup
的用法示例。
在下文中一共展示了CRM_Core_DAO_OptionGroup::find方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: date
/**
* function to get the complete information for one or more events
*
* @param date $start get events with start date >= this date
* @param integer $type get events on the a specific event type (by event_type_id)
* @param integer $eventId return a single event - by event id
* @param date $end also get events with end date >= this date
*
* @return array $all array of all the events that are searched
* @static
* @access public
*/
static function &getCompleteInfo($start = null, $type = null, $eventId = null, $end = null)
{
// if start and end date are NOT passed, return all events with start_date OR end_date >= today CRM-5133
if ($start) {
// get events with start_date >= requested start
$startDate = CRM_Utils_Type::escape($start, 'Date');
} else {
// get events with start date >= today
$startDate = date("Ymd");
}
if ($end) {
// also get events with end_date >= requested end
$endDate = CRM_Utils_Type::escape($end, 'Date');
} else {
// OR also get events with end date >= today
$endDate = date("Ymd");
}
$dateCondition = "AND (civicrm_event.start_date >= {$startDate} OR civicrm_event.end_date >= {$endDate})";
if ($type) {
$typeCondition = " AND civicrm_event.event_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
}
// Get the Id of Option Group for Event Types
require_once 'CRM/Core/DAO/OptionGroup.php';
$optionGroupDAO = new CRM_Core_DAO_OptionGroup();
$optionGroupDAO->name = 'event_type';
$optionGroupId = null;
if ($optionGroupDAO->find(true)) {
$optionGroupId = $optionGroupDAO->id;
}
$query = "\nSELECT\n civicrm_event.id as event_id, \n civicrm_email.email as email, \n civicrm_event.title as title, \n civicrm_event.summary as summary, \n civicrm_event.start_date as start, \n civicrm_event.end_date as end, \n civicrm_event.description as description, \n civicrm_event.is_show_location as is_show_location, \n civicrm_event.is_online_registration as is_online_registration,\n civicrm_event.registration_link_text as registration_link_text,\n civicrm_event.registration_start_date as registration_start_date,\n civicrm_event.registration_end_date as registration_end_date,\n civicrm_option_value.label as event_type, \n civicrm_address.name as address_name, \n civicrm_address.street_address as street_address, \n civicrm_address.supplemental_address_1 as supplemental_address_1, \n civicrm_address.supplemental_address_2 as supplemental_address_2, \n civicrm_address.city as city, \n civicrm_address.postal_code as postal_code, \n civicrm_address.postal_code_suffix as postal_code_suffix, \n civicrm_state_province.abbreviation as state, \n civicrm_country.name AS country\nFROM civicrm_event\nLEFT JOIN civicrm_loc_block ON civicrm_event.loc_block_id = civicrm_loc_block.id\nLEFT JOIN civicrm_address ON civicrm_loc_block.address_id = civicrm_address.id\nLEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id\nLEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id\nLEFT JOIN civicrm_email ON civicrm_loc_block.email_id = civicrm_email.id\nLEFT JOIN civicrm_option_value ON (\n civicrm_event.event_type_id = civicrm_option_value.value AND\n civicrm_option_value.option_group_id = %1 )\nWHERE civicrm_event.is_active = 1 \n AND civicrm_event.is_public = 1\n AND (is_template = 0 OR is_template IS NULL)\n {$dateCondition}";
if (isset($typeCondition)) {
$query .= $typeCondition;
}
if (isset($eventId)) {
$query .= " AND civicrm_event.id ={$eventId} ";
}
$query .= " ORDER BY civicrm_event.start_date ASC";
$params = array(1 => array($optionGroupId, 'Integer'));
$dao =& CRM_Core_DAO::executeQuery($query, $params);
$all = array();
$config = CRM_Core_Config::singleton();
$baseURL = parse_url($config->userFrameworkBaseURL);
$url = "@" . $baseURL['host'];
if (CRM_Utils_Array::value('path', $baseURL)) {
$url .= substr($baseURL['path'], 0, -1);
}
// check 'view event info' permission
$permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
require_once 'CRM/Utils/String.php';
while ($dao->fetch()) {
if (in_array($dao->event_id, $permissions)) {
$info = array();
$info['uid'] = "CiviCRM_EventID_{$dao->event_id}_" . md5($config->userFrameworkBaseURL) . $url;
$info['title'] = $dao->title;
$info['event_id'] = $dao->event_id;
$info['summary'] = $dao->summary;
$info['description'] = $dao->description;
$info['start_date'] = $dao->start;
$info['end_date'] = $dao->end;
$info['contact_email'] = $dao->email;
$info['event_type'] = $dao->event_type;
$info['is_show_location'] = $dao->is_show_location;
$info['is_online_registration'] = $dao->is_online_registration;
$info['registration_link_text'] = $dao->registration_link_text;
$info['registration_start_date'] = $dao->registration_start_date;
$info['registration_end_date'] = $dao->registration_end_date;
$address = '';
$addrFields = array('address_name' => $dao->address_name, 'street_address' => $dao->street_address, 'supplemental_address_1' => $dao->supplemental_address_1, 'supplemental_address_2' => $dao->supplemental_address_2, 'city' => $dao->city, 'state_province' => $dao->state, 'postal_code' => $dao->postal_code, 'postal_code_suffix' => $dao->postal_code_suffix, 'country' => $dao->country, 'county' => null);
require_once 'CRM/Utils/Address.php';
CRM_Utils_String::append($address, ', ', CRM_Utils_Address::format($addrFields));
$info['location'] = $address;
$info['url'] = CRM_Utils_System::url('civicrm/event/info', 'reset=1&id=' . $dao->event_id, true, null, false);
$all[] = $info;
}
}
return $all;
}
示例2: getOptionValuesAssocArrayFromName
/**
* Get the values of all option values given an option group Name as a key => value pair
* Use above cached function to make it super efficient
*
* @param string $optionGroupName
* The option group name for which we want the values from.
*
* @return array
* an associative array of label, value pairs
*/
public static function getOptionValuesAssocArrayFromName($optionGroupName)
{
$dao = new CRM_Core_DAO_OptionGroup();
$dao->name = $optionGroupName;
$dao->selectAdd();
$dao->selectAdd('id');
$dao->find(TRUE);
$optionValues = self::getOptionValuesArray($dao->id);
$options = array();
foreach ($optionValues as $id => $value) {
$options[$value['value']] = $value['label'];
}
return $options;
}
示例3: buildEventReport
function buildEventReport($eventIDs)
{
$this->assign('events', $eventIDs);
$eventID = implode(',', $eventIDs);
$participantStatus = CRM_Event_PseudoConstant::participantStatus(NULL, "is_counted = 1");
$participantRole = CRM_Event_PseudoConstant::participantRole();
$paymentInstruments = CRM_Contribute_PseudoConstant::paymentInstrument();
$rows = $eventSummary = $roleRows = $statusRows = $instrumentRows = $count = array();
$optionGroupDAO = new CRM_Core_DAO_OptionGroup();
$optionGroupDAO->name = 'event_type';
$optionGroupId = NULL;
if ($optionGroupDAO->find(TRUE)) {
$optionGroupId = $optionGroupDAO->id;
}
//show the income of active participant status (Counted = filter = 1)
$activeParticipantStatusIDArray = $activeParticipantStatusLabelArray = array();
foreach ($participantStatus as $id => $label) {
$activeParticipantStatusIDArray[] = $id;
$activeParticipantStatusLabelArray[] = $label;
}
$activeParticipantStatus = implode(',', $activeParticipantStatusIDArray);
$activeparticipnatStutusLabel = implode(', ', $activeParticipantStatusLabelArray);
$activeParticipantClause = " AND civicrm_participant.status_id IN ( {$activeParticipantStatus} ) ";
$sql = "\n SELECT civicrm_event.id as event_id,\n civicrm_event.title as event_title,\n civicrm_event.max_participants as max_participants, \n civicrm_event.start_date as start_date,\n civicrm_event.end_date as end_date, \n civicrm_option_value.label as event_type, \n SUM(civicrm_participant.fee_amount) as total,\n COUNT(civicrm_participant.id) as participant\n\n FROM civicrm_event\n LEFT JOIN civicrm_option_value \n ON ( civicrm_event.event_type_id = civicrm_option_value.value AND\n civicrm_option_value.option_group_id = {$optionGroupId} )\n LEFT JOIN civicrm_participant ON ( civicrm_event.id = civicrm_participant.event_id \n {$activeParticipantClause} AND civicrm_participant.is_test = 0 )\n\n WHERE civicrm_event.id IN( {$eventID}) \n \n GROUP BY civicrm_event.id\n ";
$eventDAO = CRM_Core_DAO::executeQuery($sql);
while ($eventDAO->fetch()) {
$eventSummary[$eventDAO->event_id]['Title'] = $eventDAO->event_title;
$eventSummary[$eventDAO->event_id]['Max Participants'] = $eventDAO->max_participants;
$eventSummary[$eventDAO->event_id]['Start Date'] = CRM_Utils_Date::customFormat($eventDAO->start_date);
$eventSummary[$eventDAO->event_id]['End Date'] = CRM_Utils_Date::customFormat($eventDAO->end_date);
$eventSummary[$eventDAO->event_id]['Event Type'] = $eventDAO->event_type;
$eventSummary[$eventDAO->event_id]['Event Income'] = CRM_Utils_Money::format($eventDAO->total);
$eventSummary[$eventDAO->event_id]['Registered Participant'] = "{$eventDAO->participant} ({$activeparticipnatStutusLabel})";
}
$this->assign_by_ref('summary', $eventSummary);
//Total Participant Registerd for the Event
$pariticipantCount = "\n SELECT COUNT(civicrm_participant.id ) as count, civicrm_participant.event_id as event_id\n\n FROM civicrm_participant\n\n WHERE civicrm_participant.event_id IN( {$eventID}) AND \n civicrm_participant.is_test = 0 \n {$activeParticipantClause}\n GROUP BY civicrm_participant.event_id\n ";
$counteDAO = CRM_Core_DAO::executeQuery($pariticipantCount);
while ($counteDAO->fetch()) {
$count[$counteDAO->event_id] = $counteDAO->count;
}
//Count the Participant by Role ID for Event
$role = "\n SELECT civicrm_participant.role_id as ROLEID, \n COUNT( civicrm_participant.id ) as participant, \n SUM(civicrm_participant.fee_amount) as amount,\n civicrm_participant.event_id as event_id\n\n FROM civicrm_participant\n\n WHERE civicrm_participant.event_id IN ( {$eventID}) AND\n civicrm_participant.is_test = 0 \n {$activeParticipantClause}\n GROUP BY civicrm_participant.role_id, civicrm_participant.event_id\n ";
$roleDAO = CRM_Core_DAO::executeQuery($role);
while ($roleDAO->fetch()) {
// fix for multiple role, CRM-6507
$roles = explode(CRM_Core_DAO::VALUE_SEPARATOR, $roleDAO->ROLEID);
foreach ($roles as $roleId) {
if (!isset($roleRows[$roleDAO->event_id][$participantRole[$roleId]])) {
$roleRows[$roleDAO->event_id][$participantRole[$roleId]]['total'] = 0;
$roleRows[$roleDAO->event_id][$participantRole[$roleId]]['round'] = 0;
$roleRows[$roleDAO->event_id][$participantRole[$roleId]]['amount'] = 0;
}
$roleRows[$roleDAO->event_id][$participantRole[$roleId]]['total'] += $roleDAO->participant;
$roleRows[$roleDAO->event_id][$participantRole[$roleId]]['amount'] += $roleDAO->amount;
}
}
foreach ($roleRows as $eventId => $roleInfo) {
foreach ($participantRole as $roleName) {
if (isset($roleInfo[$roleName])) {
$roleRows[$eventId][$roleName]['round'] = round($roleRows[$eventId][$roleName]['total'] / $count[$eventId] * 100, 2);
}
}
}
$rows['Role'] = $roleRows;
//Count the Participant by status ID for Event
$status = "\n SELECT civicrm_participant.status_id as STATUSID, \n COUNT( civicrm_participant.id ) as participant, \n SUM(civicrm_participant.fee_amount) as amount,\n civicrm_participant.event_id as event_id\n\n FROM civicrm_participant\n\n WHERE civicrm_participant.event_id IN ({$eventID}) AND\n civicrm_participant.is_test = 0 \n {$activeParticipantClause}\n GROUP BY civicrm_participant.status_id, civicrm_participant.event_id\n ";
$statusDAO = CRM_Core_DAO::executeQuery($status);
while ($statusDAO->fetch()) {
$statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['total'] = $statusDAO->participant;
$statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['round'] = round($statusDAO->participant / $count[$statusDAO->event_id] * 100, 2);
$statusRows[$statusDAO->event_id][$participantStatus[$statusDAO->STATUSID]]['amount'] = $statusDAO->amount;
}
$rows['Status'] = $statusRows;
//Count the Participant by payment instrument ID for Event
//e.g. Credit Card, Check,Cash etc
$paymentInstrument = "\n SELECT c.payment_instrument_id as INSTRUMENT, \n COUNT( c.id ) as participant, \n SUM(civicrm_participant.fee_amount) as amount,\n civicrm_participant.event_id as event_id\n\n FROM civicrm_participant\n LEFT JOIN civicrm_participant_payment pp ON(pp.participant_id = civicrm_participant.id )\n LEFT JOIN civicrm_contribution c ON ( pp.contribution_id = c.id)\n\n WHERE civicrm_participant.event_id IN ( {$eventID}) AND\n civicrm_participant.is_test = 0\n {$activeParticipantClause}\n GROUP BY c.payment_instrument_id, civicrm_participant.event_id\n ";
$instrumentDAO = CRM_Core_DAO::executeQuery($paymentInstrument);
while ($instrumentDAO->fetch()) {
//allow only if instrument is present in contribution table
if ($instrumentDAO->INSTRUMENT) {
$instrumentRows[$instrumentDAO->event_id][$paymentInstruments[$instrumentDAO->INSTRUMENT]]['total'] = $instrumentDAO->participant;
$instrumentRows[$instrumentDAO->event_id][$paymentInstruments[$instrumentDAO->INSTRUMENT]]['round'] = round($instrumentDAO->participant / $count[$instrumentDAO->event_id] * 100, 2);
$instrumentRows[$instrumentDAO->event_id][$paymentInstruments[$instrumentDAO->INSTRUMENT]]['amount'] = $instrumentDAO->amount;
}
}
$rows['Payment Method'] = $instrumentRows;
$this->assign_by_ref('rows', $rows);
if (!$this->_setVariable) {
$this->_params['id_value'] = NULL;
}
$this->assign('statistics', $this->statistics($eventIDs));
}
示例4: AND
/**
* function to get the complete information for one or more events
*
* @param date $start get events with start date >= this date
* @param integer $type get events on the a specific event type (by event_type_id)
* @param integer $eventId return a single event - by event id
* @param date $end also get events with end date >= this date
* @param boolean $onlyPublic include public events only, default TRUE
*
* @return array $all array of all the events that are searched
* @static
* @access public
*/
static function &getCompleteInfo($start = NULL, $type = NULL, $eventId = NULL, $end = NULL, $onlyPublic = TRUE)
{
$publicCondition = NULL;
if ($onlyPublic) {
$publicCondition = " AND civicrm_event.is_public = 1";
}
$dateCondition = '';
// if start and end date are NOT passed, return all events with start_date OR end_date >= today CRM-5133
if ($start) {
// get events with start_date >= requested start
$startDate = CRM_Utils_Type::escape($start, 'Date');
$dateCondition .= " AND ( civicrm_event.start_date >= {$startDate} )";
}
if ($end) {
// also get events with end_date <= requested end
$endDate = CRM_Utils_Type::escape($end, 'Date');
$dateCondition .= " AND ( civicrm_event.end_date <= '{$endDate}' ) ";
}
// CRM-9421 and CRM-8620 Default mode for ical/rss feeds. No start or end filter passed.
// Need to exclude old events with only start date
// and not exclude events in progress (start <= today and end >= today). DGG
if (empty($start) && empty($end)) {
// get events with end date >= today, not sure of this logic
// but keeping this for backward compatibility as per issue CRM-5133
$today = date("Y-m-d G:i:s");
$dateCondition .= " AND ( civicrm_event.end_date >= '{$today}' OR civicrm_event.start_date >= '{$today}' ) ";
}
if ($type) {
$typeCondition = " AND civicrm_event.event_type_id = " . CRM_Utils_Type::escape($type, 'Integer');
}
// Get the Id of Option Group for Event Types
$optionGroupDAO = new CRM_Core_DAO_OptionGroup();
$optionGroupDAO->name = 'event_type';
$optionGroupId = NULL;
if ($optionGroupDAO->find(TRUE)) {
$optionGroupId = $optionGroupDAO->id;
}
$query = "\nSELECT\n civicrm_event.id as event_id,\n civicrm_email.email as email,\n civicrm_event.title as title,\n civicrm_event.summary as summary,\n civicrm_event.start_date as start,\n civicrm_event.end_date as end,\n civicrm_event.description as description,\n civicrm_event.is_show_location as is_show_location,\n civicrm_event.is_online_registration as is_online_registration,\n civicrm_event.registration_link_text as registration_link_text,\n civicrm_event.registration_start_date as registration_start_date,\n civicrm_event.registration_end_date as registration_end_date,\n civicrm_option_value.label as event_type,\n civicrm_address.name as address_name,\n civicrm_address.street_address as street_address,\n civicrm_address.supplemental_address_1 as supplemental_address_1,\n civicrm_address.supplemental_address_2 as supplemental_address_2,\n civicrm_address.city as city,\n civicrm_address.postal_code as postal_code,\n civicrm_address.postal_code_suffix as postal_code_suffix,\n civicrm_state_province.abbreviation as state,\n civicrm_country.name AS country\nFROM civicrm_event\nLEFT JOIN civicrm_loc_block ON civicrm_event.loc_block_id = civicrm_loc_block.id\nLEFT JOIN civicrm_address ON civicrm_loc_block.address_id = civicrm_address.id\nLEFT JOIN civicrm_state_province ON civicrm_address.state_province_id = civicrm_state_province.id\nLEFT JOIN civicrm_country ON civicrm_address.country_id = civicrm_country.id\nLEFT JOIN civicrm_email ON civicrm_loc_block.email_id = civicrm_email.id\nLEFT JOIN civicrm_option_value ON (\n civicrm_event.event_type_id = civicrm_option_value.value AND\n civicrm_option_value.option_group_id = %1 )\nWHERE civicrm_event.is_active = 1\n AND (is_template = 0 OR is_template IS NULL)\n {$publicCondition}\n {$dateCondition}";
if (isset($typeCondition)) {
$query .= $typeCondition;
}
if (isset($eventId)) {
$query .= " AND civicrm_event.id ={$eventId} ";
}
$query .= " ORDER BY civicrm_event.start_date ASC";
$params = array(1 => array($optionGroupId, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
$all = array();
$config = CRM_Core_Config::singleton();
$baseURL = parse_url($config->userFrameworkBaseURL);
$url = "@" . $baseURL['host'];
if (!empty($baseURL['path'])) {
$url .= substr($baseURL['path'], 0, -1);
}
// check 'view event info' permission
//@todo - per CRM-14626 we have resolved that 'view event info' means 'view ALL event info'
// and passing in the specific permission here will short-circuit the evaluation of permission to
// see specific events (doesn't seem relevant to this call
// however, since this function is accessed only by a convoluted call from a joomla block function
// it seems safer not to touch here. Suggestion is that CRM_Core_Permission::check(array or relevant permissions) would
// be clearer & safer here
$permissions = CRM_Core_Permission::event(CRM_Core_Permission::VIEW);
// check if we're in shopping cart mode for events
$enable_cart = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::EVENT_PREFERENCES_NAME, 'enable_cart');
if ($enable_cart) {
}
while ($dao->fetch()) {
if (!empty($permissions) && in_array($dao->event_id, $permissions)) {
$info = array();
$info['uid'] = "CiviCRM_EventID_{$dao->event_id}_" . md5($config->userFrameworkBaseURL) . $url;
$info['title'] = $dao->title;
$info['event_id'] = $dao->event_id;
$info['summary'] = $dao->summary;
$info['description'] = $dao->description;
$info['start_date'] = $dao->start;
$info['end_date'] = $dao->end;
$info['contact_email'] = $dao->email;
$info['event_type'] = $dao->event_type;
$info['is_show_location'] = $dao->is_show_location;
$info['is_online_registration'] = $dao->is_online_registration;
$info['registration_link_text'] = $dao->registration_link_text;
$info['registration_start_date'] = $dao->registration_start_date;
$info['registration_end_date'] = $dao->registration_end_date;
$address = '';
$addrFields = array('address_name' => $dao->address_name, 'street_address' => $dao->street_address, 'supplemental_address_1' => $dao->supplemental_address_1, 'supplemental_address_2' => $dao->supplemental_address_2, 'city' => $dao->city, 'state_province' => $dao->state, 'postal_code' => $dao->postal_code, 'postal_code_suffix' => $dao->postal_code_suffix, 'country' => $dao->country, 'county' => NULL);
CRM_Utils_String::append($address, ', ', CRM_Utils_Address::format($addrFields));
$info['location'] = $address;
//.........这里部分代码省略.........
示例5: int
function upgrade_3_3_beta1($rev)
{
$upgrade = new CRM_Upgrade_Form();
$upgrade->processSQL($rev);
// CRM-6902
// Add column price_field_value_id in civicrm_line_item.
// Do not drop option_group_id column now since we need it to
// update line items.
$updateLineItem1 = "ALTER TABLE civicrm_line_item ADD COLUMN price_field_value_id int(10) unsigned default NULL;";
CRM_Core_DAO::executeQuery($updateLineItem1);
$priceFieldDAO = new CRM_Price_DAO_Field();
$priceFieldDAO->find();
$ids = array();
while ($priceFieldDAO->fetch()) {
$opGroupDAO = new CRM_Core_DAO_OptionGroup();
$opGroupDAO->name = 'civicrm_price_field.amount.' . $priceFieldDAO->id;
if (!$opGroupDAO->find(TRUE)) {
$opGroupDAO->free();
continue;
}
$opValueDAO = new CRM_Core_DAO_OptionValue();
$opValueDAO->option_group_id = $opGroupDAO->id;
$opValueDAO->find();
while ($opValueDAO->fetch()) {
// FIX ME: not migrating description(?), there will
// be a field description for each option.
$fieldValue = array('price_field_id' => $priceFieldDAO->id, 'label' => $opValueDAO->label, 'name' => CRM_Utils_String::munge($opValueDAO->label, '_', 64), 'amount' => $opValueDAO->name, 'weight' => $opValueDAO->weight, 'is_default' => $opValueDAO->is_default, 'is_active' => $opValueDAO->is_active);
if ($priceFieldDAO->count) {
// Migrate Participant Counts on option level.
// count of each option will be the same
// as earlier field count.
$fieldValue['count'] = $priceFieldDAO->count;
}
$fieldValueDAO = CRM_Price_BAO_FieldValue::add($fieldValue, $ids);
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
$lineItemDAO->unit_price = $opValueDAO->name;
$labelFound = $priceFound = FALSE;
// check with label and amount
if (!$lineItemDAO->find(TRUE)) {
$lineItemDAO->free();
$lineItemDAO = new CRM_Price_DAO_LineItem();
$lineItemDAO->option_group_id = $opGroupDAO->id;
$lineItemDAO->label = $opValueDAO->label;
// check with label only
if ($lineItemDAO->find(TRUE)) {
$labelFound = TRUE;
}
} else {
$labelFound = TRUE;
$priceFound = TRUE;
}
$lineItemDAO->free();
// update civicrm_line_item for price_field_value_id.
// Used query to avoid line by line update.
if ($labelFound || $priceFound) {
$lineItemParams = array(1 => array($fieldValueDAO->id, 'Integer'), 2 => array($opValueDAO->label, 'String'));
$updateLineItems = "UPDATE civicrm_line_item SET price_field_value_id = %1 WHERE label = %2";
if ($priceFound) {
$lineItemParams[3] = array($opValueDAO->name, 'Float');
$updateLineItems .= " AND unit_price = %3";
}
CRM_Core_DAO::executeQuery($updateLineItems, $lineItemParams);
}
}
$opGroupDAO->delete();
$opValueDAO->free();
$opGroupDAO->free();
}
$priceFieldDAO->free();
// Now drop option_group_id column from civicrm_line_item
$updateLineItem2 = "ALTER TABLE civicrm_line_item DROP option_group_id,\n ADD CONSTRAINT `FK_civicrm_price_field_value_id` FOREIGN KEY (price_field_value_id) REFERENCES civicrm_price_field_value(id) ON DELETE SET NULL;";
CRM_Core_DAO::executeQuery($updateLineItem2, array(), TRUE, NULL, FALSE, FALSE);
$updatePriceField = "ALTER TABLE civicrm_price_field DROP count";
CRM_Core_DAO::executeQuery($updatePriceField, array(), TRUE, NULL, FALSE, FALSE);
// as the table 'civicrm_price_field' is localised and column 'count' is dropped
// after the views are rebuild, we need to rebuild views to avoid invalid refrence of table.
if ($upgrade->multilingual) {
CRM_Core_I18n_Schema::rebuildMultilingualSchema($upgrade->locales, $rev);
}
}
示例6: getTitle
/**
* Function to get title of the option group
*
* @param int $optionGroupId Id of the Option Group.
*
* @return String title
*
* @access public
* @static
*/
static function getTitle($optionGroupId)
{
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionGroupId;
$optionGroup->find(TRUE);
return $optionGroup->name;
}
示例7: getSetId
/**
* Find a price_set_id associatied with the given option value or field ID
* @param array $params (reference) an assoc array of name/value pairs
* array may contain either option id or
* price field id
*
* @return price set id on success, null otherwise
* @static
* @access public
*/
public static function getSetId(&$params)
{
$fid = null;
require_once 'CRM/Utils/Array.php';
if ($oid = CRM_Utils_Array::value('oid', $params)) {
require_once 'CRM/Core/DAO/OptionGroup.php';
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $oid, 'option_group_id');
if ($optionGroup->find(true)) {
$groupName = explode(".", $optionGroup->name);
$fid = $groupName[2];
}
} else {
$fid = CRM_Utils_Array::value('fid', $params);
}
if (isset($fid)) {
return CRM_Core_DAO::getFieldValue('CRM_Price_DAO_Field', $fid, 'price_set_id');
}
return null;
}
示例8: getDataType
/**
* Get DataType for a specified option Group
*
* @param int $optionGroupId
* Id of the Option Group.
*
* @return string|null
* Data Type
*/
public static function getDataType($optionGroupId)
{
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionGroupId;
$optionGroup->find(TRUE);
return $optionGroup->data_type;
}
示例9: updateRecords
/**
* updates contacts affected by the option value passed.
*
* @param Integer $optionValueId the option value id.
* @param int $action the action describing whether prefix/suffix was UPDATED or DELETED
*
* @return void
*/
static function updateRecords(&$optionValueId, $action)
{
//finding group name
$optionValue = new CRM_Core_DAO_OptionValue();
$optionValue->id = $optionValueId;
$optionValue->find(TRUE);
$optionGroup = new CRM_Core_DAO_OptionGroup();
$optionGroup->id = $optionValue->option_group_id;
$optionGroup->find(TRUE);
// group name
$gName = $optionGroup->name;
// value
$value = $optionValue->value;
// get the proper group name & affected field name
$individuals = array('gender' => 'gender_id', 'individual_prefix' => 'prefix_id', 'individual_suffix' => 'suffix_id');
$contributions = array('payment_instrument' => 'payment_instrument_id');
$activities = array('activity_type' => 'activity_type_id');
$participant = array('participant_role' => 'role_id');
$eventType = array('event_type' => 'event_type_id');
$aclRole = array('acl_role' => 'acl_role_id');
$all = array_merge($individuals, $contributions, $activities, $participant, $eventType, $aclRole);
$fieldName = '';
foreach ($all as $name => $id) {
if ($gName == $name) {
$fieldName = $id;
}
}
if ($fieldName == '') {
return TRUE;
}
if (array_key_exists($gName, $individuals)) {
$contactDAO = new CRM_Contact_DAO_Contact();
$contactDAO->{$fieldName} = $value;
$contactDAO->find();
while ($contactDAO->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contact = new CRM_Contact_DAO_Contact();
$contact->id = $contactDAO->id;
$contact->find(TRUE);
// make sure dates doesn't get reset
$contact->birth_date = CRM_Utils_Date::isoToMysql($contact->birth_date);
$contact->deceased_date = CRM_Utils_Date::isoToMysql($contact->deceased_date);
$contact->{$fieldName} = 'NULL';
$contact->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $contributions)) {
$contribution = new CRM_Contribute_DAO_Contribution();
$contribution->{$fieldName} = $value;
$contribution->find();
while ($contribution->fetch()) {
if ($action == CRM_Core_Action::DELETE) {
$contribution->{$fieldName} = 'NULL';
$contribution->save();
}
}
return TRUE;
}
if (array_key_exists($gName, $activities)) {
$activity = new CRM_Activity_DAO_Activity();
$activity->{$fieldName} = $value;
$activity->find();
while ($activity->fetch()) {
$activity->delete();
}
return TRUE;
}
//delete participant role, type and event type option value
if (array_key_exists($gName, $participant)) {
$participantValue = new CRM_Event_DAO_Participant();
$participantValue->{$fieldName} = $value;
if ($participantValue->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete event type option value
if (array_key_exists($gName, $eventType)) {
$event = new CRM_Event_DAO_Event();
$event->{$fieldName} = $value;
if ($event->find(TRUE)) {
return FALSE;
}
return TRUE;
}
//delete acl_role option value
if (array_key_exists($gName, $aclRole)) {
$entityRole = new CRM_ACL_DAO_EntityRole();
$entityRole->{$fieldName} = $value;
$aclDAO = new CRM_ACL_DAO_ACL();
//.........这里部分代码省略.........