From 960fb99bfd02740c3652f020b76b8bd741481a4b Mon Sep 17 00:00:00 2001 From: deva Date: Tue, 2 Mar 2010 10:52:44 +0000 Subject: Set value from db/queries even though it doesn't have a value attribute (PART 2). --- server/src/widgetgenerator.cc | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/server/src/widgetgenerator.cc b/server/src/widgetgenerator.cc index 9647b9b..0240f69 100644 --- a/server/src/widgetgenerator.cc +++ b/server/src/widgetgenerator.cc @@ -40,7 +40,8 @@ static std::string automap(std::string name) if(name[i] == '.') groupcheck += " and " + group; else groupcheck += name[i]; } - groupcheck += " and " + name + ".value and " + name + ".timestamp and " + name + ".source"; + groupcheck += " and " + name + ".value and " + name + + ".timestamp and " + name + ".source"; groupcheck += ")\n"; std::string automapstring = @@ -74,6 +75,10 @@ static std::string send_macro_widget(Macro ¯o, time_t timestamp = 0; time_t now = time(NULL); + if(widget.attributes.find("value") != widget.attributes.end()) { + widget.attributes["value"] = ""; + } + result = tabs + "<" + widget.attributes["tagname"]; std::map< std::string, std::string >::iterator p = widget.attributes.begin(); @@ -137,7 +142,8 @@ static std::string send_macro_widget(Macro ¯o, if(values[widget.attributes["name"]].timestamp > timestamp) { if(values[widget.attributes["name"]].timestamp > now - Conf::db_max_ttl) { - widget.attributes["value"] = xml_encode(values[widget.attributes["name"]].value); + widget.attributes["value"] = + xml_encode(values[widget.attributes["name"]].value); timestamp = values[widget.attributes["name"]].timestamp; prefilled = "pracro"; } @@ -180,7 +186,8 @@ static void get_fields(Widget &widget, Fieldnames &fields) { // if(widget.attributes.find("value") != widget.attributes.end()) { if(widget.attributes.find("name") != widget.attributes.end()) { - if(widget.attributes["name"] != "") fields.push_back(widget.attributes["name"]); + if(widget.attributes["name"] != "") + fields.push_back(widget.attributes["name"]); } std::vector< Widget >::iterator w = widget.widgets.begin(); @@ -190,7 +197,8 @@ static void get_fields(Widget &widget, Fieldnames &fields) } } -std::string widgetgenerator(std::string cpr, Macro ¯o, LUAQueryMapper &mapper, Database &db) +std::string widgetgenerator(std::string cpr, Macro ¯o, + LUAQueryMapper &mapper, Database &db) { Fieldnames fields; get_fields(macro.widgets, fields); -- cgit v1.2.3