/** * set the html for user admin page * this function is registered in xajax * @return xajaxResponse every xajax registered function needs to return this object */ function action_get_user_admin_page() { global $logging; global $user; global $user_admin_table_configuration; 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_admin_table_configuration); # set page, title, explanation and navigation $response->assign("page_title", "innerHTML", translate("LABEL_USER_ADMIN_TITLE")); $response->assign("navigation_container", "innerHTML", get_page_navigation(PAGE_TYPE_USER_ADMIN)); $html_database_table->get_page(translate("LABEL_USER_ADMIN_TITLE"), $result); $response->assign("main_body", "innerHTML", $result->get_result_str()); # set content $html_database_table->get_content($user, HTML_NO_LIST_PERMISSION_CHECK, "", DATABASETABLE_UNKWOWN_PAGE, $result); $response->custom_response->assign_with_effect(PORTAL_CSS_NAME_PREFIX . "content_pane", $result->get_result_str()); # set action pane $html_str = $html_database_table->get_action_bar(USER_TABLE_NAME, ""); $response->custom_response->assign_and_show("action_pane", $html_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; }
/** * 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; }
/** * set the html for a list page * this function is registered in xajax * @param string $list_title title of list * @return xajaxResponse every xajax registered function needs to return this object */ function action_get_list_page($list_title) { global $logging; global $user; global $list_table_configuration; global $user_start_time_array; $logging->info("USER_ACTION " . __METHOD__ . " (user="******", list_title={$list_title})"); # store start time $user_start_time_array[__METHOD__] = microtime(TRUE); # set current list name $user->set_current_list_name($list_title); # create necessary objects $result = new Result(); $response = new xajaxResponse(); $html_database_table = new HtmlDatabaseTable($list_table_configuration); # set page, title, explanation and navigation $response->assign("page_title", "innerHTML", $list_title); $response->assign("navigation_container", "innerHTML", get_page_navigation(PAGE_TYPE_LIST)); $html_database_table->get_page($list_title, $result); $response->assign("main_body", "innerHTML", $result->get_result_str()); # set action pane $html_str = $html_database_table->get_action_bar($list_title, ""); $response->custom_response->assign_and_show('action_pane', $html_str); # 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 content $html_database_table->get_content($list_table, $list_title, "", DATABASETABLE_UNKWOWN_PAGE, $result); $response->custom_response->assign_with_effect(LIST_CSS_NAME_PREFIX . "content_pane", $result->get_result_str()); # set footer $response->assign("footer_text", "innerHTML", get_footer($list_table->get_creator_modifier_array())); # 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; }
/** * set the html for the listbuilder page * this function is registered in xajax * @param string $list_title title of list * @return xajaxResponse every xajax registered function needs to return this object */ function action_get_listbuilder_page($list_title) { global $logging; global $user; global $list_table_description; global $firstthingsfirst_field_descriptions; global $user_start_time_array; $field_types = array_keys($firstthingsfirst_field_descriptions); $old_list_loaded = FALSE; $logging->info("USER_ACTION " . __METHOD__ . " (user="******")"); # store start time $user_start_time_array[__METHOD__] = microtime(TRUE); # create necessary objects $response = new xajaxResponse(); $json = new Services_JSON(); # load list details when list title has been given if (strlen($list_title)) { $counter = 0; $definition = array(); $record = $list_table_description->select_record($list_title); # just create an empty list when list could not be loaded if (count($record) == 0) { $definition = array(0, FIELD_TYPE_DEFINITION_AUTO_NUMBER, "id", "", 1, FIELD_TYPE_DEFINITION_TEXT_LINE, "", "", 2, FIELD_TYPE_DEFINITION_ATTACHMENTS, DB_ATTACHMENTS_NAME, ""); $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $largest_id = 2; } else { $old_definition = $record[LISTTABLEDESCRIPTION_DEFINITION_FIELD_NAME]; $field_names = array_keys($old_definition); $largest_id = count($field_names) - 1; # create definition array from stored definition foreach ($field_names as $field_name) { $row = $old_definition[$field_name]; $definition[$counter * 4] = $counter; $definition[$counter * 4 + 1] = $row[0]; $definition[$counter * 4 + 2] = ListTable::_get_field_name($field_name); $definition[$counter * 4 + 3] = $row[1]; # copy in field_visible_in_overview if ($field_name == DB_ID_FIELD_NAME) { $definition[$counter * 4 + 3] = $row[2]; } $counter += 1; } $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $old_list_loaded = TRUE; } } else { $definition = array(0, FIELD_TYPE_DEFINITION_AUTO_NUMBER, "id", "", 1, FIELD_TYPE_DEFINITION_TEXT_LINE, "", "", 2, FIELD_TYPE_DEFINITION_ATTACHMENTS, DB_ATTACHMENTS_NAME, ""); $old_definition = htmlentities($json->encode($definition), ENT_QUOTES); $largest_id = 2; } # different page title when list title has been given if ($old_list_loaded == TRUE) { $page_title = translate("LABEL_MODIFY_LIST") . " '" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "'"; } else { $page_title = translate("LABEL_CONFIGURE_NEW_LIST"); } $html_str = ""; $html_str .= "\n\n <div id=\"listbuilder_statics_pane\" class=\"listbuilder_pane\">\n"; $html_str .= " </div> <!-- listbuilder_pane -->\n"; $html_str .= " <div id=\"listbuilder_configuration_pane\" class=\"listbuilder_pane\">\n"; $html_str .= " </div> <!-- listbuilder_pane -->\n"; #action bar $html_str .= " <div id=\"action_bar\" align=\"left\" valign=\"top\">\n"; $html_str .= " <div class=\"corner top_left_normal\"></div>\n"; $html_str .= " <div class=\"corner top_right_normal\"></div>\n"; # display the selection box to add a new column $html_str .= " " . get_select("add_select", 0, "") . "\n"; $args_str = "(document.getElementById('add_select').value, xajax.getFormValues('database_definition_form'), "; $args_str .= "document.getElementById('largest_id').innerHTML)"; $html_str .= " <span id=\"action_bar_button_add\">"; $html_str .= get_href(get_onclick(ACTION_INSERT_LISTBUILDER_ROW, HTML_NO_PERMISSION_CHECK, "", "", $args_str), translate("BUTTON_ADD_FIELD"), "icon_add"); $html_str .= "</span>\n"; # display the modify button when a title has been given if ($old_list_loaded == TRUE) { $args_str = "handleFunction(%22" . ACTION_MODIFY_LIST . "%22, %22" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "%22, document.getElementById(%22listbuilder_list_title_id%22).value, "; $args_str .= "document.getElementById(%22listbuilder_list_description_id%22).value, "; $args_str .= "xajax.getFormValues(%22database_definition_form%22))"; $html_str .= " <span id=\"action_bar_button_modify\">"; $html_str .= get_href(get_onclick_confirm(ACTION_MODIFY_LIST, $list_title, "action_bar_button_modify", "above", $args_str, translate("LABEL_CONFIRM_MODIFY")), translate("BUTTON_MODIFY_LIST"), "icon_accept"); $html_str .= "</span>\n"; } else { $args_str = "(document.getElementById(%27listbuilder_list_title_id%27).value, "; $args_str .= "document.getElementById(%27listbuilder_list_description_id%27).value, "; $args_str .= "xajax.getFormValues(%27database_definition_form%27))"; $html_str .= " <span id=\"action_bar_button_create\">"; $html_str .= get_href(get_onclick(ACTION_CREATE_LIST, HTML_NO_LIST_PERMISSION_CHECK, "action_bar_button_create", "above", $args_str), translate("BUTTON_CREATE_LIST"), "icon_accept"); $html_str .= "</span>\n"; } # add largest id $html_str .= " <span id=\"largest_id\" class=\"invisible_collapsed\">" . $largest_id . "</span>\n"; $html_str .= " <div class=\"corner bottom_left_normal\"></div>\n"; $html_str .= " <div class=\"corner bottom_right_normal\"></div>\n"; $html_str .= " </div> <!-- action_bar -->\n"; $response->assign("page_title", "innerHTML", $page_title); $response->assign("navigation_container", "innerHTML", get_page_navigation(PAGE_TYPE_LISTBUILDER)); $response->assign("main_body", "innerHTML", $html_str); # set html for listbuilder statics pane $html_str = ""; $html_str .= " <div class=\"corner top_left_normal\"></div>\n"; $html_str .= " <div class=\"corner top_right_normal\"></div>\n"; $html_str .= " <div class=\"listbuilder_title\">" . translate("LABEL_GENERAL_SETTINGS") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents\">\n"; $html_str .= " <div class=\"listbuilder_contents_line\">\n"; $html_str .= " <div class=\"listbuilder_contents_line_left\">" . translate("LABEL_TITLE_OF_THIS_LIST") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents_line_right\">"; # set value for title when list title has been given if ($old_list_loaded == TRUE) { $html_str .= "<input size=\"20\" maxlength=\"100\" id=\"listbuilder_list_title_id\""; $html_str .= " value=\"" . $record[LISTTABLEDESCRIPTION_TITLE_FIELD_NAME] . "\" type=\"text\"></div>\n"; } else { $html_str .= "<input size=\"20\" maxlength=\"100\" id=\"listbuilder_list_title_id\" type=\"text\"></div>\n"; } $html_str .= " </div> <!-- listbuilder_contents_line -->\n"; $html_str .= " <div class=\"listbuilder_contents_line\">\n"; $html_str .= " <div class=\"listbuilder_contents_line_left\">" . translate("LABEL_SHORT_DESCRIPTION_OF_THIS_LIST") . "</div>\n"; $html_str .= " <div class=\"listbuilder_contents_line_right\">"; # set value for description when list title has been given if ($old_list_loaded == TRUE) { $html_str .= "<textarea cols=\"60\" rows=\"4\" id=\"listbuilder_list_description_id\">"; $html_str .= $record[LISTTABLEDESCRIPTION_DESCRIPTION_FIELD_NAME] . "</textarea></div>\n"; } else { $html_str .= "<textarea cols=\"60\" rows=\"4\" id=\"listbuilder_list_description_id\"></textarea></div>\n"; } $html_str .= " </div> <!-- listbuilder_contents_line -->\n"; $html_str .= " </div> <!-- listbuilder_contents -->\n"; $html_str .= " <div class=\"corner bottom_left_normal\"></div>\n"; $html_str .= " <div class=\"corner bottom_right_normal\"></div>\n"; $response->custom_response->assign_with_effect("listbuilder_statics_pane", $html_str); # set html for listbuilder configuration pane $html_str = get_field_definition_table($definition); $response->custom_response->assign_with_effect("listbuilder_configuration_pane", $html_str); $response->assign("largest_id", "innerHTML", $largest_id); $response->assign("footer_text", "innerHTML", " "); if ($old_list_loaded == FALSE && strlen($list_title) > 0) { $error_message_str = $list_table_description->get_error_message_str(); $error_log_str = $list_table_description->get_error_log_str(); $error_str = $list_table_description->get_error_str(); set_error_message("tab_listbuilder_id", "below", $error_message_str, $error_log_str, $error_str, $response); } # log total time for this function $logging->info(get_function_time_str(__METHOD__)); return $response; }
/** * delete a list table * this function is registered in xajax * @param string $list_title title of list table * @param string $key_string comma separated name value pairs * @return xajaxResponse every xajax registered function needs to return this object */ function action_delete_portal_record($list_title) { global $logging; global $user; global $list_table_description; global $portal_table_configuration; global $user_start_time_array; $logging->info("USER_ACTION " . __METHOD__ . " (user="******", list_title={$list_title})"); # store start time $user_start_time_array[__METHOD__] = microtime(TRUE); # create necessary objects $result = new Result(); $response = new xajaxResponse(); $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_portal_id", "below", $error_message_str, $error_log_str, $error_str, $response); return $response; } $html_database_table = new HtmlDatabaseTable($portal_table_configuration); # display error when delete returns false if ($list_table->drop() == FALSE) { $logging->warn("drop list 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_portal_id", "below", $error_message_str, $error_log_str, $error_str, $response); return $response; } # set content $html_database_table->get_content($list_table_description, $list_title, "", DATABASETABLE_ALL_PAGES, $result); $response->custom_response->assign_with_effect(PORTAL_CSS_NAME_PREFIX . "content_pane", $result->get_result_str()); # reset current list name only when active list has been removed if ($list_title == $user->get_current_list_name()) { $user->set_current_list_name(""); } # set page navigation and login status to update old 'list' links $page_navigation_str = get_page_navigation(PAGE_TYPE_PORTAL); $response->assign("navigation_container", "innerHTML", $page_navigation_str); # 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; }