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


PHP CRM_Core_Page::assign方法代码示例

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


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

示例1: buildPcp

 /**
  * Add PCP form elements to a form.
  *
  * @param int $pcpId
  * @param CRM_Core_Page $page
  * @param null $elements
  */
 public static function buildPcp($pcpId, &$page, &$elements = NULL)
 {
     $prms = array('id' => $pcpId);
     CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $prms, $pcpInfo);
     if ($pcpSupporter = CRM_PCP_BAO_PCP::displayName($pcpId)) {
         if ($pcpInfo['page_type'] == 'event') {
             $pcp_supporter_text = ts('This event registration is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'event');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the registration, you will be able to create your own Personal Campaign Page!";
             }
         } else {
             $pcp_supporter_text = ts('This contribution is being made thanks to the efforts of <strong>%1</strong>, who supports our campaign. ', array(1 => $pcpSupporter));
             $text = CRM_PCP_BAO_PCP::getPcpBlockStatus($pcpInfo['page_id'], 'contribute');
             if (!empty($text)) {
                 $pcp_supporter_text .= "You can support it as well - once you complete the donation, you will be able to create your own Personal Campaign Page!";
             }
         }
         $page->assign('pcpSupporterText', $pcp_supporter_text);
     }
     $page->assign('pcp', TRUE);
     // build honor roll fields for registration form if supporter has honor roll enabled for their PCP
     if ($pcpInfo['is_honor_roll']) {
         $page->assign('is_honor_roll', TRUE);
         $page->add('checkbox', 'pcp_display_in_roll', ts('Show my support in the public honor roll'), NULL, NULL, array('onclick' => "showHideByValue('pcp_display_in_roll','','nameID|nickID|personalNoteID','block','radio',false); pcpAnonymous( );"));
         $extraOption = array('onclick' => "return pcpAnonymous( );");
         $elements = array();
         $elements[] =& $page->createElement('radio', NULL, '', ts('Include my name and message'), 0, $extraOption);
         $elements[] =& $page->createElement('radio', NULL, '', ts('List my support anonymously'), 1, $extraOption);
         $page->addGroup($elements, 'pcp_is_anonymous', NULL, '&nbsp;&nbsp;&nbsp;');
         $page->_defaults['pcp_is_anonymous'] = 0;
         $page->add('text', 'pcp_roll_nickname', ts('Name'), array('maxlength' => 30));
         $page->add('textarea', "pcp_personal_note", ts('Personal Note'), array('style' => 'height: 3em; width: 40em;'));
     } else {
         $page->assign('is_honor_roll', FALSE);
     }
 }
开发者ID:kidaa30,项目名称:yes,代码行数:44,代码来源:PCP.php

