Merge branch 'master' into PHRAS-2196-api-stories-pagination

This commit is contained in:
Nicolas Maillat
2019-11-21 17:54:23 +01:00
committed by GitHub
482 changed files with 45299 additions and 36138 deletions

View File

@@ -1115,7 +1115,6 @@ class ACL implements cache_cacheableInterface
/**
* @param array $base_ids
* @return $this
* @throws DBALException
* @throws Exception
*/
public function revoke_access_from_bases(Array $base_ids)
@@ -1125,24 +1124,30 @@ class ACL implements cache_cacheableInterface
$usr_id = $this->user->getId();
$errors = 0;
foreach ($base_ids as $base_id) {
if (!$stmt_del->execute([':base_id' => $base_id, ':usr_id' => $usr_id])) {
throw new Exception('Error while deleteing some rights');
}
$this->app['dispatcher']->dispatch(
AclEvents::ACCESS_TO_BASE_REVOKED,
new AccessToBaseRevokedEvent(
$this,
array(
'base_id'=>$base_id
if ($stmt_del->execute([':base_id' => $base_id, ':usr_id' => $usr_id])) {
$this->app['dispatcher']->dispatch(
AclEvents::ACCESS_TO_BASE_REVOKED,
new AccessToBaseRevokedEvent(
$this,
[
'base_id' => $base_id
]
)
)
);
);
}
else {
$errors++;
}
}
$stmt_del->closeCursor();
$this->delete_data_from_cache(self::CACHE_RIGHTS_BAS);
if($errors > 0) {
throw new Exception('Error while deleting some rights');
}
return $this;
}

View File

@@ -537,7 +537,11 @@ class API_OAuth2_Adapter extends OAuth2
public function verifyAccessToken($scope = null, $exit_not_present = true, $exit_invalid = true, $exit_expired = true, $exit_scope = true, $realm = null)
{
$token_param = $this->getAccessTokenParams();
$apiTokenHeader = $this->app['conf']->get(['main', 'api_token_header']);
$useTokenHeader = $this->useTokenHeaderChoice($apiTokenHeader);
$token_param = $this->getAccessTokenParams($useTokenHeader);
// Access token was not provided
if ($token_param === false) {
@@ -808,4 +812,21 @@ class API_OAuth2_Adapter extends OAuth2
return false;
}
}
/**
* Get the correct constante to call on Oauth2
*
* @param $apiTokenHeader
* @return string
*/
private function useTokenHeaderChoice($apiTokenHeader)
{
if ($apiTokenHeader === true) {
return Oauth2::TOKEN_ONLY_IN_HEADER;
} elseif ($apiTokenHeader === false) {
return Oauth2::TOKEN_ONLY_IN_GETPOST;
} else {
return Oauth2::TOKEN_AUTO_FIND;
}
}
}

View File

