Eileen has submitted this change and it was merged.

Change subject: Added is_view check to prevent editing read only custom fields.
......................................................................


Added is_view check to prevent editing read only custom fields.

Change-Id: Idfc72d1861534b974b3df186e9aa898d0b8cb32e
---
M CRM/Profile/Page/MultipleRecordFieldsListing.php
1 file changed, 25 insertions(+), 21 deletions(-)

Approvals:
  Eileen: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php 
b/CRM/Profile/Page/MultipleRecordFieldsListing.php
index e0bee92..808a5f9 100644
--- a/CRM/Profile/Page/MultipleRecordFieldsListing.php
+++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php
@@ -228,6 +228,7 @@
         'time_format',
         'default_value',
         'is_required',
+        'is_view',
       );
       foreach ($fieldIDs as $key => $fieldID) {
         $fieldIDs[$key] = !is_numeric($fieldID) ? 
CRM_Core_BAO_CustomField::getKeyID($fieldID) : $fieldID;
@@ -252,6 +253,7 @@
         $options[$fieldIDs[$key]]['attributes']['data_type'] = 
$returnValues['data_type'];
         $options[$fieldIDs[$key]]['attributes']['is_required'] = 
!empty($returnValues['is_required']);
         $options[$fieldIDs[$key]]['attributes']['default_value'] = 
CRM_Utils_Array::value('default_value', $returnValues);
+        $options[$fieldIDs[$key]]['attributes']['is_view'] = 
CRM_Utils_Array::value('is_view', $returnValues);
 
         $options[$fieldIDs[$key]]['attributes']['format']
           = $options[$fieldIDs[$key]]['attributes']['date_format'] = 
CRM_Utils_Array::value('date_format', $returnValues);
@@ -337,29 +339,31 @@
               $editable = FALSE;
               if ($linkAction & CRM_Core_Action::UPDATE) {
                 $spec = $options[$fieldId]['attributes'];
-                switch ($spec['html_type']) {
-                  case 'Text':
-                    // Other data types like money would require some extra 
validation
-                    // FIXME: crmEditable currently does not support any 
validation rules :(
-                    $supportedDataTypes = array('Float', 'String', 'Int');
-                    $editable = in_array($spec['data_type'], 
$supportedDataTypes);
-                    break;
+                if ($spec['is_view'] == '0') {
+                  switch ($spec['html_type']) {
+                    case 'Text':
+                      // Other data types like money would require some extra 
validation
+                      // FIXME: crmEditable currently does not support any 
validation rules :(
+                      $supportedDataTypes = array('Float', 'String', 'Int');
+                      $editable = in_array($spec['data_type'], 
$supportedDataTypes);
+                      break;
 
-                  case 'TextArea':
-                    $editable = TRUE;
-                    $fieldAttributes['data-type'] = 'textarea';
-                    break;
+                    case 'TextArea':
+                      $editable = TRUE;
+                      $fieldAttributes['data-type'] = 'textarea';
+                      break;
 
-                  case 'Radio':
-                  case 'Select':
-                  case 'Select Country':
-                  case 'Select State/Province':
-                    $editable = TRUE;
-                    $fieldAttributes['data-type'] = $spec['data_type'] == 
'Boolean' ? 'boolean' : 'select';
-                    if (!$spec['is_required']) {
-                      $fieldAttributes['data-empty-option'] = ts('- none -');
-                    }
-                    break;
+                    case 'Radio':
+                    case 'Select':
+                    case 'Select Country':
+                    case 'Select State/Province':
+                      $editable = TRUE;
+                      $fieldAttributes['data-type'] = $spec['data_type'] == 
'Boolean' ? 'boolean' : 'select';
+                      if (!$spec['is_required']) {
+                        $fieldAttributes['data-empty-option'] = ts('- none -');
+                      }
+                      break;
+                  }
                 }
               }
               if ($editable) {

-- 
To view, visit https://gerrit.wikimedia.org/r/268699
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idfc72d1861534b974b3df186e9aa898d0b8cb32e
Gerrit-PatchSet: 1
Gerrit-Project: wikimedia/fundraising/crm/civicrm
Gerrit-Branch: master
Gerrit-Owner: Ejegg <[email protected]>
Gerrit-Reviewer: Awight <[email protected]>
Gerrit-Reviewer: Eileen <[email protected]>
Gerrit-Reviewer: Ejegg <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to