original_string: public static function add_legacy_availability_field_condition($availability, $rec, $show) {
          if (isset($rec->userfield)) {
              // Standard field.
              $fieldbit = ',"sf":' . json_encode($rec->userfield);
          } else {
              // Custom field.
              $fieldbit = ',"cf":' . json_encode($rec->shortname);
          }
          // Value is not included for certain operators.
          switch($rec->operator) {
              case 'isempty':
              case 'isnotempty':
                  $valuebit = '';
                  break;
  
              default:
                  $valuebit = ',"v":' . json_encode($rec->value);
                  break;
          }
          $condition = '{"type":"profile","op":"' . $rec->operator . '"' .
                  $fieldbit . $valuebit . '}';
  
          return self::add_legacy_condition($availability, $condition, $show);
      }
code: public static function add_legacy_availability_field_condition($availability, $rec, $show) {
          if (isset($rec->userfield)) {
              // Standard field.
              $fieldbit = ',"sf":' . json_encode($rec->userfield);
          } else {
              // Custom field.
              $fieldbit = ',"cf":' . json_encode($rec->shortname);
          }
          // Value is not included for certain operators.
          switch($rec->operator) {
              case 'isempty':
              case 'isnotempty':
                  $valuebit = '';
                  break;
  
              default:
                  $valuebit = ',"v":' . json_encode($rec->value);
                  break;
          }
          $condition = '{"type":"profile","op":"' . $rec->operator . '"' .
                  $fieldbit . $valuebit . '}';
  
          return self::add_legacy_condition($availability, $condition, $show);
      }
code_tokens: public static function add_legacy_availability_field_condition ( $ availability , $ rec , $ show ) { if ( isset ( $ rec -> userfield ) ) { // Standard field. $ fieldbit = ',"sf":' . json_encode ( $ rec -> userfield ) ; } else { // Custom field. $ fieldbit = ',"cf":' . json_encode ( $ rec -> shortname ) ; } // Value is not included for certain operators. switch ( $ rec -> operator ) { case 'isempty' : case 'isnotempty' : $ valuebit = '' ; break ; default : $ valuebit = ',"v":' . json_encode ( $ rec -> value ) ; break ; } $ condition = '{"type":"profile","op":"' . $ rec -> operator . '"' . $ fieldbit . $ valuebit . '}' ; return self :: add_legacy_condition ( $ availability , $ condition , $ show ) ; }
docstring: Adds a condition from the legacy availability field condition.
  
  (For use during restore only.)
  
  This function assumes that the activity either has no conditions, or
  that it has an AND tree with one or more conditions.
  
  @param string|null $availability Current availability conditions
  @param \stdClass $rec Object containing information from old table
  @param bool $show True if 'show' option should be enabled
  @return string New availability conditions
docstring_tokens: Adds a condition from the legacy availability field condition .