public static function OutputMockagendaUpdate($updateCurrentEvents = FALSE, $updateFutureEvents = FALSE, $showOnlyAgendaOptions = FALSE) { $stdout = ""; $options = $headers = $allConfids = $allConfidsUpdated = array(); $eventTitle = $updatedRecords = array(); $numberOfUpdatedRecords = 0; // ---------------------------------------------- // -- GPC and initiations // ---------------------------------------------- // UPDATE manually kept fields from legacy file - ALL events: functions::gpc_declare_input("uf", false, true); // UPDATE VM fields [disabled]: functions::gpc_declare_input("uv", false, true); // UPDATE Agenda fields - ALL events: functions::gpc_declare_input("ua", false, true); // UPDATE Agenda fields - CURRENT events: functions::gpc_declare_input("uc", $updateCurrentEvents && !$updateFutureEvents, true); // UPDATE Agenda fields - CURRENT and FUTURE events: functions::gpc_declare_input("un", $updateCurrentEvents && $updateFutureEvents, true); // Recreate 'menulookup' cache: functions::gpc_declare_input("um", false, true); if (!class_exists("fromdb_nwevents", FALSE)) { require_once PATH_CLASSES . "/fromdb/nwevents.php"; } if (!isset($dbEv) || !is_object($dbEv)) { $dbEv = new fromdb_nwevents(); } $allConfids = $dbEv->getAgendaConferenceIdsForNorditaEvents(); $noRecordsInDB = (bool) (!is_array($allConfids) || empty($allConfids)); if ($noRecordsInDB) { $GLOBALS["uv"] = $GLOBALS["ua"] = $GLOBALS["un"] = false; } // ---------------------------------------------- // -- Act on selected option // ---------------------------------------------- // UPDATE manually kept fields from legacy file - ALL events if ($GLOBALS["uf"]) { $numberOfUpdatedRecords = $dbEv->updateEventsFromLocalFile(); if ($numberOfUpdatedRecords) { $noRecordsInDB = false; } } elseif ($GLOBALS["uv"]) { //if (!class_exists("fromdb_vm",FALSE)) require_once PATH_CLASSES . "/fromdb/vm.php"; //$dbEv = new fromdb_vm(); //$numberOfUpdatedRecords = ...(); } elseif ($GLOBALS["ua"]) { $updatedRecords = $dbEv->updateEventsFromAgenda(""); $numberOfUpdatedRecords = is_array($updatedRecords) ? count($updatedRecords) : $updatedRecords; } elseif ($GLOBALS["uc"]) { $updatedRecords = $dbEv->updateCurrentEventsFromAgenda(); $numberOfUpdatedRecords = is_array($updatedRecords) ? count($updatedRecords) : $updatedRecords; document::recreateMenulookupCache(); // also recreate menu cache, to make sure } elseif ($GLOBALS["un"]) { $updatedRecords = $dbEv->updateEventsFromAgenda(date("Y-m-d", strtotime("-50 days"))); $numberOfUpdatedRecords = is_array($updatedRecords) ? count($updatedRecords) : $updatedRecords; document::recreateMenulookupCache(); // also recreate menu cache, to make sure } elseif ($GLOBALS["um"]) { if (document::recreateMenulookupCache()) { $stdout .= "\r\n" . functions::boxMessage("confirm", "<strong>Cache 'menulookup'</strong> was successfully recreated.") . "\r\n"; } else { $stdout .= "\r\n" . functions::boxMessage("error", "<strong>Cache 'menulookup'</strong> could not be recreated") . "\r\n"; } } // ----------------------- $allConfidsUpdated = $numberOfUpdatedRecords ? $dbEv->getAgendaConferenceIdsForNorditaEvents() : $allConfids; // ---------------------------------------------- // -- Output // ---------------------------------------------- $stdout .= " <p class='largefont'>There are currently <strong>" . count($allConfidsUpdated) . " events</strong> in the local 'nw_events' database.</p>\r\n"; // ----------------------- $stdout .= "<div class='col c1of2'>\r\n"; $stdout .= " <p><strong>The local database 'nw_events'</strong> collects information of Nordita events (programs, workshops, conferences, meetings, schools) from several sources: most data comes from the <strong>AlbaNova Agenda database</strong>; some fields are fetched from the <strong>VM database</strong>; and some metadata fields are <strong>manually kept only in the 'nw_events' database</strong>.</p>\r\n"; if (!$showOnlyAgendaOptions) { $headers["manual"] = "Manually Kept Files"; $options["manual"][] = "<a href='" . $_SERVER["PHP_SELF"] . "?uf=1'>UPDATE manually kept fields from legacy file - ALL events</a>"; if (!$noRecordsInDB) { $options["manual"][] = "<a href='" . str_replace("nw_events_update", "nw_events_edit", $_SERVER["PHP_SELF"]) . "'>" . "EDIT manually kept fields - SINGLE event</a> " . "<span style='padding-left:1em;font-weight:normal;white-space:nowrap'>(use [Edit] links)</span>"; } } $headers["agenda"] = "Agenda Fields"; if (!$showOnlyAgendaOptions) { $options["agenda"][] = "<a href='" . $_SERVER["PHP_SELF"] . "?ua=1'>UPDATE Agenda fields - ALL events</a> " . "<span style='padding-left:1em;font-weight:normal;white-space:nowrap'>(going back to 2007)</span>"; } if (!$noRecordsInDB) { $options["agenda"][] = "<a href='" . $_SERVER["PHP_SELF"] . "?uc=1'>UPDATE Agenda fields - CURRENT events</a>"; } if (!$noRecordsInDB) { $options["agenda"][] = "<a href='" . $_SERVER["PHP_SELF"] . "?un=1'>UPDATE Agenda fields - CURRENT and FUTURE events</a>"; } if (!$showOnlyAgendaOptions) { if (!$noRecordsInDB) { $options["agenda"][] = "<a href='" . str_replace("nw_events_update", "nw_events_edit", $_SERVER["PHP_SELF"]) . "'>UPDATE Agenda fields - SINGLE event</a> <span style='padding-left:1em;font-weight:normal;white-space:nowrap'>(use [Update] links)</span>"; } $options["agenda"][] = "<a href='" . AGENDA_URI . "/'>EDIT Agenda events</a> " . EXTERNAL_LINK; } if (!$showOnlyAgendaOptions) { $headers["vm"] = "VM Fields"; $options["vm"][] = "[UPDATE VM fields - disabled]"; //$options["vm"][] = "<a href='".$_SERVER["PHP_SELF"]."?uv=1'>UPDATE VM fields</a>"; } if (!$showOnlyAgendaOptions) { $headers["varia"] = "Varia"; $options["varia"][] = "<a href='" . $_SERVER["PHP_SELF"] . "?um=1'>Recreate 'menulookup' cache</a>"; } //$stdout .= "<p><strong>» Update event records in database 'nw_events'...</strong></p>\r\n"; foreach (array("manual", "agenda", "vm", "varia") as $db) { if (!empty($options[$db])) { $stdout .= (!empty($headers[$db]) ? "<h4>" . $headers[$db] . "</h4>\r\n" : "") . "<ul class='bold tightlist'>\r\n" . " <li>" . implode($options[$db], "</li>\r\n <li>") . "</li>\r\n" . "</ul>\r\n"; } } // ----------------------- $stdout .= "</div> <div class='col c2of2'>\r\n"; if (!empty($_REQUEST) && !$GLOBALS["um"] && !$noRecordsInDB && isset($numberOfUpdatedRecords)) { $stdout .= $numberOfUpdatedRecords > 0 ? " <p class='box padding confirm background'>Successfully updated " . "<strong>" . $numberOfUpdatedRecords . "</strong> records in the database 'nw_events'.</p>\r\n" : " <p class='box padding error background'><strong>Could not update any records</strong> " . "in the database 'nw_events'." . (!$noRecordsInDB && $numberOfUpdatedRecords == ERROR_NO_EVENTS_REQUESTED ? " [No events requested]" : "") . (!$noRecordsInDB && $numberOfUpdatedRecords == 0 ? " [No events updated]" : "") . "</p>\r\n"; if (count($updatedRecords)) { $stdout .= " <ul>\r\n"; foreach ($updatedRecords as $confId) { $stdout .= " <li><a href='http://agenda.albanova.se/conferenceDisplay.py?confId=" . $confId . "'>" . $dbEv->getEventTitle($confId) . "</a></li>\r\n"; } $stdout .= " </ul>\r\n"; } } // ----------------------- $stdout .= "</div><div style='clear:both'><br></div>\r\n"; // ----------------------- return $stdout; }
public static function OutputRoomsEditor() { return "<div class='box error background bold padding'>UNDER CONSTRUCTION</div>"; $stdout = ""; $showform["list"] = 1; $showform["edit"] = $showCacheUpdateLink = 0; $error = $warning = $founderror = array(); functions::gpc_declare_input("edit", false, true); functions::gpc_declare_input("delete", false, true); functions::gpc_declare_input("c", "", false); // $confId functions::gpc_declare_input("e", false, true); functions::gpc_declare_input("u", false, true); functions::gpc_declare_input("d", false, true); functions::gpc_declare_input("menulookup", false, true); // ---------------------------------------------------------------- // -- If 'recreate menulookup cache' requested // ---------------------------------------------------------------- if ($GLOBALS["menulookup"]) { if (document::recreateMenulookupCache()) { $stdout .= "\r\n" . functions::boxMessage("confirm", "<strong>Cache 'menulookup'</strong> was successfully recreated.") . "\r\n"; } else { $stdout .= "\r\n" . functions::boxMessage("error", "<strong>Cache 'menulookup'</strong> could not be recreated") . "\r\n"; } } // ---------------------------------------------------------------- // -- If 'edit' requested // ---------------------------------------------------------------- if ($GLOBALS["edit"]) { $showform["list"] = 0; // -------------------------------- // -- GPC handling // -------------------------------- functions::gpc_declare_input("title", "", false); functions::gpc_declare_input("eventtype", "0", false); functions::gpc_declare_input("subpath", "", false); functions::gpc_declare_input("venue", "", false); functions::gpc_declare_input("surveyid", "0", false); functions::gpc_declare_input("surveyresponse", "", false); functions::gpc_declare_input("youtube", "", false); functions::gpc_declare_input("blurb", "", false); // -------------------------------- // -- Check for errors in input // -------------------------------- ///debug::rrr(); if (!in_array($GLOBALS["eventtype"], event::$eventTypeId)) { $founderror["eventtype"] = 1; $error[] = "Please select an event type."; } if (empty($GLOBALS["subpath"])) { $founderror["subpath"] = 1; $error[] = "Please write a non-empty subpath."; } // -------------------------------- // -- If errors found, display form with error messages and warnings // -------------------------------- if (!empty($error)) { $stdout .= functions::boxMessage("error", $error); $GLOBALS["e"] = 1; } if (!empty($warning)) { $stdout .= functions::boxMessage("warning", $warning); $GLOBALS["e"] = 1; } // -------------------------------- // -- If no errors, update database with submitted data // -------------------------------- if (empty($error)) { $record = array("confid" => $GLOBALS["c"], "title" => $GLOBALS["title"], "eventtype" => $GLOBALS["eventtype"], "subpath" => $GLOBALS["subpath"], "venue" => $GLOBALS["venue"], "surveyid" => $GLOBALS["surveyid"], "surveyresponse" => $GLOBALS["surveyresponse"], "youtube" => $GLOBALS["youtube"], "blurb" => $GLOBALS["blurb"]); $res = false; //TODO /* $res = $this->updateEventManualData($record); */ if (!$res) { $stdout .= "\r\n" . functions::boxMessage("error", "Could not update the event") . "\r\n"; $GLOBALS["e"] = 1; $showCacheUpdateLink = 0; } else { $stdout .= "\r\n" . functions::boxMessage("confirm", "The event was successfully updated.") . "\r\n"; $GLOBALS["e"] = 1; $showCacheUpdateLink = 1; } } // end if ($error) } // end if if ($GLOBALS["e"]) { $showform["list"] = 0; $stdout .= self::outputRoomsEditorForm($GLOBALS["c"], $founderror, $error, $showCacheUpdateLink); } // end if ($GLOBALS["e"]) // ---------------------------------------------------------------- // -- If 'update from Agenda' requested // ---------------------------------------------------------------- if ($GLOBALS["u"]) { $showform["list"] = 0; // -------------------------------- // -- GPC handling // -------------------------------- // -------------------------------- // -- Check for errors in input // -------------------------------- if (!is_numeric($GLOBALS["c"]) || $GLOBALS["c"] <= 0) { $founderror["confid"] = 1; $error[] = "There is some problem with the ID of the event you selected."; } // -------------------------------- // -- If errors found, display form with error messages and warnings // -------------------------------- if (!empty($error)) { $stdout .= functions::boxMessage("error", $error); $GLOBALS["u"] = 1; } if (!empty($warning)) { $stdout .= functions::boxMessage("warning", $warning); $GLOBALS["u"] = 1; } // -------------------------------- // -- If no errors, update database with submitted data // -------------------------------- if (empty($error)) { //TODO: keep 01-01 events when updating from Agenda $res = false; //TODO: /* $res = $this->updateOneEventFromAgenda($GLOBALS["c"],TRUE); */ if (!$res) { $stdout .= "\r\n" . functions::boxMessage("error", "Could not update the event with ID=" . $GLOBALS["c"]) . "\r\n"; $GLOBALS["u"] = 1; } else { $stdout .= "\r\n" . functions::boxMessage("confirm", "The event with <strong>ID=" . $GLOBALS["c"] . "</strong> was successfully updated.") . "\r\n"; $GLOBALS["u"] = 1; } } // end if ($error) $showform["list"] = 1; } // end if ($GLOBALS["u"]) // ---------------------------------------------------------------- // -- If 'delete' requested // ---------------------------------------------------------------- if ($GLOBALS["delete"]) { $showform["list"] = 0; // -------------------------------- // -- GPC handling // -------------------------------- functions::gpc_declare_input("xxx", "", false); // -------------------------------- // -- Check for errors in input // -------------------------------- // -------------------------------- // -- If errors found, display form with error messages and warnings // -------------------------------- if (!empty($error)) { $stdout .= functions::boxMessage("error", $error); $GLOBALS["d"] = 1; } if (!empty($warning)) { $stdout .= functions::boxMessage("warning", $warning); $GLOBALS["d"] = 1; } // -------------------------------- // -- If no errors, update database with submitted data // -------------------------------- if (empty($error)) { } // end if ($error) } // end if if ($GLOBALS["d"]) { $showform["list"] = 0; // $stdout .= self::outputRoomsEditorForm($GLOBALS["c"],$founderror,$error); $stdout .= "DELETE" . " <p class='largefont'><strong>« <a href='" . $_SERVER["PHP_SELF"] . "'>Edit other events</a></strong></p>\r\n"; } // end if ($GLOBALS["d"]) // -------------------------------- // -- Output form, if requested // -------------------------------- if ($showform["list"]) { $stdout .= self::outputRoomsEditorList(); } // -------------------------------- return $stdout; }