public function removeStaticRouteForUser($id, $completed = false) { if ($id == $this->getId()) { // check if international challenge $currentKommun = $this->getCurrentKommun(); $ruttObj = new Rutt($this); $rutt = $ruttObj->getRutt(); $curPos = false; $lastNonAbroad = false; foreach ($rutt as $id => $stracka) { $kommun = $stracka["Kommun"]; $thisKm = $stracka["ThisKm"]; $stracka_id = $stracka["id"]; if ($curPos === false) { // if this isn't the current kommun, and it's not abroad, we'll save it as the lastNonAbroad kommun if ($kommun->getAbroad() == "false") { $lastNonAbroad = $kommun; } } if ($id == $ruttObj->getCurrentIndex()) { // we're now at the current kommun $curPos = true; if ($kommun->getAbroad() == "false" || $thisKm > 0) { // if it's not abroad, and not just a "jump to" kommun if (!$completed) { $stracka = Stracka::loadById($stracka_id); $stracka->setStatic(0); $stracka->commit(); } continue; } } elseif (!$curPos) { // we haven't reached the current kommun yet if (!$curPos && $stracka["fastRutt"] == 1) { // this is part of the ended static route, and so it will be changed to non-static... if (!$completed) { // ...if it's not a completed static route $stracka = Stracka::loadById($stracka_id); $stracka->setStatic(0); $stracka->commit(); } } elseif ($stracka["fastRutt"] == 1 && !$completed) { // if this static route isn't completed, it's changed to non-static $stracka = Stracka::loadById($stracka_id); $stracka->setStatic(0); $stracka->commit(); } else { // this looks a bit weird, it's here for historic reasons } continue; } $kommun = $stracka["Kommun"]; $stracka = Stracka::loadById($stracka_id); $stracka->delete(); } if ($lastNonAbroad != false && $this->getCurrentKommun()->getId() != $lastNonAbroad->getId()) { $strackaObj = new Stracka($lastNonAbroad, $this); $strackaObj->setTempStatus(false); $strackaObj->commit(); } $this->setUserOnStaticRoute('false'); $this->setFastRuttId(0); $this->commit(); } }
<?php // LILLA RUTTKARTAN PÅ "PLANERAD RUTT" require_once $_SERVER["DOCUMENT_ROOT"] . "/php/init.php"; //Security::demand(USER); error_reporting(0); if (isset($_GET["medlem"])) { $medlem = Medlem::loadById($_GET["medlem"]); } else { $medlem = $USER; } $rutt = new Rutt($medlem); $rutten = $rutt->getRutt(); $sista = $rutt->getCurrentIndex(); $just_nu_id = $medlem->getJustNuKommunId(); $just_nu_kommun = Kommun::loadById($just_nu_id); $exclude[] = $just_nu_kommun->getKod(); $kommuntext = array(); $c = 0; while (list($key, $stracka) = each($rutten)) { $c++; $key = $stracka["Kommun"]->getKod(); $kommuntext[$key] = $kommuntext[$key] ? $kommuntext[$key] . ",{$c}" : $c; } reset($rutten); ?> <map animation='1' showShadow='1' mapLeftMargin='0' mapRightMargin='0' mapBottomMargin='0' maptopMargin='0' showBevel='0' showCanvasBorder='0' showMarkerLabels='1' fillColor='F1f1f1' borderColor='CCCCCC' baseFont='Arial Narrow' baseFontSize='10' markerBorderColor='000000' markerBgColor='FF5904' markerRadius='6' legendPosition='bottom' useHoverColor='0' hoverColor='FF0000' showMarkerToolTip='1' markerFontColor='FF5904' connectorColor='FF0000' showLabels='0' includeValueInLabels='1' BorderColor='0372AB' showToolTip='1' waterBodyColor='00CCFF' waterBodyAlpha='50' > <data> <entity id= '<?php echo $just_nu_kommun->getKod(); ?>
<?php require_once $_SERVER["DOCUMENT_ROOT"] . "/php/init.php"; Security::demand(USER); $smarty = new MMSmarty(); $smarty->assign("pagetitle", "Välj Kommun"); $rutt = new Rutt($USER); $rutter = $rutt->getRutt(); if (isset($rutter[$rutt->getCurrentIndex() + 1])) { $urlHandler->redirect("Medlem", URL_VIEW_OWN); } $current_kommun = $rutt->getCurrentKommun(); $replace = array(" ", "å", "ä", "ö", "Ö", "Lan"); $with = array("", "a", "a", "o", "O", "lan"); $lan_1 = $current_kommun->getLan(); $lan_1 = str_replace($replace, $with, $lan_1); // omvandlar namnet till kartornas namn $smarty->assign("lan_1", $lan_1); // gå igenom grannkommuner och se om de ligger i andra län $avstand = $current_kommun->listAvstand(); $count = 2; foreach ($avstand as $tmp) { $ktmp = Kommun::loadById($tmp["id"]); $ltmp = $ktmp->getLan(); $ltmp = str_replace($replace, $with, $ltmp); // omvandlar namnet till kartornas namn $add = true; for ($i = 1; $i < $count; $i++) { $lan = "lan_{$i}"; if ($ltmp == "" || $ltmp == ${$lan}) { $add = false;