Exemple #1
0
function listSearchesGUI()
{
    global $months;
    h3("Vis artikler fra gitt måned");
    form_start_post();
    select_open("month");
    for ($i = 1; $i < 10; $i++) {
        option_open("0" . $i);
        echo $months[$i];
        option_close();
    }
    for ($i = 10; $i < 13; $i++) {
        option_open($i);
        echo $months[$i];
        option_close();
    }
    select_close();
    form_hidden("m_c", "monthSearchResultGUI");
    form_select_number("year", 2004, date("Y"), date("Y"));
    form_submit("submit", "Søk");
    form_end();
    br();
    br();
    h3("Fritekstsøk");
    $author_usernames = array();
    $author_names = array();
    $author_usernames[] = "0";
    $author_names[] = "(ikke begrens)";
    $author_usernames = array_merge($author_usernames, getAllAuthorsUsernames());
    $author_names = array_merge($author_names, getAllAuthorsNames());
    form_start_post();
    form_textfield("text", "");
    br();
    echo "Sjekk mot hele ord ";
    form_checkbox("nopartialmatch", "1", "1");
    br();
    echo "Søk i kommentarer ";
    form_checkbox("searchcomments", "1", "0");
    form_hidden("m_c", "textSearchResultGUI");
    br();
    echo "Begrens til én forfatter ";
    form_dropdown("author", $author_usernames, $author_names, 0);
    br();
    form_submit("submit", "Fritekstsøk");
    form_end();
    br();
    br();
    h3("Vis alle kommentarer av gitt bruker");
    $author_usernames = getAllUsersUsernames();
    $author_names = getAllUsersNames();
    form_start_post();
    echo "Velg forfatter ";
    form_dropdown("author", $author_usernames, $author_names, 0);
    form_submit("submit", "Vis kommentarer");
    form_hidden("m_c", "listCommentsSearchResultGUI");
    form_end();
}
Exemple #2
0
 function generateForm($data = array())
 {
     $output = form_hidden("edit[step]", "confirm");
     $output .= form_textfield("Field Identification", 'edit[num]', $data['num'], 15, 15, "Location of this field at the given site; cannot be 0");
     $output .= form_select("Field Status", 'edit[status]', $data['status'], array('open' => 'open', 'closed' => 'closed'));
     $output .= form_select("Field Rating", 'edit[rating]', $data['rating'], field_rating_values(), "Rate this field on the scale provided");
     // TODO: Should become Field::get_eligible_parents()
     $sth = Field::query(array('_extra' => 'ISNULL(parent_fid)', '_order' => 'f.name,f.num'));
     $parents = array();
     $parents[0] = "---";
     while ($p = $sth->fetch(PDO::FETCH_OBJ)) {
         $parents[$p->fid] = $p->fullname;
     }
     $output .= form_select("Parent Field", 'edit[parent_fid]', $data['parent_fid'], $parents, "Inherit location and name from other field");
     if (!$data['parent_fid']) {
         $output .= form_textfield("Field Name", 'edit[name]', $data['name'], 35, 255, "Name of field (do not append number)");
         $output .= form_textfield("Field Code", 'edit[code]', $data['code'], 3, 3, "Three-letter abbreviation for field site");
         $output .= form_select("Region", 'edit[region]', $data['region'], getOptionsFromEnum('field', 'region'), "Area of city this field is located in");
         $output .= form_select("Is indoor", 'edit[is_indoor]', $data['is_indoor'], array(0 => 'No', 1 => 'Yes'), "Is this an indoor field");
         $output .= form_textfield('Street and Number', 'edit[location_street]', $data['location_street'], 25, 100);
         $output .= form_textfield('City', 'edit[location_city]', $data['location_city'], 25, 100, 'Name of city');
         $output .= form_select('Province', 'edit[location_province]', $data['location_province'], getProvinceNames(), 'Select a province from the list');
         $output .= form_textfield("Location Map", 'edit[location_url]', $data['location_url'], 50, 255, "URL for image that shows how to reach the field");
         $output .= form_textfield("Layout Map", 'edit[layout_url]', $data['layout_url'], 50, 255, "URL for image that shows how to set up fields at the site");
         $output .= form_textarea("Driving Directions", 'edit[driving_directions]', $data['driving_directions'], 60, 5, "");
         $output .= form_textarea("Parking Details", 'edit[parking_details]', $data['parking_details'], 60, 5, "");
         $output .= form_textarea("Transit Directions", 'edit[transit_directions]', $data['transit_directions'], 60, 5, "");
         $output .= form_textarea("Biking Directions", 'edit[biking_directions]', $data['biking_directions'], 60, 5, "");
         $output .= form_textarea("Public Washrooms", 'edit[washrooms]', $data['washrooms'], 60, 5, "");
         $output .= form_textarea("Special Instructions", 'edit[public_instructions]', $data['public_instructions'], 60, 5, "Specific instructions for this site that don't fit any other category.");
         $output .= form_textarea("Private Instructions", 'edit[site_instructions]', $data['site_instructions'], 60, 5, "Instructions for this site that should be shown only to logged-in members.");
         $output .= form_textarea("Sponsorship", 'edit[sponsor]', $data['sponsor'], 60, 5, "");
     }
     $output .= form_submit('Submit') . form_reset('Reset');
     return form($output);
 }
