'editgamesettings', 'setPointsPreset' => 'editgamesettings' ); public $presets; public function onLoad() { $this->presets = Core::getObject('session')->loadXML( Core::getSetting('pluginpath') . $this->id . '/presets.xml' ); } public function onOutput() { $CustomPoints = array(); if (Core::getObject('gbx')->query('GetRoundCustomPoints')) { $CustomPoints = Core::getObject('gbx')->getResponse(); } if (!is_array($CustomPoints)) { $CustomPoints = array(); } if (!Core::getObject('session')->checkPerm('editgamesettings')) { return; } echo "
"; echo "
"; echo "
" . (defined('pt_custom') ? pt_custom : 'Custom Points') . "
"; echo "
" . (defined('pt_commasep') ? pt_commasep : 'Comma separated') . "
"; echo "
"; echo "
"; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo "
"; echo "
" . (defined('pt_presets') ? pt_presets : 'Presets') . "
"; if ($this->presets && is_object($this->presets)) { foreach ($this->presets->children() as $preset) { $name = isset($preset['name']) ? $preset['name'] : 'Preset'; $points = isset($preset['points']) ? (string)$preset['points'] : ''; echo "
"; echo " "; if (strlen($points) > 25) { echo substr($points, 0, 25) . "..."; } else { echo $points; } echo "
"; echo "
"; } } echo "
"; echo ""; echo ""; echo ""; echo "
"; } public function setPoints() { if (!array_key_exists('points', $_REQUEST)) return; $str = preg_replace("/[^0-9,]/", "", $_REQUEST['points']); $array = $this->makeIntArray(explode(',', $str)); Core::getObject('actions')->add('SetRoundCustomPoints', $array, true); } public function setPointsPreset() { if (!array_key_exists('preset', $_REQUEST)) return; $str = preg_replace("/[^0-9,]/", "", $_REQUEST['preset']); $array = $this->makeIntArray(explode(',', $str)); Core::getObject('actions')->add('SetRoundCustomPoints', $array, true); } private function makeIntArray($array) { foreach ($array as $key => $value) { $array[$key] = (int)$value; } return $array; } }