Switch site->listthemes to expect a resolution rather than a target. Adjust other...
[rockboxthemes.git] / public / admin.php
blob8904666f1d1ad9782636462ecfcd2ca1352ef5ef
1 <?php
2 /***************************************************************************
3 * __________ __ ___.
4 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * \/ \/ \/ \/ \/
9 * $Id$
11 * Copyright (C) 2009 Jonas Häggqvist
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ****************************************************************************/
23 require_once('preconfig.inc.php');
24 session_start();
26 function changestatuses(&$site) {
27 foreach($_REQUEST['id'] as $n => $id) {
28 $newstatus = $_REQUEST['status'][$n];
29 $oldstatus = $_REQUEST['prevstatus'][$n];
30 $reason = $_REQUEST['reason'][$n];
31 if ($oldstatus != $newstatus) {
32 $site->changestatus($id, $newstatus, $oldstatus, $reason);
37 /* First, check if the user is logged in and handle logins */
38 if (isset($_REQUEST['logout'])) {
39 unset($_SESSION['user']);
40 $t->assign('msg', 'Logged out.');
42 if (isset($_REQUEST['user'])) {
43 if ($site->adminlogin($_REQUEST['user'], $_REQUEST['pass'])) {
44 $_SESSION['user'] = $_REQUEST['user'];
46 else {
47 $t->assign('msg', 'Login failed. Please try again');
50 /* If not logged in, show the login form */
51 if (!isset($_SESSION['user'])) {
52 $template = 'login.tpl';
54 else {
55 /* Else, we need to figure out what to do then */
56 if (isset($_REQUEST['target'])) {
57 if (isset($_REQUEST['changestatuses'])) {
58 changestatuses($site);
60 $approved = isset($_REQUEST['approved']) ? $_REQUEST['approved'] : 'any';
61 $template = 'adminlist.tpl';
62 $lcd = $site->target2lcd($_REQUEST['target']);
63 $themes = $site->listthemes($lcd['mainlcd'], 'timestamp DESC',$approved, $onlyverified = false);
64 $t->assign('mainlcd', $lcd['mainlcd']);
65 $t->assign('themes', $themes);
66 $t->assign('approved', $approved);
68 /* Adding a target */
69 elseif (isset($_REQUEST['addtarget'])) {
70 $site->addtarget(
71 $_REQUEST['shortname'],
72 $_REQUEST['fullname'],
73 $_REQUEST['mainlcd'],
74 $_REQUEST['pic'],
75 $_REQUEST['depth'],
76 empty($_REQUEST['remotelcd']) ? false : $_REQUEST['remotelcd']
78 $t->assign('adminmsg', 'Target added');
80 /* Run checkwps on all themes */
81 elseif (isset($_REQUEST['runcheckwps'])) {
82 $results = $site->checkallthemes();
83 $template = 'checkthemes.tpl';
84 $t->assign('checkwpsresults', $results);
86 /* Or just show the front page */
87 if (!isset($template)) {
88 $t->assign('title', 'Admin');
89 $t->assign('targets', $site->listtargets());
90 $t->assign('admin', true);
91 $template = 'frontpage.tpl';
94 $t->render($template);