<commit_before><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");

#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Of course verify that this uid has admin privs!
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    USERERROR("You do not have admin privileges to approve projects!", 1);
}

#
# See if we are in an initial Emulab setup.
#
$FirstInitState = (TBGetFirstInitState() == "approveproject");

echo "<center><h1>
      Approving Project '$pid' ...
      </h1></center>";

#
# Grab the head_uid for this project. This verifies it is a valid project.
#
$query_result = 
    DBQueryFatal("SELECT head_uid from projects where pid='$pid'");
if (($row = mysql_fetch_row($query_result)) == 0) {
    TBERROR("Unknown project $pid", 1);
}
$headuid = $row[0];

#
# If the user wanted to change the head uid, do that now (we change both
# the head_uid and the leader of the default project)
#
if (isset($head_uid) && strcmp($head_uid,"")) {
    $headuid = $head_uid;
    DBQueryFatal("UPDATE projects set head_uid='$headuid' where pid='$pid'");
    DBQueryFatal("UPDATE groups set leader='$headuid' where pid='$pid' and " .
	    "gid='$pid'");
}

if (!isset($user_interface) ||
    !in_array($user_interface, $TBDB_USER_INTERFACE_LIST)) {
    $user_interface = TBDB_USER_INTERFACE_EMULAB;
}

#
# Get the current status for the headuid, which we might need to change
# anyway, and to verify that the user is a valid user. We also need
# the email address to let the user know what happened.
#
# We change the status only if this person is starting his first project.
# In this case, the status will be either "newuser" or "unapproved",
# and we will change it to "unapproved" or "active", respectively.
# If the status is "active", we leave it alone. 
#
$query_result = 
    DBQueryFatal("SELECT status,usr_email,usr_name from users ".
		 "where uid='$headuid'");
if (mysql_num_rows($query_result) == 0) {
    TBERROR("Unknown user $headuid", 1);
}
$row = mysql_fetch_row($query_result);
$curstatus     = $row[0];
$headuid_email = $row[1];
$headname      = $row[2];
#echo "Status = $curstatus, Email = $headuid_email<br>\n";

#
# Then we check that the headuid is really listed in the group_membership
# table (default group), just to be sure. 
#
$query_result =
    DBQueryFatal("SELECT trust from group_membership where ".
		 "uid='$headuid' and pid='$pid' and gid='$pid'");
if (mysql_num_rows($query_result) == 0) {
    USERERROR("User $headuid is not the leader of project $pid.", 1);
}

