chg: Added the sharing group roaming setting to various parts of the application

- sharing group add/edit
- summary view
- push rule checks
pull/1387/head
Iglocska 2016-07-18 00:13:12 +02:00
parent 313aba17cb
commit 0fcf90a926
6 changed files with 35 additions and 27 deletions

View File

@ -45,7 +45,7 @@ class AppController extends Controller {
public $helpers = array('Utility');
private $__jsVersion = '2.4.48';
private $__jsVersion = '2.4.49';
// Used for _isAutomation(), a check that returns true if the controller & action combo matches an action that is a non-xml and non-json automation method
// This is used to allow authentication via headers for methods not covered by _isRest() - as that only checks for JSON and XML formats

View File

@ -53,7 +53,7 @@ class SharingGroupsController extends AppController {
'extend' => $org['extend']
));
}
if ($json['sharingGroup']['limitServers']) {
if ($json['sharingGroup']['roaming']) {
foreach ($json['servers'] as $server) {
$this->SharingGroup->SharingGroupServer->create();
$this->SharingGroup->SharingGroupServer->save(array(
@ -115,13 +115,13 @@ class SharingGroupsController extends AppController {
$json = json_decode($this->request->data['SharingGroup']['json'], true);
$sg = $json['sharingGroup'];
$sg['id'] = $id;
$fields = array('name', 'releasability', 'description', 'active', 'limitServers');
$fields = array('name', 'releasability', 'description', 'active', 'roaming');
$existingSG = $this->SharingGroup->find('first', array('recursive' => -1, 'conditions' => array('SharingGroup.id' => $id)));
foreach ($fields as $field) $existingSG['SharingGroup'][$field] = $sg[$field];
unset($existingSG['SharingGroup']['modified']);
if ($this->SharingGroup->save($existingSG)) {
$this->SharingGroup->SharingGroupOrg->updateOrgsForSG($id, $json['organisations'], $sharingGroup['SharingGroupOrg'], $this->Auth->user());
$this->SharingGroup->SharingGroupServer->updateServersForSG($id, $json['servers'], $sharingGroup['SharingGroupServer'], $json['sharingGroup']['limitServers'], $this->Auth->user());
$this->SharingGroup->SharingGroupServer->updateServersForSG($id, $json['servers'], $sharingGroup['SharingGroupServer'], $json['sharingGroup']['roaming'], $this->Auth->user());
$this->redirect('/SharingGroups/view/' . $id);
} else {
$validationReplacements = array(

View File

@ -274,20 +274,28 @@ class SharingGroup extends AppModel {
}
public function checkIfServerInSG($sg, $server) {
$results = array(
'rule' => false,
'orgs' => array(),
);
if (isset($sg['SharingGroupServer']) && !empty($sg['SharingGroupServer'])) {
$conditional = false;
if (isset($sg['SharingGroupServer']) && !empty($sg['SharingGroupServer']) && !$sg['SharingGroup']['roaming']) {
foreach ($sg['SharingGroupServer'] as $s) {
if ($s['server_id'] == $server['Server']['id']) {
if ($s['all_orgs']) return true;
else $results['rule'] = 'conditional';
if ($s['all_orgs']) {
return true;
} else {
$conditional = true;
}
}
}
if ($conditional === false) {
return false;
}
}
if (isset($sg['SharingGroupOrg']) && !empty($sg['SharingGroupOrg'])) {
foreach ($sg['SharingGroupOrg'] as $org) {
if (isset($org['Organisation']) && $org['Organisation']['uuid'] === $server['RemoteOrg']['uuid']) {
return true;
}
}
if ($results['rule'] === false) return false;
}
foreach ($sg['SharingGroupOrg'] as $org) if (isset($org['Organisation']) && $org['Organisation']['uuid'] === $server['RemoteOrg']['uuid']) return true;
return false;
}

View File

@ -39,8 +39,8 @@
</div>
<div id="page3_content" class="multi-page-form-div tabContent" style="display:none;width:544px;">
<div style="display:block;">
<input type="checkbox" style="float:left;" title="Active sharing groups can be selected by users of the local instance when creating events. Generally, sharing groups received through synchronisation will have this disabled until manually enabled." value="1" id="SharingGroupLimitservers" checked></input>
<label for="SharingGroupLimitservers" style="padding-left:20px;">Limit instances to which data in this sharing group should be pushed to (keep in mind that eligible organisations can still pull data).</label>
<input type="checkbox" style="float:left;" title="Enable roaming mode for this sharing group. Roaming mode will allow the sharing group to be passed to any instance where the remote recipient is contained in the organisation list. It is preferred to list the recipient instances instead." value="1" id="SharingGroupRoaming"></input>
<label for="SharingGroupRoaming" style="padding-left:20px;"><b>Enable roaming mode</b> for this sharing group (pass the event to any connected instance where the sync connection is tied to an organisation contained in the SG organisation list).</label>
</div>
<div id="serverList">
<div class="tabMenuFixedContainer">
@ -80,7 +80,7 @@
?>
<script type="text/javascript">
var lastPage = 4;
var limitServers = true;
var roaming = false;
var organisations = [{
id: '<?php echo h($user['Organisation']['id'])?>',
type: 'local',
@ -103,11 +103,11 @@
sharingGroupPopulateOrganisations();
sharingGroupPopulateServers();
});
$('#SharingGroupLimitservers').change(function() {
$('#SharingGroupRoaming').change(function() {
if ($(this).is(":checked")) {
$('#serverList').show();
} else {
$('#serverList').hide();
} else {
$('#serverList').show();
}
});

View File

@ -40,15 +40,15 @@
<div id="page3_content" class="multi-page-form-div tabContent" style="display:none;width:544px;">
<?php
$serverDivVisibility = "";
$checked = "checked";
if (empty($sharingGroup['SharingGroupServer'])) {
$checked = "";
if ($sharingGroup['SharingGroup']['roaming']) {
$serverDivVisibility = 'style="display:none;"';
$checked = "";
$checked = "checked";
}
?>
<div style="display:block;">
<input type="checkbox" style="float:left;" title="Active sharing groups can be selected by users of the local instance when creating events. Generally, sharing groups received through synchronisation will have this disabled until manually enabled." <?php echo $checked; ?> id="SharingGroupLimitservers"></input>
<label for="SharingGroupLimitservers" style="padding-left:20px;">Limit instances to which data in this sharing group should be pushed to (keep in mind that eligible organisations can still pull data).</label>
<input type="checkbox" style="float:left;" title="Enable roaming mode for this sharing group. Roaming mode will allow the sharing group to be passed to any instance where the remote recipient is contained in the organisation list. It is preferred to list the recipient instances instead." <?php echo $checked; ?> id="SharingGroupRoaming"></input>
<label for="SharingGroupRoaming" style="padding-left:20px;"><b>Enable roaming mode</b> for this sharing group (pass the event to any connected instance where the sync connection is tied to an organisation contained in the SG organisation list).</label>
</div>
<div id="serverList" <?php echo $serverDivVisibility; ?>>
<div class="tabMenuFixedContainer">
@ -158,11 +158,11 @@
sharingGroupPopulateOrganisations();
sharingGroupPopulateServers();
});
$('#SharingGroupLimitservers').change(function() {
$('#SharingGroupRoaming').change(function() {
if ($(this).is(":checked")) {
$('#serverList').show();
} else {
$('#serverList').hide();
} else {
$('#serverList').show();
}
});