示例2: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $values
  * @param int $mappingTypeId
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $values, $mappingTypeId)
 {
     $errors = array();
     if (!empty($fields['saveMapping']) && !empty($fields['_qf_Map_next'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Export Mapping');
         } else {
             //check for Duplicate mappingName
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Export Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         $_flag = 1;
         $assignError = new CRM_Core_Page();
         $assignError->assign('mappingDetailsError', $_flag);
         return $errors;
     } else {
         return TRUE;
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:35,代码来源:Map.php

示例3: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('membership_contact_id' => ts('Contact ID'), 'membership_type_id' => ts('Membership Type'), 'membership_start_date' => ts('Membership Start Date'));
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         $fieldMessage = '';
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'membership_contact_id') {
                     if (($weightSum >= $threshold || in_array('external_identifier', $importKeys)) && $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE || in_array('membership_id', $importKeys)) {
                         continue;
                     } else {
                         if (!isset($errors['_qf_default'])) {
                             $errors['_qf_default'] = '';
                         }
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . ' ' . ts('(OR Membership ID if update mode.)') . '<br />';
                     }
                 } else {
                     if (!isset($errors['_qf_default'])) {
                         $errors['_qf_default'] = '';
                     }
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Membership', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Membership Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:77,代码来源:MapField.php

示例4: addUrls

 /**
  * Add urls for display in the actions menu.
  * @param CRM_Core_Page $obj
  * @param int $cid
  */
 public static function addUrls(&$obj, $cid)
 {
     $uid = CRM_Core_BAO_UFMatch::getUFId($cid);
     if ($uid) {
         $userRecordUrl = CRM_Core_Config::singleton()->userSystem->getUserRecordUrl($cid);
         $obj->assign('userRecordUrl', $userRecordUrl);
         $obj->assign('userRecordId', $uid);
     } elseif (CRM_Core_Config::singleton()->userSystem->checkPermissionAddUser()) {
         $userAddUrl = CRM_Utils_System::url('civicrm/contact/view/useradd', 'reset=1&action=add&cid=' . $cid);
         $obj->assign('userAddUrl', $userAddUrl);
     }
     if (CRM_Core_Permission::check('access Contact Dashboard')) {
         $dashboardURL = CRM_Utils_System::url('civicrm/user', "reset=1&id={$cid}");
         $obj->assign('dashboardURL', $dashboardURL);
     }
     // See if other modules want to add links to the activtity bar
     $hookLinks = array();
     CRM_Utils_Hook::links('view.contact.activity', 'Contact', $cid, $hookLinks, CRM_Core_DAO::$_nullObject, CRM_Core_DAO::$_nullObject);
     if (is_array($hookLinks)) {
         $obj->assign('hookLinks', $hookLinks);
     }
 }
开发者ID:konadave,项目名称:civicrm-core,代码行数:27,代码来源:View.php

示例5: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields)
 {
     $errors = array();
     // define so we avoid notices below
     $errors['_qf_default'] = '';
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('target_contact_id' => ts('Contact ID'), 'activity_date_time' => ts('Activity Date'), 'activity_subject' => ts('Activity Subject'), 'activity_type_id' => ts('Activity Type Id'));
         $params = array('used' => 'Unsupervised', 'contact_type' => 'Individual');
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'target_contact_id') {
                     if ($weightSum >= $threshold || in_array('external_identifier', $importKeys)) {
                         continue;
                     } else {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . $fieldMessage . ' ' . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . '<br />';
                     }
                 } elseif ($field == 'activity_type_id') {
                     if (in_array('activity_label', $importKeys)) {
                         continue;
                     } else {
                         $errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2', array(1 => $title, 2 => 'Activity Type Label')) . '<br />';
                     }
                 } else {
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Activity', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
             }
         }
     }
     if (empty($errors['_qf_default'])) {
         unset($errors['_qf_default']);
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:prashantgajare,项目名称:civicrm-core,代码行数:77,代码来源:MapField.php

示例6: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array('participant_contact_id' => ts('Contact ID'), 'event_id' => ts('Event ID'));
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if ($field == 'participant_contact_id') {
                     if ($weightSum >= $threshold || in_array('external_identifier', $importKeys) || in_array('participant_id', $importKeys)) {
                         continue;
                     }
                     if ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
                         $errors['_qf_default'] .= ts('Missing required field: Provide Particiapnt ID') . '<br />';
                     } else {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . ' ' . ts('Or Provide Contact Id or External Identifier.') . '<br />';
                     }
                 } elseif (!in_array('event_title', $importKeys)) {
                     $errors['_qf_default'] .= ts('Missing required field: Provide %1 or %2', array(1 => $title, 2 => 'Event Title')) . '<br />';
                 }
             }
         }
     }
     if (CRM_Utils_Array::value('saveMapping', $fields)) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Participant', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Participant Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:78,代码来源:MapField.php