@@ -41,7 +41,6 @@ class Session_Logger
/**
*
* @param Application $app
* @param databox $databox
* @param integer $log_id
*
@@ -64,17 +63,19 @@ class Session_Logger
return $this->id;
}
public function log(record_adapter $record, $action, $final, $comment)
public function log(record_adapter $record, $action, $final, $comment, $coll_id_from=null)
{
$sql = 'INSERT INTO log_docs
(id, log_id, date, record_id, action, final, comment)
VALUES (null, :log_id, NOW(), :record_id, :action, :final, :comm)';
(id, log_id, date, record_id, coll_id_from, coll_id, action, final, comment)
VALUES (null, :log_id, NOW(), :record_id, :coll_id_from, :coll_id, :action, :final, :comm)';
$stmt = $this->databox->get_connection()->prepare($sql);
$params = [
':log_id' => $this->get_id(),
':record_id' => $record->getRecordId(),
':coll_id_from' => $coll_id_from,
':coll_id' => $record->getCollectionId(),
':action' => $action,
':final' => $final,
':comm' => $comment,
@@ -139,17 +140,6 @@ class Session_Logger
$log_id = $conn->lastInsertId();
$stmt->closeCursor();
$sql = "INSERT INTO log_colls (id, log_id, coll_id) VALUES (null, :log_id, :coll_id)";
$stmt = $conn->prepare($sql);
foreach ($colls as $collId) {
$stmt->execute([
':log_id' => $log_id,
':coll_id' => $collId
]);
}
$stmt->closeCursor();
unset($stmt, $conn);
return new Session_Logger($databox, $log_id);

View File

@@ -121,9 +121,9 @@ class cache_databox
$conn = $app->getApplicationBox()->get_connection();
$sql = 'UPDATE sitepreff SET memcached_update = :date';
$sql = 'UPDATE sitepreff SET memcached_update = current_timestamp()';
$stmt = $conn->prepare($sql);
$stmt->execute([':date' => $now]);
$stmt->execute();
$stmt->closeCursor();
self::$refreshing = false;

View File

@@ -446,7 +446,6 @@ class databox extends base implements ThumbnailedElement
databox_field::TYPE_DATE
, databox_field::TYPE_NUMBER
, databox_field::TYPE_STRING
, databox_field::TYPE_TEXT
]
) ? $type : databox_field::TYPE_STRING;
@@ -463,6 +462,9 @@ class databox extends base implements ThumbnailedElement
->set_aggregable((isset($field['aggregable']) ? (string) $field['aggregable'] : 0))
->set_type($type)
->set_tbranch(isset($field['tbranch']) ? (string) $field['tbranch'] : '')
->set_generate_cterms((isset($field['generate_cterms']) && (string) $field['generate_cterms'] == 1))
->set_gui_editable((isset($field['gui_editable']) && (string) $field['gui_editable'] == 1))
->set_gui_visible((isset($field['gui_editable']) && (string) $field['gui_visible'] == 1))
->set_thumbtitle(isset($field['thumbtitle']) ? (string) $field['thumbtitle'] : (isset($field['thumbTitle']) ? $field['thumbTitle'] : '0'))
->set_report(isset($field['report']) ? (string) $field['report'] : '1')
->save();
@@ -1202,7 +1204,7 @@ class databox extends base implements ThumbnailedElement
public function clear_logs()
{
foreach (['log', 'log_colls', 'log_docs', 'log_search', 'log_view', 'log_thumb'] as $table) {
foreach (['log', 'log_docs', 'log_search', 'log_view', 'log_thumb'] as $table) {
$this->get_connection()->delete($table, []);
}
@@ -1215,21 +1217,40 @@ class databox extends base implements ThumbnailedElement
$domct = $this->get_dom_cterms();
if ($domct !== false) {
$changed = false;
$nodesToDel = [];
// loop on first level : "fields"
for($n = $domct->documentElement->firstChild; $n; $n = $n->nextSibling) {
if(!($n->getAttribute('delbranch'))){
$nodesToDel[] = $n;
if($n->nodeType == XML_ELEMENT_NODE && !($n->getAttribute('delbranch'))){
$nodesToDel2 = [];
// loop on 2nd level : "terms"
for($n2 = $n->firstChild; $n2; $n2 = $n2->nextSibling) {
// do not remove "rejected" candidates
if(substr($n2->getAttribute('id'), 0, 1) != 'R') {
$nodesToDel2[] = $n2;
}
}
foreach($nodesToDel2 as $n2) {
$n->removeChild($n2);
$changed = true;
}
// if a field has no more candidates, we can remove it
if(!($n->firstChild)) {
$nodesToDel[] = $n;
}
}
}
foreach($nodesToDel as $n) {
$n->parentNode->removeChild($n);
$changed = true;
}
if(!empty($nodesToDel)) {
if($changed) {
$this->saveCterms($domct);
}
}
} catch (\Exception $e) {
}
catch (\Exception $e) {
// no-op
}
}

View File

@@ -43,6 +43,9 @@ class databox_field implements cache_cacheableInterface
protected $report;
protected $type;
protected $tbranch;
protected $generate_cterms;
protected $gui_editable;
protected $gui_visible;
protected $separator;
protected $thumbtitle;
@@ -100,7 +103,6 @@ class databox_field implements cache_cacheableInterface
protected $original_dces;
protected $aggregable;
const TYPE_TEXT = "text";
const TYPE_DATE = "date";
const TYPE_STRING = "string";
const TYPE_NUMBER = "number";
@@ -167,6 +169,9 @@ class databox_field implements cache_cacheableInterface
$this->position = (int)$row['sorter'];
$this->type = $row['type'] ?: self::TYPE_STRING;
$this->tbranch = $row['tbranch'];
$this->generate_cterms = (bool)$row['generate_cterms'];
$this->gui_editable = (bool)$row['gui_editable'];
$this->gui_visible = (bool)$row['gui_visible'];
$this->VocabularyType = $row['VocabularyControlType'];
$this->VocabularyRestriction = (bool)$row['RestrictToVocabularyControl'];
@@ -307,6 +312,9 @@ class databox_field implements cache_cacheableInterface
`report` = :report,
`type` = :type,
`tbranch` = :tbranch,
`generate_cterms` = :generate_cterms,
`gui_editable` = :gui_editable,
`gui_visible` = :gui_visible,
`sorter` = :position,
`thumbtitle` = :thumbtitle,
`VocabularyControlType` = :VocabularyControlType,
@@ -330,6 +338,9 @@ class databox_field implements cache_cacheableInterface
':report' => $this->report ? '1' : '0',
':type' => $this->type,
':tbranch' => $this->tbranch,
':generate_cterms' => $this->generate_cterms ? '1' : '0',
':gui_editable' => $this->gui_editable ? '1' : '0',
':gui_visible' => $this->gui_visible ? '1' : '0',
':position' => $this->position,
':thumbtitle' => $this->thumbtitle,
':VocabularyControlType' => $this->getVocabularyControl() ? $this->getVocabularyControl()->getType() : null,
@@ -381,6 +392,9 @@ class databox_field implements cache_cacheableInterface
$meta->setAttribute('aggregable', $this->aggregable);
$meta->setAttribute('type', $this->type);
$meta->setAttribute('tbranch', $this->tbranch);
$meta->setAttribute('generate_cterms', $this->generate_cterms ? '1' : '0');
$meta->setAttribute('gui_editable', $this->gui_editable ? '1' : '0');
$meta->setAttribute('gui_visible', $this->gui_visible ? '1' : '0');
if ($this->multi) {
$meta->setAttribute('separator', $this->separator);
}
@@ -440,6 +454,16 @@ class databox_field implements cache_cacheableInterface
return isset($this->labels[$code]) && '' !== $this->labels[$code] ? $this->labels[$code] : $this->name;
}
/**
* get all localized labels
*
* @return string[]
*/
public function get_labels()
{
return $this->labels;
}
/**
* @param string $name
* @return databox_field
@@ -702,6 +726,39 @@ class databox_field implements cache_cacheableInterface
return $this;
}
/**
* @param boolean $generate_cterms
* @return databox_field
*/
public function set_generate_cterms($generate_cterms)
{
$this->generate_cterms = $generate_cterms;
return $this;
}
/**
* @param boolean $gui_editable
* @return databox_field
*/
public function set_gui_editable($gui_editable)
{
$this->gui_editable = $gui_editable;
return $this;
}
/**
* @param boolean $gui_visible
* @return databox_field
*/
public function set_gui_visible($gui_visible)
{
$this->gui_visible = $gui_visible;
return $this;
}
/**
*
* @param string $separator
@@ -786,6 +843,33 @@ class databox_field implements cache_cacheableInterface
return $this->tbranch;
}
/**
*
* @return boolean
*/
public function get_generate_cterms()
{
return $this->generate_cterms;
}
/**
*
* @return boolean
*/
public function get_gui_editable()
{
return $this->gui_editable;
}
/**
*
* @return boolean
*/
public function get_gui_visible()
{
return $this->gui_visible;
}
/**
* @param Boolean $all If set to false, returns a one-char separator to use for serialiation
*
@@ -896,6 +980,9 @@ class databox_field implements cache_cacheableInterface
'sorter' => $this->position,
'thumbtitle' => $this->thumbtitle,
'tbranch' => $this->tbranch,
'generate_cterms' => $this->generate_cterms,
'gui_editable' => $this->gui_editable,
'gui_visible' => $this->gui_visible,
'separator' => $this->separator,
'required' => $this->required,
'report' => $this->report,
@@ -934,10 +1021,10 @@ class databox_field implements cache_cacheableInterface
}
$sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `required`, `indexable`, `type`, `tbranch`,
(`id`, `name`, `src`, `readonly`, `gui_editable`,`gui_visible`, `required`, `indexable`, `type`, `tbranch`, `generate_cterms`,
`thumbtitle`, `multi`, `business`, `aggregable`,
`report`, `sorter`, `separator`)
VALUES (null, :name, '', 0, 0, 1, 'string', '',
VALUES (null, :name, '', 0, 1, 1, 0, 1, 'string', '', 1,
null, 0, 0, 0,
1, :sorter, '')";

View File

@@ -44,7 +44,7 @@ class databox_subdef
SubdefType::TYPE_DOCUMENT => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_FLEXPAPER, SubdefSpecs::TYPE_PDF],
SubdefType::TYPE_FLASH => [SubdefSpecs::TYPE_IMAGE],
SubdefType::TYPE_IMAGE => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_PDF],
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION],
SubdefType::TYPE_VIDEO => [SubdefSpecs::TYPE_IMAGE, SubdefSpecs::TYPE_VIDEO, SubdefSpecs::TYPE_ANIMATION, SubdefSpecs::TYPE_AUDIO],
SubdefType::TYPE_UNKNOWN => [SubdefSpecs::TYPE_IMAGE],
];
const CLASS_THUMBNAIL = 'thumbnail';
@@ -156,6 +156,10 @@ class databox_subdef
if ($sd->audiosamplerate) {
$audio->setOptionValue(Audio::OPTION_AUDIOSAMPLERATE, (int) $sd->audiosamplerate);
}
if ($sd->audiochannel) {
$audio->setOptionValue(Audio::OPTION_AUDIOCHANNEL, (string) $sd->audiochannel);
}
return $audio;
}
/**

View File

@@ -11,6 +11,9 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Alchemy\Phrasea\Model\Repositories\UserRepository;
class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
{
@@ -31,9 +34,9 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
/**
*
* @param Array $datas
* @param string[] $data
* @param boolean $unread
* @return string
* @return array
*/
public function datas(array $data, $unread)
{
@@ -41,24 +44,29 @@ class eventsmanager_notify_orderdeliver extends eventsmanager_notifyAbstract
$ssel_id = $data['ssel_id'];
$n = $data['n'];
if (null === $user= $this->app['repo.users']->find(($from))) {
/** @var UserRepository $userRepo */
$userRepo = $this->app['repo.users'];
if( ($user= $userRepo->find(($from))) === null ) {
return [];
}
$sender = $user->getDisplayName();
try {
/** @var BasketRepository $repository */
$repository = $this->app['repo.baskets'];
$basket = $repository->findUserBasket($ssel_id, $this->app->getAuthenticatedUser(), false);
} catch (\Exception $e) {
}
catch (\Exception $e) {
return [];
}
$ret = [
'text' => $this->app->trans('%user% vous a delivre %quantity% document(s) pour votre commande %title%', ['%user%' => $sender, '%quantity%' => $n, '%title%' => '<a href="/lightbox/compare/'
. $ssel_id . '/" target="_blank">'
. $basket->getName() . '</a>'])
, 'class' => ''
. $basket->getName() . '</a>']),
'class' => ''
];
return $ret;

