/**
 * set the html for user settings page
 * this function is registered in xajax
 * @return xajaxResponse every xajax registered function needs to return this object
 */
function action_get_user_settings_page()
{
    global $logging;
    global $user;
    global $user_settings_table_configuration;
    global $firstthingsfirst_portal_title;
    global $user_start_time_array;
    $logging->info("USER_ACTION " . __METHOD__ . " (user="******")");
    # store start time
    $user_start_time_array[__METHOD__] = microtime(TRUE);
    # create necessary objects
    $result = new Result();
    $response = new xajaxResponse();
    $html_database_table = new HtmlDatabaseTable($user_settings_table_configuration);
    # create an array with selection of fields that user may change
    $db_fields_array = array(DB_ID_FIELD_NAME, USER_NAME_FIELD_NAME, USER_PW_FIELD_NAME, USER_LANG_FIELD_NAME, USER_DATE_FORMAT_FIELD_NAME, USER_DECIMAL_MARK_FIELD_NAME, USER_LINES_PER_PAGE_FIELD_NAME, USER_THEME_FIELD_NAME);
    $user_record_key_string = DatabaseTable::_get_encoded_key_string(array(DB_ID_FIELD_NAME => $user->get_id()));
    # set page, title, explanation and navigation
    $response->assign("page_title", "innerHTML", translate("LABEL_USER_SETTINGS_TITLE"));
    $response->assign("navigation_container", "innerHTML", get_page_navigation(PAGE_TYPE_USER_SETTINGS));
    $html_database_table->get_page(translate("LABEL_USER_SETTINGS_TITLE"), $result);
    $response->assign("main_body", "innerHTML", $result->get_result_str());
    # get action pane for current user
    $html_database_table->get_record($user, USER_TABLE_NAME, $user_record_key_string, $db_fields_array, $result);
    $response->custom_response->assign_with_effect("action_pane", $result->get_result_str());
    # set footer
    $response->assign("footer_text", "innerHTML", " ");
    # check post conditions
    if (check_postconditions($result, $response) == FALSE) {
        return $response;
    }
    # log total time for this function
    $logging->info(get_function_time_str(__METHOD__));
    return $response;
}
示例#2
0
/**
 * get html of one specified record (called when user edits or inserts a record)
 * this function is called by functions: action_get_insert_list_record or action_get_update_list_record
 * @param string $list_title title of list
 * @param string $key_string comma separated name value pairs
 * @return xajaxResponse every xajax registered function needs to return this object
 */
function get_list_record($list_title, $key_string)
{
    global $logging;
    global $user;
    global $list_table_configuration;
    global $user_start_time_array;
    global $firstthingsfirst_lang;
    $logging->trace("get list record (list_title={$list_title}, key_string={$key_string})");
    # create necessary objects
    $result = new Result();
    $response = new xajaxResponse();
    $html_database_table = new HtmlDatabaseTable($list_table_configuration);
    # create list table object
    $list_table = new ListTable($list_title);
    if ($list_table->get_is_valid() == FALSE) {
        $logging->warn("create list object returns false");
        $error_message_str = $list_table->get_error_message_str();
        $error_log_str = $list_table->get_error_log_str();
        $error_str = $list_table->get_error_str();
        set_error_message("tab_list_id", "below", $error_message_str, $error_log_str, $error_str, $response);
        return $response;
    }
    # set action pane
    $focus_element_name = $html_database_table->get_record($list_table, $list_title, $key_string, array(), $result);
    $response->custom_response->assign_with_effect('action_pane', $result->get_result_str());
    # check post conditions
    if (check_postconditions($result, $response) == FALSE) {
        return $response;
    }
    # focus on lower part of page
    $response->custom_response->focus("{$focus_element_name}");
    # set button action for attachments
    $user_name = $user->get_name();
    $response->custom_response->script("\r\n        var button = \$('#button_upload'), interval;\r\n        new AjaxUpload(button,\r\n        {\r\n            action: 'php/Html.Upload.php?user_name={$user_name}&lang={$firstthingsfirst_lang}',\r\n            name: 'upload_file',\r\n            onSubmit: function(file, ext)\r\n            {\r\n                this.disable();\r\n                \$('#upload_animation').html('<img src=\"images/wait_animation.gif\">');\r\n            },\r\n            onComplete: function(file, response)\r\n            {\r\n                this.enable();\r\n                if (response.substring(0, 6) != 'SUCCES')\r\n                {\r\n                    \$('#upload_animation').html('&nbsp;');\r\n                    showTooltip('#button_upload', response, 'error', 'right');\r\n                }\r\n                else\r\n                {\r\n                    \$('#upload_animation').html('');\r\n                    handleFunction('action_add_attachment', '{$list_title}', \$('#upload_attachment_id').html(), response.substring(7));\r\n                }\r\n            }\r\n        });\r\n    ");
    $logging->trace("got list record");
    return $response;
}
/**
 * get html of one specified record (called when user edits or inserts a record)
 * this function is registered in xajax
 * @param string $title title of page
 * @param string $key_string comma separated name value pairs
 * @return xajaxResponse every xajax registered function needs to return this object
 */
function action_get_user_admin_record($title, $key_string)
{
    global $logging;
    global $user;
    global $user_admin_table_configuration;
    global $user_start_time_array;
    $logging->info("USER_ACTION " . __METHOD__ . " (user="******", title={$title}, key_string={$key_string})");
    # store start time
    $user_start_time_array[__METHOD__] = microtime(TRUE);
    # create necessary objects
    $result = new Result();
    $response = new xajaxResponse();
    $html_database_table = new HtmlDatabaseTable($user_admin_table_configuration);
    # get html for one user record
    $focus_element_name = $html_database_table->get_record($user, $title, $key_string, array(), $result);
    # check post conditions
    if (check_postconditions($result, $response) == FALSE) {
        return $response;
    }
    # set action pane
    $response->custom_response->assign_with_effect("action_pane", $result->get_result_str());
    # focus on lower part of page
    $response->custom_response->focus("{$focus_element_name}");
    # log total time for this function
    $logging->info(get_function_time_str(__METHOD__));
    return $response;
}