resendapproval.php 4.11 KB
Newer Older
1 2
<?php
#
3
# Copyright (c) 2003-2014 University of Utah and the Flux Group.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# 
# {{{EMULAB-LICENSE
# 
# This file is part of the Emulab network testbed software.
# 
# This file is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or (at
# your option) any later version.
# 
# This file is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public
# License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this file.  If not, see <http://www.gnu.org/licenses/>.
# 
# }}}
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#
include("defs.php3");

#
# Only known and logged in users can do this.
#
$this_user = CheckLoginOrDie();
$uid       = $this_user->uid();
$isadmin   = ISADMIN();

if (!$isadmin) {
    USERERROR("You do not have permission to access this page!", 1);
}

#
# Verify form arguments.
#
40 41 42 43
$reqargs = RequiredPageArguments("project", PAGEARG_PROJECT);
$optargs = OptionalPageArguments("submit",  PAGEARG_STRING,
				 "message", PAGEARG_ANYTHING);
$pid = $project->pid();
44

45 46
PAGEHEADER("Resend Project Approval Message");

47 48 49
#
# Form to allow text input.
#
50
function SPITFORM($project, $message, $errors)
51
{
52
    global $this_user;
53
    $message = CleanString($message);
54 55 56 57 58 59 60 61 62 63 64 65 66
    
    if ($errors) {
	echo "<table class=nogrid
                     align=center border=0 cellpadding=6 cellspacing=0>
              <tr>
                 <th align=center colspan=2>
                   <font size=+1 color=red>
                      &nbsp;Oops, please fix the following errors!&nbsp;
                   </font>
                 </td>
              </tr>\n";

	while (list ($name, $message) = each ($errors)) {
67 68
            # XSS prevention.
	    $message = CleanString($message);
69 70 71 72 73 74 75 76 77 78 79 80 81
	    echo "<tr>
                     <td align=right>
                       <font color=red>$name:&nbsp;</font></td>
                     <td align=left>
                       <font color=red>$message</font></td>
                  </tr>\n";
	}
	echo "</table><br>\n";
    }

    #
    # Show stuff
    #
82 83 84
    $project->Show();

    $url = CreateURL("resendapproval", $project);
85 86 87

    echo "<br>";
    echo "<table align=center border=1>\n";
88
    echo "<form action='$url' method='post'>\n";
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111

    echo "<tr>
              <td>Use the text box (70 columns wide) to add a message to the
                  email notification. </td>
          </tr>\n";

    echo "<tr>
             <td align=center class=left>
                 <textarea name=message rows=15 cols=70></textarea>
             </td>
          </tr>\n";

    echo "<tr>
              <td align=center>
                  <b><input type='submit' value='Submit' name='submit'></td>
          </tr>
          </form>
          </table>\n";
}

#
# On first load, display a virgin form and exit.
#
112 113
if (! isset($submit)) {
    SPITFORM($project, "", null);
114 115 116 117 118 119 120 121 122
    PAGEFOOTER();
    return;
}

# If there is a message in the text box, it is appended below.
if (! isset($message)) {
    $message = "";
}

123
if (! ($leader = $project->GetLeader())) {
124 125 126 127 128 129
    TBERROR("Error getting leader for $pid", 1);
}
$headuid       = $leader->uid();
$headuid_email = $leader->email();
$headname      = $leader->name();

130
SendProjAdminMail(
131
       $project,
132 133
       "ADMIN",
       "$headname '$headuid' <$headuid_email>",
134 135 136 137 138 139 140 141 142 143 144
       "Project '$pid' Approval",
       "\n".
       "This message is to notify you that your project '$pid'\n".
       "has been approved.  We recommend that you save this link so that\n".
       "you can send it to people you wish to have join your project.\n".
       "Otherwise, tell them to go to ${TBBASE} and join it.\n".
       "\n".
       "    ${TBBASE}/joinproject.php3?target_pid=$pid\n".
       "\n".
       ($message != "" ? "${message}\n\n" : "") .
       "Thanks,\n".
145
       "Testbed Operations\n");
146 147 148 149 150 151 152

echo "<center>
      <h2>Done!</h2>
      </center><br>\n";

sleep(1);

153
PAGEREPLACE(CreateURL("showproject", $project));
154 155 156 157 158 159

#
# Standard Testbed Footer
# 
PAGEFOOTER();
?>