AuthShield = $AuthShield; $this->container=(null!==$container) ? $container : $AuthShield->getAppShield()->getContainer(); } /** public function auth(\UMA\JsonRpc\Request $request){ return 'admin' === $this->container->get('webfan.app.fsm.user')->getCurrentState()->getName(); } * {@inheritdoc} */ public function __invoke(\UMA\JsonRpc\Request $request): \UMA\JsonRpc\Response { $params = $request->params(); $config = $this->AuthShield->getAppShield()->config->export(); if(!file_exists($params->file)){ return new \UMA\JsonRpc\Error($request->id(), sprintf('File `%s` not found', $params->file)); } try{ $file2 = str_replace('config.xml', 'config.custom.xml', $params->file); $file = (file_exists($file2)) ? $file2 : $params->file; $f = rtrim(dirname(dirname(dirname($file))), \DIRECTORY_SEPARATOR.'/ ') .\DIRECTORY_SEPARATOR.'config'.\DIRECTORY_SEPARATOR.'module-configs'.\DIRECTORY_SEPARATOR.basename(dirname($file)).\DIRECTORY_SEPARATOR.'preferences.json'; $file4 = dirname($f).\DIRECTORY_SEPARATOR.'config.custom.xml'; $file = (file_exists($file4)) ? $file4 : $file; $WidgetConfig = new \webfan\hps\Widget\Config($file); $WidgetConfig->setPreference($params->key, $params->value, false, true); $d = $WidgetConfig->saveXML(); file_put_contents(str_replace('config.xml', 'config.custom.xml', $params->file), $d); if(!is_dir(dirname($f))){ mkdir(dirname($f), 0755, true); } file_put_contents($file4, $d); $cnf = []; $context = \frdl\Context::create($cnf); $preferences = $WidgetConfig->getPreferences(false); foreach($preferences as $k => $v){ $context->set($k, $v); } $all = json_encode($context->all()); file_put_contents($f,$all); file_put_contents(dirname($params->file).\DIRECTORY_SEPARATOR.'preferences.json', $all); }catch(\Exception $e){ return new \UMA\JsonRpc\Error($request->id(), $e->getMessage()); } return new \UMA\JsonRpc\Success($request->id(), 'Config changed'); } protected function get_inner_html( $node ) { $innerHTML= ''; $children = $node->childNodes; foreach ($children as $child) { $innerHTML .= $child->ownerDocument->saveXML( $child ); } return $innerHTML; } public function getSpec(): ?\stdClass { return \json_decode(<<<'JSON' { "$schema": "https://json-schema.org/draft-07/schema#", "type": ["object"], "properties": { "file" : { type : ["string"] }, "key" : { type : ["string"] }, "value" : { type : ["string"] } }, "required" : ["file", "key", "value"], "additionalProperties": false } JSON ); } } __halt_compiler();----SIGNATURE:----vR3OoZzcHVBhAj3MeOdZ6K7/yGFwUz8c6AV/PDUFOfVSwTQP/lh2VZNWeAVO2Lz/rq4rE4rzVdN8BPVoHMn6mcYsVlbDuQU8UVA1Wl8MYJ4r8wQMLOAmOBJwsOAHAgBC5AL9EN/fSgyW+4m+N9yW2+p4GmyXJwlC43A42C08uKNZw+4Ex62TDL4gGDvoHeWe2kjmO5+F517/p6qMNAV11y2mIX9wM4qkeC4wJcvFVhz5cYS84y8qYIdA9Gxf+2QZM0eex9HMTP7lMDRYM/kO2vim5cKr/rFmpp4chJqbG0m/LvbpBfjPI1cuKFcEpSgxdJ0/wzcaT83nBeMaixVwkvZ45wZ8ytr35BTujNs67bPgdb8583NnS9qjBnjM/PL01g2MwUtjSZYEWNOcsgg7AOrgPKDOhAiM4RBiyUweKltehVkqNvcVASUTX/oMHXkpqqGHvMV53GxYn2wxi3r6u4+icThCZuOb9TxwxBVFISlE3CyDHvd2CL26CEIUdEFYK+mzpsXocOFoa7ZTuFDvwQzbVcKTE/rHjyn+Qlu2hsdMHxmgVJxYNVq/j+I3mS1jq67xffaaRx45WaOrkIkdrUqxAPtg+Tss1UsGgGKZmSrQF0dWiH1HnTYQt2RcEeVrhaNFgRiHx/EbxtJPAhiThGGbfwqBFJzOmGz7voSmt0g=----ATTACHMENT:----Mzc5Nzg2ODY4MDE4NzEwNyAyNjU0NDg3NTQ3MDUyNTc5IDk0MTE2ODE4MDY0NjQ0Ng==