<?php## Copyright (c) 2000-2017 University of Utah and the Flux Group.# # {{{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/>.# # }}}#chdir("..");chdir("apt");include_once("profile_defs.php");include_once("instance_defs.php");include_once("ajax-routines.ajax");# This is set in CheckPageArgs();$project=null;## Need to check the permission, since we allow admins to mess with# other accounts.#functionCheckPageArgs(){global$this_user;global$ajax_args,$project;if(!ISADMIN()){SPITAJAX_ERROR(-1,"Not enough permission");return-1;}if(!isset($ajax_args["pid"])){SPITAJAX_ERROR(-1,"Must supply project");return-1;}$project=Project::LookupByPid($ajax_args["pid"]);if(!$project){SPITAJAX_ERROR(-1,"No such project");return-1;}return0;}functionDo_ProjectList(){global$this_user;global$ajax_args;$results=array();if(!ISADMIN()){SPITAJAX_ERROR(-1,"Not enough permission");return;}## Look in the projects table to see which projects have not been approved.#$projlist=Project::PendingProjectList();foreach($projlistas$project){$blob=array();$leader=$project->GetLeader();$portal=$project->portal();if(!$portal){$portal="Classic";}$blob["pid"]=$project->pid();$blob["pid_idx"]=$project->pid_idx();$blob["created"]=DateStringGMT($project->created());$blob["description"]=$project->name();if($project->URL()&&$project->URL()!=""){if(preg_match("/^http[s]?:\/\//",$project->URL())){$blob["url"]=$project->URL();}else{$blob["url"]="http://".$project->URL();}}$blob["portal"]=$portal;$blob["why"]=$project->why();$blob["leader"]=$project->head_uid();$blob["leader_idx"]=$project->head_idx();$blob["leader_name"]=$leader->name();$blob["leader_affil"]=$leader->affil();$blob["leader_email"]=$leader->email();

if(!($leader=$project->GetLeader())){TBERROR("Error getting leader for $pid",0);SPITAJAX_ERROR(-1,"Internal error getting project leader");return;}$curstatus=$leader->status();$headuid=$project->head_uid();$headuid_email=$leader->email();$headname=$leader->name();$pid=$project->pid();$optargs="";if($deleteuser){## Take the user out of the project group first.#$retval=SUEXEC($this_uid,$TBADMINGROUP,"webmodgroups -r $pid:$pid$headuid",SUEXEC_ACTION_CONTINUE);if($retval){SPITAJAX_ERROR(-1,"Internal error removing user from project");return;}## See if user is in any other projects (even unapproved).#$project_list=$leader->ProjectMembershipList();## If yes, then we cannot safely delete the user account.#if(!count($project_list)){## No other project membership. If the user is unapproved/newuser,# it means he was never approved in any project, and so will# likely not be missed. He will be unapproved if he did his# verification.#if($curstatus==TBDB_USERSTATUS_NEWUSER||$curstatus==TBDB_USERSTATUS_UNAPPROVED){$retval=SUEXEC($this_uid,$TBADMINGROUP,"webrmuser -n -p $pid$headuid",SUEXEC_ACTION_CONTINUE);if($retval){SPITAJAX_ERROR(-1,"Internal error removing user");return;}}}}$retval=SUEXEC($this_uid,$TBADMINGROUP,"webrmproj $pid",SUEXEC_ACTION_CONTINUE);if($retval){SPITAJAX_ERROR(-1,"Internal error removing project, "."see the email sent to your testbed-ops list");return;}

if(!$silent){# This works cause we still have the project object in memory.SendProjAdminMail($project,"ADMIN","$headname '$headuid' <$headuid_email>","Project application '$pid' has been denied!","This message is to notify you that your project application\n"."for $pid has been denied.\n".($message==""?"":"----------------------------------------------------------------\n"."\n".$message."\n"));}