function showSetting($row, $enabled)
{
    if ($row['settingstype'] == "boolean") {
        td_open(1);
        if ($row['value'] == "true") {
            form_checkbox("setting", $enabled, true);
        } else {
            form_checkbox("setting", $enabled, false);
        }
        td_close();
        td_open(1);
        echo getString("settings_boolean", "Boolsk");
        td_close();
    } else {
        if ($row['settingstype'] == "integer") {
            td_open(1);
            form_textfield("setting", $row['value'], $enabled);
            td_close();
            td_open(1);
            echo getString("settings_integer", "Heltall");
            td_close();
        } else {
            if ($row['settingstype'] == "string") {
                td_open(1);
                form_textfield("setting", $row['value'], $enabled);
                td_close();
                td_open(1);
                echo getString("settings_string", "Tekst");
                td_close();
            } else {
                td_open(1);
                echo $row['value'];
                td_close();
                td_open(1);
                echo getString("settings_unknown_type", "Ukjent datatype");
                td_close();
            }
        }
    }
}
Exemple #4
0
function module_polladmin()
{
    // adminpage, stop here if not logged in/right access-level
    if (!isValidAdmin()) {
        echo getString("not_valid_admin", "Administratorside, du må logge inn for å få tilgang her");
        return;
    }
    echo '<a href="http://localhost/avisCMS/index.php?m_c=module_polladmin&page_title=Polladmin">Tilbake til oversikt</a>';
    $pollaction = $_REQUEST['pollaction'];
    if ($pollaction == 'addpoll') {
        if (strlen($_REQUEST['polltitle']) < 1) {
            echo "Husk tittel.";
            return;
        }
        echo '<div class="default_header">Avstemning opprettet.</div>';
        $query = "INSERT INTO poll SET title='" . $_REQUEST['polltitle'] . "';";
        $result = DB_insert($query);
        if ($result) {
            echo '<a href="index.php?m_c=module_polladmin&amp;pollaction=editpoll&amp;pollid=' . mysql_insert_id() . '">Rediger den nye pollen</a>';
        } else {
            echo "Feilmelding: " . mysql_error();
        }
    } else {
        if ($pollaction == 'delpoll') {
            $confirm = $_REQUEST['dc'];
            $pollid = $_REQUEST['pollid'];
            if ($confirm == "yes") {
                $query = "DELETE FROM poll WHERE pollid = " . $pollid . ";";
                $result = DB_update($query);
                $num_results += DB_rows_affected($query);
                $query = "DELETE FROM pollquestion WHERE pollid = " . $pollid . ";";
                $result = DB_update($query);
                $num_results += DB_rows_affected($query);
                $query = "DELETE FROM vote WHERE pollid = " . $pollid . ";";
                $result = DB_update($query);
                $num_results += DB_rows_affected($query);
                if ($num_results < 1) {
                    echo "<br/>Ingenting slettet - feilmelding: " . mysql_error();
                } else {
                    echo "<br/>Avstemningen med tilhørende stemmer og det hele aldeles pulverisert.";
                }
            } else {
                echo "<br/><br/>Sikker på at du vil slette avstemning med id " . $pollid . "? Dette medfører også sletting av alle tilknyttede spørsmål og avlagte stemmer!!<br/>";
                echo '<a href="index.php?m_c=module_polladmin&amp;pollaction=delpoll&amp;dc=yes&amp;pollid=' . $pollid . '">Ja!</a>';
            }
        } else {
            if ($pollaction == 'editpoll') {
                $pollaction2 = $_REQUEST['pollaction2'];
                $pollid = $_REQUEST['pollid'];
                $question = $_REQUEST['question'];
                $description = $_REQUEST['description'];
                if ($pollaction2 == "changetime") {
                    $query = "UPDATE poll SET description = '" . $description . "', time_opened='" . $_REQUEST['time_opened'] . "', time_closed='" . $_REQUEST['time_closed'] . "' WHERE pollid=" . $pollid . ";";
                    DB_update($query);
                    if (!result) {
                        echo 'mysql_error()';
                    }
                }
                if ($pollaction2 == "delquestion") {
                    $altid = $_REQUEST['altid'];
                    $query = "DELETE FROM pollquestion WHERE questionid=" . $altid . " AND pollid=" . $pollid . ";";
                    $result = DB_update($query);
                    //echo $query;
                    if (!$result) {
                        echo mysql_error();
                    }
                }
                if ($pollaction2 == 'addquestion') {
                    $querymax = "SELECT MAX(questionid) as maxid FROM pollquestion;";
                    $row = DB_search($querymax);
                    $newid = $row['maxid'] + 1;
                    $query = "INSERT INTO pollquestion SET pollid=" . $pollid . ", questionid='" . $newid . "', question='" . $question . "';";
                    //echo $query;
                    $result = DB_insert($query);
                    if (!result) {
                        echo mysql_error();
                    }
                }
                $pollid = $_REQUEST['pollid'];
                $query = "SELECT * FROM poll WHERE pollid=" . $pollid . ";";
                $row = DB_search($query);
                $query_questions = "SELECT * FROM pollquestion WHERE pollid=" . $pollid . ";";
                $result = DB_get_table($query_questions);
                $pollid = $row['pollid'];
                echo '<table class="default_table">';
                echo '<tr><td colspan=2><div class="default_header">Rediger spørreundersøkelse</div></td></tr>';
                echo "<tr><td>Tittel</td><td>" . $row['title'] . "</td></tr>";
                form_start_post();
                form_hidden("pollid", $pollid);
                form_hidden("m_c", "module_polladmin");
                form_hidden("pollaction", "editpoll");
                form_hidden("pollaction2", "changetime");
                echo "<tr><td>Beskrivelse (300 tegn)</td><td>" . $row['description'] . "</td><td>";
                form_textarea("description", $row['description'], 10, 10);
                echo "</td></tr>";
                echo "<tr><td>Dato start</td><td>" . $row['time_opened'] . "</td><td>";
                form_textfield("time_opened", $row['time_opened']);
                echo "</td></tr>";
                echo "<tr><td>Date slutt</td><td>" . $row['time_closed'] . "</td><td>";
                form_textfield("time_closed", $row['time_closed']);
                echo "</td></tr>";
                echo "<tr><td colspan=2>Datoformat: 2005-01-31 23:10<br/>Utelat tidspunkt og det settes til 00:00.</td><td>";
                form_submit("submit", "Lagre endringer");
                form_end();
                echo "</tr>";
                while ($row = DB_next_row($result)) {
                    echo '<tr>';
                    echo '<td>' . $row['questionid'] . '</td>';
                    echo '<td>' . $row['question'] . '</td>';
                    echo '<td>';
                    form_start_post();
                    form_submit("submit", "Slett");
                    form_hidden("m_c", "module_polladmin");
                    form_hidden("pollaction2", "delquestion");
                    form_hidden("altid", $row['questionid']);
                    form_hidden("pollaction", "editpoll");
                    form_hidden("pollid", $pollid);
                    form_end();
                    echo '</td>';
                    echo '</tr>';
                }
                echo '</table><br/><br/>';
                echo '<table class="default_table">';
                echo '<tr><td colspan=2>Legg til et alternativ</td></tr>';
                form_start_post();
                echo '<tr><td>Alternativnavn</td><td>';
                form_textfield("question", $_SESSION['question']);
                echo '</td></tr>';
                echo '<tr><td colspan=2>';
                form_submit("submit", "Legg til");
                echo '</td></tr>';
                form_hidden("pollaction", "editpoll");
                form_hidden("pollaction2", "addquestion");
                form_hidden("pollid", $pollid);
                form_hidden("m_c", "module_polladmin");
                form_end();
                echo '</table>';
            } else {
                echo '<table class="default_table">';
                echo '<tr><td colspan=4><div class="default_header">Polladmin</div></td></tr>';
                echo "<tr><td colspan=4>Lag en ny</td></tr>";
                form_start_post();
                echo "<tr><td colspan=2>Tittel</td><td colspan=2>";
                form_textfield("polltitle", $_SESSION['polltitle']);
                echo '</td></tr>';
                echo '<tr><td colspan=4>';
                form_submit("submit", "Opprett(rediger den for å fullføre)");
                echo '</td></tr>';
                form_hidden("pollaction", "addpoll");
                form_hidden("m_c", "module_polladmin");
                form_end();
                echo '<tr><td colspan=2></td></tr>';
                echo '<tr><td colspan=4><div class="default_header">Eksisterende polls</div></td></tr>';
                $query = "SELECT * FROM poll";
                $result = DB_get_table($query);
                echo '<tr><td>Tittel</td><td>Start</td><td>Slutt</td><td>Rediger</td></tr>';
                while ($row = DB_next_row($result)) {
                    echo '<tr><td>' . $row['title'] . '</td><td>' . $row['time_opened'] . '</td>';
                    echo '<td>' . $row['time_closed'] . '</td>';
                    echo '<td><a href="index.php?m_c=module_polladmin&amp;pollaction=editpoll&pollid=' . $row['pollid'] . '">Rediger</a>';
                    echo '<br/><a href="index.php?m_c=module_polladmin&amp;pollaction=delpoll&pollid=' . $row['pollid'] . '">Slett</a></td>';
                    echo '</tr>';
                }
                echo '</table>';
            }
        }
    }
}
Exemple #5
0
function print_login_form()
{
    form_start_post("form_login");
    form_label("Brukernavn:");
    form_textfield("username", "");
    form_label("Passord:");
    form_password("password", "");
    // Returns us to the same module (usually an article view)
    // when the login sequence is completed
    if (isset($_REQUEST['m_c'])) {
        form_hidden("m_c", $_REQUEST['m_c']);
    }
    if (isset($_REQUEST['articleid'])) {
        form_hidden("articleid", $_REQUEST['articleid']);
    }
    form_hidden("logging_in", "set");
    form_label("Husk meg: ");
    form_checkbox("remember", "yes", "0");
    form_submit("login", "Logg inn");
    form_end();
}
function module_admininput()
{
    // adminpage, stop here if not logged in/right access-level
    if (!isValidAdmin()) {
        echo getString("not_valid_admin", "Administratorside, du må logge inn for å få tilgang her");
        return;
    }
    $inputaction = $_REQUEST['inputaction'];
    if ($inputaction == "addarticle") {
        save_form_article();
        $title = $_REQUEST['title'];
        $author = $_REQUEST['author'];
        $author_username = $_REQUEST['author_username'];
        $date_posted = $_REQUEST['year'] . "-" . $_REQUEST['month'] . "-" . $_REQUEST['day'];
        $time_posted = $_REQUEST['hours'] . ":" . $_REQUEST['minutes'];
        $comment_to = $_REQUEST['comment_to'];
        $is_draft = $_REQUEST['is_draft'];
        $body = $_REQUEST['body'];
        if ($is_draft == "ON") {
            $is_draft = 1;
            $log_description .= "savedraft,";
        } else {
            $is_draft = 'NULL';
        }
        if (strlen($comment_to) < 1) {
            $comment_to = "NULL";
            $log_description .= "savenewarticle,";
        } else {
            $log_description .= "savenewcomment,";
        }
        $query = "INSERT INTO articles (title, author, author_username, body, date_posted, time_posted, comment_to, is_draft, view_count) VALUES(\"{$title}\", \"{$author}\", \"{$author_username}\",  \"{$body}\", \"{$date_posted}\", \"{$time_posted}\", {$comment_to},{$is_draft},0);";
        echo $query;
        $result = DB_insert($query);
        global $logtype;
        if ($result) {
            echo "Artikkel lagt inn med id: " . mysql_insert_id();
            unset_form_article();
            if ($comment_to != "NULL") {
                $log_description .= "commentadded!,";
                write_log_entry(mysql_insert_id(), $logtype['comment'], $log_description);
            } else {
                $log_description .= "articleadded!,";
                write_log_entry(mysql_insert_id(), $logtype['article'], $log_description);
            }
        } else {
            echo "Oops: " . mysql_error();
        }
    } else {
        form_start_post();
        echo '<table class="default_table">';
        echo '<tr><td>Forfatter</td><td>';
        form_textfield("author", stripslashes($_SESSION['author']));
        echo '</td></tr>';
        echo '<tr><td>Forfatter_brukernavn</td><td>';
        form_textfield("author_username", stripslashes($_SESSION['author']));
        echo '</td></tr>';
        echo '<tr><td>Tittel</td><td class="form_article_title">';
        form_textfield("title", stripslashes(fix_quotes($_SESSION['title'])));
        echo '</td></tr>';
        echo '<tr><td>Dato</td><td>';
        form_datewidget($_SESSION['date_posted']);
        echo '</td></tr>';
        echo '<tr><td>Tidspunkt</td><td>';
        form_timewidget($_SESSION['time_posted']);
        echo '</td></tr>';
        echo '<tr><td>Kommentar til</td><td>';
        form_textfield("comment_to", $_SESSION['comment_to']);
        echo '</td></tr>';
        if ($_SESSION['is_draft'] == "ON") {
            echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>';
            form_checkbox("is_draft", "ON", "1");
            echo '</td></tr>';
        } else {
            echo '<tr><td>Bare lagre, <br/>ikke publiser</td><td>';
            form_checkbox("is_draft", "ON", "0");
            echo '</td></tr>';
        }
        echo '<tr><td colspan=2 class="form_article_text">';
        form_textarea("body", stripslashes($_SESSION['body']), 30, 10);
        echo '</td></tr>';
        echo '<tr><td colspan=2>';
        form_submit("Button", "Lagre artikkelen");
        echo '</td></tr>';
        echo '<tr><td colspan=2>';
        form_submit("preview", "Forhåndsvis artikkel");
        echo '</td></tr>';
        form_hidden("m_c", "module_admininput");
        form_hidden("inputaction", "addarticle");
        form_hidden("articleid", $_SESSION['articleid']);
        if (isset($edit)) {
            form_hidden("editarticle", "editarticle");
        }
        echo '</table>';
        form_end();
    }
}
Exemple #7
0
function enterComment($articleid)
{
    // Check if session contains variables from previous entry attempt
    $formContents = buildArticleArray($_SESSION);
    h3("Legg inn en kommentar");
    table_open();
    form_start_post();
    tr_open();
    td_open(1);
    echo "Tittel";
    td_close();
    td_open(1);
    form_textfield("title", $formContents['title']);
    td_close();
    tr_close();
    //tr_open();
    //td_open(2);	echo("Tekst"); td_close();
    //tr_close();
    tr_open();
    td_open(2);
    form_textarea("body", $formContents['body'], 50, 10);
    td_close();
    tr_close();
    tr_open();
    td_open(1);
    form_submit("submit", "Legg opp");
    form_submit("submit", "Forhåndsvis");
    form_submit("submit", "Avbryt");
    td_close();
    td_open(1);
    td_close();
    tr_close();
    form_hidden("category", "0");
    form_hidden("comment_to", $articleid);
    form_hidden("m_c", "addArticleGUI");
    br();
    if (isset($_REQUEST['commentid'])) {
        form_hidden("articleid", $_REQUEST['commentid']);
    }
    form_end();
    table_close();
}
function module_user_admin()
{
    // adminpage, stop here if not logged in/right access-level
    if (!isValidAdmin()) {
        echo getString("not_valid_admin", "Administratorside, du må logge inn for å få tilgang her");
        return;
    }
    echo "<!-- start user admin -->";
    $all_ok = true;
    global $menu_files;
    if (isset($_REQUEST['edituser'])) {
        if (isset($_REQUEST['savechanges'])) {
            if (!($password1 == $password2)) {
                $all_ok = false;
                $error_msg .= " Passwords don't match!";
            }
            if ($all_ok) {
                $result = saveuser($_POST['username'], $_POST['password1'], $_POST['email'], $_POST['firstname'], $_POST['lastname'], $_POST['webpage'], $_POST['birthdate'], $_POST['description'], $_POST['admin'], $_POST['may_post']);
            } else {
                echo $error_msg;
            }
            if ($result) {
                echo "Changes saved. Jolly good.";
                global $logtype;
                write_log_entry($_POST['username'], $logtype['user'], "admin_useredit,");
            } else {
                echo "No changes were made.";
            }
        } else {
            $query = "SELECT * FROM user WHERE username=\"" . $_POST['edituser'] . "\";";
            $row = DB_search($query);
            form_start_post();
            echo '<table class="default_table">';
            echo '<tr><td>Brukernavn</td><td>';
            echo $row['username'];
            echo '</td></tr>';
            echo '<tr><td>E-post</td><td>';
            form_textfield("email", stripslashes($row['email']));
            echo ' (må ligne på en ordentlig adresse)</td></tr>';
            echo '<tr><td>Fornavn</td><td>';
            form_textfield("firstname", $row['firstname']);
            echo ' (det dine venner kaller deg)</td></tr>';
            echo '<tr><td>Etternavn</td><td>';
            form_textfield("lastname", stripslashes($row['lastname']));
            echo ' (det du het i militæret)</td></tr>';
            echo '<tr><td>Passord</td><td>';
            form_password("password1", "");
            echo ' (minst 6 tegn)</td></tr>';
            echo '<tr><td>Gjenta passord</td><td>';
            form_password("password2", "");
            echo ' (helst likt det i feltet over)</td></tr>';
            echo '<tr><td>Fødselsdato</td><td>';
            form_select_number("birthday", 0, 0, $birthday);
            form_select_number("birthmonth", 0, 0, $birthmonth);
            form_select_number("birthyear", 0, 0, $birthyear);
            echo '</td></tr>';
            echo '<tr><td>Webside</td><td>';
            form_textfield("webpage", stripslashes($row['webpage']));
            echo ' (gjerne en som fins)</td></tr>';
            echo '<tr><td>Er administrator</td><td>';
            form_textfield("admin", stripslashes($row['admin']));
            echo ' (er brukeren admin?)</td></tr>';
            echo '<tr><td>Kan skrive artikler</td><td>';
            form_textfield("may_post", stripslashes($row['may_post']));
            echo ' 0=nei, 1=ja</td></tr>';
            echo '<tr><td>Eventuelt tilknyttet bildes fil-id:</td><td>';
            echo $row['picture'];
            echo ' (fjernes via filadmin: ' . $menu_files . ')</td></tr>';
            echo '<tr><td colspan=2>Ymse visvas<br/>';
            form_textarea("description", stripslashes($row['description']), 30, 10);
            echo '<br/>(hvis det er noe mer vi bør vite om deg)<br/><br/></td></tr>';
            echo '<tr><td colspan=2>';
            form_submit("Button", "Lagre profilendringer");
            echo '</td></tr>';
            echo '<tr><td colspan=2>';
            form_submit("canceledit", "Avbryt profilendring");
            echo '</td></tr>';
            form_hidden("username", $row['username']);
            form_hidden("savechanges", "savechanges");
            form_hidden("edituser", "savechanges");
            form_hidden("m_c", "module_user_admin");
            echo '</table>';
            form_end();
        }
    } else {
        if ($_POST['deleteuser']) {
            if ($_POST['reallysure']) {
                $query = "DELETE FROM user WHERE username =\"" . $_POST['deleteuser'] . "\";";
                $result = DB_update($query);
                if ($result == 1) {
                    global $logtype;
                    write_log_entry($_POST['username'], $logtype['user'], "admin_deleteduser,");
                    echo "Bruker " . $_POST['deleteuser'] . " er slettet.";
                } else {
                    if ($result == 0) {
                        echo "Kunne ikke slette brukeren - fins fyren?";
                    } else {
                        if ($result > 1) {
                            echo "Du har prestert &aring slette flere eksemplarer av denne brukeren :p";
                        }
                    }
                }
            } else {
                echo "<div>Sikker på at du vil slette " . $_POST['deleteuser'] . "? <a href=\"index.php\">No, go back!</a></div>";
                form_start_post();
                form_hidden("m_c", "module_user_admin");
                form_hidden("reallysure", "yes");
                form_hidden("deleteuser", $_POST['deleteuser']);
                form_submit("submit", "Ja, slett!");
                form_end();
            }
        } else {
            $query = "SELECT * FROM user";
            $result = DB_get_table($query);
            $num_users = DB_rows_affected($result);
            echo '<table class="default_table">';
            for ($i = 0; $i < $num_users; $i++) {
                $row = DB_next_row($result);
                echo '<tr><td><b>Bruker</b></td><td><b>';
                echo $row['username'];
                echo '</b></td></tr><tr><td>Fornavn</td><td>';
                echo $row['firstname'];
                //echo '</td></tr><tr><td>Etternavn</td><td>';
                //echo $row['lastname'];
                echo '</td></tr><tr><td>E-post</td><td>';
                echo $row['email'];
                echo '</td></tr><tr><td>Fødselsdato</td><td>';
                echo date_nor_sql($row['birthdate']);
                echo '</td></tr><tr><td>Admin?</td><td>';
                if ($row['admin'] != "" && $row['admin'] != 0) {
                    echo 'Ja (' . $row['admin'] . ')';
                } else {
                    echo 'Nei (' . $row['admin'] . ')';
                }
                echo '</td></tr><tr><td>Kan poste?</td><td>';
                if ($row['may_post'] != "" && $row['may_post'] != 0) {
                    echo 'Ja (' . $row['may_post'] . ')';
                } else {
                    echo 'Nei (' . $row['may_post'] . ')';
                }
                echo '</td></tr><tr><td>Tilknyttet bilde, fil-id</td><td>';
                echo $row['picture'];
                echo '</td></tr><tr><td colspan=2>';
                ?>
			  	<form action="index.php" method="post">
			  	<input type="hidden" value="module_user_admin" name="m_c" />
				 <input type="submit" name="edit" value="Edit user" />
			     <input type="hidden" name="edituser" value=<?php 
                echo $row['username'];
                ?>
 />
				 </form>
			  	<form action="index.php" method="post">
			  	<input type="hidden" value="module_user_admin" name="m_c" />
				 <input type="submit" name="delete" value="Delete user" />
			     <input type="hidden" name="deleteuser" value=<?php 
                echo $row['username'];
                ?>
 />
				 </form>

			 	<?php 
                echo '</td></tr><tr><td colspan=2><hr/></td></tr>';
            }
            echo '</table>';
        }
    }
}
Exemple #9
0
 function generateForm()
 {
     global $lr_session;
     # Alias, to avoid typing.  Bleh.
     $game =& $this->game;
     $league =& $this->league;
     $game->load_score_entries();
     $output = form_hidden('edit[step]', 'confirm');
     $teams = $league->teams_as_array();
     /* Now, since teams may not be in league any longer, we need to force
      * them to appear in the pulldown
      */
     $teams[$game->home_id] = $game->home_name;
     $teams[$game->away_id] = $game->away_name;
     $output .= form_item("League/Division", l($league->fullname, "league/view/{$league->league_id}"));
     $output .= form_item("Home Team", l($game->home_name, "team/view/{$game->home_id}"));
     $output .= form_item("Away Team", l($game->away_name, "team/view/{$game->away_id}"));
     $output .= form_item("Date and Time", "{$game->game_date}, {$game->game_start} until " . $game->display_game_end() . $note);
     $field = Field::load(array('fid' => $game->fid));
     $output .= form_item("Location", l("{$field->fullname} ({$game->field_code})", "field/view/{$game->fid}"), $note);
     if ($lr_session->is_coordinator_of($game->league_id)) {
         $output .= form_item("Site Ranking (home team)", $game->get_site_ranking($game->home_id));
         $output .= form_item("Site Ranking (away team)", $game->get_site_ranking($game->away_id));
     }
     $output .= form_item("Game Status", $game->status);
     if (isset($game->round)) {
         $output .= form_item("Round", $game->round);
     }
     $spirit_group = '';
     $score_group = '';
     /*
      * Now, for scores and spirit info.  Possibilities:
      *  - game has been finalized:
      *  	- everyone can see scores
      *  	- coordinator can edit scores/spirit
      *  - game has not been finalized
      *  	- players only see "not yet submitted"
      *  	- captains can see submitted scores
      *  	- coordinator can see everything, edit final scores/spirit
      */
     if ($game->approved_by) {
         // Game has been finalized
         if (!$this->can_edit) {
             // If we're not editing, display score.  If we are,
             // it will show up below.
             switch ($game->status) {
                 case 'home_default':
                     $home_status = " (defaulted)";
                     break;
                 case 'away_default':
                     $away_status = " (defaulted)";
                     break;
                 case 'forfeit':
                     $home_status = " (forfeit)";
                     $away_status = " (forfeit)";
                     break;
             }
             $score_group .= form_item("Home ({$game->home_name} [rated: {$game->rating_home}]) Score", "{$game->home_score} {$home_status}");
             $score_group .= form_item("Away ({$game->away_name} [rated: {$game->rating_away}]) Score", "{$game->away_score} {$away_status}");
         }
         if ($game->home_score == $game->away_score && $game->rating_points == 0) {
             $score_group .= form_item("Rating Points", "No points were transferred between teams");
         } else {
             if ($game->home_score >= $game->away_score) {
                 $winner = l($game->home_name, "team/view/{$game->home_id}");
                 $loser = l($game->away_name, "team/view/{$game->away_id}");
             } elseif ($game->home_score < $game->away_score) {
                 $winner = l($game->away_name, "team/view/{$game->away_id}");
                 $loser = l($game->home_name, "team/view/{$game->home_id}");
             }
             $score_group .= form_item("Rating Points", $game->rating_points, $winner . " gain " . $game->rating_points . " points and " . $loser . " lose " . $game->rating_points . " points");
         }
         switch ($game->approved_by) {
             case APPROVAL_AUTOMATIC:
                 $approver = 'automatic approval';
                 break;
             case APPROVAL_AUTOMATIC_HOME:
                 $approver = 'automatic approval using home submission';
                 break;
             case APPROVAL_AUTOMATIC_AWAY:
                 $approver = 'automatic approval using away submission';
                 break;
             case APPROVAL_AUTOMATIC_FORFEIT:
                 $approver = 'game automatically forfeited due to lack of score submission';
                 break;
             default:
                 $approver = Person::load(array('user_id' => $game->approved_by));
                 $approver = l($approver->fullname, "person/view/{$approver->user_id}");
         }
         $score_group .= form_item("Score Approved By", $approver);
     } else {
         /*
          * Otherwise, scores are still pending.
          */
         if ($lr_session->is_coordinator_of($game->league_id)) {
             $list = player_rfc2822_address_list($game->get_captains(), true);
             $output .= para(l('Click here to send an email', "mailto:{$list}") . ' to all captains.');
         }
         $stats_group = '';
         /* Use our ratings to try and predict the game outcome */
         $homePct = $game->home_expected_win();
         $awayPct = $game->away_expected_win();
         $stats_group .= form_item("Chance to win", table(null, array(array($game->home_name, sprintf("%0.1f%%", 100 * $homePct)), array($game->away_name, sprintf("%0.1f%%", 100 * $awayPct)), array("View the " . l('Ratings Table', "game/ratings/{$game->game_id}") . " for this game."))));
         $output .= form_group("Statistics", $stats_group);
         $score_group .= form_item('', "Score not yet finalized");
         if ($lr_session->has_permission('game', 'view', $game, 'submission')) {
             $score_group .= form_item("Score as entered", $this->score_entry_display());
         }
     }
     // Now, we always want to display this edit code if we have
     // permission to edit.
     if ($this->can_edit) {
         $score_group .= form_select('Game Status', 'edit[status]', $game->status, getOptionsFromEnum('schedule', 'status'), "To mark a game as defaulted, select the appropriate option here.  Appropriate scores will automatically be entered.");
         $score_group .= form_textfield("Home ({$game->home_name} [rated: {$game->rating_home}]) score", 'edit[home_score]', $game->home_score, 2, 2);
         $score_group .= form_textfield("Away ({$game->away_name} [rated: {$game->rating_away}]) score", 'edit[away_score]', $game->away_score, 2, 2);
     }
     $output .= form_group("Scoring", $score_group);
     if ($lr_session->has_permission('game', 'view', $game, 'spirit')) {
         $ary = $game->get_spirit_entry($game->home_id);
         $s = new Spirit();
         $formbuilder = $s->as_formbuilder();
         if ($ary) {
             $formbuilder->bulk_set_answers($ary);
             // TODO: when not editable, display viewable tabular format with symbols
             $home_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'home') : $formbuilder->render_viewable(true, 'home');
         } else {
             $formbuilder->bulk_set_answers($s->default_spirit_answers());
             $home_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'home') : 'Not entered';
         }
         $formbuilder->clear_answers();
         $ary = $game->get_spirit_entry($game->away_id);
         if ($ary) {
             $formbuilder->bulk_set_answers($ary);
             $away_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'away') : $formbuilder->render_viewable(true, 'away');
         } else {
             $formbuilder->bulk_set_answers($s->default_spirit_answers());
             $away_spirit_group = $this->can_edit ? $formbuilder->render_editable(true, 'away') : 'Not entered';
         }
         $output .= form_group("Spirit assigned TO home ({$game->home_name})", $home_spirit_group);
         $output .= form_group("Spirit assigned TO away ({$game->away_name})", $away_spirit_group);
     }
     if ($lr_session->has_permission('field', 'view reports')) {
         $sth = FieldReport::query(array('game_id' => $this->game->game_id));
         $header = array("Date Reported", "Reported By", "Report");
         while ($r = $sth->fetchObject('FieldReport')) {
             $rows[] = array($r->created, l($r->reporting_user_fullname, url("person/view/" . $r->reporting_user_id)), $r->report_text);
         }
         $output .= form_group("This game's field reports for " . $field->fullname, "<div class='listtable'>" . table($header, $rows) . "</div>\n");
     }
     if ($this->can_edit) {
         $output .= para(form_submit("submit") . form_reset("reset"));
     }
     return $script . form($output, 'post', null, 'id="score_form"');
 }
