当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Core_PseudoConstant::visibility方法代码示例

本文整理汇总了PHP中CRM_Core_PseudoConstant::visibility方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_PseudoConstant::visibility方法的具体用法?PHP CRM_Core_PseudoConstant::visibility怎么用?PHP CRM_Core_PseudoConstant::visibility使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Core_PseudoConstant的用法示例。


在下文中一共展示了CRM_Core_PseudoConstant::visibility方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: browse

 function browse()
 {
     CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'js/crm.livePage.js');
     $statusTypes = array();
     $dao = new CRM_Event_DAO_ParticipantStatusType();
     $dao->orderBy('weight');
     $dao->find();
     $visibilities = CRM_Core_PseudoConstant::visibility();
     // these statuses are reserved, but disabled by default - so should be disablable after being enabled
     $disablable = array('On waitlist', 'Awaiting approval', 'Pending from waitlist', 'Pending from approval', 'Rejected');
     while ($dao->fetch()) {
         CRM_Core_DAO::storeValues($dao, $statusTypes[$dao->id]);
         $action = array_sum(array_keys($this->links()));
         if ($dao->is_reserved) {
             $action -= CRM_Core_Action::DELETE;
             if (!in_array($dao->name, $disablable)) {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $action -= $dao->is_active ? CRM_Core_Action::ENABLE : CRM_Core_Action::DISABLE;
         $statusTypes[$dao->id]['action'] = CRM_Core_Action::formLink(self::links(), $action, array('id' => $dao->id), ts('more'), FALSE, 'participantStatusType.manage.action', 'ParticipantStatusType', $dao->id);
         $statusTypes[$dao->id]['visibility'] = $visibilities[$dao->visibility_id];
     }
     $this->assign('rows', $statusTypes);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:25,代码来源:ParticipantStatus.php

示例2: buildQuickForm

 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_ParticipantStatusType');
     $this->add('text', 'name', ts('Name'), NULL, TRUE);
     $this->add('text', 'label', ts('Label'), $attributes['label'], TRUE);
     $classes = array('Positive' => ts('Positive'), 'Pending' => ts('Pending'), 'Waiting' => ts('Waiting'), 'Negative' => ts('Negative'));
     $this->add('select', 'class', ts('Class'), $classes, TRUE);
     $this->add('checkbox', 'is_active', ts('Active?'));
     $this->add('checkbox', 'is_counted', ts('Counted?'));
     $this->add('text', 'weight', ts('Weight'), $attributes['weight'], TRUE);
     $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility(), TRUE);
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:17,代码来源:ParticipantStatus.php

示例3: buildQuickForm

 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Event_DAO_ParticipantStatusType');
     $this->add('text', 'name', ts('Name'), $attributes['name'], true);
     $this->add('text', 'label', ts('Label'), $attributes['label'], true);
     $classes = array();
     foreach (array('Positive', 'Pending', 'Waiting', 'Negative') as $class) {
         $classes[$class] = CRM_Event_DAO_ParticipantStatusType::tsEnum('class', $class);
     }
     $this->add('select', 'class', ts('Class'), $classes, true);
     $this->add('checkbox', 'is_active', ts('Active?'));
     $this->add('checkbox', 'is_counted', ts('Counted?'));
     $this->add('text', 'weight', ts('Weight'), $attributes['weight'], true);
     require_once 'CRM/Core/PseudoConstant.php';
     $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility(), true);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:21,代码来源:ParticipantStatus.php

示例4: buildQuickForm


