예제 #1
0
    public function database($args)
    {
        EStructure::view("header");
        if (!isset($args[0])) {
            echo '<h3>Database</h3>';
            echo '<p>If you just copied your ocs-server files to an other server, you would like to reconfigure database.<br>
			<a href="/admin/steps/step1">CONFIGURE DATABASE</a></p>';
            echo '<p>If you have a broken/unconsistent database running, you can attempt resetting your database.<br>
			<a href="/admin/status/database/reset">RESET DATABASE</a></p>';
            echo '<p>If you want to run sanity tests on your database you should install default data.<br>
			This is not reccomended on production and generally useful only for developers.<br>
			<a href="/admin/status/database/testdata">INSTALL TEST DATA</a></p>';
        }
        if (isset($args[0])) {
            echo '<hr>';
            if ($args[0] == 'reset') {
                echo '<h3>Database</h3>';
                echo 'Resetting...Done!<br>';
                echo 'Are you willing to execute tests? You better <a href="/admin/status/database/testdata">install default data</a>';
                echo '<br><a href="/admin/status/database">Back to database panel</a>';
                //using ocstest external library in /admin/libs
                OCSTest::reset_ocs_database();
            } else {
                if ($args[0] == 'testdata') {
                    echo '<p>adding test/password user..........';
                    $postdata = array("login" => "test", "password" => "password", "email" => "*****@*****.**", "firstname" => "cavolf", "lastname" => "chiappe");
                    $client = new OCSClient(EConfig::$data["ocs"]["host"]);
                    $check = $client->post("v1/person/add", $postdata);
                    $this->_statuscode_test($check, $client);
                    echo '<a href="/admin/status/database">Back to database panel</a>';
                }
            }
        }
        EStructure::view("footer");
    }