View File

@@ -11,6 +11,9 @@
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Entities\User;
use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Alchemy\Phrasea\Model\Repositories\UserRepository;
class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
{
@@ -31,35 +34,38 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
/**
*
* @param string $datas
* @param string[] $data
* @param boolean $unread
* @return Array
* @return array
*/
public function datas(array $data, $unread)
{
$from = $data['from'];
$ssel_id = $data['ssel_id'];
if (null === $registered_user = $this->app['repo.users']->find($from)) {
/** @var UserRepository $userRepo */
$userRepo = $this->app['repo.users'];
if ( ($registered_user = $userRepo->find($from)) === null ) {
return [];
}
$sender = $registered_user->getDisplayName();
try {
/** @var BasketRepository $repository */
$repository = $this->app['repo.baskets'];
$basket = $repository->findUserBasket($ssel_id, $this->app->getAuthenticatedUser(), false);
} catch (\Exception $e) {
}
catch (\Exception $e) {
return [];
}
$ret = [
'text' => $this->app->trans('%user% a envoye son rapport de validation de %title%', ['%user%' => $sender, '%title%' => '<a href="/lightbox/validate/'
. $ssel_id . '/" target="_blank">'
. $basket->getName() . '</a>'
])
, 'class' => ''
. $basket->getName() . '</a>']),
'class' => ''
];
return $ret;
@@ -84,12 +90,18 @@ class eventsmanager_notify_validationdone extends eventsmanager_notifyAbstract
}
/**
* @param integer $usr_id The id of the user to check
* @param User $user The id of the user to check
*
* @return boolean
*/
public function is_available(User $user)
{
return $this->app->getAclForUser($user)->has_right(\ACL::CANPUSH);
try {
return $this->app->getAclForUser($user)->has_right(\ACL::CANPUSH);
}
catch (\Exception $e) {
// has_right(unknow_right) ? will not happen !
return false;
}
}
}