//.........这里部分代码省略.........
     if (in_array($eventComponentId, $this->_extendComponentId)) {
         $this->add('text', 'count', ts('Participant Count'), $attributes['count']);
         $this->addRule('count', ts('Participant Count should be a positive number'), 'positiveInteger');
         $this->add('text', 'max_value', ts('Max Participants'), $attributes['max_value']);
         $this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
         $this->assign('useForEvent', TRUE);
     } else {
         if (in_array($memberComponentId, $this->_extendComponentId)) {
             $this->_useForMember = 1;
             $this->assign('useForMember', $this->_useForMember);
         }
         $this->assign('useForEvent', FALSE);
     }
     $sel = $this->add('select', 'html_type', ts('Input Field Type'), $htmlTypes, TRUE, $javascript);
     // price (for text inputs)
     $this->add('text', 'price', ts('Price'));
     $this->registerRule('price', 'callback', 'money', 'CRM_Utils_Rule');
     $this->addRule('price', ts('must be a monetary value'), 'money');
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->freeze('html_type');
     }
     // form fields of Custom Option rows
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         //the show hide blocks
         $showBlocks = 'optionField_' . $i;
         if ($i > 2) {
             $_showHide->addHide($showBlocks);
             if ($i == self::NUM_OPTION) {
                 $_showHide->addHide('additionalOption');
             }
         } else {
             $_showHide->addShow($showBlocks);
         }
         // label
         $attributes['label']['size'] = 25;
         $this->add('text', 'option_label[' . $i . ']', ts('Label'), $attributes['label']);
         // amount
         $this->add('text', 'option_amount[' . $i . ']', ts('Amount'), $attributes['amount']);
         $this->addRule('option_amount[' . $i . ']', ts('Please enter a valid amount for this field.'), 'money');
         //Financial Type
         $this->add('select', 'option_financial_type_id[' . $i . ']', ts('Financial Type'), array('' => ts('- select -')) + $financialType);
         if (in_array($eventComponentId, $this->_extendComponentId)) {
             // count
             $this->add('text', 'option_count[' . $i . ']', ts('Participant Count'), $attributes['count']);
             $this->addRule('option_count[' . $i . ']', ts('Please enter a valid Participants Count.'), 'positiveInteger');
             // max_value
             $this->add('text', 'option_max_value[' . $i . ']', ts('Max Participants'), $attributes['max_value']);
             $this->addRule('option_max_value[' . $i . ']', ts('Please enter a valid Max Participants.'), 'positiveInteger');
             // description
             //$this->add('textArea', 'option_description['.$i.']', ts('Description'), array('rows' => 1, 'cols' => 40 ));
         } elseif (in_array($memberComponentId, $this->_extendComponentId)) {
             $membershipTypes = CRM_Member_PseudoConstant::membershipType();
             $js = array('onchange' => "calculateRowValues( {$i} );");
             $this->add('select', 'membership_type_id[' . $i . ']', ts('Membership Type'), array('' => ' ') + $membershipTypes, FALSE, $js);
             $this->add('text', 'membership_num_terms[' . $i . ']', ts('Number of Terms'), CRM_Utils_Array::value('membership_num_terms', $attributes));
         }
         // weight
         $this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
         // is active ?
         $this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
         $defaultOption[$i] = $this->createElement('radio', NULL, NULL, NULL, $i);
         //for checkbox handling of default option
         $this->add('checkbox', "default_checkbox_option[{$i}]", NULL);
     }
     //default option selection
     $this->addGroup($defaultOption, 'default_option');
     $_showHide->addToTemplate();
     // is_display_amounts
     $this->add('checkbox', 'is_display_amounts', ts('Display Amount?'));
     // weight
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'weight'), TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // checkbox / radio options per line
     $this->add('text', 'options_per_line', ts('Options Per Line'));
     $this->addRule('options_per_line', ts('must be a numeric value'), 'numeric');
     // help post, mask, attributes, javascript ?
     $this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_PriceField', 'help_post'));
     // active_on
     $date_options = array('format' => 'dmY His', 'minYear' => date('Y') - 1, 'maxYear' => date('Y') + 5, 'addEmptyOption' => TRUE);
     $this->addDateTime('active_on', ts('Active On'), FALSE, array('formatType' => 'activityDateTime'));
     // expire_on
     $this->addDateTime('expire_on', ts('Expire On'), FALSE, array('formatType' => 'activityDateTime'));
     // is required ?
     $this->add('checkbox', 'is_required', ts('Required?'));
     // is active ?
     $this->add('checkbox', 'is_active', ts('Active?'));
     // add buttons
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => TRUE), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     // is public?
     $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
     // add a form rule to check default value
     $this->addFormRule(array('CRM_Price_Form_Field', 'formRule'), $this);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid);
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='{$url}'"));
     }
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:101,代码来源:Field.php

示例5: getRows

 /**
  * Return option-values of a particular group
  *
  * @param array $groupParams
  *   Array containing group fields whose option-values is to retrieved.
  * @param array $links
  *   Has links like edit, delete, disable ..etc.
  * @param string $orderBy
  *   For orderBy clause.
  *
  * @return array
  *   Array of option-values
  *
  */
 public static function getRows($groupParams, $links, $orderBy = 'weight')
 {
     $optionValue = array();
     $optionGroupID = NULL;
     if (!isset($groupParams['id']) || !$groupParams['id']) {
         if ($groupParams['name']) {
             $config = CRM_Core_Config::singleton();
             $optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $dnc);
             $optionGroupID = $optionGroup->id;
         }
     } else {
         $optionGroupID = $groupParams['id'];
     }
     $groupName = CRM_Utils_Array::value('name', $groupParams);
     if (!$groupName && $optionGroupID) {
         $groupName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $optionGroupID, 'name', 'id');
     }
     $dao = new CRM_Core_DAO_OptionValue();
     if ($optionGroupID) {
         $dao->option_group_id = $optionGroupID;
         if (in_array($groupName, CRM_Core_OptionGroup::$_domainIDGroups)) {
             $dao->domain_id = CRM_Core_Config::domainID();
         }
         $dao->orderBy($orderBy);
         $dao->find();
     }
     if ($groupName == 'case_type') {
         $caseTypeIds = CRM_Case_BAO_Case::getUsedCaseType();
     } elseif ($groupName == 'case_status') {
         $caseStatusIds = CRM_Case_BAO_Case::getUsedCaseStatuses();
     }
     $componentNames = CRM_Core_Component::getNames();
     $visibilityLabels = CRM_Core_PseudoConstant::visibility();
     while ($dao->fetch()) {
         $optionValue[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]);
         // form all action links
         $action = array_sum(array_keys($links));
         // update enable/disable links depending on if it is is_reserved or is_active
         if ($dao->is_reserved) {
             $action = CRM_Core_Action::UPDATE;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
             if ($groupName == 'case_type' && in_array($dao->value, $caseTypeIds) || $groupName == 'case_status' && in_array($dao->value, $caseStatusIds)) {
                 $action -= CRM_Core_Action::DELETE;
             }
         }
         $optionValue[$dao->id]['label'] = htmlspecialchars($optionValue[$dao->id]['label']);
         $optionValue[$dao->id]['order'] = $optionValue[$dao->id]['weight'];
         $optionValue[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'gid' => $optionGroupID, 'value' => $dao->value), ts('more'), FALSE, 'optionValue.row.actions', 'optionValue', $dao->id);
         if (!empty($optionValue[$dao->id]['component_id'])) {
             $optionValue[$dao->id]['component_name'] = $componentNames[$optionValue[$dao->id]['component_id']];
         } else {
             $optionValue[$dao->id]['component_name'] = 'Contact';
         }
         if (!empty($optionValue[$dao->id]['visibility_id'])) {
             $optionValue[$dao->id]['visibility_label'] = $visibilityLabels[$optionValue[$dao->id]['visibility_id']];
         }
     }
     return $optionValue;
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:79,代码来源:OptionValue.php

