Update report

This commit is contained in:
Romain Neutron
2012-09-21 14:53:51 +02:00
parent 06b4e6bc6f
commit 07a8748f8d
19 changed files with 233 additions and 201 deletions

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -227,6 +230,12 @@ class module_report
*/ */
protected $pretty_string = true; protected $pretty_string = true;
/**
*
* @var Application
*/
protected $app;
/** /**
* *
*/ */
@@ -242,18 +251,17 @@ class module_report
* @param $arg2 the maximal date of the report * @param $arg2 the maximal date of the report
* @param $sbas_id the id of the base where we want to connect * @param $sbas_id the id of the base where we want to connect
*/ */
public function __construct($d1, $d2, $sbas_id, $collist) public function __construct(Application $app, $d1, $d2, $sbas_id, $collist)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $this->app = $app;
$session = $appbox->get_session();
$this->dmin = $d1; $this->dmin = $d1;
$this->dmax = $d2; $this->dmax = $d2;
$this->sbas_id = $sbas_id; $this->sbas_id = $sbas_id;
$this->list_coll_id = $collist; $this->list_coll_id = $collist;
$this->user_id = $session->get_usr_id(); $this->user_id = $this->app['phraseanet.user']->get_id();
$this->periode = phraseadate::getPrettyString(new DateTime($d1)) $this->periode = $this->app['date-formatter']->getPrettyString(new DateTime($d1))
. ' - ' . phraseadate::getPrettyString(new DateTime($d2)); . ' - ' . $this->app['date-formatter']->getPrettyString(new DateTime($d2));
$this->dbname = phrasea::sbas_names($sbas_id); $this->dbname = phrasea::sbas_names($sbas_id, $app);
$this->cor = $this->setCor(); $this->cor = $this->setCor();
$this->jour = $this->setDay(); $this->jour = $this->setDay();
$this->month = $this->setMonth(); $this->month = $this->setMonth();
@@ -574,7 +582,7 @@ class module_report
return new module_report_sqlconnexion($this); return new module_report_sqlconnexion($this);
break; break;
case 'download' : case 'download' :
return new module_report_sqldownload($this); return new module_report_sqldownload($this->app, $this);
break; break;
case 'question' : case 'question' :
return new module_report_sqlquestion($this); return new module_report_sqlquestion($this);
@@ -622,7 +630,7 @@ class module_report
*/ */
protected function setReport() protected function setReport()
{ {
$registry = registry::get_instance(); $registry = $this->app['phraseanet.registry'];
$this->report['dbid'] = $this->sbas_id; $this->report['dbid'] = $this->sbas_id;
$this->report['periode'] = $this->periode; $this->report['periode'] = $this->periode;
$this->report['dbname'] = $this->dbname; $this->report['dbname'] = $this->dbname;
@@ -815,7 +823,7 @@ class module_report
return $this->report; return $this->report;
} }
$conn = connection::getPDOConnection($this->sbas_id); $conn = connection::getPDOConnection($this->app, $this->sbas_id);
$this->buildReq($groupby, $on); $this->buildReq($groupby, $on);
@@ -836,7 +844,7 @@ class module_report
//set display //set display
$this->setDisplay($tab, $groupby); $this->setDisplay($tab, $groupby);
//construct results //construct results
$this->buildResult($rs); $this->buildResult($this->app, $rs);
//calculate prev and next page //calculate prev and next page
$this->calculatePages($rs); $this->calculatePages($rs);
//do we display navigator ? //do we display navigator ?
@@ -850,11 +858,11 @@ class module_report
} }
} }
public static function getPreff($sbasid) public static function getPreff(Application $app, $sbasid)
{ {
$tab = array(); $tab = array();
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $app['phraseanet.appbox'];
$databox = $appbox->get_databox((int) $sbasid); $databox = $appbox->get_databox((int) $sbasid);
foreach ($databox->get_meta_structure() as $databox_field) { foreach ($databox->get_meta_structure() as $databox_field) {

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -45,9 +48,9 @@ class module_report_activity extends module_report
'size' => 'subdef.size' 'size' => 'subdef.size'
); );
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
} }
/** /**
@@ -97,7 +100,7 @@ class module_report_activity extends module_report
$this->result = array(); $this->result = array();
$this->title = _('report:: activite par heure'); $this->title = _('report:: activite par heure');
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -158,7 +161,7 @@ class module_report_activity extends module_report
{ {
$result = array(); $result = array();
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -218,7 +221,7 @@ class module_report_activity extends module_report
$this->report['value'] = array(); $this->report['value'] = array();
$this->report['value2'] = array(); $this->report['value2'] = array();
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -286,11 +289,11 @@ class module_report_activity extends module_report
public function getAllDownloadByUserBase($usr, $config = false) public function getAllDownloadByUserBase($usr, $config = false)
{ {
$result = array(); $result = array();
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $this->app['phraseanet.appbox'];
$databox = $appbox->get_databox($this->sbas_id); $databox = $appbox->get_databox($this->sbas_id);
$params = array(); $params = array();
@@ -328,7 +331,7 @@ class module_report_activity extends module_report
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$login = User_Adapter::getInstance($usr, appbox::get_instance(\bootstrap::getCore()))->get_display_name(); $login = User_Adapter::getInstance($usr, $this->app)->get_display_name();
$this->setChamp($rs); $this->setChamp($rs);
($config) ? $this->setConfigColumn($config) : ($config) ? $this->setConfigColumn($config) :
@@ -361,9 +364,9 @@ class module_report_activity extends module_report
{ {
$this->title = _('report:: telechargements par jour'); $this->title = _('report:: telechargements par jour');
$registry = registry::get_instance(); $registry = $this->app['phraseanet.registry'];
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -412,7 +415,7 @@ class module_report_activity extends module_report
$last_date = null; $last_date = null;
foreach ($rs as $row) { foreach ($rs as $row) {
$date = phraseadate::getPrettyString(new DateTime($row['ddate'])); $date = $this->app['date-formatter']->getPrettyString(new DateTime($row['ddate']));
if ($date != $last_date) { if ($date != $last_date) {
$i ++; $i ++;
$this->result[$i] = array( $this->result[$i] = array(
@@ -466,7 +469,7 @@ class module_report_activity extends module_report
$on = "user"; $on = "user";
} }
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -555,7 +558,7 @@ class module_report_activity extends module_report
{ {
empty($on) ? $on = "user" : ""; //by default always report on user empty($on) ? $on = "user" : ""; //by default always report on user
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
@@ -683,7 +686,7 @@ class module_report_activity extends module_report
public function getPush($tab = false) public function getPush($tab = false)
{ {
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$push = array(); $push = array();
@@ -719,15 +722,13 @@ class module_report_activity extends module_report
$this->setChamp($rs); $this->setChamp($rs);
$this->initDefaultConfigColumn($this->champ); $this->initDefaultConfigColumn($this->champ);
$appbox = appbox::get_instance(\bootstrap::getCore());
$i = 0; $i = 0;
foreach ($rs as $row) { foreach ($rs as $row) {
foreach ($this->champ as $key => $value) { foreach ($this->champ as $key => $value) {
$this->result[$i][$value] = $row[$value]; $this->result[$i][$value] = $row[$value];
if ($value == "getter") { if ($value == "getter") {
try { try {
$user = User_Adapter::getInstance($row[$value], $appbox); $user = User_Adapter::getInstance($row[$value], $this->app);
$this->result[$i][$value] = $user->get_display_name(); $this->result[$i][$value] = $user->get_display_name();
} catch (Exception $e) { } catch (Exception $e) {
@@ -736,7 +737,7 @@ class module_report_activity extends module_report
$this->result[$i][$value] = p4string::format_octets($row[$value]); $this->result[$i][$value] = p4string::format_octets($row[$value]);
} elseif ($value == "date") { } elseif ($value == "date") {
$date_obj = new DateTime($row[$value]); $date_obj = new DateTime($row[$value]);
$this->result[$i][$value] = phraseadate::getPrettyString($date_obj); $this->result[$i][$value] = $this->app['date-formatter']->getPrettyString($date_obj);
} }
} }
$i ++; $i ++;
@@ -753,10 +754,10 @@ class module_report_activity extends module_report
return($this->report); return($this->report);
} }
public static function topTenUser($dmin, $dmax, $sbas_id, $list_coll_id) public static function topTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$result = array(); $result = array();
$result['top_ten_doc'] = array(); $result['top_ten_doc'] = array();
$result['top_ten_prev'] = array(); $result['top_ten_prev'] = array();
@@ -768,7 +769,7 @@ class module_report_activity extends module_report
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$params = array_merge($params, $datefilter['params']); $params = array_merge($params, $datefilter['params']);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $collfilter['params']); $params = array_merge($params, $collfilter['params']);
$sql = " $sql = "
@@ -834,15 +835,15 @@ class module_report_activity extends module_report
return $result; return $result;
} }
public static function activity($dmin, $dmax, $sbas_id, $list_coll_id) public static function activity(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$res = array(); $res = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -874,16 +875,16 @@ class module_report_activity extends module_report
return $res; return $res;
} }
public static function activityDay($dmin, $dmax, $sbas_id, $list_coll_id) public static function activityDay(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$result = array(); $result = array();
$res = array(); $res = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -916,15 +917,15 @@ class module_report_activity extends module_report
return $res; return $res;
} }
public static function activityQuestion($dmin, $dmax, $sbas_id, $list_coll_id) public static function activityQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$result = array(); $result = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -954,15 +955,15 @@ class module_report_activity extends module_report
return $result; return $result;
} }
public static function activiteTopQuestion($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteTopQuestion(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$result = array(); $result = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -999,12 +1000,12 @@ class module_report_activity extends module_report
return $result; return $result;
} }
public static function activiteTopTenSiteView($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteTopTenSiteView(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(); $params = array();
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -1039,12 +1040,12 @@ class module_report_activity extends module_report
return $result; return $result;
} }
public static function activiteAddedDocument($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteAddedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(); $params = array();
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -1073,12 +1074,12 @@ class module_report_activity extends module_report
return $result; return $result;
} }
public static function activiteEditedDocument($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteEditedDocument(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(); $params = array();
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
@@ -1101,19 +1102,19 @@ class module_report_activity extends module_report
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) { foreach ($rs as $row) {
$date = phraseadate::getPrettyString(new DateTime($row['ddate'])); $date = $this->app['date-formatter']->getPrettyString(new DateTime($row['ddate']));
$result[$date] = $row['activity']; $result[$date] = $row['activity'];
} }
return $result; return $result;
} }
public static function activiteAddedTopTenUser($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteAddedTopTenUser(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(); $params = array();
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -43,9 +46,9 @@ class module_report_add extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: document ajoute'); $this->title = _('report:: document ajoute');
} }
@@ -76,20 +79,18 @@ class module_report_add extends module_report
$ret = array(); $ret = array();
$appbox = appbox::get_instance(\bootstrap::getCore());
foreach ($rs as $row) { foreach ($rs as $row) {
$value = $row['val']; $value = $row['val'];
$caption = $value; $caption = $value;
if ($field == "getter") { if ($field == "getter") {
try { try {
$user = User_Adapter::getInstance($value, $appbox); $user = User_Adapter::getInstance($value, $this->app);
$caption = $user->get_display_name(); $caption = $user->get_display_name();
} catch (Exception $e) { } catch (Exception $e) {
} }
} elseif ($field == 'date') } elseif ($field == 'date')
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
elseif ($field == 'size') elseif ($field == 'size')
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
@@ -99,14 +100,14 @@ class module_report_add extends module_report
return $ret; return $ret;
} }
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
foreach ($rs as $row) { foreach ($rs as $row) {
foreach ($this->champ as $key => $value) { foreach ($this->champ as $key => $value) {
if ($row[$value]) { if ($row[$value]) {
if ($value == 'date') { if ($value == 'date') {
$this->result[$i][$value] = $this->pretty_string ? phraseadate::getPrettyString(new DateTime($row[$value])) : $row[$value]; $this->result[$i][$value] = $this->pretty_string ? $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) : $row[$value];
} elseif ($value == 'size') { } elseif ($value == 'size') {
$this->result[$i][$value] = p4string::format_octets($row[$value]); $this->result[$i][$value] = p4string::format_octets($row[$value]);
} else } else

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -40,9 +42,9 @@ class module_report_connexion extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report::Connexions'); $this->title = _('report::Connexions');
} }
@@ -84,7 +86,7 @@ class module_report_connexion extends module_report
if ($field == "appli") if ($field == "appli")
$caption = implode(' ', phrasea::modulesName(@unserialize($value))); $caption = implode(' ', phrasea::modulesName(@unserialize($value)));
elseif ($field == 'ddate') elseif ($field == 'ddate')
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
else else
$caption = $row['val']; $caption = $row['val'];
$ret[] = array('val' => $caption, 'value' => $value); $ret[] = array('val' => $caption, 'value' => $value);
@@ -99,7 +101,7 @@ class module_report_connexion extends module_report
* @param string $sql the request from buildreq * @param string $sql the request from buildreq
* @return $this->result * @return $this->result
*/ */
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
@@ -118,9 +120,9 @@ class module_report_connexion extends module_report
foreach ($coll as $id) { foreach ($coll as $id) {
if ($this->result[$i][$value] != "") { if ($this->result[$i][$value] != "") {
$this->result[$i][$value].= " / "; $this->result[$i][$value].= " / ";
$this->result[$i][$value] .= phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $id)); $this->result[$i][$value] .= phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $id, $this->app), $this->app);
} elseif ($this->result[$i][$value] == "") { } elseif ($this->result[$i][$value] == "") {
$this->result[$i][$value] = phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $id)); $this->result[$i][$value] = phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $id, $this->app), $this->app);
} }
} }
} elseif ($value == 'appli') { } elseif ($value == 'appli') {
@@ -136,7 +138,7 @@ class module_report_connexion extends module_report
} }
} elseif ($value == 'ddate') { } elseif ($value == 'ddate') {
$this->result[$i][$value] = $this->pretty_string ? $this->result[$i][$value] = $this->pretty_string ?
phraseadate::getPrettyString(new DateTime($row[$value])) : $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) :
$row[$value]; $row[$value];
} else { } else {
$this->result[$i][$value] = $row[$value]; $this->result[$i][$value] = $row[$value];
@@ -146,13 +148,13 @@ class module_report_connexion extends module_report
} }
} }
public static function getNbConn($dmin, $dmax, $sbas_id, $list_coll_id) public static function getNbConn(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -65,6 +67,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
* @var <int> * @var <int>
*/ */
public $sbasid; public $sbasid;
private $app;
/** /**
* @desc Construit un dashboard selon les droits du usrid, si sbas vaut null * @desc Construit un dashboard selon les droits du usrid, si sbas vaut null
@@ -72,8 +75,9 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
* @param <int> $usrid * @param <int> $usrid
* @param <int> $sbasid * @param <int> $sbasid
*/ */
public function __construct($usr, $sbasid = null) public function __construct(Application $app, $usr, $sbasid = null)
{ {
$this->app = $app;
$this->usr = $usr; $this->usr = $usr;
if (is_null($sbasid)) if (is_null($sbasid))
$this->sbasid = 'all'; $this->sbasid = 'all';
@@ -136,11 +140,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
if ($d == 'dmax') { if ($d == 'dmax') {
$datetime = new Datetime($this->dmax); $datetime = new Datetime($this->dmax);
return phraseadate::getPrettyString($datetime); return $this->app['date-formatter']->getPrettyString($datetime);
} elseif ($d == 'dmin') { } elseif ($d == 'dmin') {
$datetime = new Datetime($this->dmin); $datetime = new Datetime($this->dmin);
return phraseadate::getPrettyString($datetime); return $this->app['date-formatter']->getPrettyString($datetime);
} else } else
throw new Exception('argument must be string dmin or dmax'); throw new Exception('argument must be string dmin or dmax');
} }
@@ -183,12 +187,12 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
$date = new Datetime($dmax); $date = new Datetime($dmax);
$dmax = $date->format('d-m-Y'); $dmax = $date->format('d-m-Y');
} }
$this->legendDay[] = phraseadate::getPrettyString($date); $this->legendDay[] = $this->app['date-formatter']->getPrettyString($date);
while ($dmin != $dmax) { while ($dmin != $dmax) {
$date->modify('-1 day'); $date->modify('-1 day');
$dmax = $date->format('d-m-Y'); $dmax = $date->format('d-m-Y');
$this->legendDay[] = phraseadate::getPrettyString($date); $this->legendDay[] = $this->app['date-formatter']->getPrettyString($date);
$this->nb_days ++; $this->nb_days ++;
} }
$this->legendDay = array_reverse($this->legendDay); $this->legendDay = array_reverse($this->legendDay);
@@ -277,7 +281,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
$this->authorizedCollection[] = array( $this->authorizedCollection[] = array(
'sbas_id' => (int) $sbas, 'sbas_id' => (int) $sbas,
'coll' => implode(',', $listeColl), 'coll' => implode(',', $listeColl),
'name' => phrasea::sbas_names($sbas) 'name' => phrasea::sbas_names($sbas, $this->app)
); );
} }
@@ -294,7 +298,7 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
$all_coll = $this->getAllColl(); $all_coll = $this->getAllColl();
$liste = ''; $liste = '';
foreach ($all_coll as $sbas => $info) { foreach ($all_coll as $sbas => $info) {
$liste .= phrasea::sbas_names($sbas) . ' ' . $separator . ' '; $liste .= phrasea::sbas_names($sbas, $this->app) . ' ' . $separator . ' ';
} }
return $liste; return $liste;
@@ -315,13 +319,13 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
if ($this->sbasid != "all") { if ($this->sbasid != "all") {
if ($this->sbasid == $sbasid) { if ($this->sbasid == $sbasid) {
$this->dashboard[$sbasid] = module_report_dashboard_feed::getInstance( $this->dashboard[$sbasid] = module_report_dashboard_feed::getInstance(
$sbasid, $coll, $this->dmin, $this->dmax $this->app, $sbasid, $coll, $this->dmin, $this->dmax
); );
break; break;
} }
} else { } else {
$this->dashboard[$sbasid] = module_report_dashboard_feed::getInstance( $this->dashboard[$sbasid] = module_report_dashboard_feed::getInstance(
$sbasid, $coll, $this->dmin, $this->dmax $this->app, $sbasid, $coll, $this->dmin, $this->dmax
); );
} }
} catch (Exception $e) { } catch (Exception $e) {

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -59,6 +62,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* @var <array> * @var <array>
*/ */
public $report = array(); public $report = array();
private $app;
/** /**
* @desc return l'objet stockee dans le cache si i l existe sinon instancie * @desc return l'objet stockee dans le cache si i l existe sinon instancie
@@ -69,9 +73,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* @param <string> $dmax * @param <string> $dmax
* @return self * @return self
*/ */
public static function getInstance($sbasid, $sbas_coll, $dmin, $dmax) public static function getInstance(Application $app, $sbasid, $sbas_coll, $dmin, $dmax)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = $app['phraseanet.appbox'];
$cache_id = 'feed_' . md5($sbasid . '_' . $sbas_coll . '_' . $dmin . '_' . $dmax); $cache_id = 'feed_' . md5($sbasid . '_' . $sbas_coll . '_' . $dmin . '_' . $dmax);
try { try {
@@ -80,7 +84,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
} }
$tmp = new self($sbasid, $sbas_coll, $dmin, $dmax); $tmp = new self($app, $sbasid, $sbas_coll, $dmin, $dmax);
$appbox->set_data_to_cache($tmp, $cache_id); $appbox->set_data_to_cache($tmp, $cache_id);
@@ -95,9 +99,10 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* @param <string> $dmin, Y-m-d * @param <string> $dmin, Y-m-d
* @param <string> $dmax, Y-m-d * @param <string> $dmax, Y-m-d
*/ */
public function __construct($sbasid, $sbas_collection, $dmin, $dmax) public function __construct(Application $app, $sbasid, $sbas_collection, $dmin, $dmax)
{ {
$conn = connection::getPDOConnection($sbasid); $this->app = $app;
$conn = connection::getPDOConnection($app, $sbasid);
$this->dmin = $dmin; $this->dmin = $dmin;
$this->dmax = $dmax; $this->dmax = $dmax;
$this->dminsql = $this->dateToSqlDate('dmin'); $this->dminsql = $this->dateToSqlDate('dmin');
@@ -117,11 +122,11 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
if ($d == 'dmax') { if ($d == 'dmax') {
$datetime = new Datetime($this->dmax); $datetime = new Datetime($this->dmax);
return phraseadate::format_mysql($datetime); return $this->app['date-formatter']->format_mysql($datetime);
} elseif ($d == 'dmin') { } elseif ($d == 'dmin') {
$datetime = new Datetime($this->dmin); $datetime = new Datetime($this->dmin);
return phraseadate::format_mysql($datetime); return $this->app['date-formatter']->format_mysql($datetime);
} }
} }
@@ -134,13 +139,13 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
try { try {
//Get number of DLs //Get number of DLs
$this->report['nb_dl'] = module_report_download::getNbDl( $this->report['nb_dl'] = module_report_download::getNbDl(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
//Get Number of connexions //Get Number of connexions
$this->report['nb_conn'] = module_report_connexion::getNbConn( $this->report['nb_conn'] = module_report_connexion::getNbConn(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
$registry = registry::get_instance(); $registry = $this->app['phraseanet.registry'];
if ($registry->get('GV_anonymousReport') == false) { if ($registry->get('GV_anonymousReport') == false) {
/** /**
* get Top ten user of * get Top ten user of
@@ -148,7 +153,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* number of weight dl by doc, prev * number of weight dl by doc, prev
*/ */
$top = module_report_activity::topTenUser( $top = module_report_activity::topTenUser(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
$this->report['top_ten_user_doc'] = $top['top_ten_doc']; $this->report['top_ten_user_doc'] = $top['top_ten_doc'];
@@ -161,16 +166,16 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* get avtivity by hour * get avtivity by hour
*/ */
$this->report['activity'] = module_report_activity::activity( $this->report['activity'] = module_report_activity::activity(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
// get activty by day // get activty by day
$this->report['activity_day'] = module_report_activity::activityDay( $this->report['activity_day'] = module_report_activity::activityDay(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
// get Most document and preview DL // get Most document and preview DL
$topdl = module_report_download::getTopDl( $topdl = module_report_download::getTopDl(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
$this->report['top_dl_preview'] = $topdl['preview']; $this->report['top_dl_preview'] = $topdl['preview'];
@@ -179,31 +184,31 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
if ($registry->get('GV_anonymousReport') == false) { if ($registry->get('GV_anonymousReport') == false) {
// get users that ask the most questions // get users that ask the most questions
$this->report['ask'] = module_report_activity::activityQuestion( $this->report['ask'] = module_report_activity::activityQuestion(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
} }
//get the refferer //get the refferer
$this->report['top_ten_site'] = module_report_activity::activiteTopTenSiteView( $this->report['top_ten_site'] = module_report_activity::activiteTopTenSiteView(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
//Get the most asked questions //Get the most asked questions
$this->report['top_ten_question'] = module_report_activity::activiteTopQuestion( $this->report['top_ten_question'] = module_report_activity::activiteTopQuestion(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
//get the number of added docuùments //get the number of added docuùments
$this->report['activity_added'] = module_report_activity::activiteAddedDocument( $this->report['activity_added'] = module_report_activity::activiteAddedDocument(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
//get number of edited document //get number of edited document
$this->report['activity_edited'] = module_report_activity::activiteEditedDocument( $this->report['activity_edited'] = module_report_activity::activiteEditedDocument(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
if ($registry->get('GV_anonymousReport') == false) { if ($registry->get('GV_anonymousReport') == false) {
//get users that add the most documents //get users that add the most documents
$this->report['top_ten_added'] = module_report_activity::activiteAddedTopTenUser( $this->report['top_ten_added'] = module_report_activity::activiteAddedTopTenUser(
$this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection $this->app, $this->dminsql, $this->dmaxsql, $this->sbasid, $this->collection
); );
} }
} catch (PDOException $e) { } catch (PDOException $e) {

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -45,9 +48,9 @@ class module_report_download extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: telechargements'); $this->title = _('report:: telechargements');
} }
@@ -74,8 +77,6 @@ class module_report_download extends module_report
$sql = $var['sql']; $sql = $var['sql'];
$params = $var['params']; $params = $var['params'];
$registry = registry::get_instance();
$stmt = $s->getConnBas()->prepare($sql); $stmt = $s->getConnBas()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -84,9 +85,9 @@ class module_report_download extends module_report
foreach ($rs as $row) { foreach ($rs as $row) {
$value = $row['val']; $value = $row['val'];
if ($field == 'coll_id') { if ($field == 'coll_id') {
$caption = phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value)); $caption = phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
} elseif ($field == 'ddate') } elseif ($field == 'ddate')
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
elseif ($field == 'size') elseif ($field == 'size')
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
else else
@@ -103,10 +104,10 @@ class module_report_download extends module_report
* @param string $sql the request from buildreq * @param string $sql the request from buildreq
* @return $this->result * @return $this->result
*/ */
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id); $pref = parent::getPreff($app, $this->sbas_id);
foreach ($rs as $row) { foreach ($rs as $row) {
if ($this->enable_limit && ($i > $this->nb_record)) if ($this->enable_limit && ($i > $this->nb_record))
@@ -117,7 +118,7 @@ class module_report_download extends module_report
} }
if (array_key_exists('record_id', $row)) { if (array_key_exists('record_id', $row)) {
$record = new \record_adapter($this->sbas_id, $row['record_id']); $record = new \record_adapter($app, $this->sbas_id, $row['record_id']);
foreach ($pref as $field) { foreach ($pref as $field) {
try { try {
@@ -163,22 +164,22 @@ class module_report_download extends module_report
$dateString = $datetime->format(DATE_ATOM); $dateString = $datetime->format(DATE_ATOM);
return $this->pretty_string ? return $this->pretty_string ?
phraseadate::getPrettyString($datetime) : $dateString; $this->app['date-formatter']->getPrettyString($datetime) : $dateString;
} }
private function formatCollId($value) private function formatCollId($value)
{ {
return phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value)); return phrasea::bas_names(phrasea::baseFromColl($this->sbas_id, $value, $this->app), $this->app);
} }
public static function getNbDl($dmin, $dmax, $sbas_id, $list_coll_id) public static function getNbDl(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($app, $sbas_id);
$registry = registry::get_instance(); $registry = $app['phraseanet.registry'];
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$finalfilter = $datefilter['sql'] . ' AND '; $finalfilter = $datefilter['sql'] . ' AND ';
@@ -208,9 +209,9 @@ class module_report_download extends module_report
return $row ? $row['nb'] : 0; return $row ? $row['nb'] : 0;
} }
public static function getTopDl($dmin, $dmax, $sbas_id, $list_coll_id) public static function getTopDl(Application $app, $dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$appbox = \appbox::get_instance(\bootstrap::getCore()); $appbox = $app['phraseanet.appbox'];
$databox = $appbox->get_databox((int) $sbas_id); $databox = $appbox->get_databox((int) $sbas_id);
$conn = $databox->get_connection(); $conn = $databox->get_connection();
@@ -218,7 +219,7 @@ class module_report_download extends module_report
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$finalfilter = ""; $finalfilter = "";

View File

@@ -9,6 +9,9 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
use Alchemy\Phrasea\Core\Configuration;
/** /**
* *
* @package module_report * @package module_report
@@ -43,9 +46,9 @@ class module_report_edit extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: edited documents'); $this->title = _('report:: edited documents');
} }
@@ -75,21 +78,19 @@ class module_report_edit extends module_report
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$appbox = appbox::get_instance(\bootstrap::getCore());
$ret = array(); $ret = array();
foreach ($rs as $row) { foreach ($rs as $row) {
$value = $row['val']; $value = $row['val'];
$caption = $value; $caption = $value;
if ($field == "getter") { if ($field == "getter") {
try { try {
$user = User_Adapter::getInstance($value, $appbox); $user = User_Adapter::getInstance($value, $this->app);
$caption = $user->get_display_name(); $caption = $user->get_display_name();
} catch (Exception $e) { } catch (Exception $e) {
} }
} elseif ($field == 'date') { } elseif ($field == 'date') {
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
} elseif ($field == 'size') { } elseif ($field == 'size') {
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
} }
@@ -100,7 +101,7 @@ class module_report_edit extends module_report
return $ret; return $ret;
} }
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
@@ -110,7 +111,7 @@ class module_report_edit extends module_report
foreach ($this->champ as $key => $value) { foreach ($this->champ as $key => $value) {
if ($row[$value]) { if ($row[$value]) {
if ($value == 'date') { if ($value == 'date') {
$this->result[$i][$value] = $this->pretty_string ? phraseadate::getPrettyString(new DateTime($row[$value])) : $row[$value]; $this->result[$i][$value] = $this->pretty_string ? $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) : $row[$value];
} elseif ($value == 'size') { } elseif ($value == 'size') {
$this->result[$i][$value] = p4string::format_octets($row[$value]); $this->result[$i][$value] = p4string::format_octets($row[$value]);
} else } else

View File

@@ -86,7 +86,7 @@ class module_report_filter
if ($filter['f'] == 'appli') { if ($filter['f'] == 'appli') {
$value = implode(' ', phrasea::modulesName(@unserialize($value))); $value = implode(' ', phrasea::modulesName(@unserialize($value)));
} elseif ($filter['f'] == "ddate") { } elseif ($filter['f'] == "ddate") {
$value = phraseadate::getPrettyString(new DateTime($value)); $value = $this->app['date-formatter']->getPrettyString(new DateTime($value));
} }
$this->posting_filter[] = array('f' => $field, 'v' => $value); $this->posting_filter[] = array('f' => $field, 'v' => $value);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -49,18 +51,17 @@ class module_report_nav extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id databox id * @param $sbas_id databox id
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->total_pourcent = $this->setTotalPourcent(); $this->total_pourcent = $this->setTotalPourcent();
} }
private function setTotalPourcent() private function setTotalPourcent()
{ {
$registry = registry::get_instance();
$x = $this->getTransQueryString(); $x = $this->getTransQueryString();
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$params = array(); $params = array();
@@ -120,9 +121,7 @@ class module_report_nav extends module_report
{ {
$i = 0; $i = 0;
$registry = registry::get_instance(); $s = new module_report_sql($this->app, $this);
$s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$this->title = _('report:: navigateur'); $this->title = _('report:: navigateur');
@@ -183,9 +182,7 @@ class module_report_nav extends module_report
*/ */
public function buildTabOs($tab = false) public function buildTabOs($tab = false)
{ {
$s = new module_report_sql($this->app, $this);
$registry = registry::get_instance();
$s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$i = 0; $i = 0;
$this->title = _('report:: Plateforme'); $this->title = _('report:: Plateforme');
@@ -243,9 +240,7 @@ class module_report_nav extends module_report
*/ */
public function buildTabRes($tab = false) public function buildTabRes($tab = false)
{ {
$s = new module_report_sql($this->app, $this);
$registry = registry::get_instance();
$s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$this->title = _('report:: resolution'); $this->title = _('report:: resolution');
$i = 0; $i = 0;
@@ -304,7 +299,7 @@ class module_report_nav extends module_report
*/ */
public function buildTabCombo($tab = false) public function buildTabCombo($tab = false)
{ {
$s = new module_report_sql($this); $s = new module_report_sql($this->app, $this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$this->title = _('report:: navigateurs et plateforme'); $this->title = _('report:: navigateurs et plateforme');
$i = 0; $i = 0;
@@ -367,8 +362,7 @@ class module_report_nav extends module_report
public function buildTabModule($tab = false) public function buildTabModule($tab = false)
{ {
$this->initialize(); $this->initialize();
$registry = registry::get_instance(); $s = new module_report_sql($this->app, $this);
$s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$this->title = _('report:: modules'); $this->title = _('report:: modules');
$x = array(); $x = array();
@@ -450,13 +444,11 @@ class module_report_nav extends module_report
*/ */
public function buildTabGrpInfo($req, array $params, $val, $tab = false, $on = false) public function buildTabGrpInfo($req, array $params, $val, $tab = false, $on = false)
{ {
$this->initialize(); $this->initialize();
$registry = registry::get_instance();
empty($on) ? $on = false : ""; empty($on) ? $on = false : "";
$filter_id_apbox = $filter_id_datbox = array(); $filter_id_apbox = $filter_id_datbox = array();
$conn = connection::getPDOConnection(); $conn = connection::getPDOConnection($this->app);
$conn2 = connection::getPDOConnection($this->sbas_id); $conn2 = connection::getPDOConnection($this->app, $this->sbas_id);
$datefilter = array(); $datefilter = array();
@@ -543,8 +535,8 @@ class module_report_nav extends module_report
public function buildTabUserWhat($bid, $rid, $tab = false) public function buildTabUserWhat($bid, $rid, $tab = false)
{ {
$this->initialize(); $this->initialize();
$sbas_id = phrasea::sbasFromBas($bid); $sbas_id = phrasea::sbasFromBas($this->app, $bid);
$record = new record_adapter($sbas_id, $rid); $record = new record_adapter($this->app, $sbas_id, $rid);
$this->setDisplay($tab); $this->setDisplay($tab);
$this->champ = array( $this->champ = array(
@@ -566,7 +558,7 @@ class module_report_nav extends module_report
"<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;' "<img style='width:" . $x->get_width() . "px;height:" . $x->get_height() . "px;'
src='" . $x->get_url() . "'>" src='" . $x->get_url() . "'>"
, 'record_id' => $record->get_record_id() , 'record_id' => $record->get_record_id()
, 'date' => phraseadate::getPrettyString($document->get_creation_date()) , 'date' => $this->app['date-formatter']->getPrettyString($document->get_creation_date())
, 'type' => $document->get_mime() , 'type' => $document->get_mime()
, 'titre' => $record->get_title() , 'titre' => $record->get_title()
, 'taille' => $document->get_size() , 'taille' => $document->get_size()
@@ -580,7 +572,7 @@ class module_report_nav extends module_report
public function buildTabInfoNav($tab = false, $navigator) public function buildTabInfoNav($tab = false, $navigator)
{ {
$conn = connection::getPDOConnection($this->sbas_id); $conn = connection::getPDOConnection($this->app, $this->sbas_id);
$this->title = sprintf( $this->title = sprintf(
_('report:: Information sur le navigateur %s'), $navigator); _('report:: Information sur le navigateur %s'), $navigator);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -43,9 +45,9 @@ class module_report_push extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: pushed documents'); $this->title = _('report:: pushed documents');
} }
@@ -82,13 +84,13 @@ class module_report_push extends module_report
$caption = $value; $caption = $value;
if ($field == "getter") { if ($field == "getter") {
try { try {
$user = User_Adapter::getInstance($value, $appbox); $user = User_Adapter::getInstance($value, $this->app);
$caption = $user->get_display_name(); $caption = $user->get_display_name();
} catch (Exception $e) { } catch (Exception $e) {
} }
} elseif ($field == 'date') { } elseif ($field == 'date') {
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
} elseif ($field == 'size') { } elseif ($field == 'size') {
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
} }
@@ -99,7 +101,7 @@ class module_report_push extends module_report
return $ret; return $ret;
} }
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
@@ -110,7 +112,7 @@ class module_report_push extends module_report
if ($row[$value]) { if ($row[$value]) {
if ($value == 'date') { if ($value == 'date') {
$this->result[$i][$value] = $this->pretty_string ? $this->result[$i][$value] = $this->pretty_string ?
phraseadate::getPrettyString(new DateTime($row[$value])) : $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) :
$row[$value]; $row[$value];
} elseif ($value == 'size') { } elseif ($value == 'size') {
$this->result[$i][$value] = p4string::format_octets($row[$value]); $this->result[$i][$value] = p4string::format_octets($row[$value]);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -41,9 +43,9 @@ class module_report_question extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: question'); $this->title = _('report:: question');
} }
@@ -77,7 +79,7 @@ class module_report_question extends module_report
if ($field == 'appli') if ($field == 'appli')
$caption = implode(' ', phrasea::modulesName(@unserialize($row['val']))); $caption = implode(' ', phrasea::modulesName(@unserialize($row['val'])));
elseif ($field == "ddate") elseif ($field == "ddate")
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
else else
$caption = $row['val']; $caption = $row['val'];
$ret[] = array('val' => $caption, 'value' => $value); $ret[] = array('val' => $caption, 'value' => $value);
@@ -86,7 +88,7 @@ class module_report_question extends module_report
return $ret; return $ret;
} }
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$tab = array(); $tab = array();
$i = 0; $i = 0;
@@ -97,7 +99,7 @@ class module_report_question extends module_report
if ($row[$value]) { if ($row[$value]) {
if ($value == 'ddate') if ($value == 'ddate')
$this->result[$i][$value] = $this->result[$i][$value] =
$this->pretty_string ? phraseadate::getPrettyString(new DateTime($row[$value])) : $row[$value]; $this->pretty_string ? $this->app['date-formatter']->getPrettyString(new DateTime($row[$value])) : $row[$value];
else else
$this->result[$i][$value] = $row[$value]; $this->result[$i][$value] = $row[$value];
} else } else

View File

@@ -41,11 +41,11 @@ class module_report_sql
public $groupby = false; public $groupby = false;
public $on = false; public $on = false;
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
$this->conn = connection::getPDOConnection(); $this->conn = connection::getPDOConnection($app);
$this->connbas = connection::getPDOConnection($report->getSbasId()); $this->connbas = connection::getPDOConnection($app, $report->getSbasId());
$this->filter = new module_report_sqlfilter($report); $this->filter = new module_report_sqlfilter($app, $report);
$this->sql = ''; $this->sql = '';
$this->params = array(); $this->params = array();
$this->total_row = 0; $this->total_row = 0;

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -19,9 +21,9 @@ class module_report_sqlaction extends module_report_sql implements module_report
{ {
private $action = 'add'; private $action = 'add';
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
parent::__construct($report); parent::__construct($app, $report);
} }
public function setAction($action) public function setAction($action)

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -18,9 +20,9 @@
class module_report_sqlconnexion extends module_report_sql implements module_report_sqlReportInterface class module_report_sqlconnexion extends module_report_sql implements module_report_sqlReportInterface
{ {
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
parent::__construct($report); parent::__construct($app, $report);
} }
public function buildSql() public function buildSql()

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -19,9 +21,9 @@ class module_report_sqldownload extends module_report_sql implements module_repo
{ {
protected $restrict = false; protected $restrict = false;
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
parent::__construct($report); parent::__construct($app, $report);
if ($report->isInformative()) { if ($report->isInformative()) {
$this->restrict = true; $this->restrict = true;
} }
@@ -29,7 +31,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
public function buildSql() public function buildSql()
{ {
$registry = registry::get_instance();
$report_filters = $this->filter->getReportFilter(); $report_filters = $this->filter->getReportFilter();
$record_filters = $this->filter->getRecordFilter() ? : array('sql' => '', 'params' => array()); $record_filters = $this->filter->getRecordFilter() ? : array('sql' => '', 'params' => array());
$this->params = array_merge($report_filters['params'], $record_filters['params']); $this->params = array_merge($report_filters['params'], $record_filters['params']);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -20,10 +22,12 @@ class module_report_sqlfilter
public $conn; public $conn;
private $filter; private $filter;
private $cor_query = array(); private $cor_query = array();
private $app;
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
$this->conn = connection::getPDOConnection($report->getSbasid()); $this->app = $app;
$this->conn = connection::getPDOConnection($app, $report->getSbasid());
if (is_array($report->getTransQueryString())) if (is_array($report->getTransQueryString()))
$this->cor_query = $report->getTransQueryString(); $this->cor_query = $report->getTransQueryString();
@@ -39,12 +43,12 @@ class module_report_sqlfilter
); );
} }
public static function constructCollectionFilter($list_coll_id) public static function constructCollectionFilter(Application $app, $list_coll_id)
{ {
$ret = array('sql' => '', 'params' => array()); $ret = array('sql' => '', 'params' => array());
$coll_filter = array(); $coll_filter = array();
foreach (explode(',', $list_coll_id) as $val) { foreach (explode(',', $list_coll_id) as $val) {
$coll_filter [] = " position('," . phrasea::collFromBas($val) . ",' in concat(',' ,coll_list, ',')) > 0 "; $coll_filter [] = " position('," . phrasea::collFromBas($app, $val) . ",' in concat(',' ,coll_list, ',')) > 0 ";
} }
$ret['sql'] = implode(' OR ', $coll_filter); $ret['sql'] = implode(' OR ', $coll_filter);
@@ -59,7 +63,7 @@ class module_report_sqlfilter
public function getReportFilter() public function getReportFilter()
{ {
$finalfilter = ''; $finalfilter = '';
$registry = registry::get_instance(); $registry = $this->app['phraseanet.registry'];
$params = array(':log_site' => $registry->get('GV_sit')); $params = array(':log_site' => $registry->get('GV_sit'));
@@ -82,7 +86,7 @@ class module_report_sqlfilter
public function getGvSitFilter() public function getGvSitFilter()
{ {
$registry = registry::get_instance(); $registry = $this->app['phraseanet.registry'];
$params = array(); $params = array();
$sql = ''; $sql = '';
@@ -191,7 +195,7 @@ class module_report_sqlfilter
$tab = explode(",", $report->getListCollId()); $tab = explode(",", $report->getListCollId());
if (count($tab) > 0) { if (count($tab) > 0) {
foreach ($tab as $val) { foreach ($tab as $val) {
$coll_filter[] = " position('," . phrasea::collFromBas($val) . ",' in concat(',' ,coll_list, ',')) > 0 "; $coll_filter[] = " position('," . phrasea::collFromBas($this->app, $val) . ",' in concat(',' ,coll_list, ',')) > 0 ";
} }
$this->filter['collection'] = array('sql' => implode(' OR ', $coll_filter), 'params' => array()); $this->filter['collection'] = array('sql' => implode(' OR ', $coll_filter), 'params' => array());
} }
@@ -208,7 +212,7 @@ class module_report_sqlfilter
$tab = explode(",", $report->getListCollId()); $tab = explode(",", $report->getListCollId());
foreach ($tab as $val) { foreach ($tab as $val) {
$dl_coll_filter[] = "record.coll_id = :record_fil" . $n; $dl_coll_filter[] = "record.coll_id = :record_fil" . $n;
$params[":record_fil" . $n] = phrasea::collFromBas($val); $params[":record_fil" . $n] = phrasea::collFromBas($this->app, $val);
$n ++; $n ++;
} }
$this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params); $this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params);

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -18,9 +20,9 @@
class module_report_sqlquestion extends module_report_sql implements module_report_sqlReportInterface class module_report_sqlquestion extends module_report_sql implements module_report_sqlReportInterface
{ {
public function __construct(module_report $report) public function __construct(Application $app, module_report $report)
{ {
parent::__construct($report); parent::__construct($app, $report);
} }
public function buildSql() public function buildSql()

View File

@@ -9,6 +9,8 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
use Alchemy\Phrasea\Application;
/** /**
* *
* @package module_report * @package module_report
@@ -43,9 +45,9 @@ class module_report_validate extends module_report
* @param $arg2 end date of the report * @param $arg2 end date of the report
* @param $sbas_id id of the databox * @param $sbas_id id of the databox
*/ */
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct(Application $app, $arg1, $arg2, $sbas_id, $collist)
{ {
parent::__construct($arg1, $arg2, $sbas_id, $collist); parent::__construct($app, $arg1, $arg2, $sbas_id, $collist);
$this->title = _('report:: validated documents'); $this->title = _('report:: validated documents');
} }
@@ -82,13 +84,13 @@ class module_report_validate extends module_report
$caption = $value; $caption = $value;
if ($field == "getter") { if ($field == "getter") {
try { try {
$user = User_Adapter::getInstance($value, $appbox); $user = User_Adapter::getInstance($value, $this->app);
$caption = $user->get_display_name(); $caption = $user->get_display_name();
} catch (Exception $e) { } catch (Exception $e) {
} }
} elseif ($field == 'date') { } elseif ($field == 'date') {
$caption = phraseadate::getPrettyString(new DateTime($value)); $caption = $this->app['date-formatter']->getPrettyString(new DateTime($value));
} elseif ($field == 'size') { } elseif ($field == 'size') {
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
} }
@@ -99,7 +101,7 @@ class module_report_validate extends module_report
return $ret; return $ret;
} }
protected function buildResult($rs) protected function buildResult(Application $app, $rs)
{ {
$i = 0; $i = 0;
@@ -110,7 +112,7 @@ class module_report_validate extends module_report
if ($row[$value]) { if ($row[$value]) {
if ($value == 'date') { if ($value == 'date') {
$this->result[$i][$value] = $this->pretty_string ? $this->result[$i][$value] = $this->pretty_string ?
phraseadate::getPrettyString(new DateTime($row[$value])) : $app['date-formatter']->getPrettyString(new DateTime($row[$value])) :
$row[$value]; $row[$value];
} elseif ($value == 'size') { } elseif ($value == 'size') {
$this->result[$i][$value] = p4string::format_octets($row[$value]); $this->result[$i][$value] = p4string::format_octets($row[$value]);