View File

@@ -89,6 +89,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
const TYPE_AUDIO_MP3 = 'AUDIO_MP3';
const TYPE_IMAGE = 'IMAGE';
const TYPE_NO_PLAYER = 'UNKNOWN';
const TYPE_PDF = 'PDF';
/*
* Technical datas types constants
@@ -407,6 +408,7 @@ class media_subdef extends media_abstract implements cache_cacheableInterface
{
static $types = [
'application/x-shockwave-flash' => self::TYPE_FLEXPAPER,
'application/pdf' => self::TYPE_PDF,
'audio/mp3' => self::TYPE_AUDIO_MP3,
'audio/mpeg' => self::TYPE_AUDIO_MP3,
'image/gif' => self::TYPE_IMAGE,

View File

@@ -81,8 +81,13 @@ class module_console_systemUpgrade extends Command
return $output->writeln(sprintf('<error>You have to fix your database before upgrade with the system:mailCheck command </error>'));
}
$queries = $this->getService('phraseanet.appbox')->forceUpgrade($upgrader, $this->container);
/** @var appbox $appBox */
$appBox = $this->getService('phraseanet.appbox');
$queries = $appBox->forceUpgrade($upgrader, $this->container);
/**
* todo (?) combine schema changes on a table as a simngle sql
* because on big tables like logs, adding 2 columns is 2 very long sql
*/
if ($input->getOption('dump') || $input->getOption('stderr')) {
if (0 < count($queries)) {
$output->writeln("Some SQL queries can be executed to optimize\n");
@@ -128,8 +133,23 @@ class module_console_systemUpgrade extends Command
} else {
$output->write('<info>Canceled</info>', true);
}
$output->write('Finished !', true);
$output->write('System upgrade Finished !', true);
return 0;
// need to fix autoincrements after system:upgrade
$output->write('Start fixing autoincrements !', true);
$fixAutoincrementCommand = $this->getApplication()->find('system:fix-autoincrements');
$arguments = array(
'command' => 'system:fix-autoincrements',
);
$fixAutoincrementInput = new ArrayInput($arguments);
$returnCode = $fixAutoincrementCommand->run($fixAutoincrementInput, $output);
$output->write('Fixing autoincrements finished after system:upgrade', true);
return $returnCode;
}
}