示例6: array

 /**
  * DEPRECATED. Please use the buildOptions() method in the appropriate BAO object.
  *
  * Get all Visibility levels.
  *
  * The static array visibility is returned
  *
  * @access public
  * @static
  *
  * @return array - array reference of all Visibility levels.
  *
  */
 public static function &visibility($column = 'label')
 {
     if (!isset(self::$visibility)) {
         self::$visibility = array();
     }
     if (!isset(self::$visibility[$column])) {
         self::$visibility[$column] = CRM_Core_OptionGroup::values('visibility', FALSE, FALSE, FALSE, NULL, $column);
     }
     return self::$visibility[$column];
 }
开发者ID:TheCraftyCanvas,项目名称:aegir-platforms,代码行数:23,代码来源:PseudoConstant.php

示例7: buildQuickForm

 /**
  * Build the form object.
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     $this->setPageTitle(ts('%1 Option', array(1 => $this->_gLabel)));
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $isReserved = FALSE;
     if ($this->_id) {
         $isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved');
     }
     $this->add('text', 'label', ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), TRUE);
     if ($this->_gName != 'activity_type') {
         $this->add('text', 'value', ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), TRUE);
     }
     if (!in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Value.'), 'optionExists', array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label'));
     }
     if ($this->_gName == 'case_status') {
         $classes = array('Opened' => ts('Opened'), 'Closed' => ts('Closed'));
         $grouping = $this->add('select', 'grouping', ts('Status Class'), $classes);
         if ($isReserved) {
             $grouping->freeze();
         }
     }
     // CRM-11516
     if ($this->_gName == 'payment_instrument') {
         $accountType = CRM_Core_PseudoConstant::accountOptionValues('financial_account_type', NULL, " AND v.name = 'Asset' ");
         $financialAccount = CRM_Contribute_PseudoConstant::financialAccount(NULL, key($accountType));
         $this->add('select', 'financial_account_id', ts('Financial Account'), array('' => ts('- select -')) + $financialAccount, TRUE);
     }
     $required = FALSE;
     if ($this->_gName == 'custom_search') {
         $required = TRUE;
     } elseif ($this->_gName == 'redaction_rule' || $this->_gName == 'engagement_index') {
         if ($this->_gName == 'redaction_rule') {
             $this->add('checkbox', 'filter', ts('Regular Expression?'));
         }
     }
     if ($this->_gName == 'participant_listing') {
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
     } else {
         // Hard-coding attributes here since description is still stored as varchar and not text in the schema. dgg
         $this->add('wysiwyg', 'description', ts('Description'), array('rows' => 4, 'cols' => 80), $required);
     }
     if ($this->_gName == 'event_badge') {
         $this->add('text', 'name', ts('Class Name'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'name'));
     }
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), TRUE);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component.
     // FIXME: Each component should define whether adding new activity types is allowed.
     $config = CRM_Core_Config::singleton();
     if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) && ($this->_action & CRM_Core_Action::ADD || !$isReserved)) {
         $caseID = CRM_Core_Component::getComponentID('CiviCase');
         $components = array('' => ts('Contacts AND Cases'), $caseID => ts('Cases Only'));
         $this->add('select', 'component_id', ts('Component'), $components, FALSE);
     }
     $enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($isReserved) {
         $enabled->freeze();
     }
     //fix for CRM-3552, CRM-4575
     $showIsDefaultGroups = array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address', 'case_status', 'encounter_medium', 'case_type', 'payment_instrument', 'communication_style', 'soft_credit_type', 'website_type');
     if (in_array($this->_gName, $showIsDefaultGroups)) {
         $this->assign('showDefault', TRUE);
         $this->add('checkbox', 'is_default', ts('Default Option?'));
     }
     //get contact type for which user want to create a new greeting/addressee type, CRM-4575
     if (in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $values = array(1 => ts('Individual'), 2 => ts('Household'), 3 => ts('Organization'), 4 => ts('Multiple Contact Merge'));
         $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, TRUE);
         $this->assign('showContactFilter', TRUE);
     }
     if ($this->_gName == 'participant_status') {
         // For Participant Status options, expose the 'filter' field to track which statuses are "Counted", and the Visibility field
         $element = $this->add('checkbox', 'filter', ts('Counted?'));
         $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
     }
     if ($this->_gName == 'participant_role') {
         // For Participant Role options, expose the 'filter' field to track which statuses are "Counted"
         $this->add('checkbox', 'filter', ts('Counted?'));
     }
     $this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:89,代码来源:Options.php

示例8: buildQuickForm


//.........这里部分代码省略.........
     $this->add('text', 'label', ts('Field Label'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'label'), true);
     // html_type
     $javascript = 'onchange="option_html_type(this.form)";';
     require_once 'CRM/Price/BAO/Field.php';
     $htmlTypes = CRM_Price_BAO_Field::htmlTypes();
     $sel = $this->add('select', 'html_type', ts('Input Field Type'), $htmlTypes, true, $javascript);
     // Text box for Participant Count for a field
     require_once 'CRM/Core/Component.php';
     $eventComponentId = CRM_Core_Component::getComponentID('CiviEvent');
     $attributes = CRM_Core_DAO::getAttribute('CRM_Price_DAO_FieldValue');
     if (in_array($eventComponentId, $this->_extendComponentId)) {
         $this->add('text', 'count', ts('Participant Count'), $attributes['count']);
         $this->addRule('count', ts('Participant Count should be a positive number'), 'positiveInteger');
         $this->add('text', 'max_value', ts('Max Participants'), $attributes['max_value']);
         $this->addRule('max_value', ts('Please enter a valid Max Participants.'), 'positiveInteger');
         $this->add('textArea', 'description', ts('Description'), $attributes['description']);
         $this->assign('useForEvent', true);
     } else {
         $this->assign('useForEvent', false);
     }
     // price (for text inputs)
     $this->add('text', 'price', ts('Price'));
     $this->registerRule('price', 'callback', 'money', 'CRM_Utils_Rule');
     $this->addRule('price', ts('must be a monetary value'), 'money');
     if ($this->_action == CRM_Core_Action::UPDATE) {
         $this->freeze('html_type');
     }
     // form fields of Custom Option rows
     $_showHide = new CRM_Core_ShowHideBlocks('', '');
     for ($i = 1; $i <= self::NUM_OPTION; $i++) {
         //the show hide blocks
         $showBlocks = 'optionField_' . $i;
         if ($i > 2) {
             $_showHide->addHide($showBlocks);
             if ($i == self::NUM_OPTION) {
                 $_showHide->addHide('additionalOption');
             }
         } else {
             $_showHide->addShow($showBlocks);
         }
         // label
         $attributes['label']['size'] = 25;
         $this->add('text', 'option_label[' . $i . ']', ts('Label'), $attributes['label']);
         // amount
         $this->add('text', 'option_amount[' . $i . ']', ts('Amount'), $attributes['amount']);
         $this->addRule('option_amount[' . $i . ']', ts('Please enter a valid amount for this field.'), 'money');
         if (in_array($eventComponentId, $this->_extendComponentId)) {
             // count
             $this->add('text', 'option_count[' . $i . ']', ts('Participant Count'), $attributes['count']);
             $this->addRule('option_count[' . $i . ']', ts('Please enter a valid Participants Count.'), 'positiveInteger');
             // max_value
             $this->add('text', 'option_max_value[' . $i . ']', ts('Max Participants'), $attributes['max_value']);
             $this->addRule('option_max_value[' . $i . ']', ts('Please enter a valid Max Participants.'), 'positiveInteger');
             // description
             $this->add('textArea', 'option_description[' . $i . ']', ts('Description'), array('rows' => 1, 'cols' => 40));
         }
         // weight
         $this->add('text', 'option_weight[' . $i . ']', ts('Order'), $attributes['weight']);
         // is active ?
         $this->add('checkbox', 'option_status[' . $i . ']', ts('Active?'));
         $defaultOption[$i] = $this->createElement('radio', null, null, null, $i);
         //for checkbox handling of default option
         $this->add('checkbox', "default_checkbox_option[{$i}]", null);
     }
     //default option selection
     $this->addGroup($defaultOption, 'default_option');
     $_showHide->addToTemplate();
     // is_display_amounts
     $this->add('checkbox', 'is_display_amounts', ts('Display Amount?'));
     // weight
     $this->add('text', 'weight', ts('Order'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'weight'), true);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     // checkbox / radio options per line
     $this->add('text', 'options_per_line', ts('Options Per Line'));
     $this->addRule('options_per_line', ts('must be a numeric value'), 'numeric');
     // help post, mask, attributes, javascript ?
     $this->add('textarea', 'help_post', ts('Field Help'), CRM_Core_DAO::getAttribute('CRM_Price_DAO_Field', 'help_post'));
     // active_on
     $date_options = array('minYear' => date('Y'), 'maxYear' => date('Y') + 5, 'addEmptyOption' => true);
     $this->add('date', 'active_on', ts('Active On'), $date_options);
     // expire_on
     $this->add('date', 'expire_on', ts('Expire On'), $date_options);
     // is required ?
     $this->add('checkbox', 'is_required', ts('Required?'));
     // is active ?
     $this->add('checkbox', 'is_active', ts('Active?'));
     // add buttons
     $this->addButtons(array(array('type' => 'next', 'name' => ts('Save'), 'isDefault' => true), array('type' => 'next', 'name' => ts('Save and New'), 'subName' => 'new'), array('type' => 'cancel', 'name' => ts('Cancel'))));
     // is public?
     require_once 'CRM/Core/PseudoConstant.php';
     $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
     // add a form rule to check default value
     $this->addFormRule(array('CRM_Price_Form_Field', 'formRule'), $this);
     // if view mode pls freeze it with the done button.
     if ($this->_action & CRM_Core_Action::VIEW) {
         $this->freeze();
         $url = CRM_Utils_System::url('civicrm/admin/price/field', 'reset=1&action=browse&sid=' . $this->_sid);
         $this->addElement('button', 'done', ts('Done'), array('onclick' => "location.href='{$url}'"));
     }
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:101,代码来源:Field.php

示例9: getSetDetail

    /**
     * Get price set details.
     *
     * An array containing price set details (including price fields) is returned
     *
     * @param int $setID
     *   Price Set ID.
     * @param bool $required
     *   Appears to have no effect based on reading the code.
     * @param bool $validOnly
     *   Should only fields where today's date falls within the valid range be returned?
     *
     * @return array
     *   Array consisting of field details
     */
    public static function getSetDetail($setID, $required = TRUE, $validOnly = FALSE)
    {
        // create a new tree
        $setTree = array();
        $priceFields = array('id', 'name', 'label', 'html_type', 'is_enter_qty', 'help_pre', 'help_post', 'weight', 'is_display_amounts', 'options_per_line', 'is_active', 'active_on', 'expire_on', 'javascript', 'visibility_id', 'is_required');
        if ($required == TRUE) {
            $priceFields[] = 'is_required';
        }
        // create select
        $select = 'SELECT ' . implode(',', $priceFields);
        $from = ' FROM civicrm_price_field';
        $params = array();
        $params[1] = array($setID, 'Integer');
        $where = '
WHERE price_set_id = %1
AND is_active = 1
';
        $dateSelect = '';
        if ($validOnly) {
            $currentTime = date('YmdHis');
            $dateSelect = "\nAND ( active_on IS NULL OR active_on <= {$currentTime} )\nAND ( expire_on IS NULL OR expire_on >= {$currentTime} )\n";
        }
        $orderBy = ' ORDER BY weight';
        $sql = $select . $from . $where . $dateSelect . $orderBy;
        $dao = CRM_Core_DAO::executeQuery($sql, $params);
        $visibility = CRM_Core_PseudoConstant::visibility('name');
        while ($dao->fetch()) {
            $fieldID = $dao->id;
            $setTree[$setID]['fields'][$fieldID] = array();
            $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID;
            foreach ($priceFields as $field) {
                if ($field == 'id' || is_null($dao->{$field})) {
                    continue;
                }
                if ($field == 'visibility_id') {
                    $setTree[$setID]['fields'][$fieldID]['visibility'] = $visibility[$dao->{$field}];
                }
                $setTree[$setID]['fields'][$fieldID][$field] = $dao->{$field};
            }
            $setTree[$setID]['fields'][$fieldID]['options'] = CRM_Price_BAO_PriceField::getOptions($fieldID, FALSE);
        }
        // also get the pre and post help from this price set
        $sql = "\nSELECT extends, financial_type_id, help_pre, help_post, is_quick_config\nFROM   civicrm_price_set\nWHERE  id = %1";
        $dao = CRM_Core_DAO::executeQuery($sql, $params);
        if ($dao->fetch()) {
            $setTree[$setID]['extends'] = $dao->extends;
            $setTree[$setID]['financial_type_id'] = $dao->financial_type_id;
            $setTree[$setID]['help_pre'] = $dao->help_pre;
            $setTree[$setID]['help_post'] = $dao->help_post;
            $setTree[$setID]['is_quick_config'] = $dao->is_quick_config;
        }
        return $setTree;
    }
