Пример #1
0
function display_form()
{
    global $phpc_script, $phpc_token;
    $tbody = tag('tbody');
    foreach (get_config_options() as $element) {
        $text = $element[1];
        $input = create_config_input($element);
        $tbody->add(tag('tr', tag('th', $text), tag('td', $input)));
    }
    return tag('form', attributes("action=\"{$phpc_script}\"", 'method="post"'), tag('table', attributes("class=\"phpc-container\""), tag('caption', __('Create Calendar')), tag('tfoot', tag('tr', tag('td', attributes('colspan="2"'), create_hidden('phpc_token', $phpc_token), create_hidden('action', 'calendar_form'), create_hidden('submit_form', 'submit_form'), create_submit(__('Submit'))))), $tbody));
}
Пример #2
0
function config_form()
{
    global $phpc_cal, $phpc_script, $vars;
    $tbody = tag('tbody');
    foreach (get_config_options() as $element) {
        $name = $element[0];
        $text = $element[1];
        $default = $phpc_cal->{$name};
        $input = create_config_input($element, $default);
        $tbody->add(tag('tr', tag('th', $text), tag('td', $input)));
    }
    $hidden_div = tag('div', create_hidden('action', 'cadmin_submit'));
    if (isset($vars['phpcid'])) {
        $hidden_div->add(create_hidden('phpcid', $vars['phpcid']));
    }
    return tag('div', attrs('id="phpc-config"'), tag('form', attrs("action=\"{$phpc_script}\"", 'method="post"'), $hidden_div, tag('table', attrs('class="phpc-container form ui-widget"'), tag('tfoot', tag('tr', tag('td', ''), tag('td', create_submit(__('Submit'))), $tbody)))));
}
Пример #3
0
function cadmin_submit()
{
    global $phpcid, $phpc_cal, $vars, $phpcdb, $phpc_script;
    if (!$phpc_cal->can_admin()) {
        return tag('div', __('Permission denied'));
    }
    foreach (get_config_options() as $item) {
        if ($item[2] == PHPC_CHECK) {
            if (isset($vars[$item[0]])) {
                $value = "1";
            } else {
                $value = "0";
            }
        } else {
            if (isset($vars[$item[0]])) {
                $value = $vars[$item[0]];
            } else {
                soft_error($item[0] . __(" was not set."));
            }
        }
        $phpcdb->update_config($phpcid, $item[0], $value);
    }
    return message_redirect(__('Updated options'), "{$phpc_script}?action=cadmin&phpcid={$phpcid}");
}
/**
* Process configuration options from database
* either system wide or user specific by setting
* the global variable
*
* @param int $user_id
*
* @return bool true
*/
function process_config_options($user_id = null)
{
    $config_options = array();
    if (get_config_options($user_id, $config_options)) {
        foreach ($config_options as $config_option) {
            $param_value = $config_option['value'];
            // Prepare the value since everything is stored as a string
            switch ($param_value) {
                case '1':
                case '0':
                    $param_value = (bool) $param_value;
                    break;
                case is_numeric($param_value):
                    $param_value = (int) $param_value;
                    break;
                default:
                    // we assume it is a string and set as-is
                    break;
            }
            $GLOBALS[$config_option['parameter']] = $param_value;
        }
    }
    return true;
}