Commit 3fbb6c09 authored by Cyril Vazquez's avatar Cyril Vazquez

Merge branch 'fix/miscellaneous_fixes' into 'master'

Fix/miscellaneous fixes

See merge request maarch/thirdPartyArchiving!76
parents d660964d 7b0b9a47
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle recordsManagement.
*
* Bundle recordsManagement 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 recordsManagement 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 recordsManagement. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\thirdPartyArchiving\bundle\recordsManagement\Controller;
/**
* Archival profile class
*
* @author Alexis Ragot <alexis.ragot@maarch.org>
*/
class archivalProfile extends \bundle\recordsManagement\Controller\archivalProfile
{
protected $profilesDirectory;
/**
* Constructor
* @param \dependency\sdo\Factory $sdoFactory The sdo factory
* @param bool $notifyModification The state of the fonction of notification modification
* @param string $profilesDirectory The profile directory
*/
public function __construct(\dependency\sdo\Factory $sdoFactory, $notifyModification, $profilesDirectory)
{
parent::__construct($sdoFactory, $notifyModification, $profilesDirectory);
if (!is_dir($profilesDirectory) && !empty($profilesDirectory)) {
mkdir($profilesDirectory, 0777, true);
}
$this->profilesDirectory = $profilesDirectory;
$this->notifyModification = $notifyModification;
}
/**
* Read the agragates
* @param recordsManagement/archivalProfile $archivalProfile
*/
public function readDetail($archivalProfile)
{
parent::readDetail($archivalProfile);
$profilesDirectory = $this->profilesDirectory;
$profileFile = $profilesDirectory.DIRECTORY_SEPARATOR.$archivalProfile->reference;
if (file_exists($profileFile.'.rng') || file_exists($profileFile.'.xsd')) {
$archivalProfile->profileFile = $profileFile;
}
}
/**
* delete an archival profile
* @param string $archivalProfileId The identifier of the archival profile
*
* @return boolean The request of the request
*/
public function delete($archivalProfileId)
{
$archivalProfile = $this->sdoFactory->read('recordsManagement/archivalProfile', $archivalProfileId);
$archivalAgreementController = \laabs::newController('medona/archivalAgreement');
$archivalAgreement = $archivalAgreementController->getByProfileReference($archivalProfile->reference);
if ($archivalAgreement) {
return false;
}
return parent::delete($archivalProfileId);
}
/**
* Upload a profile file
* @param string $profileReference The profile reference
* @param string $archivalProfile The profile binary file
* @param string $format The profile file format
*
* @return boolean The result of the operation
*/
public function uploadArchivalProfile($profileReference, $archivalProfile,$content, $format = 'rng')
{
$profilesDirectory = $this->profilesDirectory;
$profilesDirectory .= DIRECTORY_SEPARATOR.$profileReference.'.'.$format ;
$content = base64_decode($content);
if(!$archivalProfile->archivalProfileId){
$archivalProfileController = \laabs::newController('recordsManagement/archivalProfile');
$archivalProfileController->create($archivalProfile);
}
file_put_contents($profilesDirectory, $content);
$archivalProfile = $this->getByReference($profileReference);
$archivalProfile->descriptionSchema = $profilesDirectory;
$this->sdoFactory->update($archivalProfile, "recordsManagement/archivalProfile");
return true;
}
/**
* Export profile file
* @param string $profileReference
*
* @return string
*/
public function export($profileReference)
{
$profilesDirectory = $this->profilesDirectory;
$fileDirectory = $profilesDirectory.DIRECTORY_SEPARATOR.$profileReference.".rng";
$file = file_get_contents($fileDirectory);
return $file;
}
}
<?php
/*
* Copyright (C) 2015 Maarch
*
* This file is part of bundle recordsManagement.
*
* Bundle recordsManagement 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 recordsManagement 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 recordsManagement. If not, see <http://www.gnu.org/licenses/>.
*/
namespace ext\thirdPartyArchiving\bundle\recordsManagement;
/**
* Interface for management of archival profile
*
* @package RecordsMangement
* @author Maarch Prosper DE LAURE <prosper.delaure@maarch.org>
*/
interface archivalProfileInterface extends \bundle\recordsManagement\archivalProfileInterface
{
/**
* upload an archival profile
* @param recordsManagement/archivalProfile $archivalProfile The profile object
* @param base64 $content The profile binary file
* @param string $format The profile file format
*
* @action recordsManagement/archivalProfile/uploadArchivalProfile
*/
public function createArchivalprofileUpload_profileReference_($archivalProfile,$content, $format="rng");
/**
* Download the profile file
*
* @action recordsManagement/archivalProfile/export
*/
public function readArchivalprofileExport_profileReference_();
}
Markdown is supported
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