Skip to content
Permalink
Browse files
Merge branch 'heads/sneha/develop' into develop
This closes #58
  • Loading branch information
machristie committed Jul 2, 2017
2 parents acda62e + a5d1637 commit 1281d8277d066b83bb997f564513d4c39e1e96f3
Showing 15 changed files with 880 additions and 172 deletions.
@@ -55,5 +55,55 @@
"</p>",
"</div>"
]
},

"gateway_request" : {
"subject" : "New Gateway Request",
"body" : [
"<div>",
"<p>",
"Dear Admin,<br/>",

"$firstName $lastName has initiated a new Gateway request.",
" The requested Gateway is $gatewayName.",
" Please click the link below to verify the request.<br/>",

"<a href=\"$url\">$url</a><br/>",
"</p>",
"</div>"
]
},

"update_to_admin" : {
"subject" : "Gateway Details Updated",
"body" : [
"<div>",
"<p>",
"Dear Admin,<br/>",

"There has been an update in the Gateway info for Gateway with ID - $gatewayId.",
" Please click the link below to view the changes.<br/>",

"<a href=\"$url\">$url</a><br/>",
"</p>",
"</div>"
]
},

"update_to_user" : {
"subject" : "Gateway Details Updated",
"body" : [
"<div>",
"<p>",
"Dear $firstName $lastName,<br/>",

"There has been an update in the Gateway info for your Gateway with ID - $gatewayId.",
" Please click the link below to view the changes.<br/>",

"<a href=\"$url\">$url</a><br/>",
"</p>",
"</div>"
]
}

}
@@ -25,6 +25,9 @@ public function dashboard(){
$gatewayOfUser = "";
Session::put("super-admin", true);
$gatewaysInfo = CRUtilities::getAllGateways();
Log::info("Gateways: ", $gatewaysInfo);
Log::info("Username: ", [Session::get("username")]);
//$gatewaysInfo = CRUtilities::getAllGateways();
//var_dump( $gatewaysInfo); exit;
$requestedGateways = array();
$gatewayApprovalStatuses = AdminUtilities::get_gateway_approval_statuses();
@@ -36,8 +39,8 @@ public function dashboard(){
Session::put("new-gateway-provider", true);
Session::put("existing-gateway-provider", true);

$requestedGateways[ $gateway->gatewayId]["gatewayInfo"] = $gateway;
$requestedGateways[ $gateway->gatewayId]["approvalStatus"] = $gatewayApprovalStatuses[ $gateway->gatewayApprovalStatus];
$requestedGateways[ $gateway->airavataInternalGatewayId]["gatewayInfo"] = $gateway;
$requestedGateways[ $gateway->airavataInternalGatewayId]["approvalStatus"] = $gatewayApprovalStatuses[ $gateway->gatewayApprovalStatus];
//seeing if admin wants to start managing one of the gateways
if( Input::has("gatewayId")){
if( Input::get("gatewayId") == $gateway->gatewayId)
@@ -170,23 +173,36 @@ public function addGatewayAdminSubmit(){

public function updateGatewayRequest(){

//first step of adding tenant and changing gateway request status to Approved.
$returnVal = AdminUtilities::update_gateway( Input::get("gateway_id"), Input::all());
$returnVal = AdminUtilities::update_gateway( Input::get("gateway_id"), Input::except("oauthClientId","oauthClientSecret"));
if( Request::ajax()){
if( $returnVal == 1)
return json_encode( AdminUtilities::get_gateway( Input::get("gateway_id")) );
else
return $returnVal; // anything other than positive update result
if( $returnVal == 1) {
$username = Session::get("username");
$email = Config::get('pga_config.portal')['admin-emails'];
$user_profile = Keycloak::getUserProfile($username);
EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway_id"));
EmailUtilities::mailToAdmin($email, Input::get("gateway_id"));
return json_encode(AdminUtilities::get_gateway(Input::get("gateway_id")));
}
else {
return $returnVal; // anything other than positive update result
}
}
else{
if( $returnVal == 1)
Session::put("message", "Request has been updated");
else
Session::put("message", "An error has occurred while updating your request. Please try again or contact admin to report the issue.");
if( $returnVal) {
$username = Session::get("username");
$email = Config::get('pga_config.portal')['admin-emails'];
$user_profile = Keycloak::getUserProfile($username);
EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway_id"));
EmailUtilities::mailToAdmin($email, Input::get("gateway_id"));
Session::put("message", "Request has been updated");
}
else {
Session::put("message", "An error has occurred while updating your request. Please make sure you've entered all the details correctly. Try again or contact admin to report the issue.");
}

return Redirect::to("admin/dashboard");
return Redirect::back();

}
}
//return 1;
}

@@ -413,6 +429,12 @@ public function removePWD(){

/* ---- Super Admin Functions ------- */

public function createGateway(){

return View::make("admin/create-gateway");

}

public function addGateway(){
$inputs = Input::all();

@@ -435,25 +457,64 @@ public function addGateway(){

$validator = Validator::make( $checkValidation, $rules, $messages);
if ($validator->fails()) {
return Response::json( $validator->messages() );
Session::put("validationMessages", [$validator->messages()] );
return Redirect::back()
->withErrors($validator);
}
else{
$gateway = AdminUtilities::add_gateway(Input::all());

$tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"],
$inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);
$username = Session::get("username");
$returnVal = AdminUtilities::add_gateway(Input::all());

if ($returnVal == 1){
$email = Config::get('pga_config.portal')['admin-emails'];
$user_profile = Keycloak::getUserProfile($username);
EmailUtilities::gatewayRequestMail($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway-name"));
Session::put("message", "Gateway " . $inputs["gateway-name"] . " has been added.");
}
else{
Session::put("errorMessages", "Error: A Gateway already exists with the same GatewayId, Name or URL! Please make a new request.");
}

Session::put("message", "Gateway " . $inputs["gatewayName"] . " has been added.");

return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) );
if( $gateway == $inputs["gatewayName"] && is_object( $tm ) )
return Response::json( array( "gateway" =>$gateway, "tm" => $tm ) );
else
return 0;
//return Redirect::to("admin/dashboard/gateway")->with("message", "Gateway has been successfully added.");
return Redirect::back();
}
}

public function checkRequest(){
$inputs = Input::all();

$rules = array(
"email" => "required|email",
);

$messages = array(
'email.format' => 'Please enter a valid Email ID',
);

$checkValidation = array();
$checkValidation["email"] = $inputs["email-address"];

$validator = Validator::make( $checkValidation, $rules, $messages);
if ($validator->fails()) {
Session::put("validationMessages", [$validator->messages()] );
return Redirect::to("admin/dashboard")
->withErrors($validator);
}
else{
$username = Session::get("username");
$returnVal = AdminUtilities::check_request(Input::all());

if ($returnVal == 1) {
$email = Config::get('pga_config.portal')['admin-emails'];
$user_profile = Keycloak::getUserProfile($username);
EmailUtilities::gatewayRequestMail($user_profile["firstname"], $user_profile["lastname"], $email, $inputs["gateway-name"]);
Session::put("message", "Your request for Gateway " . $inputs["gateway-name"] . " has been created.");
}
else{
Session::put("errorMessages", "Error: A Gateway already exists with the same GatewayId, Name or URL! Please make a new request.");
}
return Redirect::to("admin/dashboard");
}
}

public function requestGateway(){
$inputs = Input::all();
@@ -484,9 +545,6 @@ public function requestGateway(){
}
else{
$gateway = AdminUtilities::request_gateway(Input::all());

//$tm = WSIS::createTenant(1, $inputs["admin-username"] . "@" . $inputs["domain"], $inputs["admin-password"], inputs["admin-email"], $inputs["admin-firstname"], $inputs["admin-lastname"], $inputs["domain"]);

Session::put("message", "Your request for Gateway " . $inputs["gateway-name"] . " has been created.");

return Redirect::to("admin/dashboard");
@@ -0,0 +1,70 @@
<?php

class GatewayRequestUpdateController extends BaseController
{

public function updateGatewayRequest(){

$gateway = AdminUtilities::update_form( Input::get("gateway-id"), Input::all() );

$gatewayData = array ("gatewayId" => $gateway->gatewayId,
"gatewayName" => $gateway->gatewayName,
"emailAddress" => $gateway->emailAddress,
"publicProjectDescription" => $gateway->gatewayPublicAbstract,
"gatewayURL" => $gateway->gatewayURL,
"adminFirstName" => $gateway->gatewayAdminFirstName,
"adminLastName" => $gateway-> gatewayAdminLastName,
"adminUsername" => $gateway->identityServerUserName,
"adminEmail" => $gateway->gatewayAdminEmail,
"projectDetails" => $gateway->reviewProposalDescription);

return View::make("account/update")->with(array('gatewayData'=>$gatewayData));

}

public function updateDetails(){

$inputs = Input::all();
$rules = array(
"username" => "required|min:6",
"password" => "required|min:6|max:48|regex:/^.*(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[@!$#*]).*$/",
"confirm_password" => "required|same:password",
"email" => "required|email",
);

$messages = array(
'password.regex' => 'Password needs to contain at least (a) One lower case letter (b) One Upper case letter and (c) One number (d) One of the following special characters - !@#$&*',
);

$checkValidation = array();
$checkValidation["username"] = $inputs["admin-username"];
$checkValidation["password"] = $inputs["admin-password"];
$checkValidation["confirm_password"] = $inputs["admin-password-confirm"];
$checkValidation["email"] = $inputs["admin-email"];

$validator = Validator::make( $checkValidation, $rules, $messages);
if ($validator->fails()) {
Session::put("validationMessages", $validator->messages() );
return Redirect::back()
->withInput(Input::except('password', 'password_confirm'))
->withErrors($validator);
}
else {
$returnVal = AdminUtilities::user_update_gateway(Input::get("gateway-id"), Input::all());

if ($returnVal == 1) {
$username = Session::get("username");
$email = Config::get('pga_config.portal')['admin-emails'];
$user_profile = Keycloak::getUserProfile($username);
EmailUtilities::mailToUser($user_profile["firstname"], $user_profile["lastname"], $email, Input::get("gateway-id"));
EmailUtilities::mailToAdmin($email, Input::get("gateway-id"));
Session::put("message", "Your Gateway has been updated");
} else
Session::put("errorMessages", "Error: Please try again or contact admin to report the issue.");
}

return Redirect::to("admin/dashboard");

}

}

0 comments on commit 1281d82

Please sign in to comment.