Commit 2ce07040 authored by Stephane Bouvry's avatar Stephane Bouvry
Browse files

- Ajout d'une option pour utiliser/ou pas la version du document dans le nom...

- Ajout d'une option pour utiliser/ou pas la version du document dans le nom du fichier téléchargé par l'utilisateur
parent f90310b9
Loading
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -216,6 +216,10 @@ class AdministrationController extends AbstractOscarController implements UsePro
                    $this->getOscarConfigurationService()->setActivityRequestLimit($value);
                    return $this->redirect()->toRoute('administration/parameters');

                case OscarConfigurationService::document_use_version_in_name:
                    $value = boolval($this->params()->fromPost('parameter_value'));
                    $this->getOscarConfigurationService()->setDocumentUseVersionInName($value);
                    return $this->redirect()->toRoute('administration/parameters');

                default:
                    return $this->getResponseBadRequest("Paramètres non-reconnue");
@@ -234,7 +238,8 @@ class AdministrationController extends AbstractOscarController implements UsePro
                'separator' => $this->getOscarConfigurationService()->getExportSeparator(),
                'dateformat' => $this->getOscarConfigurationService()->getExportDateFormat()
            ],
            'organization_leader_role' => $organization_leader_role
            'organization_leader_role' => $organization_leader_role,
            OscarConfigurationService::document_use_version_in_name => $this->getOscarConfigurationService()->getDocumentUseVersionInName()
        ];
    }

+10 −1
Original line number Diff line number Diff line
@@ -333,7 +333,16 @@ class ContractDocumentController extends AbstractOscarController implements UseS
        $fileDir = $this->getDropLocation();
        $this->getActivityLogService()->addUserInfo(sprintf("a téléchargé le document '%s'", $doc), $this->getDefaultContext(), $idDoc);

        header('Content-Disposition: attachment; filename="'.$doc->getFileName().'"');

        $filename = $doc->getFileName();

        // Utilisation du numéro de version ?
        if( $this->getOscarConfigurationService()->getDocumentUseVersionInName() === true ){
            $version = $doc->getVersion();
            $filename = preg_replace('/(.*)(\.\w*)/', '$1-version-'.$version.'$2', $filename);
        }

        header('Content-Disposition: attachment; filename="'.$filename.'"');
        header('Content-type: '. $doc->getFileTypeMime());
        readfile($fileDir.'/'.$doc->getPath());
        die();
+20 −5
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
    const organization_leader_role = 'organization_leader_role';
    const spents_account_filter = 'spents_account_filter';
    const activity_request_limit = 'activity_request_limit';
    const document_use_version_in_name = 'document_use_version_in_name';

    const theme = 'theme';

    public function getApiFormats($default=[]){
    public function getApiFormats($default = [])
    {
        try {
            $format = $this->getConfiguration('api.formats');
        } catch (\Exception $e) {
@@ -75,7 +77,8 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        return $config;
    }

    public function getPayementsConfig(){
    public function getPayementsConfig()
    {
        return $this->getOptionalConfiguration('payements', [
            'separator' => '$$',
            'persons' => '',
@@ -86,14 +89,16 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
    /**
     * @return string
     */
    public function getLoggerFilePath() :string {
    public function getLoggerFilePath(): string
    {
        return $this->getOptionalConfiguration('log_path', __DIR__ . '/../../../../../logs/oscar.log');
    }

    /**
     * @return string
     */
    public function getLoggerLevel() :int {
    public function getLoggerLevel(): int
    {
        return $this->getOptionalConfiguration('log_level', Logger::WARNING);
    }

@@ -389,6 +394,16 @@ class OscarConfigurationService implements ServiceLocatorAwareInterface
        $this->saveEditableConfKey('export_dateformat', $string);
    }

    public function getDocumentUseVersionInName(): bool
    {
        return $this->getEditableConfKey(self::document_use_version_in_name, false);
    }

    public function setDocumentUseVersionInName(bool $bool)
    {
        return $this->saveEditableConfKey(self::document_use_version_in_name, $bool);
    }

    public function getSpentAccountFilter()
    {
        return $this->getEditableConfKey(self::spents_account_filter, []);
+25 −0
Original line number Diff line number Diff line
@@ -88,6 +88,31 @@
                    <button class="btn btn-primary"><i class="icon-floppy"></i> Enregistrer</button>
                </form>
            </article>

            <h2><i class="icon-cube"></i>Activités de Recherche</h2>
            <article class="card">
                <h3><i class="icon-eye"></i>Document</h3>
                <p class="help-message">
                    <i class="icon-help-circled"></i>
                    Lors du téléchargement d'un document d'une activité, cette option ajoute au nom du fichier <strong>le numéro de version</strong> du fichier.
                </p>
                <form action="" method="post" class="form">
                    <div class="row">
                        <div class="col-md-7 col-md-push-1">
                            <strong>Utiliser la version dans le nom du fichier</strong><br>
                        </div>
                        <div class="col-md-4">
                            <div class="material-switch">
                                <input name="parameter_name" type="hidden" value="document_use_version_in_name" />
                                <input id="document_use_version_in_name" name="parameter_value" type="checkbox" <?= $document_use_version_in_name ? "checked" : "" ?> />
                                <label for="document_use_version_in_name" class="label-primary"></label>
                            </div>
                        </div>
                    </div>

                    <button class="btn btn-primary"><i class="icon-floppy"></i> Enregistrer</button>
                </form>
            </article>
        </div>
    </section>