Remove some deprecated methods calls

This commit is contained in:
Benoît Burnichon
2016-03-06 23:05:55 +01:00
parent ba4274eb28
commit 6cdc9d7a31
77 changed files with 322 additions and 307 deletions

View File

@@ -370,8 +370,19 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
* Return record collection
*
* @return \collection
* @deprecated use {@link self::getCollection} instead.
*/
public function get_collection()
{
return $this->getCollection();
}
/**
* Return collection to which the record belongs to.
*
* @return \collection
*/
public function getCollection()
{
return \collection::getByCollectionId($this->app, $this->getDatabox(), $this->collection_id);
}
@@ -460,7 +471,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
*/
public function move_to_collection(collection $collection, appbox $appbox)
{
if ($this->get_collection()->get_base_id() === $collection->get_base_id()) {
if ($this->getCollection()->get_base_id() === $collection->get_base_id()) {
return $this;
}
@@ -904,6 +915,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
/**
* @return string
* @deprecated use {@link self::getId} instead.
*/
public function get_serialize_key()
{
@@ -1694,7 +1706,7 @@ class record_adapter implements RecordInterface, cache_cacheableInterface
public function hasChild(\record_adapter $record)
{
return $this->get_children()->offsetExists($record->get_serialize_key());
return $this->get_children()->offsetExists($record->getId());
}
public function appendChild(\record_adapter $record)

View File

@@ -83,13 +83,13 @@ class record_exportElement extends record_adapter
$sd = $this->get_subdefs();
$sbas_id = phrasea::sbasFromBas($this->app, $this->get_base_id());
$sbas_id = phrasea::sbasFromBas($this->app, $this->getBaseId());
/** @var databox_subdef[] $subdefs */
$subdefs = [];
foreach ($this->app->findDataboxById($sbas_id)->get_subdef_structure() as $subdef_type => $subdefs_obj) {
if ($subdef_type == $this->get_type()) {
if ($subdef_type == $this->getType()) {
$subdefs = $subdefs_obj;
break;
}
@@ -101,10 +101,10 @@ class record_exportElement extends record_adapter
'thumbnail' => true
];
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->get_base_id(), 'candwnldhd')) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->getBaseId(), 'candwnldhd')) {
$go_dl['document'] = true;
}
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->get_base_id(), 'candwnldpreview')) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->getBaseId(), 'candwnldpreview')) {
$go_dl['preview'] = true;
}
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->has_hd_grant($this)) {
@@ -117,18 +117,18 @@ class record_exportElement extends record_adapter
$query = $this->app['phraseanet.user-query'];
$masters = $query->on_base_ids([$this->get_base_id()])
$masters = $query->on_base_ids([$this->getBaseId()])
->who_have_right(['order_master'])
->execute()->get_results();
$go_cmd = (count($masters) > 0 && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->get_base_id(), 'cancmd'));
$go_cmd = (count($masters) > 0 && $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->getBaseId(), 'cancmd'));
$orderable['document'] = false;
$downloadable['document'] = false;
if (isset($sd['document']) && is_file($sd['document']->getRealPath())) {
if ($go_dl['document'] === true) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->is_restricted_download($this->get_base_id())) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->is_restricted_download($this->getBaseId())) {
$this->remain_hd --;
if ($this->remain_hd >= 0) {
$localizedLabel = $this->app->trans('document original');
@@ -182,7 +182,7 @@ class record_exportElement extends record_adapter
if (isset($sd[$name]) && $sd[$name]->is_physically_present()) {
if ($class == 'document') {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->is_restricted_download($this->get_base_id())) {
if ($this->app->getAclForUser($this->app->getAuthenticatedUser())->is_restricted_download($this->getBaseId())) {
$this->remain_hd --;
if ($this->remain_hd >= 0)
$downloadable[$name] = [

View File

@@ -126,9 +126,9 @@ class record_preview extends record_adapter
} else {
$children = $this->container->get_children();
foreach ($children as $child) {
$sbas_id = $child->get_sbas_id();
$sbas_id = $child->getDataboxId();
$this->original_item = $child;
$record_id = $child->get_record_id();
$record_id = $child->getRecordId();
if ($child->getNumber() == $pos)
break;
}
@@ -152,8 +152,8 @@ class record_preview extends record_adapter
$i ++;
if ($first) {
$this->original_item = $element;
$sbas_id = $element->getRecord($this->app)->get_sbas_id();
$record_id = $element->getRecord($this->app)->get_record_id();
$sbas_id = $element->getRecord($this->app)->getDataboxId();
$record_id = $element->getRecord($this->app)->getRecordId();
$this->name = $Basket->getName();
$number = $element->getOrd();
}
@@ -161,8 +161,8 @@ class record_preview extends record_adapter
if ($element->getOrd() == $pos) {
$this->original_item = $element;
$sbas_id = $element->getRecord($this->app)->get_sbas_id();
$record_id = $element->getRecord($this->app)->get_record_id();
$sbas_id = $element->getRecord($this->app)->getDataboxId();
$record_id = $element->getRecord($this->app)->getRecordId();
$this->name = $Basket->getName();
$number = $element->getOrd();
}
@@ -272,7 +272,7 @@ class record_preview extends record_adapter
return $this->title;
}
$this->title = collection::getLogo($this->get_base_id(), $this->app) . ' ';
$this->title = collection::getLogo($this->getBaseId(), $this->app) . ' ';
switch ($this->env) {
@@ -323,16 +323,16 @@ class record_preview extends record_adapter
$tab = [];
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->get_base_id(), 'canreport');
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->getBaseId(), 'canreport');
$databox = $this->app->findDataboxById($this->get_sbas_id());
$databox = $this->app->findDataboxById($this->getDataboxId());
$connsbas = $databox->get_connection();
$sql = 'SELECT d . * , l.user, l.usrid as usr_id, l.site
FROM log_docs d, log l
WHERE d.log_id = l.id
AND d.record_id = :record_id ';
$params = [':record_id' => $this->get_record_id()];
$params = [':record_id' => $this->getRecordId()];
if (! $report) {
$sql .= ' AND ((l.usrid = :usr_id AND l.site= :site) OR action="add")';
@@ -374,7 +374,7 @@ class record_preview extends record_adapter
if ( ! in_array($row['final'], $tab[$hour][$site][$action][$row['usr_id']]['final'])) {
if ($action == 'collection') {
$tab[$hour][$site][$action][$row['usr_id']]['final'][] = phrasea::baseFromColl($this->get_sbas_id(), $row['final'], $this->app);
$tab[$hour][$site][$action][$row['usr_id']]['final'][] = phrasea::baseFromColl($this->getDataboxId(), $row['final'], $this->app);
} else {
$tab[$hour][$site][$action][$row['usr_id']]['final'][] = $row['final'];
}
@@ -400,7 +400,7 @@ class record_preview extends record_adapter
}
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base(
$this->get_base_id(), 'canreport');
$this->getBaseId(), 'canreport');
if ( ! $report && ! $this->app['conf']->get(['registry', 'webservices', 'google-charts-enabled'])) {
$this->view_popularity = false;
@@ -429,12 +429,12 @@ class record_preview extends record_adapter
AND site_id = :site
GROUP BY datee ORDER BY datee ASC';
$databox = $this->app->findDataboxById($this->get_sbas_id());
$databox = $this->app->findDataboxById($this->getDataboxId());
$connsbas = $databox->get_connection();
$stmt = $connsbas->prepare($sql);
$stmt->execute(
[
':record_id' => $this->get_record_id(),
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key'])
]
);
@@ -490,7 +490,7 @@ class record_preview extends record_adapter
}
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base(
$this->get_base_id(), 'canreport');
$this->getBaseId(), 'canreport');
if ( ! $report && ! $this->app['conf']->get(['registry', 'webservices', 'google-charts-enabled'])) {
$this->refferer_popularity = false;
@@ -498,7 +498,7 @@ class record_preview extends record_adapter
return $this->refferer_popularity;
}
$databox = $this->app->findDataboxById($this->get_sbas_id());
$databox = $this->app->findDataboxById($this->getDataboxId());
$connsbas = $databox->get_connection();
$sql = 'SELECT count( id ) AS views, referrer
@@ -508,7 +508,7 @@ class record_preview extends record_adapter
GROUP BY referrer ORDER BY referrer ASC';
$stmt = $connsbas->prepare($sql);
$stmt->execute([':record_id' => $this->get_record_id()]);
$stmt->execute([':record_id' => $this->getRecordId()]);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
@@ -562,7 +562,7 @@ class record_preview extends record_adapter
return $this->download_popularity;
}
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->get_base_id(), 'canreport');
$report = $this->app->getAclForUser($this->app->getAuthenticatedUser())->has_right_on_base($this->getBaseId(), 'canreport');
$ret = false;
if ( ! $report && ! $this->app['conf']->get(['registry', 'webservices', 'google-charts-enabled'])) {
@@ -592,12 +592,12 @@ class record_preview extends record_adapter
AND site= :site
GROUP BY datee ORDER BY datee ASC';
$databox = $this->app->findDataboxById($this->get_sbas_id());
$databox = $this->app->findDataboxById($this->getDataboxId());
$connsbas = $databox->get_connection();
$stmt = $connsbas->prepare($sql);
$stmt->execute(
[
':record_id' => $this->get_record_id(),
':record_id' => $this->getRecordId(),
':site' => $this->app['conf']->get(['main', 'key'])
]
);