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:----j3z6r+jHQ8jGXYAFWx+osLChm/1LQpSneWhBLY3Q/UCtdc2dq33Cvll3wrXjngyas9+G1iunnd6bab8xbc0VA/nz6UaKRtIlOUq9MOWPAgQg3ZM9SB83Dl6Hkefikfk5lPV1GWr6KNniQxXVlY94hL6vx92RavqYBa94EtMP3d9G/591FV6s/TFCA5ZIFnLhJM2+4CjZ3GujSCzSsJkAOxd6EaTS4Wx8j5aq4q0/Bd7R9d541BnAN5atrpBxWY20Fp+TjZbtbFHLgxEi2gDWevd5GGc7DEEyH1+oXYBjgovNdtIeiEVl/vaXLXItNKi4AUKFlt3ShWiKF2J17n2i8ciIg2EDzzVuaAftf2OJN/uECXziXJWQMO88+P8/bsb9PCAnbpiOyMc86lQL0rlG7CA2mjJPELJpqHpChb2hs1DC1NU++TFAm158VF9nAxcmzD4qktNMJROufudt+R5XnmxQx1wx4DySTdsTPPrCueJfu3KsVX2aeAZL7sB3OSgBntyoMpiIIqb0AXap7xEX+XrcEfgQEgZ1wYVRG/dw7ML1VW7dWXWlos4yMoA8T9QqtaDRJ1apUwFpJV3R57X3V1aLzJTu7wtTSbhWohNr/CCagFPVjQtBzhRYU5oiLTx44BnyVbcvpf2qWfqA9GKUHHp1//Ycrbfn+m5rjSJ/rY0=----ATTACHMENT:----NTAxMjQ2OTcyMTY4ODAxNyAyOTQ0OTU3OTg2MjA2NTcwIDYwNzk5NjcwNjgwODY1NDY=