$s) { $core->auth->user_prefs->addWorkspace($ws); foreach ($s as $k => $v) { if ($_POST['s_type'][$ws][$k] == 'array') { $v = json_decode($v, true); } $core->auth->user_prefs->$ws->put($k, $v); } } dcPage::addSuccessNotice(__('Preferences successfully updated')); http::redirect($p_url); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Global prefs update if (!empty($_POST['gs']) && is_array($_POST['gs'])) { try { foreach ($_POST['gs'] as $ws => $s) { $core->auth->user_prefs->addWorkspace($ws); foreach ($s as $k => $v) { if ($_POST['gs_type'][$ws][$k] == 'array') { $v = json_decode($v, true); } $core->auth->user_prefs->$ws->put($k, $v, null, null, true, true); } } dcPage::addSuccessNotice(__('Preferences successfully updated')); http::redirect($p_url . '&part=global'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } $part = !empty($_GET['part']) && $_GET['part'] == 'global' ? 'global' : 'local'; function prefLine($id, $s, $ws, $field_name, $strong_label) { if ($s['type'] == 'boolean') { $field = form::combo(array($field_name . '[' . $ws . '][' . $id . ']', $field_name . '_' . $ws . '_' . $id), array(__('yes') => 1, __('no') => 0), $s['value'] ? 1 : 0); } else { if ($s['type'] == 'array') { $field = form::field(array($field_name . '[' . $ws . '][' . $id . ']', $field_name . '_' . $ws . '_' . $id), 40, null, html::escapeHTML(json_encode($s['value']))); } else { $field = form::field(array($field_name . '[' . $ws . '][' . $id . ']', $field_name . '_' . $ws . '_' . $id), 40, null, html::escapeHTML($s['value'])); } } $type = form::hidden(array($field_name . '_type' . '[' . $ws . '][' . $id . ']', $field_name . '_' . $ws . '_' . $id . '_type'), html::escapeHTML($s['type'])); $slabel = $strong_label ? '%s' : '%s'; return '
' . __('Setting ID') . ' | ' . "\n" . '' . __('Value') . ' | ' . "\n" . '' . __('Type') . ' | ' . "\n" . '' . __('Description') . ' | ' . "\n" . '
---|