示例7: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @param $files
  * @param $self
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     $contactORContributionId = $self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE ? 'contribution_id' : 'contribution_contact_id';
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => isset($contactTypes[$contactTypeId]) ? $contactTypes[$contactTypeId] : '');
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
             if ($val == "soft_credit") {
                 $mapperKey = CRM_Utils_Array::key('soft_credit', $importKeys);
                 if (empty($fields['mapper'][$mapperKey][1])) {
                     if (empty($errors['_qf_default'])) {
                         $errors['_qf_default'] = '';
                     }
                     $errors['_qf_default'] .= ts('Missing required fields: Soft Credit') . '<br />';
                 }
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
         // FIXME: should use the schema titles, not redeclare them
         $requiredFields = array($contactORContributionId == 'contribution_id' ? 'contribution_id' : 'contribution_contact_id' => $contactORContributionId == 'contribution_id' ? ts('Contribution ID') : ts('Contact ID'), 'total_amount' => ts('Total Amount'), 'financial_type' => ts('Financial Type'));
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if (empty($errors['_qf_default'])) {
                     $errors['_qf_default'] = '';
                 }
                 if ($field == $contactORContributionId) {
                     if (!($weightSum >= $threshold || in_array('external_identifier', $importKeys)) && $self->_onDuplicate != CRM_Import_Parser::DUPLICATE_UPDATE) {
                         $errors['_qf_default'] .= ts('Missing required contact matching fields.') . " {$fieldMessage} " . ts('(Sum of all weights should be greater than or equal to threshold: %1).', array(1 => $threshold)) . '<br />';
                     } elseif ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE && !(in_array('invoice_id', $importKeys) || in_array('trxn_id', $importKeys) || in_array('contribution_id', $importKeys))) {
                         $errors['_qf_default'] .= ts('Invoice ID or Transaction ID or Contribution ID are required to match to the existing contribution records in Update mode.') . '<br />';
                     }
                 } else {
                     $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title)) . '<br />';
                 }
             }
         }
         //at least one field should be mapped during update.
         if ($self->_onDuplicate == CRM_Import_Parser::DUPLICATE_UPDATE) {
             $atleastOne = FALSE;
             foreach ($self->_mapperFields as $key => $field) {
                 if (in_array($key, $importKeys) && !in_array($key, array('doNotImport', 'contribution_id', 'invoice_id', 'trxn_id'))) {
                     $atleastOne = TRUE;
                     break;
                 }
             }
             if (!$atleastOne) {
                 $errors['_qf_default'] .= ts('At least one contribution field needs to be mapped for update during update mode.') . '<br />';
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contribution', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Contribution Mapping Name');
             }
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         if (!empty($errors['_qf_default'])) {
             CRM_Core_Session::setStatus($errors['_qf_default'], ts("Error"), "error");
             return $errors;
         }
     }
     return TRUE;
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:100,代码来源:MapField.php

示例8: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $requiredFields = array('contact_id' => ts('Contact ID'));
         foreach ($requiredFields as $field => $title) {
             if (!in_array($field, $importKeys)) {
                 if (!isset($errors['_qf_default'])) {
                     $errors['_qf_default'] = '';
                 }
                 $errors['_qf_default'] .= ts('Missing required field: %1', array(1 => $title));
             }
         }
     }
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Multi value custom data', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate ' . $self->_mappingType . 'Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:kcristiano,项目名称:civicrm-core,代码行数:56,代码来源:MapField.php

示例9: formRule


