protected static function add_legacy_condition($availability, $condition, $show) {
        $showtext = ($show ? 'true' : 'false');
        if (is_null($availability)) {
            $availability = '{"op":"&","showc":[' . $showtext .
                    '],"c":[' . $condition . ']}';
        } else {
            $matches = array();
            if (!preg_match('~^({"op":"&","showc":\[(?:true|false)(?:,(?:true|false))*)' .
                    '(\],"c":\[.*)(\]})$~', $availability, $matches)) {
                throw new \coding_exception('Unexpected availability value');
            }
            $availability = $matches[1] . ',' . $showtext . $matches[2] .
                    ',' . $condition . $matches[3];
        }
        return $availability;
    }
protected static function add_legacy_condition($availability, $condition, $show) {
        $showtext = ($show ? 'true' : 'false');
        if (is_null($availability)) {
            $availability = '{"op":"&","showc":[' . $showtext .
                    '],"c":[' . $condition . ']}';
        } else {
            $matches = array();
            if (!preg_match('~^({"op":"&","showc":\[(?:true|false)(?:,(?:true|false))*)' .
                    '(\],"c":\[.*)(\]})$~', $availability, $matches)) {
                throw new \coding_exception('Unexpected availability value');
            }
            $availability = $matches[1] . ',' . $showtext . $matches[2] .
                    ',' . $condition . $matches[3];
        }
        return $availability;
    }
protected static function add_legacy_condition ( $ availability , $ condition , $ show ) { $ showtext = ( $ show ? 'true' : 'false' ) ; if ( is_null ( $ availability ) ) { $ availability = '{"op":"&","showc":[' . $ showtext . '],"c":[' . $ condition . ']}' ; } else { $ matches = array ( ) ; if ( ! preg_match ( '~^({"op":"&","showc":\[(?:true|false)(?:,(?:true|false))*)' . '(\],"c":\[.*)(\]})$~' , $ availability , $ matches ) ) { throw new \ coding_exception ( 'Unexpected availability value' ) ; } $ availability = $ matches [ 1 ] . ',' . $ showtext . $ matches [ 2 ] . ',' . $ condition . $ matches [ 3 ] ; } return $ availability ; }
Adds a condition to an AND group.

(For use during restore only.)

This function assumes that the activity either has no conditions, or
that it has only conditions added by this function.

@param string|null $availability Current availability conditions
@param string $condition Condition text '{...}'
@param bool $show True if 'show' option should be enabled
@return string New availability conditions
Adds a condition to an AND group .