approveproject_form.php3 4.85 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
<html>
<head>
<title>New Project Approval</title>
<link rel='stylesheet' href='tbstyle.css' type='text/css'>
</head>
<body>
<?php
include("defs.php3");

#
# Only known and logged in users can do this.
#
$uid = "";
if (ereg("php3\?([[:alnum:]]+)", $REQUEST_URI, $Vals)) {
    $uid=$Vals[1];
    addslashes($uid);
}
else {
    unset($uid);
}
LOGGEDINORDIE($uid);

echo "<center><h1>Approve New Projects</h1></center>\n";

#
# Of course verify that this uid has admin privs!
#
$query_result = mysql_db_query($TBDBNAME,
	"SELECT admin from users where uid='$uid' and admin='1'" );
if (! $query_result) {
    $err = mysql_error();
    TBERROR("Database Error getting admin status for $uid: $err\n", 1);
}
if (mysql_num_rows($query_result) == 0) {
    USERERROR("You do not have admin privledges to approve projects!", 1);
}

#
# Look in the projects table to see which projects have not been approved.
# Present a menu of options to either approve or deny the projects.
# Approving a project implies approving the project leader. Denying a project
# implies denying the project leader account, when there is just a single
# project pending for that project leader. 
#
$query_result = mysql_db_query($TBDBNAME,
	"SELECT * from projects where approved='0'");
if (! $query_result) {
    $err = mysql_error();
    TBERROR("Database Error getting unapproved project list: $err\n", 1);
}
if (mysql_num_rows($query_result) == 0) {
    USERERROR("There are no projects to approve!", 1);
}

echo "For each project waiting to be approved, you may select on of the
      following choices:
      <table align=center border=0>
        <tr>
            <td>Deny</td>
            <td>-</td>
            <td>Deny project application (kills project records)</td>
        </tr>

        <tr>
            <td>Destroy</td>
            <td>-</td>
            <td>Deny project application, and kill the user account</td>
        </tr>

        <tr>
            <td>Approve</td>
            <td>-</td>
            <td>Approve the project</td>
        </tr>

        <tr>
            <td>Postpone</td>
            <td>-</td>
            <td>Twiddle your thumbs some more</td>
        </tr>
      </table>\n";

#
# Now build a table with a bunch of selections. The thing to note about the
# form inside this table is that the selection fields are constructed with
# name= on the fly, from the uid of the user to be approved. In other words:
#
#             project   menu 
#	name=testbed$$approval value=approve,deny,murder,postpone
#
# so that we can go through the entire list of post variables, looking
# for these. The alternative is to work backwards, and I don't like that.
# 
echo "<table width=\"100%\" border=2 cellpadding=0 cellspacing=2
       align='center'>\n";

echo "<tr>
          <td rowspan=2>Project</td>
          <td rowspan=2>User</td>
          <td rowspan=2>Action</td>
          <td>User Name</td>
          <td>Title</td>
          <td>User Affil</td>
          <td>E-mail</td>
      </tr>
      <tr>
          <td>Proj Name</td>
          <td>URL</td>
          <td>Proj Affil</td>
          <td>Phone</td>
      </tr>\n";

echo "<form action='approveproject.php3?$uid' method='post'>\n";

while ($projectrow = mysql_fetch_array($query_result)) {
    $pid      = $projectrow[pid];
    $headuid  = $projectrow[head_uid];
    $Purl     = $projectrow[URL];
    $Pname    = $projectrow[name];
    $Paffil   = $projectrow[affil];

    $userinfo_result = mysql_db_query($TBDBNAME,
	"SELECT * from users where uid=\"$headuid\"");

    $row	= mysql_fetch_array($userinfo_result);
    $name	= $row[usr_name];
    $email	= $row[usr_email];
    $title	= $row[usr_title];
    $affil	= $row[usr_affil];
    $addr	= $row[usr_addr];
    $addr2	= $row[usr_addr2];
    $city	= $row[usr_city];
    $state	= $row[usr_state];
    $zip	= $row[usr_zip];
    $phone	= $row[usr_phone];

    echo "<tr>
              <td colspan=7> </td>
          </tr>
          <tr>
141 142
              <td rowspan=2>
                  <A href='showproject.php3?uid=$uid&pid=$pid'>$pid</A></td>
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
              <td rowspan=2>$headuid</td>
              <td rowspan=2>
                  <select name=\"$pid\$\$approval\">
                          <option value='postpone'>Postpone</option>
                          <option value='approve'>Approve</option>
                          <option value='deny'>Deny</option>
                          <option value='destroy'>Destroy</option>
                  </select>
              </td>\n";

    echo "    <td>$name</td>
              <td>$title</td>
              <td>$affil</td>
              <td>$email</td>
          </tr>\n";
    echo "<tr>
              <td>$Pname</td>
              <td>$Purl</td>
              <td>$Paffil</td>
              <td>$phone</td>
          </tr>\n";
}
echo "<tr>
          <td align=center colspan=7>
              <b><input type='submit' value='Submit' name='OK'></td>
      </tr>
      </form>
      </table>\n";
?>
</body>
</html>