~ubuntu-branches/ubuntu/lucid/boinc/lucid-backports

« back to all changes in this revision

Viewing changes to html/ops/bolt_admin.php

  • Committer: Bazaar Package Importer
  • Author(s): Rene Mayorga
  • Date: 2009-05-23 13:29:17 UTC
  • mfrom: (1.3.1 upstream) (9.1.1 experimental)
  • Revision ID: james.westby@ubuntu.com-20090523132917-3rvmkmkxbw17181o
Tags: 6.4.5+dfsg-2
* Uploaded to unstable
* Include a patch picked from Upstream SVN
   to avoid FTBFSs whith gcc 4.4 (Closes: #526666)
* remove CUDA dir that contais binary-only non DFSG software
* change section from boinc-dbg to debug
* set orig +dfsg since we remove non-dfsg software 
  when we pull the tag from upstream
  + Add Comments about this on README.Source
* Move schedtool to Recommends, (Closes: #532133)
* Add ru debconf templates translation, thanks
  to Yuri Kozlov <yuray@komyakino.ru> (Closes: #531205)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
 
2
// This file is part of BOINC.
 
3
// http://boinc.berkeley.edu
 
4
// Copyright (C) 2008 University of California
 
5
//
 
6
// BOINC is free software; you can redistribute it and/or modify it
 
7
// under the terms of the GNU Lesser General Public License
 
8
// as published by the Free Software Foundation,
 
9
// either version 3 of the License, or (at your option) any later version.
 
10
//
 
11
// BOINC is distributed in the hope that it will be useful,
 
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 
14
// See the GNU Lesser General Public License for more details.
 
15
//
 
16
// You should have received a copy of the GNU Lesser General Public License
 
17
// along with BOINC.  If not, see <http://www.gnu.org/licenses/>.
2
18
 
3
19
require_once("../inc/bolt_db.inc");
4
20
require_once("../inc/util_ops.inc");
7
23
    $x = "<b>$course->name</b>
8
24
            <br>Description: $course->description
9
25
            <br>Created: ".date_str($course->create_time)."
10
 
            <br>Course document: $course->doc_file
11
26
    ";
12
 
    $y = "<a href=bolt_map.php?course_id=$course->id>Course map</a>
13
 
        <br><a href=bolt_compare.php?course_id=$course->id>Lesson compare</a>
 
27
    $y = "<a href=bolt_map.php?course_id=$course->id>Map</a>
 
28
        <br><a href=bolt_compare.php?course_id=$course->id>Experiments</a>
14
29
        <br>
15
30
    ";
16
31
    row2_init($x, $y);
19
34
    } else {
20
35
        show_button("bolt_admin.php?action=hide&course_id=$course->id", "Hide", "Hide this course");
21
36
    }
 
37
    show_button("bolt_admin.php?action=clear_confirm&course_id=$course->id", "Clear data", "Clear student data for this course");
22
38
    echo "</td></tr>";
23
39
}
24
40
 
42
58
    row2("Course name<span class=note><br>Visible to users</span>", "<input name=course_name>");
43
59
    row2("Internal name<span class=note><br>Not visible to users; used as a directory name, so no spaces or special chars</span>", "<input name=short_name>");
44
60
    row2("Description<span class=note><br>Visible to users</span>", "<textarea name=description cols=60></textarea>");
45
 
    row2("Course document", "<input name=doc_file>");
46
61
    row2("", "<input type=submit name=submit value=\"Add course\">");
47
62
    end_table();
48
63
    echo "</form>";
76
91
    admin_page_tail();
77
92
}
78
93
 
 
94
function clear_confirm() {
 
95
    global $course_id;
 
96
 
 
97
    admin_page_head("Bolt course administration");
 
98
    echo "This will clear all student data for this course.
 
99
        This is irrevocable.
 
100
        Are you sure you want to do this?
 
101
        <p>
 
102
        <a href=bolt_admin.php?action=clear&course_id=$course_id>Yes</a>
 
103
    ";
 
104
    admin_page_tail();
 
105
}
 
106
 
 
107
function clear() {
 
108
    global $course_id;
 
109
 
 
110
    admin_page_head("Deleting course data");
 
111
    BoltEnrollment::delete_aux("course_id = $course_id");
 
112
    BoltView::delete_aux("course_id = $course_id");
 
113
    BoltResult::delete_aux("course_id = $course_id");
 
114
    BoltXsetResult::delete_aux("course_id = $course_id");
 
115
    BoltSelectFinished::delete_aux("course_id = $course_id");
 
116
    BoltRefreshRec::delete_aux("course_id = $course_id");
 
117
    BoltQuestion::delete_aux("course_id = $course_id");
 
118
    
 
119
    echo "
 
120
        Course data deleted.
 
121
    ";
 
122
    admin_page_tail();
 
123
}
 
124
 
79
125
$user = get_logged_in_user();
 
126
 
 
127
$db = BoltDb::get();
 
128
if (!$db) error_page("Can't connect to database server");
 
129
 
 
130
if (!$db->table_exists('bolt_course')) {
 
131
    page_head("Create Bolt database");
 
132
    $db_name = $db->db_name;
 
133
    echo "
 
134
        The database tables for Bolt don't seem to exist.
 
135
        To create them, go to ~/boinc/db and type
 
136
        <pre>
 
137
mysql $db_name < bolt_schema.sql
 
138
</pre>
 
139
    Then <a href=bolt_admin.php>reload this page</a>.
 
140
    ";
 
141
    page_tail();
 
142
    exit();
 
143
}
 
144
 
80
145
BoltUser::lookup($user);
81
146
$course_id = get_int('course_id', true);
82
147
if ($course_id) $course = BoltCourse::lookup_id($course_id);
92
157
    $short_name = BoltDb::escape_string(get_str('short_name'));
93
158
    $name = BoltDb::escape_string(get_str('course_name'));
94
159
    $description = BoltDb::escape_string(get_str('description'));
95
 
    $doc_file = get_str('doc_file');
96
160
    $now = time();
97
 
    BoltCourse::insert("(create_time, short_name, name, description, doc_file) values ($now, '$short_name', '$name', '$description', '$doc_file')");
 
161
    BoltCourse::insert("(create_time, short_name, name, description) values ($now, '$short_name', '$name', '$description')");
98
162
    Header('Location: bolt_admin.php');
99
163
    break;
100
164
case 'update_user_form':
120
184
    $course->update("hidden=0");
121
185
    Header('Location: bolt_admin.php');
122
186
    break;
 
187
case 'clear_confirm':
 
188
    clear_confirm();
 
189
    break;
 
190
case 'clear':
 
191
    clear();
 
192
    break;
123
193
case '':
124
194
    show_all();
125
195
    break;