Commit 8a71536c authored by Prosper De Laure's avatar Prosper De Laure
Browse files

Reorganization of the code linked to archivalProfileAccess

The archival profiles displayed on main screen correspond to organization configuration #5745
The profile structure is fully configurable #5734
parent 592e790b
......@@ -261,4 +261,44 @@ abstract class abstractPosition
return $childrenService;
}
/**
* Get descendant archival profiles
*
* @return array
*/
public function getdescendantArchivalProfiles()
{
$descendantArchivalProfiles = [];
$descendantServicesOrgId = [];
$descendantServices = $this->listMyCurrentDescendantServices();
foreach ($descendantServices as $orgRegNumber) {
$organization = $this->sdoFactory->read("organization/organization", array('registrationNumber' => $orgRegNumber));
if (!empty($organization)) {
$descendantServicesOrgId[] = $organization->orgId;
}
}
$archivalProfileAccesses = $this->sdoFactory->find('organization/archivalProfileAccess', "orgId=['". \laabs\implode("','" , $descendantServicesOrgId)."']");
$archivalProfileController = \laabs::newController("recordsManagement/archivalProfile");
foreach ($archivalProfileAccesses as $archivalProfileAccess) {
if ($archivalProfileAccess->archivalProfileReference == '*') {
$descendantArchivalProfiles['*']='*';
continue;
}
if (!empty($descendantArchivalProfiles[$archivalProfileAccess->archivalProfileReference])){
continue;
}
if ($archivalProfileAccess->archivalProfileReference != '*') {
$descendantArchivalProfiles[$archivalProfileAccess->archivalProfileReference] = $archivalProfileController->getByReference($archivalProfileAccess->archivalProfileReference);
}
}
return $descendantArchivalProfiles;
}
}
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle organization.
*
* Bundle organization is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Bundle organization 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with bundle organization. If not, see <http://www.gnu.org/licenses/>.
*/
namespace bundle\organization\Controller;
/**
* Control of the organization
*
* @package Organization
* @author Prosper De Laure <prosper.delaure@maarch.org>
*/
class archivalProfilAccess
{
protected $sdoFactory;
/**
* Constructor
* @param object $sdoFactory The model for organization
*
* @return void
*/
public function __construct(\dependency\sdo\Factory $sdoFactory)
{
$this->sdoFactory = $sdoFactory;
}
/**
* get children archival profile access
* @param string $orgId The organization id
*
* @return void
*/
public function getOrgProfilAccess($orgId)
{
return $this->sdoFactory->find('organization/archivalProfilAccess', "orgId = '$orgId'");
}
/**
* get children archival profile access
* @param organization/archivalProfileAccess $profilAccess The profil access
*
* @return void
*/
public function getOrgProfilAccess($profilAccess)
{
}
}
......@@ -720,4 +720,32 @@ class organization
return true;
}
/**
* Get the archival profile descriptions for the given org unit
* @param string $orgRegNumber
* @param string $originatorAccess
*
* @return array
*/
public function getOrgUnitArchivalProfiles($orgRegNumber, $originatorAccess=false)
{
$archivalProfileAccesses = [];
$orgUnitArchivalProfiles = [];
$organization = $this->sdoFactory->read("organization/organization", array('registrationNumber' => $orgRegNumber));
$archivalProfileAccesses = $this->sdoFactory->find('organization/archivalProfileAccess', "orgId='".$organization->orgId."'");
$archivalProfileController = \laabs::newController("recordsManagement/archivalProfile");
foreach ($archivalProfileAccesses as $archivalProfileAccess) {
if ($archivalProfileAccess->archivalProfileReference == "*") {
$orgUnitArchivalProfiles[] ='*';
continue;
}
$orgUnitArchivalProfiles[] = $archivalProfileController->getByReference($archivalProfileAccess->archivalProfileReference);
}
return $orgUnitArchivalProfiles;
}
}
......@@ -276,4 +276,14 @@ interface organizationInterface
* @action organization/organization/updateArchivalProfileAccess
*/
public function update_orgId_Archivalprofileaccess($archivalProfileAccess);
/**
* Get the profiles by orgRegNumber
* @param string $orgRegNumber
* @param string $originatorAccess
*
* @return array
* @action organization/organization/getOrgUnitArchivalProfiles
*/
public function readOrgunitprofiles($orgRegNumber, $originatorAccess=false);
}
\ No newline at end of file
......@@ -75,4 +75,11 @@ interface userPositionInterface
*/
public function readDescendantorgs();
/**
* Get descendant profiles
*
* @action organization/userPosition/getdescendantArchivalProfiles
*/
public function readDescendantprofiles();
}
......@@ -506,57 +506,4 @@ class archivalProfile
$this->sdoFactory->deleteChildren('recordsManagement/documentProfile', $archivalProfile);*/
}
/**
* Get the archival profile descriptions for the given org unit
* @param string $orgRegNumber
* @param string $originatorAccess
*
* @return array
*/
public function getOrgUnitArchivalProfiles($orgRegNumber, $originatorAccess=false)
{
$archivalProfileAccesses = [];
$orgUnitArchivalProfiles = [];
$organization = \laabs::callService('organization/organization/readByregnumber_registrationNumber_', $orgRegNumber);
$archivalProfileAccesses = $this->sdoFactory->find('organization/archivalProfileAccess', "orgId='".$organization->orgId."'");
foreach ($archivalProfileAccesses as $archivalProfileAccess) {
$orgUnitArchivalProfiles[] = $this->getByReference($archivalProfileAccess->archivalProfileReference);
}
return $orgUnitArchivalProfiles;
}
/**
* Get descendant archival profiles
*
* @return array
*/
public function getdescendantArchivalProfiles()
{
$descendantArchivalProfiles = [];
$descendantServicesOrgId = [];
$descendantServices = \laabs::callService('organization/userPosition/readDescendantservices');
foreach ($descendantServices as $orgRegNumber) {
$organization = \laabs::callService('organization/organization/readByregnumber_registrationNumber_', $orgRegNumber);
if (!empty($organization)) {
$descendantServicesOrgId[] = $organization->orgId;
}
}
$archivalProfileAccesses = $this->sdoFactory->find('organization/archivalProfileAccess', "orgId=['". \laabs\implode("','" , $descendantServicesOrgId)."']");
foreach ($archivalProfileAccesses as $archivalProfileAccess) {
if (!empty($descendantArchivalProfiles[$archivalProfileAccess->archivalProfileReference])){
continue;
}
$descendantArchivalProfiles[$archivalProfileAccess->archivalProfileReference] = $this->getByReference($archivalProfileAccess->archivalProfileReference);
}
return $descendantArchivalProfiles;
}
}
......@@ -92,20 +92,4 @@ interface archivalProfileInterface
*/
public function delete_archivalProfileId_();
/**
* Get the profiles by orgRegNumber
* @param string $orgRegNumber
* @param string $originatorAccess
*
* @return array
* @action recordsManagement/archivalProfile/getOrgUnitArchivalProfiles
*/
public function readOrgunitprofiles($orgRegNumber, $originatorAccess=false);
/**
* Get descendant profiles
*
* @action recordsManagement/archivalProfile/getdescendantArchivalProfiles
*/
public function readDescendantprofiles();
}
......@@ -61,7 +61,6 @@ class filePlan
*/
public function showTree($filePlan)
{
$this->view->addContentFile('filePlan/filePlanTree.html');
$this->markTreeLeaf([$filePlan]);
......
......@@ -75,6 +75,7 @@ class welcome
$this->view->setSource("filePlan", $filePlan);
}
// Retention
$retentionRules = \laabs::callService('recordsManagement/retentionRule/readIndex');
for ($i = 0, $count = count($retentionRules); $i < $count; $i++) {
......@@ -82,12 +83,17 @@ class welcome
}
// archival profiles for search form
$archivalProfileController = \laabs::newController("recordsManagement/archivalProfile");
if (!empty($currentOrganization->registrationNumber)) {
$archivalProfiles = \laabs::callService('recordsManagement/archivalProfile/readDescendantprofiles');
$archivalProfiles = \laabs::callService('organization/userPosition/readDescendantprofiles');
foreach ($archivalProfiles as $archivalProfile) {
if ($archivalProfile == "*") {
continue;
}
$archivalProfileController->readDetail($archivalProfile);
$archivalProfile->searchFields = [];
foreach ($archivalProfile->archiveDescription as $archiveDescription) {
......@@ -104,7 +110,6 @@ class welcome
}
$depositPrivilege = \laabs::callService('auth/userAccount/readHasprivilege', "archiveDeposit/deposit");
$this->view->translate();
......@@ -183,7 +188,7 @@ class welcome
$list = [];
if ($archivalProfile->acceptAnyProfile) {
$list = \laabs::callService('recordsManagement/archivalProfile/readDescendantprofiles');
$list = \laabs::callService('organization/userPosition/readDescendantprofiles');
} else if (count($archivalProfile->containedProfiles)) {
$list = $archivalProfile->containedProfiles;
......@@ -444,7 +449,7 @@ class welcome
protected function getOrgUnitArchivalProfiles($orgUnit)
{
$orgUnit->archivalProfiles = \laabs::callService('recordsManagement/archivalProfile/readOrgunitprofiles', $orgUnit->registrationNumber);
$orgUnit->archivalProfiles = \laabs::callService('organization/organization/readOrgunitprofiles', $orgUnit->registrationNumber);
if (!empty($orgUnit->organization)) {
foreach ($orgUnit->organization as $subOrgUnit) {
......
......@@ -14,9 +14,7 @@
<div id="folderToolbarBtn" class="dropdown pull-right btn-group">
<button type="button" class="btn btn-sm btn-default" id="folderToolbarSearch" title="Search" disabled><span class="fa fa-search"></span></button>
<button type="button" class="btn btn-sm btn-default dropdown-toggle [?merge depositPrivilege.not().then('disabled', '') ?]" id="folderToolbarImport" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true" title="New archive" disabled><span class="fa fa-plus"></span></button>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
<li><a class="small newArchive" style="cursor: pointer;" data-reference="">Without profile</a></li>
</ul>
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1"/>
</div>
</div>
</div>
......@@ -51,6 +49,8 @@
<span id="previous_text">Previous</span>
<span id="next_text">Next</span>
<span id="last_text">Last</span>
<span id="withoutProfile_text">Without profile</span>
</div>
<script type="text/javascript">
......@@ -91,6 +91,7 @@
})
this.getImportForm(orgRegNumber, folderId, archivalProfiles);
this.buildNewArchiveDropdownMenu();
$("#folderToolbarSearch").data("orgregnumber", orgRegNumber).data("folderid", folderId);
},
......@@ -210,26 +211,35 @@
refresh: function() {
FilePlan.selectedNode.find('b:first').click();
}
}
},
NewArchive = {
buildNewArchiveDropdownMenu: function() {
var archivalProfiles = $("#folderToolbarBtn .dropdown-menu").data("archivalprofiles");
var dropdown = $("#folderToolbarBtn .dropdown-menu");
dropdown.children().not(":first").remove();
for (var i = 0; i < archivalProfiles.length; i++) {
var a = $("<a/>")
if (archivalProfiles[i] == '*') {
var a = $("<a/>")
.addClass("small newArchive")
.data("reference", '')
.attr('style', "cursor: pointer;")
.text($('#withoutProfile_text').html());
} else {
var a = $("<a/>")
.addClass("userProfile small newArchive")
.data("reference", archivalProfiles[i].reference)
.data("json", archivalProfiles[i])
.attr('style', "cursor: pointer;")
.text(archivalProfiles[i].name);
}
$("<li/>").append(a).appendTo(dropdown);
}
},
}
}
NewArchive = {
loadImportForm: function(e) {
var importPanel = $("#importPanel");
$("#archiveForm [name='archivalProfileReference']").val(e.data("reference")).data("json", e.data("json")).change();
......@@ -247,7 +257,7 @@
}
$("#folderToolbarBtn").on("show.bs.dropdown", function() {
NewArchive.buildNewArchiveDropdownMenu();
//NewArchive.buildNewArchiveDropdownMenu();
});
$("#folderToolbarBtn").on('click', '.newArchive', function() {
......
......@@ -46,6 +46,8 @@ var ArchivalProfileAccessForm = {
}
})
}
$('#saveArchivalProfileAccess').addClass('hide');
},
add: function() {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment