<?php

final class Admin {

    public $sql;
    public $main;
    public $file;
    var $cleaner = '<div style="clear: both;"></div>';
    var $form_action;
    var $include;
    var $var_paging = 15;
    var $margin = 0;
    var $sekcia = 0;
    var $category;

    public function __construct() {
        global $sql;
        global $main;
        global $file;
        $this->sql = &$sql;
        $this->file = &$file;
        $this->main = &$main;
        $this->form_action = str_replace('&', '&amp;', $_SERVER['REQUEST_URI']);
        $this->category = true;
    }


public function manage_content() {
    echo 'Prejdi na: <a href="?id=' . $_GET['id'] . '&amp;edit_users=1" title="Spravovanie užívateľov">Spravovanie užívateľov</a><br /><br />';
    ?>
        <form action="<?=$main->form_action?>" method="post">
            zobraz len:
            <select name="stav" onchange="this.form.submit()" style="font-size: 10px; border: 1px solid #00377E;">
                <option <?php if ($_POST['stav'] == 0) {echo 'selected="selected"';} ?> value="0">bez akcie</option>
                <option <?php if ($_POST['stav'] == 1) {echo 'selected="selected"';} ?> value="1">ponechané</option>
                <option <?php if ($_POST['stav'] == 2) {echo 'selected="selected"';} ?> value="2">odstránené</option>
            </select>
        </form><br />
        <table id="myTable" cellpadding="0" cellpadding="0" style="width: 800px;">
            <thead>
                <th axis="number">ID</th>
                <th axis="string">Ucitel</th>
                <th axis="string">Sekcia</th>
                <th axis="string">Linka</th>
                <th axis="date">Nahlásené</th>
                <th axis="string">Dôvod</th>
                <th>Akcia:</td>
            </thead>
            <tbody>
                <?php
                if ( isset($_POST['stav']) ) {
                    $sub_sql = ' WHERE stav=' . $_POST['stav'];
                } else {
                    $sub_sql = ' WHERE stav=0';
                }
                $result = mysql_query('SELECT * FROM reported_content' . $sub_sql);
                $i = 1;
                while ( $row = mysql_fetch_assoc($result) ) {
                    if ( $_POST['stav'] != 0 ) {
                        $done = '<a style="margin-left: 20px;" href="?id=18&amp;del_list=' . $row['version'] . '" title="odstrániť príspevok z listu administrovaných príspevkov"><img src="images/admin_trash.png" alt="odstranit z listu" /></a>';
                    } else { $done = ''; }
                    echo '
                        <tr id="' . $i . '" onmouseover="document.getElementById(\'dovod\').innerHTML=\'' . $row['dovod'] . '\'; onmouseout="document.getElementById(\'dovod\').innerHTML=\'\'" >
                            <td class="rightAlign">' . $row['id'] . '</td>
                            <td><a href="" style="display: block;">' . $this->main->get_user_name($row['id_user']) . '</a></td>
                            <td>' . $this->main->get_section_name($row['main_section']) . '</td>
                            <td><a href="?id=' . $row['main_section'] . '&amp;article=' . $row['root_post'] . '&amp;history=' . $row['version'] . '" title="">clanok</a></td>
                            <td class="rightAlign">' . $row['date'] . '</td>
                            <td>' . $row['dovod'] . '</td>
                            <td style="text-align: center;"><a href="?id=18&amp;let=' . $row['version'] . '" title="ponechať príspevok"><img src="images/admin_yes.png" alt="nechat" /></a> <a href="?id=18&amp;del=' . $row['version'] . '" title="odstrániť príspevok"><img src="images/admin_no.png" alt="odstranit" /></a> ' . $done . '</td>
                        </tr>
                    ';
                    $i++;
                }
                ?>
            </tbody>
            <tfoot>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </tfoot>
        </table>
        <?php
}

public function manage_users() {
    //add_rights=1 odbaveny add_rights=2 chce byt ucitel
    echo 'Prejdi na: <a href="?id=' . $_GET['id'] . '" title="Spravovanie obsahu">Spravovanie obsahu</a><br /><br />';
?>
        <form action="<?=$main->form_action?>" method="post">
            zobraz len:
            <select name="stav" onchange="this.form.submit()" style="font-size: 10px; border: 1px solid #00377E;">
                <option <?php if ($_POST['stav'] == 0) {echo 'selected="selected"';} ?> value="0">žiadateľov o učiteľské konto</option>
                <option <?php if ($_POST['stav'] == 1) {echo 'selected="selected"';} ?> value="1">učiteľov</option>
            </select>
        </form><br />
        <table id="myTable" cellpadding="0" cellpadding="0" style="width: 800px;">
            <thead>
                <th axis="number">ID</th>
                <th axis="string">Nick</th>
                <th axis="string">Meno</th>
                <th axis="string">Priezvysko</th>
                <th axis="string">Mail</th>
                <th>Akcia:</td>
            </thead>
            <tbody>
                <?php
                if ( isset($_POST['stav']) ) {
                    if ( $_POST['stav'] == 0 ) {
                        $sub_sql = ' WHERE add_rights=2';
                    } elseif ( $_POST['stav'] == 1 ) {
                        $sub_sql = ' WHERE add_rights=1 AND group_rights=1';
                    }
                } else {
                    $sub_sql = ' WHERE add_rights=2';
                }
                $result = mysql_query('SELECT * FROM login.users' . $sub_sql);
                $i = 1;
                while ( $row = mysql_fetch_assoc($result) ) {
                    echo '
                        <tr id="' . $i . '">
                            <td class="rightAlign">' . $row['id_user'] . '</td>
                            <td>' . $row['nick'] . '</td>
                            <td>' . $row['first_name'] . '</td>
                            <td>' . $row['last_name'] . '</td>
                            <td>' . $row['mail'] . '</td>
                            <td style="text-align: center;">
                                <a href="?id=18&amp;edit_users=1&amp;lector=' . $row['id_user'] . '" title="Aktivovať učiteľské konto"><img src="images/admin_lector.png" alt="lector" /></a>
                                <a href="?id=18&amp;edit_users=1&amp;del_lector=' . $row['id_user'] . '" title="Nieje učiteľ"><img src="images/admin_no.png" alt="odstranit" /></a>
                            </td>
                        </tr>
                    ';
                    $i++;
                }
                ?>
            </tbody>
            <tfoot>
                <tr>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                    <td></td>
                </tr>
            </tfoot>
        </table>
<?php
}

}