//.........这里部分代码省略.........
                 if ($fields['option_value'][$i]) {
                     $errors['option_label[' . $i . ']'] = ts('Option label cannot be empty');
                     $_flagOption = 1;
                 } else {
                     $_emptyRow = 1;
                 }
             } else {
                 if (!strlen(trim($fields['option_value'][$i]))) {
                     if (!$fields['option_value'][$i]) {
                         $errors['option_value[' . $i . ']'] = ts('Option value cannot be empty');
                         $_flagOption = 1;
                     }
                 }
             }
             if ($fields['option_value'][$i] && $dataType != 'String') {
                 if ($dataType == 'Int') {
                     if (!CRM_Utils_Rule::integer($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid integer.');
                     }
                 } elseif ($dataType == 'Money') {
                     if (!CRM_Utils_Rule::money($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid money value.');
                     }
                 } else {
                     if (!CRM_Utils_Rule::numeric($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid number.');
                     }
                 }
             }
             $showBlocks = 'optionField_' . $i;
             if ($_flagOption) {
                 $_showHide->addShow($showBlocks);
                 $_rowError = 1;
             }
             if (!empty($_emptyRow)) {
                 $_showHide->addHide($showBlocks);
             } else {
                 $_showHide->addShow($showBlocks);
             }
             if ($i == self::NUM_OPTION) {
                 $hideBlock = 'additionalOption';
                 $_showHide->addHide($hideBlock);
             }
             $_flagOption = $_emptyRow = 0;
         }
     } elseif (isset($dataField) && in_array($dataField, $optionFields) && !in_array($dataType, array('Boolean', 'Country', 'StateProvince'))) {
         if (!$fields['option_group_id']) {
             $errors['option_group_id'] = ts('You must select a Multiple Choice Option set if you chose Reuse an existing set.');
         } else {
             $query = "\nSELECT count(*)\nFROM   civicrm_custom_field\nWHERE  data_type != %1\nAND    option_group_id = %2";
             $params = array(1 => array(self::$_dataTypeKeys[$fields['data_type'][0]], 'String'), 2 => array($fields['option_group_id'], 'Integer'));
             $count = CRM_Core_DAO::singleValueQuery($query, $params);
             if ($count > 0) {
                 $errors['option_group_id'] = ts('The data type of the multiple choice option set you\'ve selected does not match the data type assigned to this field.');
             }
         }
     }
     $assignError = new CRM_Core_Page();
     if ($_rowError) {
         $_showHide->addToTemplate();
         $assignError->assign('optionRowError', $_rowError);
     } else {
         if (isset($fields['data_type'][1])) {
             switch (self::$_dataToHTML[$fields['data_type'][0]][$fields['data_type'][1]]) {
                 case 'Radio':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 case 'Checkbox':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 case 'Select':
                     $_fieldError = 1;
                     $assignError->assign('fieldError', $_fieldError);
                     break;
                 default:
                     $_fieldError = 0;
                     $assignError->assign('fieldError', $_fieldError);
             }
         }
         for ($idx = 1; $idx <= self::NUM_OPTION; $idx++) {
             $showBlocks = 'optionField_' . $idx;
             if (!empty($fields['option_label'][$idx])) {
                 $_showHide->addShow($showBlocks);
             } else {
                 $_showHide->addHide($showBlocks);
             }
         }
         $_showHide->addToTemplate();
     }
     // we can not set require and view at the same time.
     if (CRM_Utils_Array::value('is_required', $fields) && CRM_Utils_Array::value('is_view', $fields)) {
         $errors['is_view'] = ts('Can not set this field Required and View Only at the same time.');
     }
     return empty($errors) ? TRUE : $errors;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:101,代码来源:Field.php

示例10: formRule

 /**
  * Global validation rules for the form.
  *
  * @param array $fields
  *   Posted values of the form.
  *
  * @return array
  *   list of errors to be posted back to the form
  */
 public static function formRule($fields)
 {
     $errors = array();
     if (!empty($fields['saveMapping'])) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', 'Import Contact', 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate Import Mapping Name');
             }
         }
     }
     $template = CRM_Core_Smarty::singleton();
     if (!empty($fields['saveMapping'])) {
         $template->assign('isCheked', TRUE);
     }
     if (!empty($errors)) {
         $_flag = 1;
         $assignError = new CRM_Core_Page();
         $assignError->assign('mappingDetailsError', $_flag);
         return $errors;
     } else {
         return TRUE;
     }
 }
开发者ID:nganivet,项目名称:civicrm-core,代码行数:36,代码来源:MapField.php

示例11: createMapXML

 /**
  * Assign smarty variables to the template that will be used by google api to plot the contacts.
  *
  * @param array $ids
  * @param int $locationId
  *   Location_id.
  * @param CRM_Core_Page $page
  * @param bool $addBreadCrumb
  * @param string $type
  */
 public static function createMapXML($ids, $locationId, &$page, $addBreadCrumb, $type = 'Contact')
 {
     $config = CRM_Core_Config::singleton();
     CRM_Utils_System::setTitle(ts('Map Location(s)'));
     $page->assign('query', 'CiviCRM Search Query');
     $page->assign('mapProvider', $config->mapProvider);
     $page->assign('mapKey', urlencode($config->mapAPIKey));
     if ($type == 'Contact') {
         $imageUrlOnly = FALSE;
         // google needs image url, CRM-6564
         if ($config->mapProvider == 'Google' || $config->mapProvider == 'OpenStreetMaps') {
             $imageUrlOnly = TRUE;
         }
         $locations = CRM_Contact_BAO_Contact_Location::getMapInfo($ids, $locationId, $imageUrlOnly);
     } else {
         $locations = CRM_Event_BAO_Event::getMapInfo($ids);
     }
     if (empty($locations)) {
         CRM_Core_Error::statusBounce(ts('This address does not contain latitude/longitude information and cannot be mapped.'));
     }
     if (empty($config->mapProvider)) {
         CRM_Core_Error::statusBounce(ts('You need to configure a Mapping Provider before using this feature (Administer > System Settings > Mapping and Geocoding).'));
     }
     if ($addBreadCrumb) {
         $session = CRM_Core_Session::singleton();
         $redirect = $session->readUserContext();
         if ($type == 'Contact') {
             $bcTitle = ts('Contact');
         } else {
             $bcTitle = ts('Event Info');
             $action = CRM_Utils_Request::retrieve('action', 'String', $page, FALSE);
             if ($action) {
                 $args = 'reset=1&action=preview&id=';
             } else {
                 $args = 'reset=1&id=';
             }
             $session->pushUserContext(CRM_Utils_System::url('civicrm/event/info', "{$args}{$ids}"));
         }
         CRM_Utils_System::appendBreadCrumb($bcTitle, $redirect);
     }
     $page->assign_by_ref('locations', $locations);
     // only issue a javascript warning if we know we will not
     // mess the poor user with too many warnings
     if (count($locations) <= 3) {
         $page->assign('geoCodeWarn', TRUE);
     } else {
         $page->assign('geoCodeWarn', FALSE);
     }
     $sumLat = $sumLng = 0;
     $maxLat = $maxLng = -400;
     $minLat = $minLng = 400;
     foreach ($locations as $location) {
         $sumLat += $location['lat'];
         $sumLng += $location['lng'];
         if ($location['lat'] > $maxLat) {
             $maxLat = $location['lat'];
         }
         if ($location['lat'] < $minLat) {
             $minLat = $location['lat'];
         }
         if ($location['lng'] > $maxLng) {
             $maxLng = $location['lng'];
         }
         if ($location['lng'] < $minLng) {
             $minLng = $location['lng'];
         }
     }
     $center = array('lat' => (double) $sumLat / count($locations), 'lng' => (double) $sumLng / count($locations));
     $span = array('lat' => (double) ($maxLat - $minLat), 'lng' => (double) ($maxLng - $minLng));
     $page->assign_by_ref('center', $center);
     $page->assign_by_ref('span', $span);
 }
