Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion api/assets/emails/html/dewar-dispatch-lite.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1 style="font-size: 16px; font-weight: normal; border-bottom: 1px solid #000; margin: 1%; margin-bottom: 1.5%">Dewar ready to leave diamond</h1>
<h1 style="font-size: 16px; font-weight: normal; border-bottom: 1px solid #000; margin: 1%; margin-bottom: 1.5%">Dewar ready to leave Diamond</h1>

<div class="inset" style="margin: 1%; padding: 1%; margin-bottom: 2%; border-radius: 5px; background: #82d180">
Goods Handling, please arrange dispatch of the following Dewar.
Expand Down
5 changes: 5 additions & 0 deletions api/config_sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@
# Server log location
$server_log = '/dls_sw/<%=BEAMLINENAME%>/logs/gda-server.log';

# Path to ccp4 location
$ccp4_location = '/dls_sw/apps/ccp4/latest/ccp4-9';

# Email addresses, comma separate for multiple recepients
# - Email templates in assets/emails in plain and html/ format

Expand Down Expand Up @@ -239,6 +242,8 @@
$facility_courier_countries = array('United Kingdom');
// List of non dom eu free countries
$facility_courier_countries_nde = array('France', 'Italy', 'Spain');
// Link to help with international shipments
$facility_courier_countries_link = '';
$package_description = 'Dry shipper containing frozen crystals';
$dewar_weight = 18;

Expand Down
3 changes: 2 additions & 1 deletion api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function setupApplication($mode): Slim

$app->get('/options', function () use ($app) {
global $motd, $authentication_type, $cas_url, $cas_sso, $sso_url, $package_description,
$facility_courier_countries, $facility_courier_countries_nde,
$facility_courier_countries, $facility_courier_countries_nde, $facility_courier_countries_link,
$dhl_enable, $scale_grid, $scale_grid_end_date, $preset_proposal, $timezone,
$valid_components, $enabled_container_types, $ifsummary, $synchweb_version, $redirects,
$shipping_service_app_url, $use_shipping_service_redirect, $use_shipping_service_redirect_incoming_shipments;
Expand All @@ -83,6 +83,7 @@ function setupApplication($mode): Slim
'package_description' => $package_description,
'facility_courier_countries' => $facility_courier_countries,
'facility_courier_countries_nde' => $facility_courier_countries_nde,
'facility_courier_countries_link' => $facility_courier_countries_link,
'dhl_enable' => $dhl_enable,
'scale_grid' => $scale_grid,
'scale_grid_end_date' => $scale_grid_end_date,
Expand Down
21 changes: 8 additions & 13 deletions api/scripts/mtz2map.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,6 @@

cd /tmp

# If you are running with the module system, load ccp4
#. /etc/profile.d/modules.sh
#module load ccp4

# If not, define the environment variables required below
#export CCP4_MASTER=/dls_sw/apps/ccp4/<ccp4 version>
export CCP4_MASTER=/dls_sw/apps/ccp4/latest/ccp4-8.0
export CINCL=$CCP4_MASTER/include
export CLIBD=$CCP4_MASTER/lib/data

export CCP4_SCR=/tmp
export root=$CCP4_MASTER/bin

if [ -f $1 ]; then
mtz=$1
else
Expand All @@ -41,6 +28,14 @@ else
fi
fi

#export CCP4_MASTER=/dls_sw/apps/ccp4/<ccp4 version>
export CCP4_MASTER=$5
export CINCL=$CCP4_MASTER/include
export CLIBD=$CCP4_MASTER/lib/data

export CCP4_SCR=/tmp
export root=$CCP4_MASTER/bin

if [ $3 == 'dimple' ]; then

if $root/mtzinfo $mtz | grep -q PH2FOFCWT; then
Expand Down
2 changes: 2 additions & 0 deletions api/src/Authentication/AuthenticationParent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ public function check();
public function authorise();

public function authenticateByCode($code);

public function logout();
}
5 changes: 5 additions & 0 deletions api/src/Authentication/Type/CAS.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,10 @@ function validate($service, $ticket)

return rtrim($resp);
}

function logout()
{
return false;
}
}

5 changes: 5 additions & 0 deletions api/src/Authentication/Type/Combined.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public function authorise() {
public function authenticateByCode($code){
return $this->OIDCAuth->authenticateByCode($code);
}

public function logout()
{
return $this->OIDCAuth->logout();
}
}
5 changes: 5 additions & 0 deletions api/src/Authentication/Type/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,9 @@ function authenticate($login, $password)
{
return true;
}

