本文整理汇总了PHP中CRM_Utils_Weight类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Weight类的具体用法?PHP CRM_Utils_Weight怎么用?PHP CRM_Utils_Weight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Weight类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createEntry
public function createEntry($id, $key)
{
$e = self::$_extensions;
$ids = array();
$groupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', self::OPTION_GROUP_NAME, 'id', 'name');
$params = array('option_group_id' => $groupId, 'weight' => CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $groupId)), 'label' => $e['per_id'][$id]['label'], 'name' => $e['per_id'][$id]['label'], 'value' => $key, 'grouping' => $e['per_id'][$id]['type'], 'is_active' => 1);
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例2: install
public function install()
{
if (array_key_exists($this->ext->key, $this->customSearches)) {
CRM_Core_Error::fatal('This custom search is already registered.');
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'name' => $this->ext->key, 'value' => max($this->customSearches) + 1, 'label' => $this->ext->key, 'is_active' => 1);
$ids = array();
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例3: onPreInstall
/**
* @param CRM_Extension_Info $info
*
* @return bool
* @throws Exception
*/
public function onPreInstall(CRM_Extension_Info $info)
{
$customSearchesByName = $this->getCustomSearchesByName();
if (array_key_exists($info->key, $customSearchesByName)) {
CRM_Core_Error::fatal('This custom search is already registered.');
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$params = array('option_group_id' => $this->groupId, 'weight' => $weight, 'description' => $info->label . ' (' . $info->key . ')', 'name' => $info->key, 'value' => max($customSearchesByName) + 1, 'label' => $info->key, 'is_active' => 1);
$ids = array();
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
return $optionValue ? TRUE : FALSE;
}
示例4: deleteParticipantStatusType
/**
* @param int $id
*
* @return bool
*/
public static function deleteParticipantStatusType($id)
{
// return early if there are participants with this status
$participant = new CRM_Event_DAO_Participant();
$participant->status_id = $id;
if ($participant->find()) {
return FALSE;
}
CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
$dao = new CRM_Event_DAO_ParticipantStatusType();
$dao->id = $id;
$dao->find(TRUE);
$dao->delete();
return TRUE;
}
示例5: deleteParticipantStatusType
static function deleteParticipantStatusType($id)
{
// return early if there are participants with this status
require_once 'CRM/Event/DAO/Participant.php';
$participant = new CRM_Event_DAO_Participant();
$participant->status_id = $id;
if ($participant->find()) {
return false;
}
require_once 'CRM/Utils/Weight.php';
CRM_Utils_Weight::delWeight('CRM_Event_DAO_ParticipantStatusType', $id);
$dao = new CRM_Event_DAO_ParticipantStatusType();
$dao->id = $id;
$dao->find(true);
$dao->delete();
return true;
}
示例6: install
public function install()
{
if (array_key_exists($this->ext->key, $this->customReports)) {
CRM_Core_Error::fatal('This report is already registered.');
}
if ($this->ext->typeInfo['component'] === 'Contact') {
$compId = 'null';
} else {
$comp = CRM_Core_Component::get($this->ext->typeInfo['component']);
$compId = $comp->componentID;
}
if (empty($compId)) {
CRM_Core_Error::fatal("Component for which you're trying to install the extension (" . $this->ext->typeInfo['component'] . ") is currently disabled.");
}
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $this->groupId));
$ids = array();
$params = array('label' => $this->ext->label . ' (' . $this->ext->key . ')', 'value' => $this->ext->typeInfo['reportUrl'], 'name' => $this->ext->key, 'weight' => $weight, 'description' => $this->ext->label . ' (' . $this->ext->key . ')', 'component_id' => $compId, 'option_group_id' => $this->groupId, 'is_active' => 1);
$optionValue = CRM_Core_BAO_OptionValue::add($params, $ids);
}
示例7: civicrm_api3_option_value_create
/**
* Add a OptionValue. OptionValues are used to classify CRM entities (including Contacts, Groups and Actions).
*
* Allowed @params array keys are:
*
* {@example OptionValueCreate.php}
*
* @return array of newly created option_value property values.
* {@getfields OptionValue_create}
* @access public
*/
function civicrm_api3_option_value_create($params)
{
$weight = 0;
if (!array_key_exists('label', $params) && array_key_exists('name', $params)) {
// no idea why that's a "mandatory" field
$params['label'] = $params['name'];
}
if (!CRM_Utils_Array::value('value', $params) && array_key_exists('option_group_id', $params)) {
require_once 'CRM/Utils/Weight.php';
$fieldValues = array('option_group_id' => $params['option_group_id']);
// use the next available value
/* CONVERT(value, DECIMAL) is used to convert varchar
field 'value' to decimal->integer */
$params['value'] = (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues, 'CONVERT(value, DECIMAL)');
$weight = $params['value'];
}
if (!array_key_exists('weight', $params) && array_key_exists('value', $params)) {
// no idea why that's a "mandatory" field
$params['weight'] = $params['value'];
} elseif (array_key_exists('weight', $params) && $params['weight'] == 'next') {
// weight is numeric, so it's safe-ish to treat symbol 'next' as magical value
$params['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $params['option_group_id']));
}
if (array_key_exists('component', $params)) {
if (empty($params['component'])) {
$params['component_id'] = '';
} else {
$params['component_id'] = array_search($params['component'], CRM_Core_PseudoConstant::component());
}
unset($params['component']);
}
if (CRM_Utils_Array::value('id', $params)) {
$ids = array('optionValue' => $params['id']);
}
$optionValueBAO = CRM_Core_BAO_OptionValue::add($params, $ids);
civicrm_api('option_value', 'getfields', array('version' => 3, 'cache_clear' => 1));
$values = array();
_civicrm_api3_object_to_array($optionValueBAO, $values[$optionValueBAO->id]);
return civicrm_api3_create_success($values, $params);
}
示例8: create
/**
* Creates a new entry in the database.
*
* @param array $params (reference), array $ids
*
* @return object CRM_Price_DAO_FieldValue object
* @access public
* @static
*/
static function create(&$params, $ids)
{
if (!is_array($params) || empty($params)) {
return;
}
if ($id = CRM_Utils_Array::value('id', $ids)) {
if (isset($params['name'])) {
unset($params['name']);
}
$oldWeight = null;
if ($id) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Price_DAO_FieldValue', $id, 'weight', 'id');
}
$fieldValues = array('price_field_id' => CRM_Utils_Array::value('price_field_id', $params, 0));
$params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Price_DAO_FieldValue', $oldWeight, $params['weight'], $fieldValues);
} else {
if (!CRM_Utils_Array::value('name', $params)) {
$params['name'] = CRM_Utils_String::munge(CRM_Utils_Array::value('label', $params), '_', 64);
}
$params['weight'] = 1;
}
$params['is_active'] = CRM_Utils_Array::value('is_active', $params, 0);
return self::add($params, $ids);
}
示例9: browse
/**
* Browse all price fields.
*
* @param null
*
* @return void
* @access public
*/
function browse()
{
$customOption = array();
CRM_Price_BAO_PriceFieldValue::getValues($this->_fid, $customOption);
$config = CRM_Core_Config::singleton();
$financialType = CRM_Contribute_PseudoConstant::financialType();
foreach ($customOption as $id => $values) {
$action = array_sum(array_keys($this->actionLinks()));
if (CRM_Utils_Array::value('financial_type_id', $values)) {
$customOption[$id]['financial_type_id'] = $financialType[$values['financial_type_id']];
}
// update enable/disable links depending on price_field properties.
if ($this->_isSetReserved) {
$action -= CRM_Core_Action::UPDATE + CRM_Core_Action::DELETE + CRM_Core_Action::DISABLE + CRM_Core_Action::ENABLE;
} else {
if ($values['is_active']) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
}
if (CRM_Utils_Array::value('is_default', $customOption[$id])) {
$customOption[$id]['is_default'] = '<img src="' . $config->resourceBase . 'i/check.gif" />';
} else {
$customOption[$id]['is_default'] = '';
}
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('oid' => $id, 'fid' => $this->_fid, 'sid' => $this->_sid));
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/price/field/option', "action=browse&reset=1&fid={$this->_fid}&sid={$this->_sid}");
$filter = "price_field_id = {$this->_fid}";
CRM_Utils_Weight::addOrder($customOption, 'CRM_Price_DAO_PriceFieldValue', 'id', $returnURL, $filter);
$this->assign('customOption', $customOption);
$this->assign('sid', $this->_sid);
}
示例10: getDefaultWeight
/**
* Get next available value.
* We will take the highest numeric value (or 0 if no numeric values exist)
* and add one. The calling function is responsible for any
* more complex decision making
*
* @param array $params
*
* @return int
*/
public static function getDefaultWeight($params)
{
return (int) CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', array('option_group_id' => $params['option_group_id']));
}
示例11: upgrade
function upgrade($rev)
{
// fix CRM-5270: if civicrm_report_instance.description is localised,
// recreate it based on the first locale’s description_xx_YY contents
// and drop all the description_xx_YY columns
if (!CRM_Core_DAO::checkFieldExists('civicrm_report_instance', 'description')) {
require_once 'CRM/Core/DAO/Domain.php';
$domain = new CRM_Core_DAO_Domain();
$domain->find(true);
$locales = explode(CRM_Core_DAO::VALUE_SEPARATOR, $domain->locales);
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance ADD description VARCHAR(255)");
CRM_Core_DAO::executeQuery("UPDATE civicrm_report_instance SET description = description_{$locales[0]}");
CRM_Core_DAO::executeQuery("DROP TRIGGER civicrm_report_instance_before_insert");
foreach ($locales as $locale) {
CRM_Core_DAO::executeQuery("DROP VIEW civicrm_report_instance_{$locale}");
CRM_Core_DAO::executeQuery("ALTER TABLE civicrm_report_instance DROP description_{$locale}");
}
}
//We execute some part of php after sql and then again sql
//So using conditions for skipping some part of sql CRM-4575
$upgrade =& new CRM_Upgrade_Form();
//Run the SQL file (1)
$upgrade->processSQL($rev);
//replace with ; in report instance
$sql = "UPDATE civicrm_report_instance \n SET form_values = REPLACE(form_values,'#',';') ";
CRM_Core_DAO::executeQuery($sql, CRM_Core_DAO::$_nullArray);
//delete unnecessary activities
$bulkEmailID = CRM_Core_OptionGroup::getValue('activity_type', 'Bulk Email', 'name');
if ($bulkEmailID) {
$mailingActivityIds = array();
$query = " \n SELECT max( ca.id ) as aid, \n ca.source_record_id sid\n FROM civicrm_activity ca\n WHERE ca.activity_type_id = %1 \n GROUP BY ca.source_record_id";
$params = array(1 => array($bulkEmailID, 'Integer'));
$dao = CRM_Core_DAO::executeQuery($query, $params);
while ($dao->fetch()) {
$updateQuery = "\n UPDATE civicrm_activity_target cat, civicrm_activity ca \n SET cat.activity_id = {$dao->aid} \n WHERE ca.source_record_id IS NOT NULL AND\n ca.activity_type_id = %1 AND \n ca.id <> {$dao->aid} AND \n ca.source_record_id = {$dao->sid} AND \n ca.id = cat.activity_id";
$updateParams = array(1 => array($bulkEmailID, 'Integer'));
CRM_Core_DAO::executeQuery($updateQuery, $updateParams);
$deleteQuery = " \n DELETE ca.* \n FROM civicrm_activity ca \n WHERE ca.source_record_id IS NOT NULL AND \n ca.activity_type_id = %1 AND \n ca.id <> {$dao->aid} AND \n ca.source_record_id = {$dao->sid}";
$deleteParams = array(1 => array($bulkEmailID, 'Integer'));
CRM_Core_DAO::executeQuery($deleteQuery, $deleteParams);
}
}
//CRM-4453
//lets insert column in civicrm_aprticipant table
$query = "\n ALTER TABLE `civicrm_participant` \n ADD `fee_currency` VARCHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL COMMENT '3 character string, value derived from config setting.' AFTER `discount_id`";
CRM_Core_DAO::executeQuery($query);
//get currency from contribution table if exists/default
//insert currency when fee_amount != NULL or event is paid.
$query = "\n SELECT civicrm_participant.id \n FROM civicrm_participant\n LEFT JOIN civicrm_event \n ON ( civicrm_participant.event_id = civicrm_event.id )\n WHERE civicrm_participant.fee_amount IS NOT NULL OR \n civicrm_event.is_monetary = 1";
$participant = CRM_Core_DAO::executeQuery($query);
while ($participant->fetch()) {
$query = "\n SELECT civicrm_contribution.currency \n FROM civicrm_contribution, \n civicrm_participant_payment\n WHERE civicrm_contribution.id = civicrm_participant_payment.contribution_id AND \n civicrm_participant_payment.participant_id = {$participant->id}";
$currencyID = CRM_Core_DAO::singleValueQuery($query);
if (!$currencyID) {
$config =& CRM_Core_Config::singleton();
$currencyID = $config->defaultCurrency;
}
//finally update participant record.
CRM_Core_DAO::setFieldValue('CRM_Event_DAO_Participant', $participant->id, 'fee_currency', $currencyID);
}
//CRM-4575
//check whether {contact.name} is set in mailing labels
require_once 'CRM/Core/BAO/Preferences.php';
$mailingFormat = CRM_Core_BAO_Preferences::value('mailing_format');
$addNewAddressee = true;
if (strpos($mailingFormat, '{contact.contact_name}') === false) {
$addNewAddressee = false;
} else {
//else compare individual name format with default individual addressee.
$individualNameFormat = CRM_Core_BAO_Preferences::value('individual_name_format');
$defaultAddressee = CRM_Core_OptionGroup::values('addressee', false, false, false, " AND v.filter = 1 AND v.is_default = 1", 'label');
if (array_search($individualNameFormat, $defaultAddressee) !== false) {
$addNewAddressee = false;
}
}
require_once 'CRM/Utils/System.php';
$docURL = CRM_Utils_System::docURL2('Update Greetings and Address Data for Contacts', false, null, null, 'color: white; text-decoration: underline;');
if ($addNewAddressee) {
//otherwise insert new token in addressee and set as a default
$addresseeGroupId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', 'addressee', 'id', 'name');
$optionValueParams = array('label' => $individualNameFormat, 'is_active' => 1, 'contactOptions' => 1, 'filter' => 1, 'is_default' => 1, 'reset_default_for' => array('filter' => "0, 1"));
$action = CRM_Core_Action::ADD;
$addresseeGroupParams = array('name' => 'addressee');
$fieldValues = array('option_group_id' => $addresseeGroupId);
$weight = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
$optionValueParams['weight'] = $weight;
$addresseeToken = CRM_Core_OptionValue::addOptionValue($optionValueParams, $addresseeGroupParams, $action, $optionId = null);
$afterUpgradeMessage = ts("During this upgrade, Postal Addressee values have been stored for each contact record using the system default format - %2.You will need to run the included command-line script to update your Individual contact records to use the \"Individual Name Format\" previously specified for your site %1", array(1 => $docURL, 2 => array_pop($defaultAddressee)));
} else {
$afterUpgradeMessage = ts("Email Greeting, Postal Greeting and Postal Addressee values have been stored for all contact records based on the system default formats. If you want to use a different format for any of these contact fields - you can run the provided command line script to update contacts to a different format %1 ", array(1 => $docURL));
}
//replace contact.contact_name with contact.addressee in civicrm_preference.mailing_format
$updateQuery = "\n UPDATE civicrm_preferences \n SET `mailing_format` = \n replace(`mailing_format`, '{contact.contact_name}','{contact.addressee}')";
CRM_Core_DAO::executeQuery($updateQuery);
//drop column individual_name_format
$alterQuery = "\n ALTER TABLE `civicrm_preferences`\n DROP `individual_name_format`";
CRM_Core_DAO::executeQuery($alterQuery);
//set status message for default greetings
$template =& CRM_Core_Smarty::singleton();
$template->assign('afterUpgradeMessage', $afterUpgradeMessage);
//.........这里部分代码省略.........
示例12: browse
//.........这里部分代码省略.........
*/
function browse($action = NULL)
{
// get all custom groups sorted by weight
$customGroup = array();
$dao = new CRM_Core_DAO_CustomGroup();
$dao->orderBy('weight, title');
$dao->find();
while ($dao->fetch()) {
$customGroup[$dao->id] = array();
CRM_Core_DAO::storeValues($dao, $customGroup[$dao->id]);
// form all action links
$action = array_sum(array_keys($this->actionLinks()));
// update enable/disable links depending on custom_group properties.
if ($dao->is_active) {
$action -= CRM_Core_Action::ENABLE;
} else {
$action -= CRM_Core_Action::DISABLE;
}
$customGroup[$dao->id]['order'] = $customGroup[$dao->id]['weight'];
$customGroup[$dao->id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action, array('id' => $dao->id));
}
$customGroupExtends = CRM_Core_SelectValues::customGroupExtends();
foreach ($customGroup as $key => $array) {
CRM_Core_DAO_CustomGroup::addDisplayEnums($customGroup[$key]);
$customGroup[$key]['extends_display'] = $customGroupExtends[$customGroup[$key]['extends']];
}
//fix for Displaying subTypes
$subTypes = array();
$subTypes['Activity'] = CRM_Core_PseudoConstant::activityType(FALSE, TRUE, FALSE, 'label', TRUE);
$subTypes['Contribution'] = CRM_Contribute_PseudoConstant::contributionType();
$subTypes['Membership'] = CRM_Member_BAO_MembershipType::getMembershipTypes(FALSE);
$subTypes['Event'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Grant'] = CRM_Core_OptionGroup::values('grant_type');
$subTypes['Campaign'] = CRM_Campaign_PseudoConstant::campaignType();
$subTypes['Participant'] = array();
$subTypes['ParticipantRole'] = CRM_Core_OptionGroup::values('participant_role');
$subTypes['ParticipantEventName'] = CRM_Event_PseudoConstant::event();
$subTypes['ParticipantEventType'] = CRM_Core_OptionGroup::values('event_type');
$subTypes['Individual'] = CRM_Contact_BAO_ContactType::subTypePairs('Individual', FALSE, NULL);
$subTypes['Household'] = CRM_Contact_BAO_ContactType::subTypePairs('Household', FALSE, NULL);
$subTypes['Organization'] = CRM_Contact_BAO_ContactType::subTypePairs('Organization', FALSE, NULL);
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
//adding subtype specific relationships CRM-5256
$relSubType = CRM_Contact_BAO_ContactType::subTypeInfo();
foreach ($relSubType as $subType => $val) {
$subTypeRelationshipTypes = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, NULL, NULL, $val['parent'], FALSE, 'label', TRUE, $subType);
$allRelationshipType = array_merge($allRelationshipType, $subTypeRelationshipTypes);
}
$subTypes['Relationship'] = $allRelationshipType;
$cSubTypes = CRM_Core_Component::contactSubTypes();
$contactSubTypes = array();
foreach ($cSubTypes as $key => $value) {
$contactSubTypes[$key] = $key;
}
$subTypes['Contact'] = $contactSubTypes;
CRM_Core_BAO_CustomGroup::getExtendedObjectTypes($subTypes);
foreach ($customGroup as $key => $values) {
$subValue = CRM_Utils_Array::value('extends_entity_column_value', $customGroup[$key]);
$subName = CRM_Utils_Array::value('extends_entity_column_id', $customGroup[$key]);
$type = CRM_Utils_Array::value('extends', $customGroup[$key]);
if ($subValue) {
$subValue = explode(CRM_Core_DAO::VALUE_SEPARATOR, substr($subValue, 1, -1));
$colValue = NULL;
foreach ($subValue as $sub) {
if ($sub) {
if ($type == 'Participant') {
if ($subName == 1) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantRole'][$sub] : $subTypes['ParticipantRole'][$sub];
} elseif ($subName == 2) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventName'][$sub] : $subTypes['ParticipantEventName'][$sub];
} elseif ($subName == 3) {
$colValue = $colValue ? $colValue . ', ' . $subTypes['ParticipantEventType'][$sub] : $subTypes['ParticipantEventType'][$sub];
}
} elseif ($type == 'Relationship') {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_a_b'] : $subTypes[$type][$sub . '_a_b'];
if (isset($subTypes[$type][$sub . '_b_a'])) {
$colValue = $colValue ? $colValue . ', ' . $subTypes[$type][$sub . '_b_a'] : $subTypes[$type][$sub . '_b_a'];
}
} else {
$colValue = $colValue ? $colValue . (isset($subTypes[$type][$sub]) ? ', ' . $subTypes[$type][$sub] : '') : (isset($subTypes[$type][$sub]) ? $subTypes[$type][$sub] : '');
}
}
}
$customGroup[$key]["extends_entity_column_value"] = $colValue;
} else {
if (is_array(CRM_Utils_Array::value($type, $subTypes))) {
$customGroup[$key]["extends_entity_column_value"] = ts("Any");
}
}
}
$returnURL = CRM_Utils_System::url('civicrm/admin/custom/group', "reset=1&action=browse");
CRM_Utils_Weight::addOrder($customGroup, 'CRM_Core_DAO_CustomGroup', 'id', $returnURL);
$this->assign('rows', $customGroup);
}
示例13: browse
/**
* Browse all options
*
*
* @return void
* @access public
* @static
*/
function browse()
{
$campaingCompId = CRM_Core_Component::getComponentID('CiviCampaign');
$groupParams = array('name' => $this->_gName);
$optionValues = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'component_id,weight');
foreach ($optionValues as $key => $optionValue) {
if (CRM_Utils_Array::value('component_id', $optionValue) != $campaingCompId) {
unset($optionValues[$key]);
}
}
$returnURL = CRM_Utils_System::url("civicrm/admin/campaign/surveyType", "reset=1");
$filter = "option_group_id = " . $this->_gid;
CRM_Utils_Weight::addOrder($optionValues, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('rows', $optionValues);
}
示例14: del
/**
* Delete a PDF Page Format.
*
* @param int $id
* ID of the PDF Page Format to be deleted.
*
*/
public static function del($id)
{
if ($id) {
$dao = new CRM_Core_DAO_OptionValue();
$dao->id = $id;
if ($dao->find(TRUE)) {
if ($dao->option_group_id == self::_getGid()) {
$filter = array('option_group_id' => self::_getGid());
CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $id, $filter);
$dao->delete();
return;
}
}
}
CRM_Core_Error::fatal(ts('Invalid value passed to delete function.'));
}
示例15: browse
/**
* Browse all options.
*/
public function browse()
{
$groupParams = array('name' => self::$_gName);
$optionValue = CRM_Core_OptionValue::getRows($groupParams, $this->links(), 'weight');
$gName = self::$_gName;
$returnURL = CRM_Utils_System::url("civicrm/admin/report/options/{$gName}", "reset=1");
$filter = "option_group_id = " . self::$_gId;
$session = new CRM_Core_Session();
$session->replaceUserContext($returnURL);
CRM_Utils_Weight::addOrder($optionValue, 'CRM_Core_DAO_OptionValue', 'id', $returnURL, $filter);
$this->assign('rows', $optionValue);
}