Exemple #10
0
 /**
  * Render for maintenance of the form.
  */
 function render_maintenance()
 {
     // Remember the last sort order found, new question defaults to one past
     $sorder = 0;
     $output = form_hidden('edit[step]', 'confirm');
     while (list(, $q) = each($this->_questions)) {
         $output .= question_render_maintenance($q);
         $sorder = $q->sorder;
         // assume they're in order
     }
     // Add a form group for adding a new element
     $element = form_textfield('Element name', "data[_new][name]", '', 60, 60, 'If this is blank, no new element will be added');
     $element .= form_textarea('Element text', "data[_new][question]", '', 60, 5);
     $element .= form_textfield('Sort order', "data[_new][sorder]", $sorder + 1, 10, 10);
     $element .= form_checkbox('Required', "data[_new][required]", 1, false, 'Does this element require an answer? (Ignored for checkboxes, labels and descriptions)');
     $type = form_radio('Text field', 'data[_new][type]', 'textfield', true, 'A single line of text');
     $type .= form_radio('Text area', 'data[_new][type]', 'freetext', false, 'A 60x5 text box');
     $type .= form_radio('Multiple choice', 'data[_new][type]', 'multiplechoice', false, 'Multiple choice, answers can be defined later.');
     $type .= form_radio('Checkbox', 'data[_new][type]', 'checkbox', false, 'A true/false checkbox.');
     $type .= form_radio('Label', 'data[_new][type]', 'label', false, 'Not a question, used for inserting a label anywhere (e.g. before a checkbox group).');
     $type .= form_radio('Description', 'data[_new][type]', 'description', false, 'Not a question, a block of descriptive text.');
     $element .= form_item('Element type', $type);
     $output .= form_group("Add a new element", $element);
     $output .= form_submit('Submit');
     $output .= form_reset('Reset');
     return form($output);
 }
