-/*
- * Display a task by itself (for editing)
- */
-void display_edit_individual_task(icalcomponent *supplied_vtodo, long msgnum, char *from,
- int unread, struct calview *calv)
-{
- icalcomponent *vtodo;
- icalproperty *p;
- struct icaltimetype IcalTime;
- time_t now;
- int created_new_vtodo = 0;
- icalproperty_status todoStatus;
-
- now = time(NULL);
-
- if (supplied_vtodo != NULL) {
- vtodo = supplied_vtodo;
-
- /**
- * If we're looking at a fully encapsulated VCALENDAR
- * rather than a VTODO component, attempt to use the first
- * relevant VTODO subcomponent. If there is none, the
- * NULL returned by icalcomponent_get_first_component() will
- * tell the next iteration of this function to create a
- * new one.
- */
- if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- display_edit_individual_task(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT
- ),
- msgnum, from, unread, calv
- );
- return;
- }
- }
- else {
- vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
- created_new_vtodo = 1;
- }
-
- /*/ TODO: Can we take all this and move it into a template? */
- output_headers(1, 1, 1, 0, 0, 0);
- wprintf("<!-- start task edit form -->");
- p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
- /* Get summary early for title */
- wprintf("<div class=\"box\">\n");
- wprintf("<div class=\"boxlabel\">");
- wprintf(_("Edit task"));
- wprintf("- ");
- if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
- }
- wprintf("</div>");
-
- wprintf("<div class=\"boxcontent\">\n");
- wprintf("<FORM METHOD=\"POST\" action=\"save_task\">\n");
- wprintf("<div style=\"display: none;\">\n ");
- wprintf("<input type=\"hidden\" name=\"nonce\" value=\"%d\">\n", WC->nonce);
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"msgnum\" VALUE=\"%ld\">\n", msgnum);
- wprintf("<INPUT TYPE=\"hidden\" NAME=\"return_to_summary\" VALUE=\"%d\">\n",
- ibstr("return_to_summary"));
- wprintf("</div>");
- wprintf("<table class=\"calendar_background\"><tr><td>");
- wprintf("<TABLE STYLE=\"border: none;\">\n");
-
- wprintf("<TR><TD>");
- wprintf(_("Summary:"));
- wprintf("</TD><TD>"
- "<INPUT TYPE=\"text\" NAME=\"summary\" "
- "MAXLENGTH=\"64\" SIZE=\"64\" VALUE=\"");
- p = icalcomponent_get_first_property(vtodo, ICAL_SUMMARY_PROPERTY);
- if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
- }
- wprintf("\"></TD></TR>\n");
-
- wprintf("<TR><TD>");
- wprintf(_("Start date:"));
- wprintf("</TD><TD>");
- p = icalcomponent_get_first_property(vtodo, ICAL_DTSTART_PROPERTY);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodtstart\" ID=\"nodtstart\" VALUE=\"NODTSTART\" ");
- if (p == NULL) {
- wprintf("CHECKED=\"CHECKED\"");
- }
- wprintf(">");
- wprintf(_("No date"));
-
- wprintf(" ");
- wprintf(_("or"));
- wprintf(" ");
- if (p != NULL) {
- IcalTime = icalproperty_get_dtstart(p);
- }
- else
- IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
- display_icaltimetype_as_webform(&IcalTime, "dtstart", 0);
- wprintf("</TD></TR>\n");
-
- wprintf("<TR><TD>");
- wprintf(_("Due date:"));
- wprintf("</TD><TD>");
- p = icalcomponent_get_first_property(vtodo, ICAL_DUE_PROPERTY);
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"nodue\" ID=\"nodue\" VALUE=\"NODUE\"");
- if (p == NULL) {
- wprintf("CHECKED=\"CHECKED\"");
- }
- wprintf(">");
- wprintf(_("No date"));
- wprintf(" ");
- wprintf(_("or"));
- wprintf(" ");
- if (p != NULL) {
- IcalTime = icalproperty_get_due(p);
- }
- else
- IcalTime = icaltime_current_time_with_zone(get_default_icaltimezone());
- display_icaltimetype_as_webform(&IcalTime, "due", 0);
-
- wprintf("</TD></TR>\n");
- todoStatus = icalcomponent_get_status(vtodo);
- wprintf("<TR><TD>\n");
- wprintf(_("Completed:"));
- wprintf("</TD><TD>");
- wprintf("<INPUT TYPE=\"CHECKBOX\" NAME=\"status\" VALUE=\"COMPLETED\"");
- if (todoStatus == ICAL_STATUS_COMPLETED) {
- wprintf(" CHECKED=\"CHECKED\"");
- }
- wprintf(" >");
- wprintf("</TD></TR>");
- /* start category field */
- p = icalcomponent_get_first_property(vtodo, ICAL_CATEGORIES_PROPERTY);
- wprintf("<TR><TD>");
- wprintf(_("Category:"));
- wprintf("</TD><TD>");
- wprintf("<INPUT TYPE=\"text\" NAME=\"category\" MAXLENGTH=\"32\" SIZE=\"32\" VALUE=\"");
- if (p != NULL) {
- escputs((char *)icalproperty_get_categories(p));
- }
- wprintf("\">");
- wprintf("</TD></TR>\n ");
- /* end category field */
- wprintf("<TR><TD>");
- wprintf(_("Description:"));
- wprintf("</TD><TD>");
- wprintf("<TEXTAREA NAME=\"description\" "
- "ROWS=\"10\" COLS=\"80\">\n"
- );
- p = icalcomponent_get_first_property(vtodo, ICAL_DESCRIPTION_PROPERTY);
- if (p != NULL) {
- escputs((char *)icalproperty_get_comment(p));
- }
- wprintf("</TEXTAREA></TD></TR></TABLE>\n");
-
- wprintf("<SPAN STYLE=\"text-align: center;\">"
- "<INPUT TYPE=\"submit\" NAME=\"save_button\" VALUE=\"%s\">"
- " "
- "<INPUT TYPE=\"submit\" NAME=\"delete_button\" VALUE=\"%s\">\n"
- " "
- "<INPUT TYPE=\"submit\" NAME=\"cancel_button\" VALUE=\"%s\">\n"
- "</SPAN>\n",
- _("Save"),
- _("Delete"),
- _("Cancel")
- );
- wprintf("</td></tr></table>");
- wprintf("</FORM>\n");
- wprintf("</div></div></div>\n");
- wprintf("<!-- end task edit form -->");
- wDumpContent(1);
-
- if (created_new_vtodo) {
- icalcomponent_free(vtodo);
- }
-}
-
-/*
- * \brief Save an edited task
- * \param supplied_vtodo the task to save
- * \param msgnum number of the mesage in our db
- */
-void save_individual_task(icalcomponent *supplied_vtodo, long msgnum, char* from, int unread,
- struct calview *calv)
-{
- char buf[SIZ];
- int delete_existing = 0;
- icalproperty *prop;
- icalcomponent *vtodo, *encaps;
- int created_new_vtodo = 0;
- int i;
- int sequence = 0;
- struct icaltimetype t;
-
- if (supplied_vtodo != NULL) {
- vtodo = supplied_vtodo;
- /**
- * If we're looking at a fully encapsulated VCALENDAR
- * rather than a VTODO component, attempt to use the first
- * relevant VTODO subcomponent. If there is none, the
- * NULL returned by icalcomponent_get_first_component() will
- * tell the next iteration of this function to create a
- * new one.
- */
- if (icalcomponent_isa(vtodo) == ICAL_VCALENDAR_COMPONENT) {
- save_individual_task(
- icalcomponent_get_first_component(
- vtodo, ICAL_VTODO_COMPONENT),
- msgnum, from, unread, calv
- );
- return;
- }
- }
- else {
- vtodo = icalcomponent_new(ICAL_VTODO_COMPONENT);
- created_new_vtodo = 1;
- }
-
- if (havebstr("save_button")) {
-
- /** Replace values in the component with ones from the form */
-
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_SUMMARY_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo, prop);
- icalproperty_free(prop);
- }
- if (havebstr("summary")) {
-
- icalcomponent_add_property(vtodo,
- icalproperty_new_summary(bstr("summary")));
- } else {
- icalcomponent_add_property(vtodo,
- icalproperty_new_summary("Untitled Task"));
- }
-
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_DESCRIPTION_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo, prop);
- icalproperty_free(prop);
- }
- if (havebstr("description")) {
- icalcomponent_add_property(vtodo,
- icalproperty_new_description(bstr("description")));
- }
-
- while (prop = icalcomponent_get_first_property(vtodo,
- ICAL_DTSTART_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo, prop);
- icalproperty_free(prop);
- }
- if (IsEmptyStr(bstr("nodtstart"))) {
- icaltime_from_webform(&t, "dtstart");
- icalcomponent_add_property(vtodo,
- icalproperty_new_dtstart(t)
- );
- }
- while(prop = icalcomponent_get_first_property(vtodo,
- ICAL_STATUS_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo,prop);
- icalproperty_free(prop);
- }
- while(prop = icalcomponent_get_first_property(vtodo,
- ICAL_PERCENTCOMPLETE_PROPERTY), prop != NULL) {
- icalcomponent_remove_property(vtodo,prop);
- icalproperty_free(prop);
- }