Merge branch 'master' into PHRAS-3358-renaming-patch

This commit is contained in:
Nicolas Maillat
2021-02-22 19:06:35 +01:00
committed by GitHub
65 changed files with 7150 additions and 2949 deletions

View File

@@ -821,22 +821,6 @@ class collection implements ThumbnailedElement, cache_cacheableInterface
return $this->get_databox()->getAutoregisterModel($email);
}
/**
* Gets terms of use.
*
* @return null|string
*/
public function getTermsOfUse()
{
if (false === $xml = simplexml_load_string($this->get_prefs())) {
return null;
}
foreach ($xml->xpath('/baseprefs/cgu') as $sbpcgu) {
return $sbpcgu->saveXML();
}
}
public function get_cache_key($option = null)
{
return 'collection_' . $this->collectionVO->getCollectionId() . ($option ? '_' . $option : '');

View File

@@ -273,15 +273,20 @@ class record_preview extends record_adapter
$this->title .= ' : </span> ' . parent::get_title($options);
break;
case "BASK":
$this->title .= $this->name . ' (' . $this->getNumber() . '/' . $this->total . ') - ' . parent::get_title($options);
$this->title = '<span style="color:#27bbe2;">';
$this->title .= $this->name . ' (' . $this->getNumber() . '/' . $this->total . ') : </span>' . parent::get_title($options);
break;
case "REG":
$this->title = '<span style="color:#27bbe2;">';
$this->title .= $this->name;
if ($this->getNumber() != 0) {
$this->title .= sprintf(
' (%s) - %s',$this->getNumber() . '/' . $this->total, parent::get_title($options)
' (%s) : </span> %s',$this->getNumber() . '/' . $this->total, parent::get_title($options)
);
} else {
$this->title .= '</span>';
}
break;

View File

@@ -14,6 +14,7 @@ use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Alchemy\Phrasea\Model\Repositories\StoryWZRepository;
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
use Alchemy\Phrasea\Out\Module\PDFCgu;
use Assert\Assertion;
use Doctrine\DBAL\Connection;
use Symfony\Component\Filesystem\Filesystem;
@@ -418,6 +419,7 @@ class set_export extends set_abstract
$files[$id] = [
'base_id' => $download_element->getBaseId(),
'databox_id' => $download_element->getDataboxId(),
'record_id' => $download_element->getRecordId(),
'original_name' => '',
'export_name' => '',
@@ -691,6 +693,13 @@ class set_export extends set_abstract
$toRemove = [];
$archiveFiles = [];
$databoxIds = [];
$recordIdsPerDatabox = [];
// group recordId per databoxId
foreach ($files as $file) {
$recordIdsPerDatabox[$file['databox_id']][] = $file['record_id'];
}
foreach ($files as $record) {
if (isset($record["subdefs"])) {
@@ -709,6 +718,28 @@ class set_export extends set_abstract
}
$toRemove[] = $path;
}
if (!in_array($record['databox_id'], $databoxIds)) {
// add also the databox cgu in the zip
$databoxIds[] = $record['databox_id'];
// if cgu content empty, do not add pdf in zip
if (!PDFCgu::isDataboxCguEmpty($app, $record['databox_id'])) {
try {
$pdfCgu = new PDFCgu($app, $record['databox_id'], $recordIdsPerDatabox[$record['databox_id']]);
$pdfCgu->save();
$databoxCguPath = PDFCgu::getDataboxCguPath($app, $record['databox_id']);
} catch (\Exception $e) {
$app['logger']->error("Exception occurred when generating cgu pdf : " . $e->getMessage());
continue;
}
$archiveFiles[$app['unicode']->remove_diacritics($obj["folder"].PDFCgu::getDataboxCguPdfName($app, $record['databox_id']))] = $databoxCguPath;
$toRemove[] = $databoxCguPath;
}
}
}
}
}