开发者ID:nielosz,项目名称:civicrm-core,代码行数:82,代码来源:Map.php

示例12: formRule


//.........这里部分代码省略.........
         }
         //capture duplicate Custom Option label
         if (!empty($fields['option_label'])) {
             $countValue = count($fields['option_label']);
             $uniqueCount = count(array_unique($fields['option_label']));
             if ($countValue > $uniqueCount) {
                 $start = 1;
                 while ($start < CRM_CUSTOM_FORM_FIELD_NUM_OPTION) {
                     $nextIndex = $start + 1;
                     while ($nextIndex <= CRM_CUSTOM_FORM_FIELD_NUM_OPTION) {
                         if ($fields['option_label'][$start] == $fields['option_label'][$nextIndex] && !empty($fields['option_label'][$nextIndex])) {
                             $errors['option_label[' . $start . ']'] = ts('Duplicate Option label');
                             $errors['option_label[' . $nextIndex . ']'] = ts('Duplicate Option label');
                             $_flagOption = 1;
                         }
                         $nextIndex++;
                     }
                     $start++;
                 }
             }
         }
         for ($i = 1; $i <= CRM_CUSTOM_FORM_FIELD_NUM_OPTION; $i++) {
             if (!$fields['option_label'][$i]) {
                 if ($fields['option_value'][$i]) {
                     $errors['option_label[' . $i . ']'] = ts('Option label cannot be empty');
                     $_flagOption = 1;
                 } else {
                     $_emptyRow = 1;
                 }
             } else {
                 if (!strlen(trim($fields['option_value'][$i]))) {
                     if (!$fields['option_value'][$i]) {
                         $errors['option_value[' . $i . ']'] = ts('Option value cannot be empty');
                         $_flagOption = 1;
                     }
                 }
             }
             if ($fields['option_value'][$i] && $dataType != 'String') {
                 if ($dataType == 'Int') {
                     if (!CRM_Utils_Rule::integer($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid integer.');
                     }
                 } else {
                     if (!CRM_Utils_Rule::numeric($fields['option_value'][$i])) {
                         $_flagOption = 1;
                         $errors['option_value[' . $i . ']'] = ts('Please enter a valid number.');
                     }
                 }
             }
             $showBlocks = 'optionField[' . $i . ']';
             if ($_flagOption) {
                 $_showHide->addShow($showBlocks);
                 $_rowError = 1;
             }
             if ($_emptyRow) {
                 $_showHide->addHide($showBlocks);
             } else {
                 $_showHide->addShow($showBlocks);
             }
             if ($i == CRM_CUSTOM_FORM_FIELD_NUM_OPTION) {
                 $hideBlock = 'additionalOption';
                 $_showHide->addHide($hideBlock);
             }
             $_flagOption = $_emptyRow = 0;
         }
         if ($_rowError) {
             $_showHide->addToTemplate();
             CRM_Core_Page::assign('optionRowError', $_rowError);
         } else {
             switch ($GLOBALS['_CRM_CUSTOM_FORM_FIELD']['_dataToHTML'][$fields['data_type'][0]][$fields['data_type'][1]]) {
                 case 'Radio':
                     $_fieldError = 1;
                     CRM_Core_Page::assign('fieldError', $_fieldError);
                     break;
                 case 'Checkbox':
                     $_fieldError = 1;
                     CRM_Core_Page::assign('fieldError', $_fieldError);
                     break;
                 case 'Select':
                     $_fieldError = 1;
                     CRM_Core_Page::assign('fieldError', $_fieldError);
                     break;
                 default:
                     $_fieldError = 0;
                     CRM_Core_Page::assign('fieldError', $_fieldError);
             }
             for ($idx = 1; $idx <= CRM_CUSTOM_FORM_FIELD_NUM_OPTION; $idx++) {
                 $showBlocks = 'optionField[' . $idx . ']';
                 if (!empty($fields['option_label'][$idx])) {
                     $_showHide->addShow($showBlocks);
                 } else {
                     $_showHide->addHide($showBlocks);
                 }
             }
             $_showHide->addToTemplate();
         }
     }
     return empty($errors) ? true : $errors;
 }
