Example #1
0
/**
 * delete list item
 */
function delete_list_item()
{
    $list_table = new ListTable(REGRESSION_TEST_LIST_TITLE);
    if ($list_table->delete("_id=3") == TRUE) {
        return TRUE;
    }
    return FALSE;
}
/**
 * delete a record from current list
 * this function is registered in xajax
 * @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 action_delete_list_record($list_title, $key_string)
{
    global $logging;
    global $user;
    global $list_table_configuration;
    global $user_start_time_array;
    $logging->info("USER_ACTION " . __METHOD__ . " (user="******", list_title={$list_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($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;
    }
    # display error when delete returns false
    if (!$list_table->delete($key_string)) {
        $logging->warn("delete list record 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;
}