public static function loadByNamn($namn) { global $db; $sql = "SELECT id FROM " . self::classToTable(get_class()) . " WHERE namn='" . SECURITY::secure_postdata($namn) . "'"; $id = $db->value($sql); if ($id) { return parent::loadById($id, get_class()); } else { return false; } }
$_POST["profildatavals"] = trim($_POST["profildatavals"]); if (!empty($_POST["profildatavals"])) { $profildatavals = explode("\n", trim($_POST["profildatavals"])); if (count($profildatavals) > 0) { while (list($key, $value) = each($profildatavals)) { new ProfilDataVal(trim($value), $profildata->getId()); } } } $urlHandler->redirect("ProfilData", URL_ADMIN_EDIT, $profildata->getId()); break; case "texteditor": if (empty($_GET["id"])) { $texteditor = new TextEditor($_POST["namn"], $_POST["tema"]); } else { $texteditor = TextEditor::loadById($_GET["id"]); if (!empty($_POST["namn"])) { $texteditor->setNamn($_POST["namn"]); } if (!empty($_POST["tema"])) { $texteditor->setTema($_POST["tema"]); } if (!empty($_POST["texten"])) { $texteditor->setTexten($_POST["texten"]); } $texteditor->commit(); } $urlHandler->redirect("TextEditor", URL_ADMIN_EDIT, $texteditor->getId()); break; case "help": if (empty($_GET["id"])) {
//phpinfo(); die(); require_once $_SERVER["DOCUMENT_ROOT"] . "/php/init.php"; $smarty = new MMSmarty(); $medlemsprofiler = Medlem::getMedlemmarFrontpage(3); shuffle($medlemsprofiler); $smarty->assign("title", "Välkommen till Motiomera"); $smarty->assign("medlemsprofiler", $medlemsprofiler); list($key, $medlem) = each($medlemsprofiler); $medlem->getProfilDataValObject("random"); $totalVecka = Steg::getTotalSteg(date("Y-m-d", time() - 60 * 60 * 24 * 7), date("Y-m-d")); $smarty->assign("totalVecka", $totalVecka); $smarty->showSidebar(); $browser = $medlem->getCurrentBrowserVersion(); $smarty->assign("browser", $browser); $texteditor = TextEditor::loadById(10); $smarty->assign("texteditor_nh", $texteditor); $texteditor = TextEditor::loadById(9); $smarty->assign("texteditor_nm", $texteditor); $namn = "Startsidan under menyn"; $texteditor = TextEditor::loadByNamn($namn); $smarty->assign("texteditor_um", $texteditor); //the rss flow from mabra.com $file = ROOT . "/files/rsscache/motiofeed.txt"; $fh = fopen($file, "r"); $smotiofeed = file_get_contents($file); fclose($fh); $rss = unserialize($smotiofeed); $smarty->assign("rss", $rss); // throw new Exception("testar"); // echo Medlem::loadById(12431243); $smarty->display("index.tpl");