View File

@@ -50,6 +50,21 @@ class patch_380alpha3a extends patchAbstract
{
$conn = $databox->get_connection();
$sql = "CREATE TABLE IF NOT EXISTS `log_colls` (\n"
. " `id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n"
. " `log_id` int(11) unsigned NOT NULL,\n"
. " `coll_id` int(11) unsigned NOT NULL,\n"
. " PRIMARY KEY (`id`),\n"
. " UNIQUE KEY `couple` (`log_id`,`coll_id`),\n"
. " KEY `log_id` (`log_id`),\n"
. " KEY `coll_id` (`coll_id`)\n"
. ") ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;";
$stmt = $conn->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
unset($stmt);
$removeProc = "DROP PROCEDURE IF EXISTS explode_log_table";
$stmt = $conn->prepare($removeProc);

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,122 @@
<?php
/**
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration\PropertyAccess;
use Alchemy\Phrasea\Model\Manipulator\ApiApplicationManipulator;
use Alchemy\Phrasea\Model\Entities\ApiApplication;
use Alchemy\Phrasea\Model\Repositories\ApiApplicationRepository;
class patch_410alpha13a implements patchInterface
{
/** @var string */
private $release = '4.1.0-alpha.13';
/** @var array */
private $concern = [base::DATA_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function apply(base $databox, Application $app)
{
// @see : https://phraseanet.atlassian.net/browse/PHRAS-2468
// to be able to migrate from 3.5 to 4.0.8, we must not delete the table anymore
// so the cli "bin/setup patch:log_coll_id" can be executed.
/*
$sql = "DROP TABLE IF EXISTS `log_colls`";
$databox->get_connection()->prepare($sql)->execute();
*/
/*
* no need to do those ops, it's done by system:upgrade after fixing the xml scheme
*
$sql = "ALTER TABLE `log_docs`\n"
. "CHANGE `action` `action` ENUM(\n"
. " 'push',\n"
. " 'add',\n"
. " 'validate',\n"
. " 'edit',\n"
. " 'collection',\n"
. " 'status',\n"
. " 'print',\n"
. " 'substit',\n"
. " 'publish',\n"
. " 'download',\n"
. " 'mail',\n"
. " 'ftp',\n"
. " 'delete',\n"
. " 'collection_from',\n"
. " ''\n"
. ")\n"
. "CHARACTER SET ascii BINARY NOT NULL DEFAULT ''";
try {
$databox->get_connection()->prepare($sql)->execute();
}
catch(\Exception $e) {
// no-op
}
$sql = "ALTER TABLE `log_docs` ADD `coll_id` INT(11) UNSIGNED NULL DEFAULT NULL,\n"
. " ADD INDEX(coll_id)";
try {
$databox->get_connection()->prepare($sql)->execute();
}
catch(\Exception $e) {
// no-op (the field exists ?)
}
$sql = "ALTER TABLE `log_view` ADD `coll_id` INT(11) UNSIGNED NULL DEFAULT NULL,\n"
. " ADD INDEX(coll_id)";
try {
$databox->get_connection()->prepare($sql)->execute();
}
catch(\Exception $e) {
// no-op (the field exists ?)
}
*/
return true;
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_410alpha13b implements patchInterface
{
/** @var string */
private $release = '4.1.0-alpha.13b';
/** @var array */
private $concern = [base::DATA_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function apply(base $databox, Application $app)
{
$sql = "UPDATE `log_docs` SET `coll_id`=`final` WHERE `action`='collection'";
$databox->get_connection()->prepare($sql)->execute();
return true;
}
}

View File

@@ -0,0 +1,64 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_410alpha14a implements patchInterface
{
/** @var string */
private $release = '4.1.0-alpha.14a';
/** @var array */
private $concern = [base::DATA_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function apply(base $databox, Application $app)
{
$sql = "UPDATE metadatas_structure SET type = 'string' where type = 'text' OR type = '' ";
$databox->get_connection()->executeQuery($sql);
return true;
}
}

View File

@@ -0,0 +1,67 @@
<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2016 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Alchemy\Phrasea\Application;
class patch_410alpha17a implements patchInterface
{
/** @var string */
private $release = '4.1.0-alpha.17a';
/** @var array */
private $concern = [base::DATA_BOX];
/**
* {@inheritdoc}
*/
public function get_release()
{
return $this->release;
}
/**
* {@inheritdoc}
*/
public function getDoctrineMigrations()
{
return [];
}
/**
* {@inheritdoc}
*/
public function require_all_upgrades()
{
return false;
}
/**
* {@inheritdoc}
*/
public function concern()
{
return $this->concern;
}
/**
* {@inheritdoc}
*/
public function apply(base $databox, Application $app)
{
// -- done by xml schema --
// $sql = "ALTER TABLE `metadatas_structure` ADD `generate_cterms` INT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `tbranch`";
// $databox->get_connection()->executeQuery($sql);
// $sql = "ALTER TABLE `metadatas_structure` ADD `gui_editable` INT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `readonly`";
// $databox->get_connection()->executeQuery($sql);
return true;
}
}

View File

@@ -529,10 +529,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
return $this;
}
$coll_id_from = $this->getCollectionId();
$coll_id_to = $collection->get_coll_id();
$sql = "UPDATE record SET moddate = NOW(), coll_id = :coll_id WHERE record_id =:record_id";
$params = [
':coll_id' => $collection->get_coll_id(),
':coll_id' => $coll_id_to,
':record_id' => $this->getRecordId(),
];
@@ -541,12 +544,13 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
$stmt->closeCursor();
$this->base_id = $collection->get_base_id();
$this->app['phraseanet.logger']($this->getDatabox())
->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '');
$this->collection_id = $coll_id_to;
$this->delete_data_from_cache();
$this->app['phraseanet.logger']($this->getDatabox())
->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '', $coll_id_from);
$this->dispatch(RecordEvents::COLLECTION_CHANGED, new CollectionChangedEvent($this));
return $this;
@@ -1208,13 +1212,14 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
try {
$log_id = $app['phraseanet.logger']($collection->get_databox())->get_id();
$sql = 'INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment)'
. ' VALUES (null, :log_id, now(), :record_id, "add", :coll_id,"")';
$sql = 'INSERT INTO log_docs (id, log_id, date, record_id, coll_id, action, final, comment)'
. ' VALUES (null, :log_id, now(), :record_id, :coll_id, "add", :final, "")';
$stmt = $connection->prepare($sql);
$stmt->execute([
':log_id' => $log_id,
':record_id' => $story_id,
':coll_id' => $collection->get_coll_id(),
':final' => $collection->get_coll_id(),
]);
$stmt->closeCursor();
} catch (\Exception $e) {
@@ -1261,14 +1266,15 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
try {
$log_id = $app['phraseanet.logger']($databox)->get_id();
$sql = "INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment)"
. " VALUES (null, :log_id, now(), :record_id, 'add', :coll_id, '')";
$sql = "INSERT INTO log_docs (id, log_id, date, record_id, coll_id, action, final, comment)"
. " VALUES (null, :log_id, now(), :record_id, :coll_id, 'add', :final, '')";
$stmt = $databox->get_connection()->prepare($sql);
$stmt->execute([
':log_id' => $log_id,
':record_id' => $record_id,
':coll_id' => $file->getCollection()->get_coll_id(),
':final' => $file->getCollection()->get_coll_id(),
]);
$stmt->closeCursor();
} catch (\Exception $e) {
@@ -1600,14 +1606,15 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function log_view($log_id, $referrer, $gv_sit)
{
$sql = "INSERT INTO log_view (id, log_id, date, record_id, referrer, site_id)"
. " VALUES (null, :log_id, now(), :rec, :referrer, :site)";
$sql = "INSERT INTO log_view (id, log_id, date, record_id, referrer, site_id, coll_id)"
. " VALUES (null, :log_id, now(), :rec, :referrer, :site, :collid)";
$params = [
':log_id' => $log_id
, ':rec' => $this->getRecordId()
, ':referrer' => $referrer
, ':site' => $gv_sit,
, ':site' => $gv_sit
, ':collid' => $this->getCollectionId()
];
$stmt = $this->getDataboxConnection()->prepare($sql);
$stmt->execute($params);

View File

@@ -9,13 +9,16 @@
*/
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
use Alchemy\Phrasea\Model\Entities\Token;
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 Assert\Assertion;
use Doctrine\DBAL\Connection;
use Symfony\Component\Filesystem\Filesystem;
class set_export extends set_abstract
{
private static $maxFilenameLength = 256;
@@ -60,6 +63,7 @@ class set_export extends set_abstract
$remain_hd = [];
if ($storyWZid) {
/** @var StoryWZRepository $repository */
$repository = $app['repo.story-wz'];
$storyWZ = $repository->findByUserAndId($this->app, $app->getAuthenticatedUser(), $storyWZid);
@@ -68,6 +72,7 @@ class set_export extends set_abstract
}
if ($sstid != "") {
/** @var BasketRepository $repository */
$repository = $app['repo.baskets'];
$Basket = $repository->findUserBasket($sstid, $app->getAuthenticatedUser(), false);