Beispiel #1
0
     } else {
         $lagnamn = LagNamn::loadById($_POST["id"]);
         $lagnamn->setNamn($_POST["namn"]);
         if (file_exists($_FILES["bild"]["tmp_name"])) {
             $bild = new Bild($_FILES["bild"]);
             $lagnamn->setImg($bild);
         }
         $lagnamn->commit();
     }
     $urlHandler->redirect("LagNamn", URL_ADMIN_LIST);
     break;
 case "profildata":
     if (empty($_GET["id"])) {
         $profildata = new ProfilData($_POST["namn"], $_POST["beskrivning"]);
     } else {
         $profildata = ProfilData::loadById($_GET["id"]);
         if (!empty($_POST["namn"])) {
             $profildata->setNamn($_POST["namn"]);
         }
         if (isset($_POST["beskrivning"])) {
             $profildata->setBeskrivning($_POST["beskrivning"]);
         }
         $profildata->commit();
     }
     // Lägg in nya val:
     $_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());
Beispiel #2
0
    $lanKommuner[] = array("opt" => $opt_kommuner);
}
$smarty->assign("lanKommuner", $lanKommuner);
$opt_kon = array("" => "Välj...", "man" => "Man", "kvinna" => "Kvinna");
$sel_kon = isset($_POST["kon"]) ? $_POST["kon"] : "";
$smarty->assign("opt_kon", $opt_kon);
$smarty->assign("sel_kon", $sel_kon);
$opt_fodelsear = array("" => "Välj...");
for ($i = 2008; $i > 1899; $i--) {
    $opt_fodelsear[$i] = $i;
}
$sel_fodelsear = isset($_POST["fodelsear"]) ? $_POST["fodelsear"] : "";
$smarty->assign("opt_fodelsear", $opt_fodelsear);
$smarty->assign("sel_fodelsear", $sel_fodelsear);
// Profildata
$attribut = ProfilData::listAll();
foreach ($attribut as $thisAttribut) {
    $alternativ = $thisAttribut->getProfilDataVals();
    $opt_alternativ = array("" => "Välj...");
    foreach ($alternativ as $thisAlternativ) {
        $opt_alternativ[$thisAlternativ->getId()] = $thisAlternativ->getVarde();
    }
    $sel_alternativ = !empty($_POST["profilData" . $thisAttribut->getId()]) ? $_POST["profilData" . $thisAttribut->getId()] : "";
    $profilData[$thisAttribut->getId()] = array("namn" => $thisAttribut->getNamn(), "opt" => $opt_alternativ, "sel" => $sel_alternativ, "formId" => "profilData" . $thisAttribut->getId());
}
$smarty->assign("profilData", $profilData);
$topplista = new Topplista();
if (!empty($_POST["kommun_id"])) {
    $kommun = Kommun::loadById($_POST["kommun_id"]);
    $topplista->addParameter(Topplista::PARAM_KOMMUN, $kommun);
}
Beispiel #3
0
 public static function getMedlemmarFrontpage($antal)
 {
     $profilDatas = ProfilData::listAll();
     $count = 0;
     $valda = array();
     do {
         $count++;
         reset($profilDatas);
         foreach ($profilDatas as $key => $profilData) {
             if (rand(0, 100) < 10 && (!in_array($profilData, $valda) || $antal > sizeof($profilDatas))) {
                 $valda[] = $profilData;
                 if (sizeof($valda) >= $antal) {
                     break;
                 }
             }
         }
     } while (sizeof($valda) < $antal && $count < 10);
     $ids = array();
     foreach ($valda as $key => $profilData) {
         $id = 0;
         $alla_medlemmar = $profilData->getMedlemmar();
         if (sizeof($alla_medlemmar) > 0) {
             do {
                 $id = $alla_medlemmar[rand(0, sizeof($alla_medlemmar) - 1)];
             } while (false && in_array($id, $ids));
         }
         if ($id > 0) {
             $ids[] = $id;
         }
     }
     return self::listByIds($ids);
 }
Beispiel #4
0
<?php

require_once $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(ADMIN);
$smarty = new AdminSmarty();
$profilDatas = ProfilData::listAll();
$smarty->assign("listProfilData", $profilDatas);
$smarty->display('listProfilData.tpl');
Beispiel #5
0
 public function getProfilDataObject()
 {
     return ProfilData::loadById($this->profilDataId);
 }