some more migrating to new settings class, refs #1325

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2013-12-15 15:37:07 +01:00
parent 352749c798
commit e7c53e4abb
3 changed files with 32 additions and 49 deletions

View File

@@ -360,8 +360,7 @@ if ($page == 'customers'
if ($tickets !== false && isset($tickets[0])) { if ($tickets !== false && isset($tickets[0])) {
foreach ($tickets as $ticket) { foreach ($tickets as $ticket) {
$now = time(); $now = time();
// FIXME ticket -> settings $mainticket = ticket::getInstanceOf($userinfo, (int)$ticket);
$mainticket = ticket::getInstanceOf($userinfo, $settings, (int)$ticket);
$mainticket->Set('lastchange', $now, true, true); $mainticket->Set('lastchange', $now, true, true);
$mainticket->Set('lastreplier', '1', true, true); $mainticket->Set('lastreplier', '1', true, true);
$mainticket->Set('status', '3', true, true); $mainticket->Set('status', '3', true, true);

View File

@@ -15,60 +15,47 @@
* *
*/ */
function buildFormEx($form, $part = '') function buildFormEx($form, $part = '') {
{
global $settings, $theme;
$fields = ''; $fields = '';
if(validateFormDefinition($form)) if (validateFormDefinition($form)) {
{ foreach ($form['groups'] as $groupname => $groupdetails) {
foreach($form['groups'] as $groupname => $groupdetails)
{
// show overview // show overview
if($part == '') if ($part == '') {
{ if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
if(isset($groupdetails['title']) && $groupdetails['title'] != '')
{
$fields .= getFormOverviewGroupOutput($groupname, $groupdetails); $fields .= getFormOverviewGroupOutput($groupname, $groupdetails);
} }
} }
// only show one section // only show one section
elseif($part != '' && ($groupname == $part || $part == 'all')) elseif ($part != '' && ($groupname == $part || $part == 'all')) {
{
/** /**
* this part checks for the 'websrv_avail' entry in the settings-array * this part checks for the 'websrv_avail' entry in the settings-array
* if found, we check if the current webserver is in the array. If this * if found, we check if the current webserver is in the array. If this
* is not the case, we change the setting type to "hidden", #502 * is not the case, we change the setting type to "hidden", #502
*/ */
$do_show = true; $do_show = true;
if(isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) if (isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) {
{ $websrv = Settings::Get('system.webserver');
$websrv = $settings['system']['webserver']; if (!in_array($websrv, $groupdetails['websrv_avail'])) {
if(!in_array($websrv, $groupdetails['websrv_avail']))
{
$do_show = false; $do_show = false;
} }
} }
if($do_show) if ($do_show) {
{ if (isset($groupdetails['title']) && $groupdetails['title'] != '') {
if(isset($groupdetails['title']) && $groupdetails['title'] != '')
{
$fields .= getFormGroupOutput($groupname, $groupdetails); $fields .= getFormGroupOutput($groupname, $groupdetails);
} }
if(validateFieldDefinition($groupdetails)) if (validateFieldDefinition($groupdetails)) {
{
// Prefetch form fields // Prefetch form fields
foreach($groupdetails['fields'] as $fieldname => $fielddetails) foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
{
$groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails)); $groupdetails['fields'][$fieldname] = array_merge_prefix($fielddetails, $fielddetails['type'], prefetchFormFieldData($fieldname, $fielddetails));
$form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname]; $form['groups'][$groupname]['fields'][$fieldname] = $groupdetails['fields'][$fieldname];
} }
// Collect form field output // Collect form field output
foreach($groupdetails['fields'] as $fieldname => $fielddetails) foreach ($groupdetails['fields'] as $fieldname => $fielddetails) {
{
$fields .= getFormFieldOutput($fieldname, $fielddetails); $fields .= getFormFieldOutput($fieldname, $fielddetails);
} }
} }

View File

@@ -17,16 +17,16 @@
* *
*/ */
function getFormGroupOutput($groupname, $groupdetails) function getFormGroupOutput($groupname, $groupdetails) {
{
global $lng, $theme; global $lng, $theme;
eval("\$group = \"" . getTemplate("settings/settings_group") . "\";"); eval("\$group = \"" . getTemplate("settings/settings_group") . "\";");
return $group; return $group;
} }
function getFormOverviewGroupOutput($groupname, $groupdetails) function getFormOverviewGroupOutput($groupname, $groupdetails) {
{
global $lng, $settings, $filename, $s, $theme; global $lng, $filename, $s, $theme;
$group = ''; $group = '';
$title = $groupdetails['title']; $title = $groupdetails['title'];
@@ -53,7 +53,7 @@ function getFormOverviewGroupOutput($groupname, $groupdetails)
$options = ''; $options = '';
foreach($options_array as $value => $vtitle) foreach($options_array as $value => $vtitle)
{ {
$options .= makeoption($vtitle, $value, $settings[$fielddetails['settinggroup']][$fielddetails['varname']]); $options .= makeoption($vtitle, $value, Settings::Get($fielddetails['settinggroup'].'.'.$fielddetails['varname']));
} }
$option.= $fielddetails['label'].':&nbsp;'; $option.= $fielddetails['label'].':&nbsp;';
$option.= '<select class="dropdown_noborder" name="'.$fieldname.'">'; $option.= '<select class="dropdown_noborder" name="'.$fieldname.'">';
@@ -64,30 +64,27 @@ function getFormOverviewGroupOutput($groupname, $groupdetails)
else else
{ {
$option.= $lng['admin']['activated'].':&nbsp;'; $option.= $lng['admin']['activated'].':&nbsp;';
$option.= makeyesno($fieldname, '1', '0', $settings[$fielddetails['settinggroup']][$fielddetails['varname']]); $option.= makeyesno($fieldname, '1', '0', Settings::Get($fielddetails['settinggroup'].'.'.$fielddetails['varname']));
$activated = (int)$settings[$fielddetails['settinggroup']][$fielddetails['varname']]; $activated = (int)Settings::Get($fielddetails['settinggroup'].'.'.$fielddetails['varname']);
} }
} }
} }
} }
/** /**
* this part checks for the 'websrv_avail' entry in the settings-array * this part checks for the 'websrv_avail' entry in the settings
* if found, we check if the current webserver is in the array. If this * if found, we check if the current webserver is in the array. If this
* is not the case, we change the setting type to "hidden", #502 * is not the case, we change the setting type to "hidden", #502
*/ */
$do_show = true; $do_show = true;
if(isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) if (isset($groupdetails['websrv_avail']) && is_array($groupdetails['websrv_avail'])) {
{ $websrv = Settings::Get('system.webserver');
$websrv = $settings['system']['webserver']; if (!in_array($websrv, $groupdetails['websrv_avail'])) {
if(!in_array($websrv, $groupdetails['websrv_avail']))
{
$do_show = false; $do_show = false;
} }
} }
if($do_show) if ($do_show) {
{
eval("\$group = \"" . getTemplate("settings/settings_overviewgroup") . "\";"); eval("\$group = \"" . getTemplate("settings/settings_overviewgroup") . "\";");
} }
return $group; return $group;