mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Error in fetching User ID. Improvement of SQLs
Fixes PHPCS in set classes.
This commit is contained in:
@@ -12,36 +12,22 @@
|
|||||||
abstract class set_abstract implements IteratorAggregate
|
abstract class set_abstract implements IteratorAggregate
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
*
|
* @var \record_adapter[]
|
||||||
* @var Array
|
|
||||||
*/
|
*/
|
||||||
protected $elements = [];
|
protected $elements = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return ArrayIterator
|
* @return ArrayIterator
|
||||||
*/
|
*/
|
||||||
public function getIterator()
|
public function getIterator()
|
||||||
{
|
{
|
||||||
$this->load_elements();
|
|
||||||
|
|
||||||
return new ArrayIterator($this->elements);
|
return new ArrayIterator($this->elements);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return set
|
|
||||||
*/
|
|
||||||
protected function load_elements()
|
|
||||||
{
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param string $offset
|
* @param string $offset
|
||||||
* @param string $value
|
* @param record_adapter $value
|
||||||
* @return Void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function offsetSet($offset, $value)
|
public function offsetSet($offset, $value)
|
||||||
{
|
{
|
||||||
@@ -53,9 +39,8 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $offset
|
* @param string $offset
|
||||||
* @return boolean
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function offsetExists($offset)
|
public function offsetExists($offset)
|
||||||
{
|
{
|
||||||
@@ -63,9 +48,8 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $offset
|
* @param string $offset
|
||||||
* @return Void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function offsetUnset($offset)
|
public function offsetUnset($offset)
|
||||||
{
|
{
|
||||||
@@ -73,9 +57,8 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param string $offset
|
* @param string $offset
|
||||||
* @return record_adapter
|
* @return record_adapter|null
|
||||||
*/
|
*/
|
||||||
public function offsetGet($offset)
|
public function offsetGet($offset)
|
||||||
{
|
{
|
||||||
@@ -83,8 +66,7 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return bool
|
||||||
* @return int
|
|
||||||
*/
|
*/
|
||||||
public function is_empty()
|
public function is_empty()
|
||||||
{
|
{
|
||||||
@@ -104,7 +86,7 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
/**
|
/**
|
||||||
* Get the number of element in the set
|
* Get the number of element in the set
|
||||||
*
|
*
|
||||||
* @return Int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function get_count()
|
public function get_count()
|
||||||
{
|
{
|
||||||
@@ -112,7 +94,6 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function get_count_groupings()
|
public function get_count_groupings()
|
||||||
@@ -127,20 +108,16 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return record_adapter[]
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_elements()
|
public function get_elements()
|
||||||
{
|
{
|
||||||
$this->load_elements();
|
|
||||||
|
|
||||||
return $this->elements;
|
return $this->elements;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param record_adapter $record
|
* @param record_adapter $record
|
||||||
* @return set
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function add_element(\record_adapter $record)
|
public function add_element(\record_adapter $record)
|
||||||
{
|
{
|
||||||
@@ -150,9 +127,8 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param record_adapter $record
|
* @param record_adapter $record
|
||||||
* @return set
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function remove_element(\record_adapter $record)
|
public function remove_element(\record_adapter $record)
|
||||||
{
|
{
|
||||||
@@ -164,7 +140,6 @@ abstract class set_abstract implements IteratorAggregate
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function serialize_list()
|
public function serialize_list()
|
||||||
|
@@ -12,10 +12,14 @@ use Alchemy\Phrasea\Application;
|
|||||||
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
|
use Alchemy\Phrasea\Model\Serializer\CaptionSerializer;
|
||||||
use Alchemy\Phrasea\Model\Entities\Token;
|
use Alchemy\Phrasea\Model\Entities\Token;
|
||||||
use Alchemy\Phrasea\Model\Entities\User;
|
use Alchemy\Phrasea\Model\Entities\User;
|
||||||
|
use Doctrine\DBAL\Connection;
|
||||||
use Symfony\Component\Filesystem\Filesystem;
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
|
||||||
class set_export extends set_abstract
|
class set_export extends set_abstract
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var Application
|
||||||
|
*/
|
||||||
protected $app;
|
protected $app;
|
||||||
protected $storage = [];
|
protected $storage = [];
|
||||||
protected $total_download;
|
protected $total_download;
|
||||||
@@ -30,19 +34,15 @@ class set_export extends set_abstract
|
|||||||
protected $exportName;
|
protected $exportName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param string $lst
|
* @param string $lst
|
||||||
* @param integer $sstid
|
* @param int $sstid
|
||||||
* @param integer $storyWZid
|
* @param int $storyWZid
|
||||||
* @return set_export
|
|
||||||
*/
|
*/
|
||||||
public function __construct(Application $app, $lst, $sstid, $storyWZid = null)
|
public function __construct(Application $app, $lst, $sstid, $storyWZid = null)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
|
|
||||||
$download_list = [];
|
|
||||||
|
|
||||||
$remain_hd = [];
|
$remain_hd = [];
|
||||||
|
|
||||||
if ($storyWZid) {
|
if ($storyWZid) {
|
||||||
@@ -60,8 +60,8 @@ class set_export extends set_abstract
|
|||||||
$this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
|
$this->exportName = str_replace([' ', '\\', '/'], '_', $Basket->getName()) . "_" . date("Y-n-d");
|
||||||
|
|
||||||
foreach ($Basket->getElements() as $basket_element) {
|
foreach ($Basket->getElements() as $basket_element) {
|
||||||
$base_id = $basket_element->getRecord($this->app)->get_base_id();
|
$base_id = $basket_element->getRecord($this->app)->getBaseId();
|
||||||
$record_id = $basket_element->getRecord($this->app)->get_record_id();
|
$record_id = $basket_element->getRecord($this->app)->getRecordId();
|
||||||
|
|
||||||
if (!isset($remain_hd[$base_id])) {
|
if (!isset($remain_hd[$base_id])) {
|
||||||
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
||||||
@@ -71,14 +71,14 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_element = $download_list[] =
|
$current_element = new record_exportElement(
|
||||||
new record_exportElement(
|
$app,
|
||||||
$app,
|
$basket_element->getRecord($this->app)->getDataboxId(),
|
||||||
$basket_element->getRecord($this->app)->get_sbas_id(),
|
$record_id,
|
||||||
$record_id,
|
$Basket->getName(),
|
||||||
$Basket->getName(),
|
$remain_hd[$base_id]
|
||||||
$remain_hd[$base_id]
|
|
||||||
);
|
);
|
||||||
|
$this->add_element($current_element);
|
||||||
|
|
||||||
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
||||||
}
|
}
|
||||||
@@ -99,9 +99,9 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($record->isStory()) {
|
if ($record->isStory()) {
|
||||||
foreach ($record->get_children() as $child_basrec) {
|
foreach ($record->getChildren() as $child_basrec) {
|
||||||
$base_id = $child_basrec->get_base_id();
|
$base_id = $child_basrec->getBaseId();
|
||||||
$record_id = $child_basrec->get_record_id();
|
$record_id = $child_basrec->getRecordId();
|
||||||
|
|
||||||
if (!isset($remain_hd[$base_id])) {
|
if (!isset($remain_hd[$base_id])) {
|
||||||
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
||||||
@@ -111,20 +111,20 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_element = $download_list[] =
|
$current_element = new record_exportElement(
|
||||||
new record_exportElement(
|
$app,
|
||||||
$app,
|
$child_basrec->getDataboxId(),
|
||||||
$child_basrec->get_sbas_id(),
|
$record_id,
|
||||||
$record_id,
|
$record->get_title(null, null, true) . '_' . $n,
|
||||||
$record->get_title(null, null, true) . '_' . $n,
|
$remain_hd[$base_id]
|
||||||
$remain_hd[$base_id]
|
|
||||||
);
|
);
|
||||||
|
$this->add_element($current_element);
|
||||||
|
|
||||||
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$base_id = $record->get_base_id();
|
$base_id = $record->getBaseId();
|
||||||
$record_id = $record->get_record_id();
|
$record_id = $record->getRecordId();
|
||||||
|
|
||||||
if (!isset($remain_hd[$base_id])) {
|
if (!isset($remain_hd[$base_id])) {
|
||||||
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
||||||
@@ -134,15 +134,14 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$current_element =
|
$current_element = new record_exportElement(
|
||||||
$download_list[$basrec[0] . '_' . $basrec[1]] =
|
$app,
|
||||||
new record_exportElement(
|
$record->getDataboxId(),
|
||||||
$app,
|
$record_id,
|
||||||
$record->get_sbas_id(),
|
'',
|
||||||
$record_id,
|
$remain_hd[$base_id]
|
||||||
'',
|
|
||||||
$remain_hd[$base_id]
|
|
||||||
);
|
);
|
||||||
|
$this->add_element($current_element);
|
||||||
|
|
||||||
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
$remain_hd[$base_id] = $current_element->get_remain_hd();
|
||||||
}
|
}
|
||||||
@@ -150,8 +149,6 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->elements = $download_list;
|
|
||||||
|
|
||||||
$display_download = [];
|
$display_download = [];
|
||||||
$display_orderable = [];
|
$display_orderable = [];
|
||||||
|
|
||||||
@@ -161,18 +158,19 @@ class set_export extends set_abstract
|
|||||||
|
|
||||||
$this->businessFieldsAccess = false;
|
$this->businessFieldsAccess = false;
|
||||||
|
|
||||||
foreach ($this->elements as $download_element) {
|
/** @var record_exportElement $download_element */
|
||||||
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
|
foreach ($this->get_elements() as $download_element) {
|
||||||
|
if ($app->getAclForUser($app->getAuthenticatedUser())->has_right_on_base($download_element->getBaseId(), 'canmodifrecord')) {
|
||||||
$this->businessFieldsAccess = true;
|
$this->businessFieldsAccess = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($download_element->get_downloadable() as $name => $properties) {
|
foreach ($download_element->get_downloadable() as $name => $properties) {
|
||||||
if (!isset($display_download[$name])) {
|
if (!isset($display_download[$name])) {
|
||||||
$display_download[$name] = [
|
$display_download[$name] = [
|
||||||
'size' => 0,
|
'size' => 0,
|
||||||
'total' => 0,
|
'total' => 0,
|
||||||
'available' => 0,
|
'available' => 0,
|
||||||
'refused' => []
|
'refused' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,9 +189,9 @@ class set_export extends set_abstract
|
|||||||
foreach ($download_element->get_orderable() as $name => $properties) {
|
foreach ($download_element->get_orderable() as $name => $properties) {
|
||||||
if (!isset($display_orderable[$name])) {
|
if (!isset($display_orderable[$name])) {
|
||||||
$display_orderable[$name] = [
|
$display_orderable[$name] = [
|
||||||
'total' => 0,
|
'total' => 0,
|
||||||
'available' => 0,
|
'available' => 0,
|
||||||
'refused' => []
|
'refused' => [],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +207,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($display_download as $name => $values) {
|
foreach ($display_download as $name => $values) {
|
||||||
$display_download[$name]['size'] = (int) $values['size'];
|
$display_download[$name]['size'] = (int)$values['size'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$display_ftp = [];
|
$display_ftp = [];
|
||||||
@@ -222,79 +220,73 @@ class set_export extends set_abstract
|
|||||||
|
|
||||||
$this->ftp_datas = [];
|
$this->ftp_datas = [];
|
||||||
|
|
||||||
if ($this->app['conf']->get(['registry', 'ftp', 'ftp-enabled']) && ($hasadminright || $this->app['conf']->get(['registry', 'ftp', 'ftp-user-access']))) {
|
if ($this->app['conf']->get([
|
||||||
|
'registry',
|
||||||
|
'ftp',
|
||||||
|
'ftp-enabled',
|
||||||
|
]) && ($hasadminright || $this->app['conf']->get(['registry', 'ftp', 'ftp-user-access']))
|
||||||
|
) {
|
||||||
$display_ftp = $display_download;
|
$display_ftp = $display_download;
|
||||||
$this->total_ftp = $this->total_download;
|
$this->total_ftp = $this->total_download;
|
||||||
|
|
||||||
$lst_base_id = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base());
|
$lst_base_id = array_keys($app->getAclForUser($app->getAuthenticatedUser())->get_granted_base());
|
||||||
|
|
||||||
if ($hasadminright) {
|
$userFilterSQL = '';
|
||||||
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
|
$params = [];
|
||||||
FROM (
|
$types = [];
|
||||||
FtpCredential INNER JOIN Users ON (
|
|
||||||
FtpCredential.active = 1 AND FtpCredential.user_id = Users.id
|
if (!$hasadminright) {
|
||||||
) INNER JOIN basusr ON (
|
$userFilterSQL = ' AND Users.id = :usr_id';
|
||||||
Users.id=basusr.usr_id
|
$params['usr_id'] = $app->getAuthenticatedUser()->getId();
|
||||||
AND (basusr.base_id=
|
$types['usr_id'] = PDO::PARAM_INT;
|
||||||
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
GROUP BY Users.id ";
|
|
||||||
$params = [];
|
|
||||||
} elseif ($this->app['conf']->get(['registry', 'ftp', 'ftp-user-access'])) {
|
|
||||||
$sql = "SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
|
|
||||||
FROM (
|
|
||||||
FtpCredential INNER JOIN Users ON (
|
|
||||||
FtpCredential.active = 1 AND FtpCredential.id = Users.id
|
|
||||||
) INNER JOIN basusr ON (
|
|
||||||
Users.id=basusr.usr_id
|
|
||||||
AND Users.id = :usr_id
|
|
||||||
AND (basusr.base_id=
|
|
||||||
'" . implode("' OR basusr.base_id='", $lst_base_id) . "'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
GROUP BY Users.id ";
|
|
||||||
$params = [':usr_id' => $app->getAuthenticatedUser()->getId()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$sql = <<<SQL
|
||||||
|
SELECT Users.id AS usr_id ,Users.login AS usr_login ,Users.email AS usr_mail, FtpCredential.*
|
||||||
|
FROM (
|
||||||
|
FtpCredential INNER JOIN Users ON (FtpCredential.active = 1 AND FtpCredential.user_id = Users.id)
|
||||||
|
INNER JOIN basusr ON (
|
||||||
|
Users.id=basusr.usr_id
|
||||||
|
${userFilterSQL}
|
||||||
|
AND (basusr.base_id IN (:baseIds))
|
||||||
|
)
|
||||||
|
)
|
||||||
|
GROUP BY Users.id
|
||||||
|
SQL;
|
||||||
|
$params['baseIds'] = $lst_base_id;
|
||||||
|
$types['baseIds'] = Connection::PARAM_INT_ARRAY;
|
||||||
|
|
||||||
$datas[] = [
|
$datas[] = [
|
||||||
'name' => $app->trans('export::ftp: reglages manuels'),
|
'name' => $app->trans('export::ftp: reglages manuels'),
|
||||||
'usr_id' => '0',
|
'usr_id' => '0',
|
||||||
'address' => '',
|
'address' => '',
|
||||||
'login' => '',
|
'login' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'ssl' => false,
|
'ssl' => false,
|
||||||
'dest_folder' => '',
|
'dest_folder' => '',
|
||||||
'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"),
|
'prefix_folder' => 'Export_' . date("Y-m-d_H.i.s"),
|
||||||
'passive' => false,
|
'passive' => false,
|
||||||
'max_retry' => 5,
|
'max_retry' => 5,
|
||||||
'sendermail' => $app->getAuthenticatedUser()->getEmail()
|
'sendermail' => $app->getAuthenticatedUser()->getEmail(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$stmt = $app->getApplicationBox()->get_connection()->prepare($sql);
|
foreach ($app->getApplicationBox()->get_connection()->fetchAll($sql, $params, $types) as $row) {
|
||||||
$stmt->execute($params);
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row) {
|
|
||||||
$datas[] = [
|
$datas[] = [
|
||||||
'name' => $row["usr_login"],
|
'name' => $row["usr_login"],
|
||||||
'usr_id' => $row['usr_id'],
|
'usr_id' => $row['usr_id'],
|
||||||
'address' => $row['address'],
|
'address' => $row['address'],
|
||||||
'login' => $row['login'],
|
'login' => $row['login'],
|
||||||
'password' => $row['password'],
|
'password' => $row['password'],
|
||||||
'ssl' => !! $row['tls'],
|
'ssl' => !!$row['tls'],
|
||||||
'dest_folder' => $row['reception_folder'],
|
'dest_folder' => $row['reception_folder'],
|
||||||
'prefix_folder' =>
|
'prefix_folder' =>
|
||||||
(strlen(trim($row['repository_prefix_name'])) > 0 ?
|
(strlen(trim($row['repository_prefix_name'])) > 0 ?
|
||||||
trim($row['repository_prefix_name']) :
|
trim($row['repository_prefix_name']) :
|
||||||
'Export_' . date("Y-m-d_H.i.s")),
|
'Export_' . date("Y-m-d_H.i.s")),
|
||||||
'passive' => !! $row['passive'],
|
'passive' => !!$row['passive'],
|
||||||
'max_retry' => $row['max_retry'],
|
'max_retry' => $row['max_retry'],
|
||||||
'usr_mail' => $row['usr_mail'],
|
'usr_mail' => $row['usr_mail'],
|
||||||
'sender_mail' => $app->getAuthenticatedUser()->getEmail()
|
'sender_mail' => $app->getAuthenticatedUser()->getEmail(),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,8 +296,6 @@ class set_export extends set_abstract
|
|||||||
$this->display_orderable = $display_orderable;
|
$this->display_orderable = $display_orderable;
|
||||||
$this->display_download = $display_download;
|
$this->display_download = $display_download;
|
||||||
$this->display_ftp = $display_ftp;
|
$this->display_ftp = $display_ftp;
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -319,8 +309,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_ftp_datas()
|
public function get_ftp_datas()
|
||||||
{
|
{
|
||||||
@@ -333,8 +322,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_display_orderable()
|
public function get_display_orderable()
|
||||||
{
|
{
|
||||||
@@ -342,8 +330,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_display_download()
|
public function get_display_download()
|
||||||
{
|
{
|
||||||
@@ -351,8 +338,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
|
||||||
*/
|
*/
|
||||||
public function get_display_ftp()
|
public function get_display_ftp()
|
||||||
{
|
{
|
||||||
@@ -360,8 +346,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return int
|
||||||
* @return Int
|
|
||||||
*/
|
*/
|
||||||
public function get_total_download()
|
public function get_total_download()
|
||||||
{
|
{
|
||||||
@@ -369,8 +354,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return int
|
||||||
* @return Int
|
|
||||||
*/
|
*/
|
||||||
public function get_total_order()
|
public function get_total_order()
|
||||||
{
|
{
|
||||||
@@ -378,8 +362,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return int
|
||||||
* @return Int
|
|
||||||
*/
|
*/
|
||||||
public function get_total_ftp()
|
public function get_total_ftp()
|
||||||
{
|
{
|
||||||
@@ -387,16 +370,15 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @param User $user
|
||||||
* @param User $user
|
|
||||||
* @param Filesystem $filesystem
|
* @param Filesystem $filesystem
|
||||||
* @param Array $subdefs
|
* @param array $subdefs
|
||||||
* @param boolean $rename_title
|
* @param bool $rename_title
|
||||||
* @param boolean $includeBusinessFields
|
* @param bool $includeBusinessFields
|
||||||
*
|
* @return array
|
||||||
* @return Array
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function prepare_export(User $user, Filesystem $filesystem, Array $subdefs, $rename_title, $includeBusinessFields)
|
public function prepare_export(User $user, Filesystem $filesystem, array $subdefs, $rename_title, $includeBusinessFields)
|
||||||
{
|
{
|
||||||
if (!is_array($subdefs)) {
|
if (!is_array($subdefs)) {
|
||||||
throw new Exception('No subdefs given');
|
throw new Exception('No subdefs given');
|
||||||
@@ -414,32 +396,33 @@ class set_export extends set_abstract
|
|||||||
|
|
||||||
$unicode = new \unicode();
|
$unicode = new \unicode();
|
||||||
|
|
||||||
foreach ($this->elements as $download_element) {
|
/** @var record_exportElement $download_element */
|
||||||
|
foreach ($this->get_elements() as $download_element) {
|
||||||
$id = count($files);
|
$id = count($files);
|
||||||
|
|
||||||
$files[$id] = [
|
$files[$id] = [
|
||||||
'base_id' => $download_element->get_base_id(),
|
'base_id' => $download_element->getBaseId(),
|
||||||
'record_id' => $download_element->get_record_id(),
|
'record_id' => $download_element->getRecordId(),
|
||||||
'original_name' => '',
|
'original_name' => '',
|
||||||
'export_name' => '',
|
'export_name' => '',
|
||||||
'subdefs' => []
|
'subdefs' => [],
|
||||||
];
|
];
|
||||||
|
|
||||||
$BF = false;
|
$BF = false;
|
||||||
|
|
||||||
if ($includeBusinessFields && $this->app->getAclForUser($user)->has_right_on_base($download_element->get_base_id(), 'canmodifrecord')) {
|
if ($includeBusinessFields && $this->app->getAclForUser($user)->has_right_on_base($download_element->getBaseId(), 'canmodifrecord')) {
|
||||||
$BF = true;
|
$BF = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$desc = $this->app['serializer.caption']->serialize($download_element->get_caption(), CaptionSerializer::SERIALIZE_XML, $BF);
|
$desc = $this->app['serializer.caption']->serialize($download_element->get_caption(), CaptionSerializer::SERIALIZE_XML, $BF);
|
||||||
|
|
||||||
$files[$id]['original_name'] =
|
$files[$id]['original_name'] =
|
||||||
$files[$id]['export_name'] =
|
$files[$id]['export_name'] =
|
||||||
$download_element->get_original_name(true);
|
$download_element->get_original_name(true);
|
||||||
|
|
||||||
$files[$id]['original_name'] =
|
$files[$id]['original_name'] =
|
||||||
trim($files[$id]['original_name']) != '' ?
|
trim($files[$id]['original_name']) != '' ?
|
||||||
$files[$id]['original_name'] : $id;
|
$files[$id]['original_name'] : $id;
|
||||||
|
|
||||||
$infos = pathinfo($files[$id]['original_name']);
|
$infos = pathinfo($files[$id]['original_name']);
|
||||||
|
|
||||||
@@ -456,13 +439,14 @@ class set_export extends set_abstract
|
|||||||
$sizeMaxAjout = 0;
|
$sizeMaxAjout = 0;
|
||||||
$sizeMaxExt = 0;
|
$sizeMaxExt = 0;
|
||||||
|
|
||||||
$sd = $download_element->get_subdefs();
|
|
||||||
|
|
||||||
foreach ($download_element->get_downloadable() as $name => $properties) {
|
foreach ($download_element->get_downloadable() as $name => $properties) {
|
||||||
if ($properties === false || !in_array($name, $subdefs)) {
|
if ($properties === false || !in_array($name, $subdefs)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!in_array($name, ['caption', 'caption-yaml']) && !isset($sd[$name])) {
|
|
||||||
|
$subdef = $download_element->get_subdef($name);
|
||||||
|
|
||||||
|
if (!in_array($name, ['caption', 'caption-yaml']) && !isset($subdef)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,23 +465,23 @@ class set_export extends set_abstract
|
|||||||
break;
|
break;
|
||||||
case 'thumbnail':
|
case 'thumbnail':
|
||||||
$tmp_pathfile = [
|
$tmp_pathfile = [
|
||||||
'path' => $sd[$name]->get_path()
|
'path' => $subdef->get_path(),
|
||||||
, 'file' => $sd[$name]->get_file()
|
'file' => $subdef->get_file(),
|
||||||
];
|
];
|
||||||
$subdef_export = true;
|
$subdef_export = true;
|
||||||
$subdef_alive = true;
|
$subdef_alive = true;
|
||||||
break;
|
break;
|
||||||
case 'document':
|
case 'document':
|
||||||
$subdef_export = true;
|
$subdef_export = true;
|
||||||
$path = \recordutils_image::stamp($this->app , $sd[$name]);
|
$path = \recordutils_image::stamp($this->app, $subdef);
|
||||||
$tmp_pathfile = [
|
$tmp_pathfile = [
|
||||||
'path' => $sd[$name]->get_path()
|
'path' => $subdef->get_path(),
|
||||||
, 'file' => $sd[$name]->get_file()
|
'file' => $subdef->get_file(),
|
||||||
];
|
];
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$tmp_pathfile = [
|
$tmp_pathfile = [
|
||||||
'path' => dirname($path)
|
'path' => dirname($path),
|
||||||
, 'file' => basename($path)
|
'file' => basename($path),
|
||||||
];
|
];
|
||||||
$subdef_alive = true;
|
$subdef_alive = true;
|
||||||
}
|
}
|
||||||
@@ -507,17 +491,18 @@ class set_export extends set_abstract
|
|||||||
$subdef_export = true;
|
$subdef_export = true;
|
||||||
|
|
||||||
$tmp_pathfile = [
|
$tmp_pathfile = [
|
||||||
'path' => $sd[$name]->get_path()
|
'path' => $subdef->get_path(),
|
||||||
, 'file' => $sd[$name]->get_file()
|
'file' => $subdef->get_file(),
|
||||||
];
|
];
|
||||||
if (!$this->app->getAclForUser($user)->has_right_on_base($download_element->get_base_id(), "nowatermark")
|
if (!$this->app->getAclForUser($user)->has_right_on_base($download_element->getBaseId(), "nowatermark")
|
||||||
&& !$this->app->getAclForUser($user)->has_preview_grant($download_element)
|
&& !$this->app->getAclForUser($user)->has_preview_grant($download_element)
|
||||||
&& $sd[$name]->get_type() == media_subdef::TYPE_IMAGE) {
|
&& $subdef->get_type() == media_subdef::TYPE_IMAGE
|
||||||
$path = recordutils_image::watermark($this->app, $sd[$name]);
|
) {
|
||||||
|
$path = recordutils_image::watermark($this->app, $subdef);
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$tmp_pathfile = [
|
$tmp_pathfile = [
|
||||||
'path' => dirname($path)
|
'path' => dirname($path),
|
||||||
, 'file' => basename($path)
|
'file' => basename($path),
|
||||||
];
|
];
|
||||||
$subdef_alive = true;
|
$subdef_alive = true;
|
||||||
}
|
}
|
||||||
@@ -560,14 +545,12 @@ class set_export extends set_abstract
|
|||||||
$files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
|
$files[$id]["subdefs"][$name]["path"] = $tmp_pathfile["path"];
|
||||||
$files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
|
$files[$id]["subdefs"][$name]["file"] = $tmp_pathfile["file"];
|
||||||
$files[$id]["subdefs"][$name]["label"] = $properties['label'];
|
$files[$id]["subdefs"][$name]["label"] = $properties['label'];
|
||||||
$files[$id]["subdefs"][$name]["size"] = $sd[$name]->get_size();
|
$files[$id]["subdefs"][$name]["size"] = $subdef->get_size();
|
||||||
$files[$id]["subdefs"][$name]["mime"] = $sd[$name]->get_mime();
|
$files[$id]["subdefs"][$name]["mime"] = $subdef->get_mime();
|
||||||
$files[$id]["subdefs"][$name]["folder"] =
|
$files[$id]["subdefs"][$name]["folder"] = $download_element->get_directory();
|
||||||
$download_element->get_directory();
|
$files[$id]["subdefs"][$name]["exportExt"] = isset($infos['extension']) ? $infos['extension'] : '';
|
||||||
$files[$id]["subdefs"][$name]["exportExt"] =
|
|
||||||
isset($infos['extension']) ? $infos['extension'] : '';
|
|
||||||
|
|
||||||
$size += $sd[$name]->get_size();
|
$size += $subdef->get_size();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -611,10 +594,12 @@ class set_export extends set_abstract
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$name = utf8_decode($files[$id]["export_name"]);
|
$name = utf8_decode($files[$id]["export_name"]);
|
||||||
$tmp_name = "";
|
$tmp_name = "";
|
||||||
$good_keys = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
$good_keys = [
|
||||||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j',
|
||||||
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't',
|
||||||
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3',
|
||||||
'4', '5', '6', '7', '8', '9', '-', '_', '.', '#'];
|
'4', '5', '6', '7', '8', '9', '-', '_', '.', '#',
|
||||||
|
];
|
||||||
|
|
||||||
while (isset($name[$i])) {
|
while (isset($name[$i])) {
|
||||||
if (!in_array(mb_strtolower($name[$i]), $good_keys))
|
if (!in_array(mb_strtolower($name[$i]), $good_keys))
|
||||||
@@ -629,7 +614,7 @@ class set_export extends set_abstract
|
|||||||
$files[$id]["export_name"] = $tmp_name;
|
$files[$id]["export_name"] = $tmp_name;
|
||||||
|
|
||||||
if (in_array('caption', $subdefs)) {
|
if (in_array('caption', $subdefs)) {
|
||||||
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/';
|
$caption_dir = $this->app['tmp.caption.path'] . '/' . time() . $this->app->getAuthenticatedUser()->getId() . '/';
|
||||||
|
|
||||||
$filesystem->mkdir($caption_dir, 0750);
|
$filesystem->mkdir($caption_dir, 0750);
|
||||||
|
|
||||||
@@ -650,7 +635,7 @@ class set_export extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (in_array('caption-yaml', $subdefs)) {
|
if (in_array('caption-yaml', $subdefs)) {
|
||||||
$caption_dir = $this->app['tmp.caption.path'].'/'.time().$this->app->getAuthenticatedUser()->getId().'/';
|
$caption_dir = $this->app['tmp.caption.path'] . '/' . time() . $this->app->getAuthenticatedUser()->getId() . '/';
|
||||||
|
|
||||||
$filesystem->mkdir($caption_dir, 0750);
|
$filesystem->mkdir($caption_dir, 0750);
|
||||||
|
|
||||||
@@ -674,23 +659,22 @@ class set_export extends set_abstract
|
|||||||
$this->list = [
|
$this->list = [
|
||||||
'files' => $files,
|
'files' => $files,
|
||||||
'names' => $file_names,
|
'names' => $file_names,
|
||||||
'size' => $size,
|
'size' => $size,
|
||||||
'count' => $n_files
|
'count' => $n_files,
|
||||||
];
|
];
|
||||||
|
|
||||||
return $this->list;
|
return $this->list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param String $token
|
* @param Token $token
|
||||||
* @param Array $list
|
* @param array $list
|
||||||
* @param string $zipFile
|
* @param string $zipFile
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public static function build_zip(Application $app, Token $token, Array $list, $zipFile)
|
public static function build_zip(Application $app, Token $token, array $list, $zipFile)
|
||||||
{
|
{
|
||||||
if (isset($list['complete']) && $list['complete'] === true) {
|
if (isset($list['complete']) && $list['complete'] === true) {
|
||||||
return;
|
return;
|
||||||
@@ -745,19 +729,22 @@ class set_export extends set_abstract
|
|||||||
* @todo a revoir le cas anonymous
|
* @todo a revoir le cas anonymous
|
||||||
*
|
*
|
||||||
* @param Application $app
|
* @param Application $app
|
||||||
* @param Array $list
|
* @param array $list
|
||||||
* @param String $type
|
* @param String $type
|
||||||
* @param boolean $anonymous
|
* @param boolean $anonymous
|
||||||
* @param string $comment
|
* @param string $comment
|
||||||
*
|
*
|
||||||
* @return Void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function log_download(Application $app, Array $list, $type, $anonymous = false, $comment = '')
|
public static function log_download(Application $app, array $list, $type, $anonymous = false, $comment = '')
|
||||||
{
|
{
|
||||||
$tmplog = [];
|
$tmplog = [];
|
||||||
$files = $list['files'];
|
$files = $list['files'];
|
||||||
|
|
||||||
$event_name = in_array($type, [Session_Logger::EVENT_EXPORTMAIL,Session_Logger::EVENT_EXPORTDOWNLOAD]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD;
|
$event_name = in_array($type, [
|
||||||
|
Session_Logger::EVENT_EXPORTMAIL,
|
||||||
|
Session_Logger::EVENT_EXPORTDOWNLOAD,
|
||||||
|
]) ? $type : Session_Logger::EVENT_EXPORTDOWNLOAD;
|
||||||
|
|
||||||
foreach ($files as $record) {
|
foreach ($files as $record) {
|
||||||
foreach ($record["subdefs"] as $o => $obj) {
|
foreach ($record["subdefs"] as $o => $obj) {
|
||||||
@@ -765,16 +752,16 @@ class set_export extends set_abstract
|
|||||||
|
|
||||||
$record_object = new record_adapter($app, $sbas_id, $record['record_id']);
|
$record_object = new record_adapter($app, $sbas_id, $record['record_id']);
|
||||||
|
|
||||||
$app['phraseanet.logger']($record_object->get_databox())->log($record_object, $event_name, $o, $comment);
|
$app['phraseanet.logger']($record_object->getDatabox())->log($record_object, $event_name, $o, $comment);
|
||||||
|
|
||||||
if ($o != "caption") {
|
if ($o != "caption") {
|
||||||
$log["rid"] = $record_object->get_record_id();
|
$log["rid"] = $record_object->getRecordId();
|
||||||
$log["subdef"] = $o;
|
$log["subdef"] = $o;
|
||||||
$log["poids"] = $obj["size"];
|
$log["poids"] = $obj["size"];
|
||||||
$log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML);
|
$log["shortXml"] = $app['serializer.caption']->serialize($record_object->get_caption(), CaptionSerializer::SERIALIZE_XML);
|
||||||
$tmplog[$record_object->get_base_id()][] = $log;
|
$tmplog[$record_object->getBaseId()][] = $log;
|
||||||
if (!$anonymous && $o == 'document' && null !== $app->getAuthenticatedUser()) {
|
if (!$anonymous && $o == 'document' && null !== $app->getAuthenticatedUser()) {
|
||||||
$app->getAclForUser($app->getAuthenticatedUser())->remove_remaining($record_object->get_base_id());
|
$app->getAclForUser($app->getAuthenticatedUser())->remove_remaining($record_object->getBaseId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -794,9 +781,9 @@ class set_export extends set_abstract
|
|||||||
foreach ($list_base as $base_id) {
|
foreach ($list_base as $base_id) {
|
||||||
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
if ($app->getAclForUser($app->getAuthenticatedUser())->is_restricted_download($base_id)) {
|
||||||
$params = [
|
$params = [
|
||||||
':remain_dl' => $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id)
|
':remain_dl' => $app->getAclForUser($app->getAuthenticatedUser())->remaining_download($base_id),
|
||||||
, ':base_id' => $base_id
|
':base_id' => $base_id,
|
||||||
, ':usr_id' => $app->getAclForUser($app->getAuthenticatedUser())->getId()
|
':usr_id' => $app->getAuthenticatedUser()->getId(),
|
||||||
];
|
];
|
||||||
|
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
@@ -805,7 +792,5 @@ class set_export extends set_abstract
|
|||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -14,21 +14,17 @@ use Alchemy\Phrasea\Model\Entities\Basket;
|
|||||||
|
|
||||||
class set_selection extends set_abstract
|
class set_selection extends set_abstract
|
||||||
{
|
{
|
||||||
protected $app;
|
|
||||||
/**
|
/**
|
||||||
*
|
* @var Application
|
||||||
* @return set_selection
|
|
||||||
*/
|
*/
|
||||||
|
protected $app;
|
||||||
|
|
||||||
public function __construct(Application $app)
|
public function __construct(Application $app)
|
||||||
{
|
{
|
||||||
$this->app = $app;
|
$this->app = $app;
|
||||||
$this->elements = [];
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param Basket $Basket
|
* @param Basket $Basket
|
||||||
* @return set_selection
|
* @return set_selection
|
||||||
*/
|
*/
|
||||||
@@ -42,20 +38,19 @@ class set_selection extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param array $rights
|
* @param array $rights
|
||||||
* @param array $sbas_rights
|
* @param array $sbas_rights
|
||||||
*
|
*
|
||||||
* @return set_selection
|
* @return set_selection
|
||||||
*/
|
*/
|
||||||
public function grep_authorized(Array $rights = [], Array $sbas_rights = [])
|
public function grep_authorized(array $rights = [], array $sbas_rights = [])
|
||||||
{
|
{
|
||||||
$to_remove = [];
|
$to_remove = [];
|
||||||
|
|
||||||
foreach ($this->elements as $id => $record) {
|
foreach ($this->get_elements() as $id => $record) {
|
||||||
$base_id = $record->get_base_id();
|
$base_id = $record->getBaseId();
|
||||||
$sbas_id = $record->get_sbas_id();
|
$sbas_id = $record->getDataboxId();
|
||||||
$record_id = $record->get_record_id();
|
$record_id = $record->getRecordId();
|
||||||
if (! $rights) {
|
if (! $rights) {
|
||||||
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) {
|
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($record)) {
|
||||||
continue;
|
continue;
|
||||||
@@ -84,7 +79,7 @@ class set_selection extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$connsbas = $record->get_databox()->get_connection();
|
$connsbas = $record->getDatabox()->get_connection();
|
||||||
|
|
||||||
$sql = 'SELECT record_id
|
$sql = 'SELECT record_id
|
||||||
FROM record
|
FROM record
|
||||||
@@ -105,31 +100,30 @@ class set_selection extends set_abstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach ($to_remove as $id) {
|
foreach ($to_remove as $id) {
|
||||||
unset($this->elements[$id]);
|
$this->offsetUnset($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @param array $lst
|
* @param array $lst
|
||||||
* @param Boolean $flatten_groupings
|
* @param Boolean $flatten_groupings
|
||||||
*
|
*
|
||||||
* @return set_selection
|
* @return set_selection
|
||||||
*/
|
*/
|
||||||
public function load_list(Array $lst, $flatten_groupings = false)
|
public function load_list(array $lst, $flatten_groupings = false)
|
||||||
{
|
{
|
||||||
foreach ($lst as $basrec) {
|
foreach ($lst as $basrec) {
|
||||||
$basrec = explode('_', $basrec);
|
$basrec = explode('_', $basrec);
|
||||||
if (count($basrec) == 2) {
|
if (count($basrec) == 2) {
|
||||||
try {
|
try {
|
||||||
$record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], count($this->elements));
|
$record = new record_adapter($this->app, (int) $basrec[0], (int) $basrec[1], $this->get_count());
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($record->isStory() && $flatten_groupings === true) {
|
if ($record->isStory() && $flatten_groupings === true) {
|
||||||
foreach ($record->get_children() as $rec) {
|
foreach ($record->getChildren() as $rec) {
|
||||||
$this->add_element($rec);
|
$this->add_element($rec);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -142,14 +136,13 @@ class set_selection extends set_abstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* @return array<int>
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function get_distinct_sbas_ids()
|
public function get_distinct_sbas_ids()
|
||||||
{
|
{
|
||||||
$ret = [];
|
$ret = [];
|
||||||
foreach ($this->elements as $record) {
|
foreach ($this->get_elements() as $record) {
|
||||||
$sbas_id = phrasea::sbasFromBas($this->app, $record->get_base_id());
|
$sbas_id = $record->getDataboxId();
|
||||||
$ret[$sbas_id] = $sbas_id;
|
$ret[$sbas_id] = $sbas_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user