开发者ID:bhirsch,项目名称:voipdrupal-4.7-1.0,代码行数:101,代码来源:Field.php

示例13: formRule

 /**
  * global validation rules for the form
  *
  * @param array $fields posted values of the form
  *
  * @param $files
  * @param $self
  *
  * @return array list of errors to be posted back to the form
  * @static
  * @access public
  */
 static function formRule($fields, $files, $self)
 {
     $errors = array();
     $fieldMessage = NULL;
     if (!array_key_exists('savedMapping', $fields)) {
         $importKeys = array();
         foreach ($fields['mapper'] as $mapperPart) {
             $importKeys[] = $mapperPart[0];
         }
         $contactTypeId = $self->get('contactType');
         $contactTypes = array(CRM_Import_Parser::CONTACT_INDIVIDUAL => 'Individual', CRM_Import_Parser::CONTACT_HOUSEHOLD => 'Household', CRM_Import_Parser::CONTACT_ORGANIZATION => 'Organization');
         $params = array('used' => 'Unsupervised', 'contact_type' => $contactTypes[$contactTypeId]);
         list($ruleFields, $threshold) = CRM_Dedupe_BAO_RuleGroup::dedupeRuleFieldsWeight($params);
         $weightSum = 0;
         foreach ($importKeys as $key => $val) {
             if (array_key_exists($val, $ruleFields)) {
                 $weightSum += $ruleFields[$val];
             }
         }
         foreach ($ruleFields as $field => $weight) {
             $fieldMessage .= ' ' . $field . '(weight ' . $weight . ')';
         }
     }
     if (CRM_Utils_Array::value('saveMapping', $fields)) {
         $nameField = CRM_Utils_Array::value('saveMappingName', $fields);
         if (empty($nameField)) {
             $errors['saveMappingName'] = ts('Name is required to save Import Mapping');
         } else {
             $mappingTypeId = CRM_Core_OptionGroup::getValue('mapping_type', $this->_mappingType, 'name');
             if (CRM_Core_BAO_Mapping::checkMapping($nameField, $mappingTypeId)) {
                 $errors['saveMappingName'] = ts('Duplicate ' . $this->_mappingType . 'Mapping Name');
             }
         }
     }
     //display Error if loaded mapping is not selected
     if (array_key_exists('loadMapping', $fields)) {
         $getMapName = CRM_Utils_Array::value('savedMapping', $fields);
         if (empty($getMapName)) {
             $errors['savedMapping'] = ts('Select saved mapping');
         }
     }
     if (!empty($errors)) {
         if (!empty($errors['saveMappingName'])) {
             $_flag = 1;
             $assignError = new CRM_Core_Page();
             $assignError->assign('mappingDetailsError', $_flag);
         }
         return $errors;
     }
     return TRUE;
 }
开发者ID:wayneYaw,项目名称:nz.co.fuzion.csvimport,代码行数:63,代码来源:MapFieldBaseClass.php


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