Browse Source

Add extra fields value update exception when launching scripts from the command line - refs BT#12885

Yannick Warnier 7 years ago
parent
commit
738831304c
1 changed files with 11 additions and 3 deletions
  1. 11 3
      main/inc/lib/extra_field_value.lib.php

+ 11 - 3
main/inc/lib/extra_field_value.lib.php

@@ -106,12 +106,20 @@ class ExtraFieldValue extends Model
 
         // Parse params.
         foreach ($extraFields as $fieldDetails) {
-            if ($fieldDetails['visible_to_self'] != 1 && !api_is_platform_admin(true, true)) {
-                continue;
-            }
 
             $field_variable = $fieldDetails['variable'];
 
+            // if the field is not visible to the user in the end, we need to apply special rules
+            if ($fieldDetails['visible_to_self'] != 1) {
+                //only admins should be able to add those values
+                if (!api_is_platform_admin(true, true)) {
+                    // although if not admin but sent through a CLI script, we should accept it as well
+                    if (PHP_SAPI != 'cli') {
+                        continue; //not a CLI script, so don't write the value to DB
+                    }
+                }
+            }
+
             if (isset($params['extra_'.$field_variable])) {
                 $value = $params['extra_'.$field_variable];
             } else {