#
# Well, looks like everything is okay. Change the project approval
# value appropriately.
#
if (strcmp($approval, "postpone") == 0) {
    if (isset($message) && strcmp($message, "")) {
	USERERROR("You requested postponement for $pid, but there is a ".
		  "message in the text box which will vanish. If that is ".
		  "not what you intended, the back button will give you ".
		  "another chance, with text intact.", 1);
    }
    echo "<p><h3>
             Project approval for project $pid (User: $headuid) was
             postponed for later decision.
          </h3>\n";
}
elseif (strcmp($approval, "moreinfo") == 0) {
    TBMAIL("$headname '$headuid' <$headuid_email>",
         "Project '$pid' Approval Postponed",
         "\n".
         "This message is to notify you that your project application\n".
         "for $pid has been postponed until we have more information.\n".
         "You can just reply to this message to provide more information.\n".
         "\n$message".
         "\n\n".
         "Thanks,\n".
         "Testbed Operations\n",
         "From: $TBMAIL_APPROVAL\n".
         "Bcc: $TBMAIL_APPROVAL\n".
         "Errors-To: $TBMAIL_WWW");

    echo "<p><h3>
             Project approval for project $pid (User: $headuid) was
             postponed pending the reception of more information.
          </h3>\n";
}
elseif ((strcmp($approval, "deny") == 0) ||
	(strcmp($approval, "annihilate") == 0) ||
	(strcmp($approval, "destroy") == 0)) {
    SUEXEC($uid, $TBADMINGROUP, "rmproj $pid", 1);
    
    if (strcmp($approval, "annihilate")) {
	TBMAIL("$headname '$headuid' <$headuid_email>",
	       "Project '$pid' Denied",
	       "\n".
	       "This message is to notify you that your project application\n".
	       "for $pid has been denied.\n".<commit_msg>Tweak the msg for "more info" to also include "take actions."<commit_after><?php
#
# EMULAB-COPYRIGHT
# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
# All rights reserved.
#
include("defs.php3");

#
# Standard Testbed Header
#
PAGEHEADER("New Project Approved");

#
# Only known and logged in users can do this.
#
$uid = GETLOGIN();
LOGGEDINORDIE($uid);

#
# Of course verify that this uid has admin privs!
#
$isadmin = ISADMIN($uid);
if (! $isadmin) {
    USERERROR("You do not have admin privileges to approve projects!", 1);
}

#
# See if we are in an initial Emulab setup.
#
$FirstInitState = (TBGetFirstInitState() == "approveproject");

echo "<center><h1>
      Approving Project '$pid' ...
      </h1></center>";

#
# Grab the head_uid for this project. This verifies it is a valid project.
#
$query_result = 
    DBQueryFatal("SELECT head_uid from projects where pid='$pid'");
if (($row = mysql_fetch_row($query_result)) == 0) {
    TBERROR("Unknown project $pid", 1);
}
$headuid = $row[0];

#
# If the user wanted to change the head uid, do that now (we change both
# the head_uid and the leader of the default project)
#
if (isset($head_uid) && strcmp($head_uid,"")) {
    $headuid = $head_uid;
    DBQueryFatal("UPDATE projects set head_uid='$headuid' where pid='$pid'");
    DBQueryFatal("UPDATE groups set leader='$headuid' where pid='$pid' and " .
	    "gid='$pid'");
}

if (!isset($user_interface) ||
    !in_array($user_interface, $TBDB_USER_INTERFACE_LIST)) {
    $user_interface = TBDB_USER_INTERFACE_EMULAB;
}

#
# Get the current status for the headuid, which we might need to change
# anyway, and to verify that the user is a valid user. We also need
# the email address to let the user know what happened.
#
# We change the status only if this person is starting his first project.
# In this case, the status will be either "newuser" or "unapproved",
# and we will change it to "unapproved" or "active", respectively.
# If the status is "active", we leave it alone. 
#
$query_result = 
    DBQueryFatal("SELECT status,usr_email,usr_name from users ".
		 "where uid='$headuid'");
if (mysql_num_rows($query_result) == 0) {
    TBERROR("Unknown user $headuid", 1);
}
$row = mysql_fetch_row($query_result);
$curstatus     = $row[0];
$headuid_email = $row[1];
$headname      = $row[2];
#echo "Status = $curstatus, Email = $headuid_email<br>\n";

#
# Then we check that the headuid is really listed in the group_membership
# table (default group), just to be sure. 
#
$query_result =
    DBQueryFatal("SELECT trust from group_membership where ".
		 "uid='$headuid' and pid='$pid' and gid='$pid'");
if (mysql_num_rows($query_result) == 0) {
    USERERROR("User $headuid is not the leader of project $pid.", 1);
}

#
# Well, looks like everything is okay. Change the project approval
# value appropriately.
#
if (strcmp($approval, "postpone") == 0) {
    if (isset($message) && strcmp($message, "")) {
	USERERROR("You requested postponement for $pid, but there is a ".
		  "message in the text box which will vanish. If that is ".
		  "not what you intended, the back button will give you ".
		  "another chance, with text intact.", 1);
    }
    echo "<p><h3>
             Project approval for project $pid (User: $headuid) was
             postponed for later decision.
          </h3>\n";
}
elseif (strcmp($approval, "moreinfo") == 0) {
    TBMAIL("$headname '$headuid' <$headuid_email>",
         "Project '$pid' Approval Postponed",
         "\n".
         "This message is to notify you that your project application\n".
         "for $pid has been postponed until we have more information\n".
         "or you take certain actions.  You can just reply to this message\n".
         "to provide that information or report your actions.\n".
         "You can just reply to this message to provide more information.\n".
         "\n$message".
         "\n\n".
         "Thanks,\n".
         "Testbed Operations\n",
         "From: $TBMAIL_APPROVAL\n".
         "Bcc: $TBMAIL_APPROVAL\n".
         "Errors-To: $TBMAIL_WWW");

    echo "<p><h3>
             Project approval for project $pid (User: $headuid) was
             postponed pending the reception of more information.
          </h3>\n";
}
elseif ((strcmp($approval, "deny") == 0) ||
	(strcmp($approval, "annihilate") == 0) ||
	(strcmp($approval, "destroy") == 0)) {
    SUEXEC($uid, $TBADMINGROUP, "rmproj $pid", 1);
    
    if (strcmp($approval, "annihilate")) {
	TBMAIL("$headname '$headuid' <$headuid_email>",
	       "Project '$pid' Denied",
	       "\n".
	       "This message is to notify you that your project application\n".
	       "for $pid has been denied.\n".
{'fraction_non_alphanumeric': 0.13939261525016386, 'fraction_numerical': 0.008083897749617654, 'mean_word_length': 3.3972142170989432, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1646647', 'n_tokens_mistral': 3058, 'n_tokens_neox': 2941, 'n_words': 1003}