开发者ID:rollox,项目名称:civicrm-core,代码行数:68,代码来源:PriceSet.php

示例10: run

 /**
  * Run the page.
  *
  * This method is called after the page is created. It checks for the
  * type of action and executes that action.
  * Finally it calls the parent's run method.
  *
  * @return void
  */
 public function run()
 {
     //get the event id.
     $this->_id = CRM_Utils_Request::retrieve('id', 'Positive', $this, TRUE);
     $config = CRM_Core_Config::singleton();
     // ensure that the user has permission to see this page
     if (!CRM_Core_Permission::event(CRM_Core_Permission::VIEW, $this->_id, 'view event info')) {
         CRM_Utils_System::setUFMessage(ts('You do not have permission to view this event'));
         return CRM_Utils_System::permissionDenied();
     }
     $action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
     $context = CRM_Utils_Request::retrieve('context', 'String', $this, FALSE, 'register');
     $this->assign('context', $context);
     // Sometimes we want to suppress the Event Full msg
     $noFullMsg = CRM_Utils_Request::retrieve('noFullMsg', 'String', $this, FALSE, 'false');
     // set breadcrumb to append to 2nd layer pages
     $breadCrumbPath = CRM_Utils_System::url('civicrm/event/info', "id={$this->_id}&reset=1");
     //retrieve event information
     $params = array('id' => $this->_id);
     CRM_Event_BAO_Event::retrieve($params, $values['event']);
     if (!$values['event']['is_active']) {
         // form is inactive, die a fatal death
         CRM_Utils_System::setUFMessage(ts('The event you requested is currently unavailable (contact the site administrator for assistance).'));
         return CRM_Utils_System::permissionDenied();
     }
     if (!empty($values['event']['is_template'])) {
         // form is an Event Template
         CRM_Core_Error::fatal(ts('The page you requested is currently unavailable.'));
     }
     // Add Event Type to $values in case folks want to display it
     $values['event']['event_type'] = CRM_Utils_Array::value($values['event']['event_type_id'], CRM_Event_PseudoConstant::eventType());
     $this->assign('isShowLocation', CRM_Utils_Array::value('is_show_location', $values['event']));
     // show event fees.
     if ($this->_id && !empty($values['event']['is_monetary'])) {
         //CRM-6907
         $config = CRM_Core_Config::singleton();
         $config->defaultCurrency = CRM_Utils_Array::value('currency', $values['event'], $config->defaultCurrency);
         //CRM-10434
         $discountId = CRM_Core_BAO_Discount::findSet($this->_id, 'civicrm_event');
         if ($discountId) {
             $priceSetId = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Discount', $discountId, 'price_set_id');
         } else {
             $priceSetId = CRM_Price_BAO_PriceSet::getFor('civicrm_event', $this->_id);
         }
         // get price set options, - CRM-5209
         if ($priceSetId) {
             $setDetails = CRM_Price_BAO_PriceSet::getSetDetail($priceSetId, TRUE, TRUE);
             $priceSetFields = $setDetails[$priceSetId]['fields'];
             if (is_array($priceSetFields)) {
                 $fieldCnt = 1;
                 $visibility = CRM_Core_PseudoConstant::visibility('name');
                 // CRM-14492 Admin price fields should show up on event registration if user has 'administer CiviCRM' permissions
                 $adminFieldVisible = FALSE;
                 if (CRM_Core_Permission::check('administer CiviCRM')) {
                     $adminFieldVisible = TRUE;
                 }
                 foreach ($priceSetFields as $fid => $fieldValues) {
                     if (!is_array($fieldValues['options']) || empty($fieldValues['options']) || CRM_Utils_Array::value('visibility_id', $fieldValues) != array_search('public', $visibility) && $adminFieldVisible == FALSE) {
                         continue;
                     }
                     if (count($fieldValues['options']) > 1) {
                         $values['feeBlock']['value'][$fieldCnt] = '';
                         $values['feeBlock']['label'][$fieldCnt] = $fieldValues['label'];
                         $values['feeBlock']['lClass'][$fieldCnt] = 'price_set_option_group-label';
                         $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
                         $fieldCnt++;
                         $labelClass = 'price_set_option-label';
                     } else {
                         $labelClass = 'price_set_field-label';
                     }
                     // show tax rate with amount
                     $invoiceSettings = Civi::settings()->get('contribution_invoice_settings');
                     $taxTerm = CRM_Utils_Array::value('tax_term', $invoiceSettings);
                     $displayOpt = CRM_Utils_Array::value('tax_display_settings', $invoiceSettings);
                     $invoicing = CRM_Utils_Array::value('invoicing', $invoiceSettings);
                     foreach ($fieldValues['options'] as $optionId => $optionVal) {
                         $values['feeBlock']['isDisplayAmount'][$fieldCnt] = CRM_Utils_Array::value('is_display_amounts', $fieldValues);
                         if ($invoicing && isset($optionVal['tax_amount'])) {
                             $values['feeBlock']['value'][$fieldCnt] = CRM_Price_BAO_PriceField::getTaxLabel($optionVal, 'amount', $displayOpt, $taxTerm);
                             $values['feeBlock']['tax_amount'][$fieldCnt] = $optionVal['tax_amount'];
                         } else {
                             $values['feeBlock']['value'][$fieldCnt] = $optionVal['amount'];
                         }
                         $values['feeBlock']['label'][$fieldCnt] = $optionVal['label'];
                         $values['feeBlock']['lClass'][$fieldCnt] = $labelClass;
                         $fieldCnt++;
                     }
                 }
             }
             // Tell tpl we have price set fee data and whether it's a quick_config price set
             $this->assign('isPriceSet', 1);
//.........这里部分代码省略.........
开发者ID:konadave,项目名称:civicrm-core,代码行数:101,代码来源:EventInfo.php

示例11:

 /**
  * Get all Visibility levels.
  *
  * The static array visibility is returned
  *
  * @access public
  * @static
  *
  * @return array - array reference of all Visibility levels.
  *
  */
 public static function &visibility($column = 'label')
 {
     if (!self::$visibility) {
         require_once 'CRM/Core/OptionGroup.php';
         self::$visibility = CRM_Core_OptionGroup::values('visibility', false, false, false, null, $column);
     }
     return self::$visibility;
 }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:19,代码来源:PseudoConstant.php

示例12:

 /**
  * Get all Visibility levels.
  *
  * The static array visibility is returned
  *
  * @access public
  * @static
  *
  * @return array - array reference of all Visibility levels.
  *
  */
 public static function &visibility()
 {
     if (!self::$visibility) {
         require_once 'CRM/Core/OptionGroup.php';
         self::$visibility = CRM_Core_OptionGroup::values('visibility');
     }
     return self::$visibility;
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:19,代码来源:PseudoConstant.php

示例13: getRows

 /**
  * Function to return option-values of a particular group
  *
  * @param  array     $groupParams   Array containing group fields whose option-values is to retrieved.
  * @param  string    $orderBy       for orderBy clause
  * @param  array     $links         has links like edit, delete, disable ..etc
  *
  * @return array of option-values     
  * 
  * @access public
  * @static
  */
 static function getRows($groupParams, $links, $orderBy = 'weight')
 {
     $optionValue = array();
     if (!isset($groupParams['id']) || !$groupParams['id']) {
         if ($groupParams['name']) {
             $config =& CRM_Core_Config::singleton();
             $optionGroup = CRM_Core_BAO_OptionGroup::retrieve($groupParams, $dnc);
             $optionGroupID = $optionGroup->id;
         }
     } else {
         $optionGroupID = $groupParams['id'];
     }
     $dao =& new CRM_Core_DAO_OptionValue();
     if ($optionGroupID) {
         $dao->option_group_id = $optionGroupID;
         $dao->orderBy($orderBy);
         $dao->find();
     }
     require_once 'CRM/Core/Component.php';
     $componentNames = CRM_Core_Component::getNames();
     $visibilityLabels = CRM_Core_PseudoConstant::visibility();
     while ($dao->fetch()) {
         $optionValue[$dao->id] = array();
         CRM_Core_DAO::storeValues($dao, $optionValue[$dao->id]);
         // form all action links
         $action = array_sum(array_keys($links));
         // update enable/disable links depending on if it is is_reserved or is_active
         if ($dao->is_reserved) {
             $action = CRM_Core_Action::UPDATE;
         } else {
             if ($dao->is_active) {
                 $action -= CRM_Core_Action::ENABLE;
             } else {
                 $action -= CRM_Core_Action::DISABLE;
             }
         }
         $optionValue[$dao->id]['label'] = htmlspecialchars($optionValue[$dao->id]['label']);
         $optionValue[$dao->id]['order'] = $optionValue[$dao->id]['weight'];
         $optionValue[$dao->id]['action'] = CRM_Core_Action::formLink($links, $action, array('id' => $dao->id, 'gid' => $optionGroupID, 'value' => $dao->value));
         if (CRM_Utils_Array::value('component_id', $optionValue[$dao->id])) {
             $optionValue[$dao->id]['component_name'] = $componentNames[$optionValue[$dao->id]['component_id']];
         } else {
             $optionValue[$dao->id]['component_name'] = 'Contact';
         }
         if (CRM_Utils_Array::value('visibility_id', $optionValue[$dao->id])) {
             $optionValue[$dao->id]['visibility_label'] = $visibilityLabels[$optionValue[$dao->id]['visibility_id']];
         }
     }
     return $optionValue;
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:62,代码来源:OptionValue.php

示例14: buildQuickForm

 /**
  * Function to build the form
  *
  * @return None
  * @access public
  */
 public function buildQuickForm()
 {
     parent::buildQuickForm();
     if ($this->_action & CRM_Core_Action::DELETE) {
         return;
     }
     $this->applyFilter('__ALL__', 'trim');
     $this->add('text', 'label', ts('Label'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'label'), true);
     $this->addRule('label', ts('This Label already exists in the database for this option group. Please select a different Value.'), 'optionExists', array('CRM_Core_DAO_OptionValue', $this->_id, $this->_gid, 'label'));
     $required = false;
     if ($this->_gName == 'custom_search') {
         $required = true;
     } elseif ($this->_gName == 'redaction_rule') {
         $this->add('text', 'value', ts('Value'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'value'), true);
         $this->add('checkbox', 'filter', ts('Regular Expression?'));
     }
     if ($this->_gName == 'participant_listing') {
         $this->add('text', 'description', ts('Description'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'description'));
     } else {
         // Hard-coding attributes here since description is still stored as varchar and not text in the schema. dgg
         $this->addWysiwyg('description', ts('Description'), array('rows' => 4, 'cols' => 80), $required);
     }
     $this->add('text', 'weight', ts('Weight'), CRM_Core_DAO::getAttribute('CRM_Core_DAO_OptionValue', 'weight'), true);
     $this->addRule('weight', ts('is a numeric field'), 'numeric');
     $isReserved = false;
     if ($this->_id) {
         $isReserved = (bool) CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'is_reserved');
     }
     // If CiviCase enabled AND "Add" mode OR "edit" mode for non-reserved activities, only allow user to pick Core or CiviCase component.
     // FIXME: Each component should define whether adding new activity types is allowed.
     require_once 'CRM/Core/Config.php';
     $config =& CRM_Core_Config::singleton();
     if ($this->_gName == 'activity_type' && in_array("CiviCase", $config->enableComponents) && ($this->_action & CRM_Core_Action::ADD || !$isReserved)) {
         require_once 'CRM/Core/Component.php';
         $caseID = CRM_Core_Component::getComponentID('CiviCase');
         $components = array('' => ts('Contact'), $caseID => 'CiviCase');
         $this->add('select', 'component_id', ts('Component'), $components, false);
     }
     $enabled = $this->add('checkbox', 'is_active', ts('Enabled?'));
     if ($isReserved) {
         $enabled->freeze();
     }
     //fix for CRM-3552, CRM-4575
     if (in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee', 'from_email_address'))) {
         $this->assign('showDefault', true);
         $this->add('checkbox', 'is_default', ts('Default Option?'));
     }
     //get contact type for which user want to create a new greeting/addressee type, CRM-4575
     if (in_array($this->_gName, array('email_greeting', 'postal_greeting', 'addressee')) && !$isReserved) {
         $values = array(1 => ts('Individual'), 2 => ts('Household'));
         if ($this->_gName == 'addressee') {
             $values[] = ts('Organization');
         }
         $this->add('select', 'contactOptions', ts('Contact Type'), array('' => '-select-') + $values, true);
         $this->assign('showContactFilter', true);
     }
     if ($this->_gName == 'participant_status') {
         // For Participant Status options, expose the 'filter' field to track which statuses are "Counted", and the Visibility field
         $element = $this->add('checkbox', 'filter', ts('Counted?'));
         require_once "CRM/Core/PseudoConstant.php";
         $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility());
     }
     if ($this->_gName == 'participant_role') {
         // For Participant Role options, expose the 'filter' field to track which statuses are "Counted"
         $this->add('checkbox', 'filter', ts('Counted?'));
     }
     $this->addFormRule(array('CRM_Admin_Form_Options', 'formRule'), $this);
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:74,代码来源:Options.php

示例15: getSetDetail

    /**
     * Get price set details
     *
     * An array containing price set details (including price fields) is returned
     *
     * @param int $setId - price set id whose details are needed
     * @return array $setTree - array consisting of field details
     */
    public static function getSetDetail($setID, $required = true)
    {
        // create a new tree
        $setTree = array();
        $select = $from = $where = $orderBy = '';
        $priceFields = array('id', 'name', 'label', 'html_type', 'is_enter_qty', 'help_post', 'is_display_amounts', 'options_per_line', 'is_active', 'visibility_id');
        if ($required == true) {
            $priceFields[] = 'is_required';
        }
        // create select
        $select = 'SELECT ' . implode(',', $priceFields);
        $from = ' FROM civicrm_price_field';
        $params = array();
        $params[1] = array($setID, 'Integer');
        $where = '
WHERE price_set_id = %1
AND is_active = 1
';
        $orderBy = ' ORDER BY weight';
        $sql = $select . $from . $where . $orderBy;
        $dao =& CRM_Core_DAO::executeQuery($sql, $params);
        $visibility = CRM_Core_PseudoConstant::visibility('name');
        while ($dao->fetch()) {
            $fieldID = $dao->id;
            $setTree[$setID]['fields'][$fieldID] = array();
            $setTree[$setID]['fields'][$fieldID]['id'] = $fieldID;
            foreach ($priceFields as $field) {
                if ($field == 'id' || is_null($dao->{$field})) {
                    continue;
                }
                if ($field == 'visibility_id') {
                    $setTree[$setID]['fields'][$fieldID]['visibility'] = $visibility[$dao->{$field}];
                }
                $setTree[$setID]['fields'][$fieldID][$field] = $dao->{$field};
            }
            $setTree[$setID]['fields'][$fieldID]['options'] = CRM_Price_BAO_Field::getOptions($fieldID, false);
        }
        // also get the pre and post help from this price set
        $sql = "\nSELECT help_pre, help_post\nFROM   civicrm_price_set\nWHERE  id = %1";
        $dao =& CRM_Core_DAO::executeQuery($sql, $params);
        if ($dao->fetch()) {
            $setTree[$setID]['help_pre'] = $dao->help_pre;
            $setTree[$setID]['help_post'] = $dao->help_post;
        }
        return $setTree;
    }
开发者ID:hampelm,项目名称:Ginsberg-CiviDemo,代码行数:54,代码来源:Set.php


注:本文中的CRM_Core_PseudoConstant::visibility方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。