function logout()
{
return false;
}
}
5 changes: 5 additions & 0 deletions api/src/Authentication/Type/LDAP.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,9 @@ function authenticate($login, $password)
}
}
}

function logout()
{
return false;
}
}
5 changes: 5 additions & 0 deletions api/src/Authentication/Type/OIDC.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,9 @@ function authenticateByCode($code)
setcookie($cookie_key, $token, $cookieOpts);
return $this->getUser($token);
}

function logout()
{
return $this->getProviderConfig()->end_session_endpoint;
}
}
5 changes: 5 additions & 0 deletions api/src/Authentication/Type/Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ function check()
return false;
}

function logout()
{
return false;
}

function authenticate($login, $password)
{
$person = $this->db->pq("SELECT password FROM person WHERE login=:1", array($login));
Expand Down
34 changes: 22 additions & 12 deletions api/src/Controllers/AuthenticationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ private function checkAuthRequiredForSpecificSituations($parts): bool
($parts[0] == 'shipment' && $parts[1] == 'containers' && $parts[2] == 'notify' && in_array($_SERVER["REMOTE_ADDR"], $auto)) ||

# Allow barcode reader ips unauthorised access to add container history
($parts[0] == 'shipment' && $parts[1] == 'containers' && $parts[2] == 'history' && in_array($_SERVER["REMOTE_ADDR"], $bcr))
($parts[0] == 'shipment' && $parts[1] == 'containers' && $parts[2] == 'history' && in_array($_SERVER["REMOTE_ADDR"], $bcr)) ||

# Allow shipping service to update dewar status
($parts[0] == 'shipment' && $parts[1] == 'dewars' && $parts[2] == 'confirmdispatch')
)
{
$need_auth = false;
Expand Down Expand Up @@ -391,17 +394,24 @@ function authenticateByCode()
// Logout
function logout()
{
global $cookie_key;
if (isset($_COOKIE[$cookie_key])) {
$cookieOpts = array (
'expires' => time() - 3600,
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'Strict'
);

setcookie($cookie_key, null, $cookieOpts);
global $cookie_key, $cas_sso;
if($cas_sso) {
if (isset($_COOKIE[$cookie_key])) {
$cookieOpts = array (
'expires' => time() - 3600,
'path' => '/',
'secure' => true,
'httponly' => true,
'samesite' => 'Strict'
);

setcookie($cookie_key, null, $cookieOpts);
}

header('Location: ' . $this->authenticateByType()->logout());
$this->returnResponse(302, array('status' => "Redirecting to SSO provider"));
} else {
$this->returnError(501, "SSO not configured");
}
}

Expand Down
13 changes: 6 additions & 7 deletions api/src/Downstream/DownstreamProcessing.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ function _lookup_autoproc($aid, $scalingid = null) {
* @param string $pdb The input pdb file to generate the map around
*/
function convert_mtz($mtz, $aid, $program, $pdb, $map = 0) {
global $ccp4_location;
exec(
'/bin/bash ./scripts/mtz2map.sh ' .
$mtz .
' ' .
$aid .
' ' .
$program .
' ' .
$pdb,
$mtz . ' ' .
$aid . ' ' .
$program . ' ' .
$pdb . ' ' .
$ccp4_location,
$output,
$res
);
Expand Down
91 changes: 91 additions & 0 deletions api/src/Downstream/Type/Shelxt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<?php

namespace SynchWeb\Downstream\Type;

use SynchWeb\Downstream\DownstreamPlugin;
use SynchWeb\Downstream\DownstreamResult;

class Shelxt extends DownstreamPlugin {
var $has_images = true;
var $friendlyname = 'Shelxt';
var $has_mapmodel = array(1, 0);

function _get_shelxt_results_json() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filePath from autoprocprogramattachment app where autoprocprogramid = :1 and filename = 'shelxt_results.json' ",
$appid
);
return $filepath;
}

function _get_shelxt_results_png() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filepath, app.filename from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.png%' ",
$appid
);
return $filepath;
}

function _get_pdb() {
$appid = array($this->autoprocprogramid);
$filepath = $this->db->pq(
"SELECT app.filepath, app.filename from autoprocprogramattachment app where autoprocprogramid = :1 and filename like '%.pdb%' ",
$appid
);
if (sizeof($filepath)) {
return $filepath[0]["FILEPATH"] . "/" . $filepath[0]["FILENAME"];
} else {
return;
}
}

function results() {
$json_filepath = $this->_get_shelxt_results_json();
if (sizeof($json_filepath)) {
$json_path = $json_filepath[0]["FILEPATH"] . "/shelxt_results.json" ;
$json_data = file_get_contents($json_path);
} else {
$json_data = "[]";
}
$dat = array();
$dat['BLOBS'] = 1;
$dat['SOLUTIONS'] = json_decode($json_data);

// scaling_id should always be present, but just in case...
if (array_key_exists('scaling_id', $this->process['PARAMETERS'])) {
$integrator = $this->_lookup_autoproc(
null,
$this->process['PARAMETERS']['scaling_id']
);
if ($integrator) {
$dat['PARENTAUTOPROCPROGRAM'] = $integrator['PROCESSINGPROGRAMS'];
$dat['PARENTAUTOPROCPROGRAMID'] = $integrator['AUTOPROCPROGRAMID'];
}
}
$results = new DownstreamResult($this);
$results->data = $dat;

return $results;
}

function images($n = 0) {
$png = $this->_get_shelxt_results_png();
if (sizeof($png)) {
return $png[0]["FILEPATH"] . "/" . $png[0]["FILENAME"];
} else {
return;
}

}

function mapmodel($n = 0, $map = false) {
$pdb = $this->_get_pdb();
if (!$pdb) {
return;
} else {
return $pdb;
}
}
}
28 changes: 21 additions & 7 deletions api/src/Page/Sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -631,13 +631,15 @@ function _sub_samples()
$where = '';
$first_inner_select_where = '';
$second_inner_select_where = '';
$third_inner_select_where = '';
$args = array($this->proposalid);

