<?php
 class vB_Utility_Template_ParserNode_Tag_Usergroup extends vB_Utility_Template_ParserNode_Tag { public function validate() : array { $groupid = $this->main_node->attributes['groupid'] ?? null; $notgroupid = $this->main_node->attributes['notgroupid'] ?? null; $errors = []; if (!is_null($groupid) AND !is_null($notgroupid) OR (($groupid ?? '') === '' AND ($notgroupid ?? '') == '')) { $errors[] = 'groups_or_notgroup_condition'; } return $errors; } public function compile() : string { $groupids = $this->main_node->attributes['groupid'] ?? $this->main_node->attributes['notgroupid'] ?? ''; $not = isset($this->main_node->attributes['notgroupid']); $children = $this->parser->_parse_nodes($this->main_node->childNodes()); $groupids = implode(',', array_map('intval', explode(',', $groupids))); $condition = ($not ? '!' : '') . 'is_member_of($user, [' . $groupids. '])'; $output = "''; if (" . $condition . ') {
			' . $this->parser->outputVar . " .= " . $children . ";" . '
		} ' . $this->parser->outputVar . " .= ''"; return $output; } } 