Exemple #11
0
function form_register()
{
    global $max_profile_image_size;
    if (isset($_SESSION['stored_reg_info'])) {
        $stored_reg_info = $_SESSION['stored_reg_info'];
    }
    if (isset($_SESSION['editing_profile'])) {
        $editing_profile = $_SESSION['editing_profile'];
    }
    $username = "";
    $email = "";
    $firstname = "";
    $lastname = "";
    $magic = "";
    $birthday = "";
    $birthmonth = "";
    $birthyear = "";
    $webpage = "";
    $description = "";
    if (isset($stored_reg_info)) {
        $username = $_SESSION['username'];
        $email = $_SESSION['email'];
        $firstname = $_SESSION['firstname'];
        $lastname = $_SESSION['lastname'];
        $magic = $_SESSION['magic'];
        $birthday = $_SESSION['birthday'];
        $birthmonth = $_SESSION['birthmonth'];
        $birthyear = $_SESSION['birthyear'];
        $webpage = $_SESSION['webpage'];
        $description = $_SESSION['description'];
    }
    form_start_post_file();
    echo '<tr><td>Brukernavn</td><td>';
    form_textfield("username", $username);
    echo ' (maks 16 tegn, kun tall og små bokstaver)</td></tr>';
    echo '<tr><td>E-post</td><td>';
    form_textfield("email", $email);
    echo ' (må ligne på en ordentlig adresse)</td></tr>';
    echo '<tr><td>Fornavn</td><td>';
    form_textfield("firstname", $firstname);
    echo ' (det venner kaller deg)</td></tr>';
    echo '<tr><td>Etternavn</td><td>';
    form_textfield("lastname", $lastname);
    echo ' (det du het i militæret)</td></tr>';
    echo '<tr><td>Passord</td><td>';
    form_password("password1", "");
    echo ' (minst 6 tegn)</td></tr>';
    echo '<tr><td>Gjenta passord</td><td>';
    form_password("password2", "");
    echo ' (helst likt det i feltet over)</td></tr>';
    //echo '<tr><td>Magisk nummer</td><td>'; form_textfield("magic", $magic); echo ' (gitt til deg av et medlem)</td></tr>';
    echo '<tr><td>Fødselsdato</td><td>';
    form_select_number("birthday", 0, 0, $birthday);
    form_select_number("birthmonth", 0, 0, $birthmonth);
    form_select_number("birthyear", 0, 0, $birthyear);
    echo '</td></tr>';
    echo '<tr><td>Webside</td><td>';
    form_textfield("webpage", $webpage);
    echo ' (gjerne en som fins)</td></tr>';
    echo '<tr><td>Bilde</td><td>';
    form_hidden("MAX_FILE_SIZE", $max_profile_image_size);
    form_file("picturepath");
    echo '<br/>(Maksimal størrelse er ' . $max_profile_image_size / 1000 . ' kilobytes. Bildet skaleres ned til maks 400 pikslers bredde og 600 pikslers høyde hvis det er større enn disse verdiene)</td></tr>';
    echo '<tr><td colspan=2>Ymse visvas<br/>';
    form_textarea("description", $description, 30, 10);
    echo '<br/>(hvis det er noe mer vi bør vite om deg)<br/><br/></td></tr>';
    echo '<tr><td colspan=2>';
    form_submit("Button", "Send informasjon over usikret, avlyttet linje");
    echo '</td></tr>';
    echo '<tr><td colspan=2>';
    form_submit("cancelreg", "Avbryt registrering");
    echo '</td></tr>';
    form_hidden("m_c", "module_register_user");
    form_hidden("registration", "registration_going_on");
    form_end();
}
Exemple #12
0
function registration_settings()
{
    $group = form_textfield('Order ID format string', 'edit[order_id_format]', variable_get('order_id_format', 'R%09d'), 60, 120, 'sprintf format string for the unique order ID.');
    $group .= form_textarea('Text of refund policy', 'edit[refund_policy_text]', variable_get('refund_policy_text', ''), 70, 10, 'Customize the text of your refund policy, to be shown on registration pages and invoices.');
    $offline = <<<END
<ul>
\t<li>Mail (or personally deliver) a cheque for the appropriate amount to the league office</li>
\t<li>Ensure that you quote order #<b>%order_num</b> on the cheque in order for your payment to be properly credited.</li>
\t<li>Also include a note indicating which registration the cheque is for, along with your full name.</li>
\t<li>If you are paying for multiple registrations with a single cheque, be sure to list all applicable order numbers, registrations and member names.</li>
</ul>
<p>Please note that you will not be registered to the appropriate category that you are paying for until the cheque is received and processed (usually within 1-2 business days of receipt)</p>
END;
    $group .= form_textarea('Text of offline payment directions', 'edit[offline_payment_text]', variable_get('offline_payment_text', $offline), 70, 10, 'Customize the text of your offline payment policy. Available variables are: %order_num');
    $group .= form_textarea('Text for "Partner Info" section', 'edit[partner_info_text]', variable_get('partner_info_text', ''), 70, 10, 'Customize the text for the "Partner Info" section of the registration results.');
    $output = form_group('Registration configuration', $group);
    return $output;
}