mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-10 19:43:16 +00:00
Refactor reports into silex controllers
Refactor reports into silex controllers
This commit is contained in:
@@ -45,6 +45,8 @@ rewrite ^/user/notifications/.*$ /index.php last;
|
|||||||
rewrite ^/download/.*$ /index.php last;
|
rewrite ^/download/.*$ /index.php last;
|
||||||
rewrite ^/session/.*$ /index.php last;
|
rewrite ^/session/.*$ /index.php last;
|
||||||
|
|
||||||
|
rewrite ^/report/.*$ /index.php last;
|
||||||
|
|
||||||
rewrite ^/client/.*$ /index.php last;
|
rewrite ^/client/.*$ /index.php last;
|
||||||
rewrite ^/client/baskets.*$ /index.php last;
|
rewrite ^/client/baskets.*$ /index.php last;
|
||||||
|
|
||||||
|
@@ -56,6 +56,7 @@ use Alchemy\Phrasea\Controller\Prod\TOU;
|
|||||||
use Alchemy\Phrasea\Controller\Prod\Upload;
|
use Alchemy\Phrasea\Controller\Prod\Upload;
|
||||||
use Alchemy\Phrasea\Controller\Prod\UsrLists;
|
use Alchemy\Phrasea\Controller\Prod\UsrLists;
|
||||||
use Alchemy\Phrasea\Controller\Prod\WorkZone;
|
use Alchemy\Phrasea\Controller\Prod\WorkZone;
|
||||||
|
use Alchemy\Phrasea\Controller\Report\Root as ReportRoot;
|
||||||
use Alchemy\Phrasea\Controller\Root\Account;
|
use Alchemy\Phrasea\Controller\Root\Account;
|
||||||
use Alchemy\Phrasea\Controller\Root\Developers;
|
use Alchemy\Phrasea\Controller\Root\Developers;
|
||||||
use Alchemy\Phrasea\Controller\Root\Login;
|
use Alchemy\Phrasea\Controller\Root\Login;
|
||||||
@@ -649,6 +650,8 @@ class Application extends SilexApplication
|
|||||||
|
|
||||||
$this->mount('/download/', new DoDownload());
|
$this->mount('/download/', new DoDownload());
|
||||||
$this->mount('/session/', new Session());
|
$this->mount('/session/', new Session());
|
||||||
|
|
||||||
|
$this->mount('/report/', new ReportRoot());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function reinitUser()
|
private function reinitUser()
|
||||||
|
1575
lib/Alchemy/Phrasea/Controller/Report/Root.php
Normal file
1575
lib/Alchemy/Phrasea/Controller/Report/Root.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -415,13 +415,6 @@ class module_report_nav extends module_report
|
|||||||
$filter_id_apbox = $filter_id_datbox = array();
|
$filter_id_apbox = $filter_id_datbox = array();
|
||||||
$conn = $this->app['phraseanet.appbox']->get_connection();
|
$conn = $this->app['phraseanet.appbox']->get_connection();
|
||||||
|
|
||||||
$datefilter = array();
|
|
||||||
|
|
||||||
if ($this->dmin && $this->dmax) {
|
|
||||||
$params = array(':dmin' => $this->dmin, ':dmax' => $this->dmax);
|
|
||||||
$datefilter = "date > :dmin AND date < :dmax";
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->title = sprintf(_('report:: Information sur les utilisateurs correspondant a %s'), $val);
|
$this->title = sprintf(_('report:: Information sur les utilisateurs correspondant a %s'), $val);
|
||||||
|
|
||||||
if ($on) {
|
if ($on) {
|
||||||
@@ -446,7 +439,7 @@ class module_report_nav extends module_report
|
|||||||
usr_mail as mail,
|
usr_mail as mail,
|
||||||
adresse, tel
|
adresse, tel
|
||||||
FROM usr
|
FROM usr
|
||||||
WHERE $on = :value AND (" . $filter_id_apbox . ")";
|
WHERE $on = :value " . (('' !== $filter_id_apbox) ? "AND (" . $filter_id_apbox . ")" : '');
|
||||||
} else {
|
} else {
|
||||||
$sql = '
|
$sql = '
|
||||||
SELECT
|
SELECT
|
||||||
@@ -548,19 +541,19 @@ class module_report_nav extends module_report
|
|||||||
_('report:: Information sur le navigateur %s'), $navigator);
|
_('report:: Information sur le navigateur %s'), $navigator);
|
||||||
$sqlBuilder = new module_report_sql($this->app, $this);
|
$sqlBuilder = new module_report_sql($this->app, $this);
|
||||||
$filter = $sqlBuilder->getFilters();
|
$filter = $sqlBuilder->getFilters();
|
||||||
$params = array(':browser' => $navigator);
|
|
||||||
$report_filter = $filter->getReportFilter();
|
$report_filter = $filter->getReportFilter();
|
||||||
|
$params = array_merge($report_filter['params'], array(':browser' => $navigator));
|
||||||
|
|
||||||
$sql = "
|
$sql = "
|
||||||
SELECT DISTINCT(version), COUNT(version) as nb
|
SELECT DISTINCT(tt.version), COUNT(tt.version) as nb
|
||||||
FROM (
|
FROM (
|
||||||
SELECT DISTINCT (log.id)
|
SELECT DISTINCT (log.id), version
|
||||||
FROM log FORCE INDEX (date_site, nav, version)
|
FROM log FORCE INDEX (date_site, nav, version)
|
||||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||||
WHERE ". $report_filter['sql'] . "
|
|
||||||
WHERE nav = :browser
|
WHERE nav = :browser
|
||||||
|
AND ". $report_filter['sql'] . "
|
||||||
) AS tt
|
) AS tt
|
||||||
GROUP BY tt.version
|
GROUP BY version
|
||||||
ORDER BY nb DESC";
|
ORDER BY nb DESC";
|
||||||
|
|
||||||
$stmt = $conn->prepare($sql);
|
$stmt = $conn->prepare($sql);
|
||||||
|
@@ -38,6 +38,8 @@ class module_report_sqlaction extends module_report_sql implements module_report
|
|||||||
|
|
||||||
public function buildSql()
|
public function buildSql()
|
||||||
{
|
{
|
||||||
|
$customFieldMap = array();
|
||||||
|
|
||||||
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
|
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
|
||||||
$this->params = array_merge(array(':action' => $this->action), $filter['params']);
|
$this->params = array_merge(array(':action' => $this->action), $filter['params']);
|
||||||
|
|
||||||
@@ -53,12 +55,22 @@ class module_report_sqlaction extends module_report_sql implements module_report
|
|||||||
WHERE (" . $filter['sql'] . ") AND (d.action = :action)
|
WHERE (" . $filter['sql'] . ") AND (d.action = :action)
|
||||||
) AS tt";
|
) AS tt";
|
||||||
|
|
||||||
|
$customFieldMap = array(
|
||||||
|
'log.usrid' => 'tt.usrid',
|
||||||
|
'log.user' => 'tt.user',
|
||||||
|
'd.final' => 'getter',
|
||||||
|
'd.record_id' => 'tt.record_id',
|
||||||
|
'd.date' => 'tt.date',
|
||||||
|
'record.mime' => 'tt.mime',
|
||||||
|
'file' => 'tt.file',
|
||||||
|
);
|
||||||
|
|
||||||
$stmt = $this->getConnBas()->prepare($this->sql);
|
$stmt = $this->getConnBas()->prepare($this->sql);
|
||||||
$stmt->execute($this->params);
|
$stmt->execute($this->params);
|
||||||
$this->total = $stmt->rowCount();
|
$this->total = $stmt->rowCount();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
$this->sql .= $this->filter->getOrderFilter($customFieldMap) ? : '';
|
||||||
$this->sql .= $this->filter->getLimitFilter() ? : '';
|
$this->sql .= $this->filter->getLimitFilter() ? : '';
|
||||||
} else {
|
} else {
|
||||||
$this->sql = "
|
$this->sql = "
|
||||||
|
@@ -25,6 +25,8 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
|||||||
|
|
||||||
public function buildSql()
|
public function buildSql()
|
||||||
{
|
{
|
||||||
|
$customFieldMap = array();
|
||||||
|
|
||||||
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
|
$filter = $this->filter->getReportFilter() ? : array('params' => array(), 'sql' => false);
|
||||||
$this->params = array_merge(array(), $filter['params']);
|
$this->params = array_merge(array(), $filter['params']);
|
||||||
|
|
||||||
@@ -54,6 +56,16 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
|||||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.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 record ON (log_docs.record_id = record.record_id)
|
||||||
INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)';
|
INNER JOIN subdef ON (log_docs.record_id = subdef.record_id)';
|
||||||
|
|
||||||
|
$customFieldMap = array(
|
||||||
|
$field => $name,
|
||||||
|
'log_docs.comment' => 'tt.comment',
|
||||||
|
'subdef.size' => 'tt.size',
|
||||||
|
'subdef.file' => 'tt.file',
|
||||||
|
'subdef.mime' => 'tt.mime',
|
||||||
|
'log_docs.final' => 'tt.final',
|
||||||
|
);
|
||||||
|
|
||||||
} elseif ($this->on == 'DOC') {
|
} elseif ($this->on == 'DOC') {
|
||||||
$this->sql = '
|
$this->sql = '
|
||||||
SELECT ' . $name . ', SUM(1) AS telechargement
|
SELECT ' . $name . ', SUM(1) AS telechargement
|
||||||
@@ -88,7 +100,12 @@ class module_report_sqldownload extends module_report_sql implements module_repo
|
|||||||
$this->total = $stmt->rowCount();
|
$this->total = $stmt->rowCount();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
if (count($customFieldMap) > 0) {
|
||||||
|
$this->sql .= $this->filter->getOrderFilter($customFieldMap) ? : '';
|
||||||
|
} else {
|
||||||
|
$this->sql .= $this->filter->getOrderFilter() ? : '';
|
||||||
|
}
|
||||||
|
|
||||||
$this->sql .= $this->filter->getLimitFilter() ? : '';
|
$this->sql .= $this->filter->getLimitFilter() ? : '';
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -17,6 +17,7 @@ class module_report_sqlfilter
|
|||||||
private $filter;
|
private $filter;
|
||||||
private $cor_query = array();
|
private $cor_query = array();
|
||||||
private $app;
|
private $app;
|
||||||
|
private $report;
|
||||||
|
|
||||||
public function __construct(Application $app, module_report $report)
|
public function __construct(Application $app, module_report $report)
|
||||||
{
|
{
|
||||||
@@ -27,6 +28,8 @@ class module_report_sqlfilter
|
|||||||
$this->cor_query = $report->getTransQueryString();
|
$this->cor_query = $report->getTransQueryString();
|
||||||
|
|
||||||
$this->buildFilter($report);
|
$this->buildFilter($report);
|
||||||
|
|
||||||
|
$this->report = $report;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function constructDateFilter($dmin, $dmax)
|
public static function constructDateFilter($dmin, $dmax)
|
||||||
@@ -123,9 +126,13 @@ class module_report_sqlfilter
|
|||||||
return $this->filter['limit'];
|
return $this->filter['limit'];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOrderFilter()
|
public function getOrderFilter($customFieldMap = null)
|
||||||
{
|
{
|
||||||
return $this->filter['order'];
|
if (null === $customFieldMap) {
|
||||||
|
return $this->filter['order'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->overrideOrderFilter($customFieldMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function dateFilter(module_report $report)
|
private function dateFilter(module_report $report)
|
||||||
@@ -259,4 +266,19 @@ class module_report_sqlfilter
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function overrideOrderFilter($customFieldMap)
|
||||||
|
{
|
||||||
|
if (sizeof($this->report->getOrder()) > 0) {
|
||||||
|
if (!isset($customFieldMap[$this->cor_query[$this->report->getOrder('champ')]])) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return " ORDER BY "
|
||||||
|
. $customFieldMap[$this->cor_query[$this->report->getOrder('champ')]]
|
||||||
|
. ' ' . $this->report->getOrder('order');
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -39,10 +39,10 @@
|
|||||||
data : ({
|
data : ({
|
||||||
tbl : 'what',
|
tbl : 'what',
|
||||||
rid : riid,
|
rid : riid,
|
||||||
sbasid : '{{ param.sbasid }}',
|
sbasid : '{{ app['request'].get('sbasid') }}',
|
||||||
collection : '{{ param.collection }}',
|
collection : '{{ app['request'].get('collection') }}',
|
||||||
dmin : '{{ param.dmin }}',
|
dmin : '{{ app['request'].get('dmin') }}',
|
||||||
dmax : '{{ param.dmax }}',
|
dmax : '{{ app['request'].get('dmax') }}',
|
||||||
from : 'TOOL'
|
from : 'TOOL'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@@ -3,12 +3,12 @@
|
|||||||
<div class="horizontal-scroller">
|
<div class="horizontal-scroller">
|
||||||
<ul class="tabb">
|
<ul class="tabb">
|
||||||
{% for key in selection|keys %}
|
{% for key in selection|keys %}
|
||||||
<li class ="number_{{ key }}"><a href="#tab-{{ key }}-{{ param.tbl }}">{{ key|sbas_names(app)}}</a></li>
|
<li class ="number_{{ key }}"><a href="#tab-{{ key }}-{{ app['request'].get('tbl') }}">{{ key|sbas_names(app)}}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{% for key, value in selection %}
|
{% for key, value in selection %}
|
||||||
<div id="tab-{{ key }}-{{ param.tbl }}">
|
<div id="tab-{{ key }}-{{ app['request'].get('tbl') }}">
|
||||||
<div class="load">
|
<div class="load">
|
||||||
{% block ajax_data_content %}{% endblock %}
|
{% block ajax_data_content %}{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
@@ -28,14 +28,14 @@
|
|||||||
<input type="button" name="go" value ="ok" class="submiter" />
|
<input type="button" name="go" value ="ok" class="submiter" />
|
||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<input type="hidden" name="tbl" value ="{{ param['tbl'] }}"/>
|
<input type="hidden" name="tbl" value ="{{ app['request'].get('tbl') }}"/>
|
||||||
<input type="hidden" name="dmin" value ="{{ param['dmin'] }}"/>
|
<input type="hidden" name="dmin" value ="{{ app['request'].get('dmin') }}"/>
|
||||||
<input type="hidden" name="dmax" value ="{{ param['dmax'] }}"/>
|
<input type="hidden" name="dmax" value ="{{ app['request'].get('dmax') }}"/>
|
||||||
<input type="hidden" name="sbasid" value ="{{ key }}"/>
|
<input type="hidden" name="sbasid" value ="{{ key }}"/>
|
||||||
<input type="hidden" name="collection" value ="{{ value.liste }}"/>
|
<input type="hidden" name="collection" value ="{{ value.liste }}"/>
|
||||||
<input type="hidden" name="user" value =""/>
|
<input type="hidden" name="user" value =""/>
|
||||||
<input type="hidden" name="word" value ="{{ param['tbl'] == 'DOC' ? param['preciseWord'] : '' }}"/>
|
<input type="hidden" name="word" value ="{{ app['request'].get('tbl') == 'DOC' ? app['request'].get('preciseWord') : '' }}"/>
|
||||||
<input type="hidden" name="precise" value ="{{ param['tbl'] == 'DOC' ? param['precise'] : '' }}"/>
|
<input type="hidden" name="precise" value ="{{ app['request'].get('tbl') == 'DOC' ? app['request'].get('precise') : '' }}"/>
|
||||||
<input type="hidden" name="order" value =""/>
|
<input type="hidden" name="order" value =""/>
|
||||||
<input type="hidden" name="champ" value =""/>
|
<input type="hidden" name="champ" value =""/>
|
||||||
<input type="hidden" name="rid" value =""/>
|
<input type="hidden" name="rid" value =""/>
|
||||||
@@ -51,11 +51,11 @@
|
|||||||
<input type="hidden" name="fonction" value =""/>
|
<input type="hidden" name="fonction" value =""/>
|
||||||
<input type="hidden" name="activite" value =""/>
|
<input type="hidden" name="activite" value =""/>
|
||||||
{% if anonymous %}
|
{% if anonymous %}
|
||||||
<input type="hidden" name="on" value ="{{ param['on'] }}"/>
|
<input type="hidden" name="on" value ="{{ app['request'].get('on') }}"/>
|
||||||
{% else %}
|
{% else %}
|
||||||
<input type="hidden" name="on" value =""/>
|
<input type="hidden" name="on" value =""/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<input type="hidden" name="docwhat" value ="{{ param['tbl'] == 'WDOC' ? param['docwhat'] : '' }}"/>
|
<input type="hidden" name="docwhat" value ="{{ app['request'].get('tbl') == 'WDOC' ? app['request'].get('docwhat') : '' }}"/>
|
||||||
<input type="hidden" name="from" value =""/>
|
<input type="hidden" name="from" value =""/>
|
||||||
<input type="hidden" name="printcsv" value ="off"/>
|
<input type="hidden" name="printcsv" value ="off"/>
|
||||||
</form>
|
</form>
|
||||||
|
1309
tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php
Normal file
1309
tests/Alchemy/Tests/Phrasea/Controller/Report/RootTest.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -46,6 +46,8 @@
|
|||||||
RewriteRule ^download/.*$ /index.php [L]
|
RewriteRule ^download/.*$ /index.php [L]
|
||||||
RewriteRule ^session/.*$ /index.php [L]
|
RewriteRule ^session/.*$ /index.php [L]
|
||||||
|
|
||||||
|
RewriteRule ^report/.*$ /index.php [L]
|
||||||
|
|
||||||
RewriteRule ^client/.*$ /index.php [L]
|
RewriteRule ^client/.*$ /index.php [L]
|
||||||
RewriteRule ^client/baskets.*$ /index.php [L]
|
RewriteRule ^client/baskets.*$ /index.php [L]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user