if ($this->has_arg('sid')) {
$where .= ' AND s.blsampleid=:' . (sizeof($args) + 1);
$first_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 2);
$second_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 3);
array_push($args, $this->arg('sid'), $this->arg('sid'), $this->arg('sid'));
$third_inner_select_where .= ' AND s.blsampleid=:' . (sizeof($args) + 4);
array_push($args, $this->arg('sid'), $this->arg('sid'), $this->arg('sid'), $this->arg('sid'));
}

if ($this->has_arg('cid')) {
Expand All @@ -648,7 +650,7 @@ function _sub_samples()
}

$this->db->wait_rep_sync(true);
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where);
$ss_query_string = $this->get_sub_samples_query($where, $first_inner_select_where, $second_inner_select_where, $third_inner_select_where);
$subs = $this->db->pq($ss_query_string, $args);

$this->db->wait_rep_sync(false);
Expand Down Expand Up @@ -683,7 +685,7 @@ function _get_sub_sample()
}
}

private function get_sub_samples_query($where, $first_inner_select_where = '', $second_inner_select_where = '')
private function get_sub_samples_query($where, $first_inner_select_where = '', $second_inner_select_where = '', $third_inner_select_where = '')
{
$group_by = "";
$order_by = "";
Expand All @@ -707,22 +709,34 @@ private function get_sub_samples_query($where, $first_inner_select_where = '', $
$from_query = "FROM (
SELECT ss.blsubsampleid
FROM (
SELECT s.blsampleid, max(si.blsampleimageid) AS blsampleimageid
SELECT s.blsampleid, max(si.blsampleimageid) AS blsampleimageid
FROM blsample s
INNER JOIN blsampleimage si ON si.blsampleid = s.blsampleid
WHERE 1=1 $first_inner_select_where
GROUP BY s.blsampleid
) qq
JOIN blsubsample ss ON ss.blsampleimageid = qq.blsampleimageid
WHERE ss.source = 'auto'

UNION ALL

SELECT ss.blsubsampleid
FROM blsubsample ss
LEFT JOIN blsample s on ss.blsampleid = s.blsampleid
WHERE ss.source = 'manual' $second_inner_select_where
) q JOIN blsubsample ss ON ss.blsubsampleid = q.blsubsampleid";
WHERE ss.source = 'manual' $second_inner_select_where";

// show auto generated subsamples with data collections
if ($third_inner_select_where != '') {
$from_query .= "
UNION ALL
SELECT ss.blsubsampleid
FROM blsubsample ss
LEFT JOIN blsample s on ss.blsampleid = s.blsampleid
INNER JOIN datacollection dc ON ss.blsubsampleid = dc.blsubsampleid
WHERE ss.source = 'auto' $third_inner_select_where";
}

$from_query .= ") q JOIN blsubsample ss ON ss.blsubsampleid = q.blsubsampleid";

$group_by = "GROUP BY pr.acronym,
s.name,
Expand Down
Loading