Exemplo n.º 1
0
    /**
     * Vis informasjon om artikkel
     */
    protected function article_show(ff_avis_artikkel $ffna)
    {
        $more = '';
        // tilbake til "legg til artikkel"
        if (isset($_GET['to_ffn']) && !$ffna->ffn && $this->ff->access(2)) {
            $ffn_id = intval(getval("to_ffn"));
            $more .= ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;u&amp;ffn=' . $ffn_id . '&amp;add_ffna' . (isset($_GET['add_ffna']) ? '&amp;ffna=' . $ffna->id : '') . '">Tilbake</a>';
        }
        // link: redigere
        $more .= $this->ff->mod || !$ffna->ffn || $ffna->ffn->data['ffn_published'] == 0 ? ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;a&amp;ffna=' . $ffna->id . '&amp;edit">Rediger</a>' : '';
        if ($ffna->access_write) {
            // link: slette
            $more .= $ffna->data['ffna_published'] == 0 || $this->ff->mod ? ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;a&amp;ffna=' . $ffna->id . '&amp;delete">Slett</a>' : '';
            // link: publiser/fjern publisering
            $more .= $ffna->data['ffna_published'] == 0 ? ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;a&amp;ffna=' . $ffna->id . '&amp;publish">Publiser</a>' : ($ffna->data['ffna_ffn_id'] == 0 || $this->ff->mod ? ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;a&amp;ffna=' . $ffna->id . '&amp;unpublish">Fjern publisering</a>' : '');
        }
        // link: utgivelse
        $more .= $ffna->data['ffna_ffn_id'] != 0 ? ' | <a href="avis?ff_id=' . $this->ff->id . '&amp;u&amp;ffn=' . $ffna->data['ffna_ffn_id'] . '">Vis utgivelse</a>' : '';
        echo '
<p class="c">' . htmlspecialchars($ffna->data['ffna_title']) . $more . '</p>';
        // er dette en annen sin artikkel?
        if ($ffna->data['ffna_up_id'] != login::$user->player->id) {
            echo '
<p class="c">Denne artikkelen er laget av <user id="' . $ffna->data['ffna_up_id'] . '" /></p>';
        }
        echo '
<div class="section center w250">
	<h2>Artikkelinformasjon</h2>
	<form action="" method="get">';
        foreach ($_GET as $name => $value) {
            if ($name == "pos") {
                continue;
            }
            echo '
		<input type="hidden" name="' . htmlspecialchars($name) . '" value="' . htmlspecialchars($value) . '" />';
        }
        echo '
	<dl class="dd_right">
		<dt>Opprettet</dt>
		<dd>' . ess::$b->date->get($ffna->data['ffna_created_time'])->format() . '</dd>
		<dt>Sist endret</dt>
		<dd>' . ($ffna->data['ffna_updated_time'] == 0 ? 'Aldri' : ess::$b->date->get($ffna->data['ffna_updated_time'])->format()) . '</dd>
		<dt>Publisert</dt>
		<dd>' . ($ffna->data['ffna_published'] == 0 ? 'Nei' : ess::$b->date->get($ffna->data['ffna_published_time'])->format() . '</dd>
		<dt>Salgspris</dt>
		<dd>' . game::format_cash($ffna->data['ffna_price']) . '</dd>
		<dt>Utgivelse</dt>
		<dd>' . ($ffna->data['ffna_ffn_id'] == 0 ? 'Ingen' : '<a href="avis?ff_id=' . $this->ff->id . '&amp;u&amp;ffn=' . $ffna->data['ffna_ffn_id'] . '">' . htmlspecialchars($ffna->ffn->data['ffn_title']) . '</a>' . ($ffna->ffn->data['ffn_published'] == 0 ? ' (ikke publisert)' : ' (publisert ' . ess::$b->date->get($ffna->ffn->data['ffn_published_time'])->format() . ')'))) . '</dd>
		<dt>' . ($ffna->data['ffna_ffn_id'] ? 'Plassering' : 'Forhåndsvisning') . '</dt>
		<dd>';
        // finn ut hvilken template som skal benyttes og vis informasjon
        if ($ffna->data['ffna_ffn_id']) {
            $template = new ff_avis_template($ffna->ffn->data['ffn_template']);
            $template->ffn = $ffna->ffn;
            $template->add_ffna($ffna->data);
            echo htmlspecialchars($template->template['areas'][$ffna->data['ffna_theme_position']]) . '<br />' . htmlspecialchars($template->template['name']);
        } else {
            $ok = false;
            $pos_name = false;
            // egendefinert plassering?
            if (isset($_GET['pos'])) {
                $pos = explode(",", $_GET['pos']);
                if (isset($pos[1]) && isset(ff_avis::$templates[$pos[0]]) && isset(ff_avis::$templates[$pos[0]]['areas'][$pos[1]])) {
                    $ok = true;
                    $template = new ff_avis_template($pos[0]);
                    $pos_name = $pos[1];
                    $template->add_ffna($ffna->data, $pos[1]);
                    // lagre valget
                    $params = new params_update(-1, "ff_newspapers_articles", "ffna_theme_parameters", "ffna_id = {$ffna->data['ffna_id']}");
                    $params->update("template", $template->template_id);
                    \Kofradia\DB::get()->exec("UPDATE ff_newspapers_articles SET ffna_theme_position = " . \Kofradia\DB::quote($pos_name) . " WHERE ffna_id = {$ffna->data['ffna_id']}");
                    $params->commit();
                }
            }
            if (!$ok) {
                // har vi plassering? er plasseringen fremdeles gyldig? (i tilfelle den har vært tilegnet en utgivelse men fjernet fra utgivelsen og fått ny template)
                $params = new params($ffna->data['ffna_theme_parameters']);
                $t = $params->get("template");
                if ($t && isset(ff_avis::$templates[$t]) && isset(ff_avis::$templates[$t]['areas'][$ffna->data['ffna_theme_position']])) {
                    $template = new ff_avis_template($t);
                    $pos_name = $ffna->data['ffna_theme_position'];
                } else {
                    // benytt første template som standard
                    $f = ff_avis::$templates;
                    $k = key($f);
                    $template = new ff_avis_template($k);
                    $pos_name = key($template->template['areas']);
                }
                // legg til artikkelen i templaten
                $template->add_ffna($ffna->data, $pos_name);
            }
            ess::$b->page->add_js_domready('
	document.id("template_pos").addEvent("change", function()
	{
		this.form.submit();
	});');
            echo '
			<select name="pos" id="template_pos">';
            foreach (ff_avis::$templates as $key1 => $row1) {
                echo '
				<optgroup label="' . htmlspecialchars($row1['name']) . '">';
                foreach ($row1['areas'] as $key2 => $row2) {
                    echo '
					<option value="' . htmlspecialchars($key1) . ',' . htmlspecialchars($key2) . '"' . ($template->template_id == $key1 && $pos_name == $key2 ? ' selected="selected"' : '') . '>' . htmlspecialchars($row2) . '</option>';
                }
                echo '
				</optgroup>';
            }
            echo '
			</select>
		';
        }
        // legg til dummytekst på de plasseringene det ikke er artikler
        $template->add_dummy_text();
        echo '</dd>
	</dl>
	</form>
</div>
<h2 class="c">Forhåndsvisning</h2>' . $template->build();
    }
Exemplo n.º 2
0
<?php

// sjekk alle bankene for forandringer som skal gjøres med overføringsgebyret
$result = \Kofradia\DB::get()->query("SELECT ff_id, ff_name, ff_params FROM ff WHERE ff_type = 3");
while ($row = $result->fetch()) {
    $params = new params_update($row['ff_params'], "ff", "ff_params", "ff_id = {$row['ff_id']}");
    $change = $params->get("bank_overforing_tap_change", 0);
    $current = $params->get("bank_overforing_tap", 0);
    // ikke endre?
    if ($change == 0) {
        continue;
    }
    $next = $current + $change;
    // overstiger maks/min?
    $cancel = false;
    if ($next >= ff::$type_bank['bank_overforing_gebyr_max'] && $change > 0) {
        $next = ff::$type_bank['bank_overforing_gebyr_max'];
        $cancel = true;
    } elseif ($next <= ff::$type_bank['bank_overforing_gebyr_min'] && $change < 0) {
        $next = ff::$type_bank['bank_overforing_gebyr_min'];
        $cancel = true;
    }
    // lagre verdier
    $params->update("bank_overforing_tap", $next, false);
    // avbryte neste endring?
    if ($cancel) {
        $params->update("bank_overforing_tap_change", 0, false);
    }
    // lagre
    $params->commit();
    // logg
Exemplo n.º 3
0
 /**
  * Regn ut progresjon
  */
 public function get_progress()
 {
     if (!$this->data) {
         $this->load_active();
     }
     if (!$this->data) {
         return null;
     }
     // kan ikke regne ut pregresjon?
     if (!$this->params->get("c") || !$this->a->params->get("count")) {
         return null;
     }
     return array("current" => $this->params->get("c"), "target" => $this->a->params->get("count"));
 }
Exemplo n.º 4
0
 /**
  * Marker forumet som sett
  */
 public function forum_seen()
 {
     $this->params_load();
     $container = new container($this->params_user->get("forums"));
     foreach ($container->items as $key => $row) {
         if ($row[0] != "ff") {
             continue;
         }
         if ($row[1] != $this->ff->id) {
             continue;
         }
         // må oppdatere antallet?
         if (isset($row[4]) && $row[4] > 0) {
             $this->params_user->lock();
             $forums = $this->params_user->get("forums");
             $container = new container($forums);
             foreach ($container->items as $key => $row) {
                 if ($row[0] != "ff" || $row[1] != $this->ff->id) {
                     continue;
                 }
                 // fjern antallet og lagre
                 unset($container->items[$key][4]);
                 $this->params_user->update("forums", $container->build());
                 $this->params_user->commit();
                 return true;
             }
             $this->params_user->commit();
             return NULL;
         }
         return false;
     }
     return NULL;
 }
Exemplo n.º 5
0
 /** Fjern fra status */
 public function status_remove()
 {
     $this->params->lock();
     $status = unserialize($this->params->get("repliers"));
     // oppdater oppføringen for denne spilleren
     if (isset($status[login::$user->player->id])) {
         unset($status[login::$user->player->id]);
     }
     // lagre
     if (is_array($status) && count($status) == 0) {
         $this->params->remove("repliers", true);
     } else {
         $this->params->update("repliers", serialize($status), true);
     }
 }