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

« back to all changes in this revision

Viewing changes to html/user/team_admins.php

  • Committer: Bazaar Package Importer
  • Author(s): Frank S. Thomas, Frank S. Thomas
  • Date: 2008-05-31 08:02:47 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20080531080247-4ce890lp2rc768cr
Tags: 6.2.7-1
[ Frank S. Thomas ]
* New upstream release.
  - BOINC Manager: Redraw disk usage charts immediately after connecting to
    a (different) client. (closes: 463823)
* debian/copyright:
  - Added the instructions from debian/README.Debian-source about how
    repackaged BOINC tarballs can be reproduced because DevRef now
    recommends to put this here instead of in the afore-mentioned file.
  - Updated for the new release.
* Removed the obsolete debian/README.Debian-source.
* For consistency upstream renamed the core client and the command tool
  ("boinc_client" to "boinc" and "boinc_cmd" to "boinccmd"). Done the same
  in all packages and created symlinks with the old names for the binaries
  and man pages. Also added an entry in debian/boinc-client.NEWS explaining
  this change.
* debian/rules: Do not list Makefile.ins in the clean target individually,
  just remove all that can be found.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
require_once("../inc/boinc_db.inc");
 
4
require_once("../inc/util.inc");
 
5
require_once("../inc/team.inc");
 
6
 
 
7
function show_admin($user, $admin) {
 
8
    $admin_user = BoincUser::lookup_id($admin->userid);
 
9
    $tokens = url_tokens($user->authenticator);
 
10
    $date = date_str($admin->create_time);
 
11
    echo "<tr>
 
12
        <td>".user_links($admin_user)."</td>
 
13
        <td>$date</td>
 
14
        <td>
 
15
    ";
 
16
    show_button("team_admins.php?teamid=$admin->teamid&action=remove&userid=$admin_user->id".$tokens, "Remove", "Remove Team Admin status from this member");
 
17
    echo "</td></tr>
 
18
    ";
 
19
}
 
20
 
 
21
function show_admins($user, $teamid) {
 
22
    page_head("Add or remove Team Admins");
 
23
    echo "
 
24
        You can select team members as 'Team Admins'.
 
25
        Team Admins can:
 
26
        <ul>
 
27
        <li> Edit team information (name, URL, description, country).
 
28
        <li> View the team's join/quit history.
 
29
        <li> Moderate the team forum, if any (admins get emails notification
 
30
            of moderation events and red X reports).
 
31
        </ul>
 
32
        Team Admins cannot:
 
33
        <ul>
 
34
        <li> Change the team founder.
 
35
        <li> Remove members.
 
36
        <li> Add or remove Team Admins.
 
37
        </ul>
 
38
        If a Team Admin quits the team, they cease to be a Team Admin.
 
39
        <p>
 
40
        We recommend that you select only people
 
41
        you know and trust very well as Team Admins.
 
42
    ";
 
43
    $admins = BoincTeamAdmin::enum("teamid=$teamid");
 
44
    start_table();
 
45
    if (count($admins)==0) {
 
46
        row1("There are currently no Team Admins");
 
47
    } else {
 
48
        row1("Current Team Admins", 3);
 
49
        table_header("Name", "Became Team Admin on", "");
 
50
        foreach ($admins as $admin) {
 
51
            show_admin($user, $admin);
 
52
        }
 
53
    }
 
54
    end_table();
 
55
 
 
56
    echo "
 
57
        <p>
 
58
        <form action=team_admins.php>
 
59
        <input type=hidden name=action value=add>
 
60
        <input type=hidden name=teamid value=$teamid>
 
61
    ";
 
62
    echo form_tokens($user->authenticator);
 
63
    start_table();
 
64
    row1("Add Team Admin");
 
65
    row2("Email address of team member:", "<input name=email_addr>");
 
66
    row2("", "<input type=submit action value=\"Add\">");
 
67
    end_table();
 
68
    echo "</form>";
 
69
 
 
70
    page_tail();
 
71
}
 
72
 
 
73
function remove_admin($team) {
 
74
    $userid = get_int('userid');
 
75
    $ret = BoincTeamAdmin::delete("teamid=$team->id and userid=$userid");
 
76
    if (!$ret) {
 
77
        error_page("failed to remove admin");
 
78
    }
 
79
}
 
80
 
 
81
function add_admin($team) {
 
82
    $email_addr = get_str('email_addr');
 
83
    $user = BoincUser::lookup("email_addr='$email_addr'");
 
84
    if (!$user) error_page("no such user");
 
85
    if ($user->teamid != $team->id) error_page("User is not member of team");
 
86
    if (is_team_admin($user, $team)) {
 
87
        error_page("$email_addr is already an admin of $team->name");
 
88
    }
 
89
    $now = time();
 
90
    $ret = BoincTeamAdmin::insert("(teamid, userid, create_time) values ($team->id, $user->id, $now)");
 
91
    if (!$ret) error_page("Couldn't add admin");
 
92
}
 
93
 
 
94
$user = get_logged_in_user();
 
95
$teamid = get_int('teamid');
 
96
$team = BoincTeam::lookup_id($teamid);
 
97
if (!$team) error_page("No such team");
 
98
require_founder_login($user, $team);
 
99
 
 
100
$action = get_str('action', true);
 
101
switch($action) {
 
102
case 'remove':
 
103
    check_tokens($user->authenticator);
 
104
    remove_admin($team);
 
105
    Header("Location: team_admins.php?teamid=$teamid");
 
106
    exit();
 
107
case 'add':
 
108
    check_tokens($user->authenticator);
 
109
    add_admin($team);
 
110
    Header("Location: team_admins.php?teamid=$teamid");
 
111
    exit();
 
112
}
 
113
show_admins($user, $teamid);
 
114
 
 
115
?>