本文整理汇总了PHP中CRM_Utils_Weight类的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_Weight类的具体用法?PHP CRM_Utils_Weight怎么用?PHP CRM_Utils_Weight使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CRM_Utils_Weight类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:8,代码来源:ExtensionType.php
示例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);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:10,代码来源:Search.php
示例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;
}
开发者ID:nielosz,项目名称:civicrm-core,代码行数:18,代码来源:Search.php
示例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;
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:20,代码来源:ParticipantStatusType.php
示例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;
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:17,代码来源:ParticipantStatusType.php
示例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);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:19,代码来源:Report.php
示例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);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:51,代码来源:OptionValue.php
示例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);
}
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:33,代码来源:FieldValue.php
示例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);
}
开发者ID:hguru,项目名称:224Civi,代码行数:44,代码来源:Option.php
示例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']));
}
开发者ID:kidaa30,项目名称:yes,代码行数:14,代码来源:OptionValue.php
示例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);
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:ThreeZero.php
示例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);
}
开发者ID:peteainsworth,项目名称:civicrm-4.2.9-drupal,代码行数:101,代码来源:Group.php
示例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);
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:23,代码来源:SurveyType.php
示例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.'));
}
开发者ID:kidaa30,项目名称:yes,代码行数:23,代码来源:PdfFormat.php
示例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);
}
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:15,代码来源:Options.php
示例16: postProcess
/**
* Process the form.
*
* @return void
*/
public function postProcess()
{
// get the submitted form values.
$params = $this->controller->exportValues($this->_name);
$urlParams = 'civicrm/admin/contribute/premium';
if ($this->_action & CRM_Core_Action::PREVIEW) {
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
$single = $session->get('singleForm');
CRM_Utils_System::redirect($url);
return;
}
if ($this->_action & CRM_Core_Action::DELETE) {
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->id = $this->_pid;
$dao->delete();
CRM_Core_Session::setStatus(ts('Selected Premium Product has been removed from this Contribution Page.'), ts('Saved'), 'success');
CRM_Utils_System::redirect($url);
} else {
$session = CRM_Core_Session::singleton();
$url = CRM_Utils_System::url($urlParams, 'reset=1&action=update&id=' . $this->_id);
if ($this->_pid) {
$params['id'] = $this->_pid;
}
$dao = new CRM_Contribute_DAO_Premium();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $this->_id;
$dao->find(TRUE);
$premiumID = $dao->id;
$params['premiums_id'] = $premiumID;
$oldWeight = NULL;
if ($this->_pid) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_PremiumsProduct', $this->_pid, 'weight', 'id');
}
// updateOtherWeights needs to filter on premiums_id
$filter = array('premiums_id' => $params['premiums_id']);
$params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Contribute_DAO_PremiumsProduct', $oldWeight, $params['weight'], $filter);
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->copyValues($params);
$dao->save();
CRM_Utils_System::redirect($url);
}
}
开发者ID:kidaa30,项目名称:yes,代码行数:50,代码来源:AddProduct.php
示例17: postProcess
/**
* Process the form when submitted
*
* @return void
* @access public
*/
public function postProcess()
{
$group = new CRM_Core_DAO_CustomGroup();
$group->id = $this->_id;
$group->find(TRUE);
$wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_CustomGroup', $this->_id);
CRM_Core_BAO_CustomGroup::deleteGroup($group);
CRM_Core_Session::setStatus(ts("The Group '%1' has been deleted.", array(1 => $group->title)), '', 'success');
}
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:15,代码来源:DeleteGroup.php
示例18: postProcess
/**
* Process the form
*
* @param null
*
* @return void
* @access public
*/
public function postProcess()
{
// store the submitted values in an array
$params = $this->controller->exportValues('Option');
// set values for custom field properties and save
require_once 'CRM/Core/DAO/OptionValue.php';
require_once 'CRM/Utils/String.php';
$customOption =& new CRM_Core_DAO_OptionValue();
$customOption->label = $params['label'];
$customOption->name = CRM_Utils_String::titleToVar($params['label']);
$customOption->weight = $params['weight'];
$customOption->value = $params['value'];
$customOption->is_active = CRM_Utils_Array::value('is_active', $params, false);
if ($this->_action == CRM_Core_Action::DELETE) {
$fieldValues = array('option_group_id' => $this->_optionGroupID);
$wt = CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
CRM_Core_BAO_CustomOption::del($this->_id);
CRM_Core_Session::setStatus(ts('Your multiple choice option has been deleted', array(1 => $customOption->label)));
return;
}
if ($this->_action & CRM_Core_Action::UPDATE) {
$customOption->id = $this->_id;
CRM_Core_BAO_CustomOption::updateCustomValues($params);
}
if ($this->_id) {
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id');
}
$fieldValues = array('option_group_id' => $this->_optionGroupID);
$customOption->weight = CRM_Utils_Weight::updateOtherWeights('CRM_Core_DAO_OptionValue', $oldWeight, $params['weight'], $fieldValues);
$customOption->option_group_id = $this->_optionGroupID;
$customField =& new CRM_Core_DAO_CustomField();
$customField->id = $this->_fid;
if ($customField->find(true) && ($customField->html_type == 'CheckBox' || $customField->html_type == 'AdvMulti-Select' || $customField->html_type == 'Multi-Select')) {
$defVal = explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, substr($customField->default_value, 1, -1));
if (CRM_Utils_Array::value('default_value', $params)) {
if (!in_array($customOption->value, $defVal)) {
if (empty($defVal[0])) {
$defVal = array($customOption->value);
} else {
$defVal[] = $customOption->value;
}
$customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $defVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
$customField->save();
}
} else {
if (in_array($customOption->value, $defVal)) {
$tempVal = array();
foreach ($defVal as $v) {
if ($v != $customOption->value) {
$tempVal[] = $v;
}
}
$customField->default_value = CRM_Core_BAO_CustomOption::VALUE_SEPERATOR . implode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $tempVal) . CRM_Core_BAO_CustomOption::VALUE_SEPERATOR;
$customField->save();
}
}
} else {
switch ($customField->data_type) {
case 'Money':
require_once 'CRM/Utils/Rule.php';
$customOption->value = CRM_Utils_Rule::cleanMoney($customOption->value);
break;
case 'Int':
$customOption->value = intval($customOption->value);
break;
case 'Float':
$customOption->value = floatval($customOption->value);
break;
}
if (CRM_Utils_Array::value('default_value', $params)) {
$customField->default_value = $customOption->value;
$customField->save();
} else {
if ($customField->find(true) && $customField->default_value == $customOption->value) {
// this is the case where this option is the current default value and we have been reset
$customField->default_value = 'null';
$customField->save();
}
}
}
$customOption->save();
CRM_Core_Session::setStatus(ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label)));
$buttonName = $this->controller->getButtonName();
$session =& CRM_Core_Session::singleton();
if ($buttonName == $this->getButtonName('next', 'new')) {
CRM_Core_Session::setStatus(ts(' You can add another option.'));
$session->replaceUserContext(CRM_Utils_System::url('civicrm/admin/custom/group/field/option', 'reset=1&action=add&fid=' . $this->_fid . '&gid=' . $this->_gid));
}
}
开发者ID:bhirsch,项目名称:voipdev,代码行数:97,代码来源:Option.php
示例19: browse
/**
* Browse function.
*/
public function browse()
{
// get all custom groups sorted by weight
$premiums = array();
$pageID = CRM_Utils_Request::retrieve('id', 'Positive', $this, FALSE, 0);
$dao = new CRM_Contribute_DAO_Premium();
$dao->entity_table = 'civicrm_contribution_page';
$dao->entity_id = $pageID;
$dao->find(TRUE);
$premiumID = $dao->id;
$this->assign('products', FALSE);
$this->assign('id', $pageID);
if (!$premiumID) {
return;
}
$dao = new CRM_Contribute_DAO_PremiumsProduct();
$dao->premiums_id = $premiumID;
$dao->orderBy('weight');
$dao->find();
while ($dao->fetch()) {
$productDAO = new CRM_Contribute_DAO_Product();
$productDAO->id = $dao->product_id;
$productDAO->is_active = 1;
if ($productDAO->find(TRUE)) {
$premiums[$productDAO->id] = array();
$premiums[$productDAO->id]['weight'] = $dao->weight;
CRM_Core_DAO::storeValues($productDAO, $premiums[$productDAO->id]);
$action = array_sum(array_keys($this->links()));
$premiums[$dao->product_id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $pageID, 'pid' => $dao->id), ts('more'), FALSE, 'premium.contributionpage.row', 'Premium', $dao->id);
//Financial Type
if (!empty($dao->financial_type_id)) {
$premiums[$productDAO->id]['financial_type_id'] = CRM_Core_DAO::getFieldValue('CRM_Financial_DAO_FinancialType', $dao->financial_type_id, 'name');
}
}
}
if (count(CRM_Contribute_PseudoConstant::products($pageID)) == 0) {
$this->assign('products', FALSE);
} else {
$this->assign('products', TRUE);
}
// Add order changing widget to selector
$returnURL = CRM_Utils_System::url('civicrm/admin/contribute/premium', "reset=1&action=update&id={$pageID}");
$filter = "premiums_id = {$premiumID}";
CRM_Utils_Weight::addOrder($premiums, 'CRM_Contribute_DAO_PremiumsProduct', 'id', $returnURL, $filter);
$this->assign('rows', $premiums);
}
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:49,代码来源:Premium.php |
请发表评论