Remove references to collection filter

This commit is contained in:
Nicolas Le Goff
2014-11-05 12:57:48 +01:00
parent a353dc4de6
commit d7b8a67ac3
9 changed files with 5 additions and 92 deletions

View File

@@ -352,7 +352,7 @@ class module_report_activity extends module_report
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, var_export($this->result, true)), FILE_APPEND);
foreach($this->result as $k=>$row) {
$_row = array();
foreach($tab as $k2=>$f) {
foreach((array) $tab as $k2=>$f) {
$_row[$k2] = array_key_exists($k2, $row) ? $row[$k2] : '';
}
$this->result[$k] = $_row;
@@ -571,7 +571,7 @@ class module_report_activity extends module_report
foreach($this->result as $k=>$row) {
$_row = array();
foreach($tab as $k2=>$f) {
foreach((array) $tab as $k2=>$f) {
$_row[$k2] = array_key_exists($k2, $row) ? $row[$k2] : '';
}
$_row['usrid'] = array_key_exists('usrid', $row) ? $row['usrid'] : '';

View File

@@ -139,17 +139,14 @@ class module_report_connexion extends module_report
$conn = connection::getPDOConnection($app, $sbas_id);
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge(array(
':site_id' => $app['phraseanet.configuration']['main']['key']
),
$datefilter['params'],
$collfilter['params']
$datefilter['params']
);
$finalfilter = $datefilter['sql'] . ' AND ';
$finalfilter .= $collfilter['sql'] . ' AND ';
$finalfilter .= 'log_date.site = :site_id';
/*
$sql = "SELECT COUNT(DISTINCT(log_date.id)) as nb
@@ -159,7 +156,6 @@ class module_report_connexion extends module_report
*/
$sql = "SELECT COUNT(DISTINCT(log_date.id)) as nb\n"
. " FROM log as log_date FORCE INDEX (date_site)\n"
. " INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)\n"
. " WHERE " . $finalfilter . "\n";
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $sql), FILE_APPEND);

View File

@@ -21,7 +21,6 @@ class module_report_download extends module_report
'activite' => 'log.activite',
'fonction' => 'log.fonction',
'usrid' => 'log.usrid',
'coll_id' => 'log_colls.coll_id',
'ddate' => "log_docs.date",
'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id',
@@ -186,12 +185,9 @@ ini_set('display_errors', true);
$params = array(':site_id' => $app['phraseanet.configuration']['main']['key']);
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
// $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
// $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$params = array_merge($params, $datefilter['params']);
$finalfilter = $datefilter['sql'] . ' AND ';
// $finalfilter .= $collfilter['sql'] . ' AND ';
$finalfilter .= 'log.site = :site_id';
/*
$sql = '
@@ -213,7 +209,6 @@ ini_set('display_errors', true);
. " FROM (\n"
. " SELECT DISTINCT(log.id)\n"
. " FROM log FORCE INDEX (date_site)\n"
. " INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)\n"
. " WHERE " . $finalfilter . "\n"
. " AND ( log_date.action = 'download' OR log_date.action = 'mail' )\n"
. " ) AS tt";
@@ -235,8 +230,7 @@ ini_set('display_errors', true);
$params = array(':site_id' => $app['phraseanet.configuration']['main']['key']);
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
$params = array_merge($params, $datefilter['params']);
$finalfilter = "";
$array = array(
@@ -245,7 +239,6 @@ ini_set('display_errors', true);
);
$finalfilter .= $datefilter['sql'] . ' AND ';
$finalfilter .= $collfilter['sql'] . ' AND ';
$finalfilter .= 'log.site = :site_id';
/*
$sql = '

View File

@@ -548,7 +548,6 @@ class module_report_nav extends module_report
FROM (
SELECT DISTINCT (log.id), version
FROM log FORCE INDEX (date_site, nav, version)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE nav = :browser
AND ". $report_filter['sql'] . "
) AS tt

View File

@@ -50,7 +50,6 @@ class module_report_sqlaction extends module_report_sql implements module_report
SELECT DISTINCT(log.id), log.usrid, log.user, d.final, d.comment, d.record_id, d.date, record.mime, record.originalname as file
FROM (log_docs AS d)
INNER JOIN log FORCE INDEX (date_site) ON (log.id = d.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (record.record_id = d.record_id)
WHERE (" . $filter['sql'] . ") AND (d.action = :action)
) AS tt";
@@ -82,7 +81,6 @@ class module_report_sqlaction extends module_report_sql implements module_report
SELECT DISTINCT(log.id), TRIM(" . $this->getTransQuery($this->groupby) . ") AS " . $this->groupby . " , log.usrid , d.final, d.record_id, d.date
FROM (log_docs as d)
INNER JOIN log FORCE INDEX (date_site) ON (log.id = d.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (record.record_id = d.record_id)
WHERE (" . $filter['sql'] . ") AND (d.action = :action)
) AS tt
@@ -113,7 +111,6 @@ class module_report_sqlaction extends module_report_sql implements module_report
SELECT DISTINCT(log.id), " . $this->getTransQuery($field) . " AS val
FROM (log_docs as d)
INNER JOIN log FORCE INDEX (date_site) ON (log.id = d.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (record.record_id = d.record_id)
LEFT JOIN subdef as s ON (s.record_id=d.record_id AND s.name='document')
WHERE (" . $filter['sql'] . ")

View File

@@ -60,7 +60,6 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
FROM (
SELECT DISTINCT(log.id), TRIM(" . $this->getTransQuery($this->groupby) . ") AS " . $this->groupby . "
FROM log FORCE INDEX (date_site)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE (" . $filter['sql'] .")
) AS tt
GROUP BY " . $this->groupby. "
@@ -87,7 +86,6 @@ class module_report_sqlconnexion extends module_report_sql implements module_rep
FROM (
SELECT DISTINCT(log.id), ' . $this->getTransQuery($field) . ' AS val
FROM log FORCE INDEX (date_site)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE (' . $filter['sql'] . ')
) AS tt ORDER BY val ASC';

View File

@@ -92,7 +92,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
SELECT DISTINCT(log.id), TRIM(' . $field . ') AS ' . $name . '
FROM log FORCE INDEX (date_site)
INNER JOIN log_docs ON (log.id = log_docs.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (log_docs.record_id = record.record_id)
INNER JOIN subdef ON ( log_docs.record_id = subdef.record_id)';
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
@@ -103,7 +102,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
SELECT DISTINCT(log.id), TRIM( ' . $this->getTransQuery($this->groupby) . ') AS ' . $name . '
FROM log FORCE INDEX (date_site)
INNER JOIN log_docs ON (log.id = log_docs.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (log_docs.record_id = record.record_id)
INNER JOIN subdef ON (record.record_id = subdef.record_id)';
// no_file_put_contents("/tmp/report.txt", sprintf("%s (%s)\n%s\n\n", __FILE__, __LINE__, $this->sql), FILE_APPEND);
@@ -149,7 +147,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
SELECT DISTINCT(log.id), ' . $this->getTransQuery($field) . ' AS val
FROM log FORCE INDEX (date_site)
INNER JOIN log_docs ON (log.id = log_docs.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
INNER JOIN record ON (log_docs.record_id = record.record_id)
INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)
WHERE (' . $filter['sql'] . ')

View File

@@ -40,25 +40,6 @@ class module_report_sqlfilter
);
}
public static function constructCollectionFilter(Application $app, $list_coll_id)
{
$ret = array('sql' => '', 'params' => array());
$coll_filter = array();
foreach (array_filter(explode(',', $list_coll_id)) as $val) {
$val = \phrasea::collFromBas($app, $val);
if ($val) {
$coll_filter[] = 'log_colls.coll_id = ' . $val;
}
}
$collections = array_unique($coll_filter);
if (count($collections) > 0) {
$ret['sql'] = ' (' . implode(' OR ', $collections) . ') ';
}
return $ret;
}
public function getCorFilter()
{
return $this->cor_query;
@@ -67,11 +48,8 @@ class module_report_sqlfilter
public function getReportFilter()
{
$sql = '';
/*
$params = array(':log_site' => $this->app['phraseanet.configuration']['main']['key']);
*/
$params = array();
$params = array(':log_site' => $this->app['phraseanet.configuration']['main']['key']);
if ($this->filter['date'] && $this->filter['date']['sql'] !== '') {
$sql .= $this->filter['date']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['date']['params']);
@@ -80,15 +58,9 @@ class module_report_sqlfilter
$sql .= $this->filter['user']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['user']['params']);
}
if ($this->filter['collection'] && $this->filter['collection']['sql'] !== '') {
$sql .= $this->filter['collection']['sql'] . ' AND ';
$params = array_merge($params, $this->filter['collection']['params']);
}
$sql .= ' log.site = :log_site';
// $sql .= ' log.site=' . $this->conn->quote($this->app['phraseanet.configuration']['main']['key']);
return array('sql' => $sql, 'params' => $params);
}
@@ -99,8 +71,6 @@ class module_report_sqlfilter
$sql = 'log.site = :log_site_gv_filter';
$params[':log_site_gv_filter'] = $this->app['phraseanet.configuration']['main']['key'];
// $sql = "log.site=" . $this->conn->quote($this->app['phraseanet.configuration']['main']['key']);
return array('sql' => $sql, 'params' => $params);
}
@@ -120,11 +90,6 @@ class module_report_sqlfilter
return $this->filter['user'];
}
public function getCollectionFilter()
{
return $this->filter['collection'];
}
public function getRecordFilter()
{
return $this->filter['record'];
@@ -212,35 +177,6 @@ class module_report_sqlfilter
return;
}
private function collectionFilter(module_report $report)
{
$this->filter['collection'] = false;
$coll_filter = array();
if ($report->getUserId() == '') {
return;
}
$tab = array_filter(explode(",", $report->getListCollId()));
if (count($tab) > 0) {
foreach ($tab as $val) {
$val = \phrasea::collFromBas($this->app, $val);
if (!!$val) {
$coll_filter[] = 'log_colls.coll_id = ' . $val;
}
}
$collections = array_unique($coll_filter);
if (count($collections) > 0) {
$this->filter['collection'] = array('sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => array());
}
}
return;
}
private function recordFilter(module_report $report)
{
$this->filter['record'] = false;
@@ -295,7 +231,6 @@ class module_report_sqlfilter
$this->orderFilter($report);
$this->recordFilter($report);
$this->userFilter($report);
$this->collectionFilter($report);
return;
}

View File

@@ -49,7 +49,6 @@ class module_report_sqlquestion extends module_report_sql implements module_repo
SELECT DISTINCT(log.id), TRIM(" . $this->getTransQuery($this->groupby) . ") AS " . $this->groupby . "
FROM (`log_search`)
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE (" . $filter['sql'] .")
) AS tt
GROUP BY " . $this->groupby ."
@@ -77,7 +76,6 @@ class module_report_sqlquestion extends module_report_sql implements module_repo
SELECT DISTINCT(log.id), " . $this->getTransQuery($field) . " AS val
FROM (`log_search`)
INNER JOIN log FORCE INDEX (date_site) ON (log.id = log_search.log_id)
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
WHERE (" . $filter['sql'] . ")
) as tt
ORDER BY tt.val ASC";