mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-11 03:53:13 +00:00
Merge branch '3.8'
Conflicts: lib/Alchemy/Phrasea/Controller/Thesaurus/Thesaurus.php lib/Alchemy/Phrasea/Controller/Thesaurus/Xmlhttp.php lib/classes/connection.php lib/classes/connection/abstract.php lib/classes/connection/interface.php lib/classes/connection/pdo.php lib/classes/connection/pdoStatementDebugger.php lib/classes/module/report/activity.php lib/classes/module/report/sqlfilter.php lib/classes/record/adapter.php lib/classes/task/period/subdef.php templates/web/prod/thesaurus.js.twig tests/Alchemy/Tests/Phrasea/Setup/InstallerTest.php tests/classes/PhraseanetPHPUnitAbstract.php tests/classes/connectionTest.php
This commit is contained in:
@@ -1138,7 +1138,7 @@ class Thesaurus implements ControllerProviderInterface
|
||||
{
|
||||
list($term, $context) = $this->splitTermAndContext($request->get("t"));
|
||||
|
||||
$dom = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $request->get('term'), $request->get('context'), $request->get('piv'));
|
||||
$dom = $this->doSearchCandidate($app, $request->get('bid'), $request->get('pid'), $term, $context, $request->get('piv'));
|
||||
|
||||
$xpath = new \DOMXPath($dom);
|
||||
|
||||
@@ -1158,10 +1158,10 @@ class Thesaurus implements ControllerProviderInterface
|
||||
$candidates_list = [];
|
||||
for ($i = 0; $i < $candidates->length; $i ++) {
|
||||
if ($candidates->item($i)->getAttribute("sourceok") == "1") {
|
||||
$candidates_list = [
|
||||
$candidates_list[] = array(
|
||||
'id' => $candidates->item($i)->getAttribute("id"),
|
||||
'field' => $candidates->item($i)->getAttribute("field"),
|
||||
];
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2948,8 +2948,8 @@ class Thesaurus implements ControllerProviderInterface
|
||||
$xpathth = new \DOMXPath($domth);
|
||||
$xpathct = new \DOMXPath($domct);
|
||||
|
||||
// on cherche les champs d'oe peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme
|
||||
$fields = [];
|
||||
// on cherche les champs d'ou peut provenir un candidat, en fct de l'endroit oe on veut inserer le nouveau terme
|
||||
$fields = array();
|
||||
$xpathstruct = new \DOMXPath($domstruct);
|
||||
$nodes = $xpathstruct->query("/record/description/*[@tbranch]");
|
||||
for ($i = 0; $i < $nodes->length; $i ++) {
|
||||
@@ -2992,7 +2992,7 @@ class Thesaurus implements ControllerProviderInterface
|
||||
];
|
||||
|
||||
if (count($fields) > 0) {
|
||||
$q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
|
||||
$q = "@w='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t)) . "'";
|
||||
if ($k) {
|
||||
if ($k != "*") {
|
||||
$q .= " and @k='" . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($k)) . "'";
|
||||
|
@@ -44,6 +44,7 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$controllers->match('openbranch_prod.j.php', 'controller.thesaurus.xmlhttp:OpenBranchJson');
|
||||
$controllers->match('openbranches_prod.h.php', 'controller.thesaurus.xmlhttp:OpenBranchesHtml');
|
||||
$controllers->match('openbranches_prod.x.php', 'controller.thesaurus.xmlhttp:OpenBranchesXml');
|
||||
$controllers->match('openbranches_prod.j.php', 'controller.thesaurus.xmlhttp:OpenBranchesJson');
|
||||
$controllers->match('replacecandidate.j.php', 'controller.thesaurus.xmlhttp:ReplaceCandidateJson')
|
||||
->before(function () use ($app) {
|
||||
$app['firewall']->requireAccessToModule('thesaurus');
|
||||
@@ -772,72 +773,19 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$lthid = strlen($thid);
|
||||
|
||||
// count occurences
|
||||
if ($lthid == 1) {
|
||||
if ($lthid > 1) {
|
||||
$dthid = str_replace('.', 'd', $thid);
|
||||
|
||||
$sql = 'SELECT COUNT(DISTINCT r.record_id) AS n
|
||||
FROM (thit AS t INNER JOIN record AS r USING(record_id))
|
||||
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
|
||||
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0';
|
||||
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
|
||||
$sql = "SELECT"
|
||||
. " 0+SUBSTR(t.value, " . ($lthid + 2) . ") AS k, COUNT(DISTINCT(`record_id`)) AS n"
|
||||
. " FROM (thit AS t INNER JOIN record AS r USING(record_id))"
|
||||
. " INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id"
|
||||
. " WHERE t.value LIKE :like AND r.coll_id IN(".$lcoll.") AND (r.status^c.mask_xor)&c.mask_and=0"
|
||||
. " GROUP BY k ORDER BY NULL";
|
||||
$sqlparm = array(':like' => $dthid . 'd%', ':site'=>$site, ':usr_id'=>$usr_id);
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute($sqlparm);
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid] = $rowbas;
|
||||
}
|
||||
|
||||
$sql = 'SELECT
|
||||
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid + 1) . '), "d", 1) AS k ,
|
||||
COUNT(DISTINCT t.record_id) AS n
|
||||
FROM (thit AS t INNER JOIN record AS r USING(record_id))
|
||||
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
|
||||
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
|
||||
GROUP BY k';
|
||||
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute([':like' => $dthid . '%']);
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid . $rowbas['k']] = $rowbas;
|
||||
}
|
||||
} elseif (strlen($thid) > 1) {
|
||||
$dthid = str_replace('.', 'd', $thid);
|
||||
$sql = 'SELECT
|
||||
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid) . '), \'d\', 1) AS k ,
|
||||
COUNT(DISTINCT t.record_id) AS n
|
||||
FROM (thit AS t INNER JOIN record AS r USING(record_id))
|
||||
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
|
||||
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
|
||||
GROUP BY k';
|
||||
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute($sqlparm);
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
foreach ($rs as $rowbas) {
|
||||
$t_nrec[$thid] = $rowbas;
|
||||
}
|
||||
|
||||
$sql = 'SELECT
|
||||
SUBSTRING_INDEX(SUBSTR(t.value, ' . ($lthid + 2) . '), \'d\', 1) AS k ,
|
||||
COUNT(DISTINCT t.record_id) AS n
|
||||
FROM (thit AS t INNER JOIN record AS r USING(record_id))
|
||||
INNER JOIN collusr AS c ON c.site=:site AND c.usr_id=:usr_id AND r.coll_id=c.coll_id
|
||||
WHERE t.value LIKE :like AND r.coll_id IN('.$lcoll.') AND (r.status^c.mask_xor)&c.mask_and=0
|
||||
GROUP BY k';
|
||||
$sqlparm = [':like' => $dthid . '%', ':site'=>$site, ':usr_id'=>$usr_id];
|
||||
|
||||
$stmt = $connbas->prepare($sql);
|
||||
$stmt->execute($sqlparm);
|
||||
$rs = $stmt->fetchAll(\PDO::FETCH_ASSOC);
|
||||
$stmt->closeCursor();
|
||||
|
||||
@@ -879,17 +827,6 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
if ($request->get('last')) {
|
||||
$class .= ( $class == '' ? '' : ' ') . 'last';
|
||||
}
|
||||
|
||||
$html .= '<LI id="' . $request->get('type') . 'X_P.' . $sbid . '.' . $thid . '" class="' . $class . '" loaded="1">' . "\n";
|
||||
$html .= ' <div class="hitarea expandable-hitarea"></div>' . "\n";
|
||||
$html .= ' <span>' . $label . '</span>';
|
||||
|
||||
if (isset($t_nrec[$thid])) {
|
||||
$html .= ' <I>' . $t_nrec[$thid]['n'] . '</I>';
|
||||
}
|
||||
|
||||
$html .= "\n";
|
||||
|
||||
// on dresse la liste des termes specifiques avec comme cle le synonyme dans la langue pivot
|
||||
$nts = 0;
|
||||
$tts = [];
|
||||
@@ -1165,6 +1102,92 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
}
|
||||
}
|
||||
|
||||
public function OpenBranchesJson(Application $app, Request $request)
|
||||
{
|
||||
if ('' === ($mod = strtoupper($request->get('mod')))) {
|
||||
$mod = 'TREE';
|
||||
}
|
||||
|
||||
$ret = array(
|
||||
'parms'=> array(
|
||||
'bid' => $request->get('bid'),
|
||||
't' => $request->get('t'),
|
||||
'mod' => $request->get('mod'),
|
||||
'debug' => $request->get('debug')
|
||||
),
|
||||
'result'=>NULL,
|
||||
'error'=>'',
|
||||
'error_code'=>0,
|
||||
);
|
||||
|
||||
if (null === ($bid = $request->get('bid'))) {
|
||||
$ret['error'] = 'Missing bid parameter';
|
||||
$ret['error_code'] = 400;
|
||||
|
||||
return json_encode($ret);
|
||||
}
|
||||
if ($mod != 'TREE' && $mod != "LIST") {
|
||||
$ret['error'] = 'bad mod, TREE|LIST';
|
||||
$ret['error_code'] = 400;
|
||||
|
||||
return json_encode($ret);
|
||||
}
|
||||
|
||||
|
||||
$databox = $app['phraseanet.appbox']->get_databox((int) $bid);
|
||||
$dom = $databox->get_dom_thesaurus();
|
||||
|
||||
if (!$dom) {
|
||||
$ret['error'] = 'Unable to load thesaurus';
|
||||
$ret['error_code'] = 500;
|
||||
|
||||
return json_encode($ret);
|
||||
}
|
||||
|
||||
$xpath = $databox->get_xpath_thesaurus();
|
||||
$q = '/thesaurus';
|
||||
|
||||
if (($znode = $xpath->query($q)->item(0))) {
|
||||
$q2 = '//sy';
|
||||
if ($request->get('t')) {
|
||||
$t = $this->splitTermAndContext($request->get('t'));
|
||||
$q2 = 'starts-with(@w, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[0])) . '\')';
|
||||
if ($t[1])
|
||||
$q2 .= ' and starts-with(@k, \'' . \thesaurus::xquery_escape($app['unicode']->remove_indexer_chars($t[1])) . '\')';
|
||||
$q2 = '//sy[' . $q2 . ']';
|
||||
}
|
||||
$nodes = $xpath->query($q2, $znode);
|
||||
if ($mod == 'TREE') {
|
||||
for ($i = 0; $i < $nodes->length; $i++) {
|
||||
$nodes->item($i)->setAttribute('bold', '1');
|
||||
for ($n = $nodes->item($i)->parentNode; $n && $n->nodeType == XML_ELEMENT_NODE && $n->nodeName == 'te'; $n = $n->parentNode) {
|
||||
$n->setAttribute('open', '1');
|
||||
}
|
||||
}
|
||||
$ret['result'] = $this->getBrancheJson($bid, $znode, $ret['result'], 0);
|
||||
} else {
|
||||
$ret['result'] = array();
|
||||
for ($i = 0; $i < $nodes->length; $i++) {
|
||||
$n = $nodes->item($i);
|
||||
$t = $n->getAttribute('v');
|
||||
$tid = $n->getAttribute('id');
|
||||
|
||||
$ret['result'][] = array(
|
||||
'id' => $n->getAttribute('id'),
|
||||
't' => $n->getAttribute('v'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
if($request->get('debug')) {
|
||||
printf("<pre>%s</pre>", var_export($ret, true));
|
||||
// printf("<pre>%s</pre>", json_encode($ret, JSON_PRETTY_PRINT));
|
||||
die;
|
||||
}
|
||||
return json_encode($ret, JSON_PRETTY_PRINT);
|
||||
}
|
||||
|
||||
|
||||
public function OpenBranchesXml(Application $app, Request $request)
|
||||
{
|
||||
if (null === $mod = $request->get('mod')) {
|
||||
@@ -1233,7 +1256,44 @@ class Xmlhttp implements ControllerProviderInterface
|
||||
$html->appendChild($ret->createTextNode($zhtml));
|
||||
}
|
||||
|
||||
return new Response($zhtml, 200, ['Content-Type' => 'text/xml']);
|
||||
return new Response($zhtml, 200, array('Content-Type' => 'text/xml'));
|
||||
}
|
||||
|
||||
private function getBrancheJson($bid, $srcnode, &$ret, $depth)
|
||||
{
|
||||
$tid = $srcnode->getAttribute('id');
|
||||
$nts = 0;
|
||||
$allsy = array();
|
||||
for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) {
|
||||
if ($n->nodeName == 'sy') {
|
||||
$t = $n->getAttribute('v');
|
||||
$allsy[] = array(
|
||||
'id' => $n->getAttribute('id'),
|
||||
't' => $t,
|
||||
'lng' => $n->getAttribute('lng'),
|
||||
'bold' => (bool)$n->getAttribute('bold'),
|
||||
);
|
||||
} elseif ($n->nodeName == 'te') {
|
||||
$nts++;
|
||||
}
|
||||
}
|
||||
|
||||
$nret = array(
|
||||
'id' => $tid,
|
||||
'nts' => $nts,
|
||||
'synonyms' => $allsy,
|
||||
'children' => array(),
|
||||
);
|
||||
|
||||
for ($n = $srcnode->firstChild; $n; $n = $n->nextSibling) {
|
||||
if ($n->nodeName == 'te') {
|
||||
if ($n->getAttribute('open')) {
|
||||
$nret['children'][] = $this->getBrancheJson($bid, $n, $ret['children'], $depth + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $nret;
|
||||
}
|
||||
|
||||
private function getBrancheXML($bid, $srcnode, &$html, $depth)
|
||||
|
@@ -61,7 +61,9 @@ class ApiOauth2ErrorsSubscriber implements EventSubscriberInterface
|
||||
$msg = json_encode(['msg' => $msg, 'code' => $code]);
|
||||
$event->setResponse(new Response($msg, $code, $headers));
|
||||
} else {
|
||||
$event->setResponse($this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException()));
|
||||
$response = $this->handler->createResponseBasedOnRequest($event->getRequest(), $event->getException());
|
||||
$response->headers->set('Content-Type', 'text/html');
|
||||
$event->setResponse($response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,7 +34,6 @@ class Installer
|
||||
$this->rollbackInstall($abConn, $dbConn);
|
||||
|
||||
try {
|
||||
|
||||
$this->createConfigFile($abConn, $serverName, $binaryData);
|
||||
$this->createAB();
|
||||
$this->populateRegistryData($serverName, $dataPath, $binaryData);
|
||||
@@ -134,7 +133,7 @@ class Installer
|
||||
|
||||
foreach ($appbox->tables->table as $table) {
|
||||
try {
|
||||
$sql = 'DROP TABLE `' . $table['name'] . '`';
|
||||
$sql = 'DROP TABLE IF EXISTS `' . $table['name'] . '`';
|
||||
$stmt = $abConn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
@@ -145,7 +144,7 @@ class Installer
|
||||
if (null !== $dbConn) {
|
||||
foreach ($databox->tables->table as $table) {
|
||||
try {
|
||||
$sql = 'DROP TABLE `' . $table['name'] . '`';
|
||||
$sql = 'DROP TABLE IF EXISTS `' . $table['name'] . '`';
|
||||
$stmt = $dbConn->prepare($sql);
|
||||
$stmt->execute();
|
||||
$stmt->closeCursor();
|
||||
|
@@ -10,13 +10,13 @@ class CrossDomainParser
|
||||
public function parse($file)
|
||||
{
|
||||
if (!file_exists($file)) {
|
||||
throw new RuntimeException(sprintf('File "%s" does not exist.'));
|
||||
throw new RuntimeException(sprintf('File "%s" does not exist.', $file));
|
||||
}
|
||||
|
||||
$xml = simplexml_load_file($file);
|
||||
|
||||
if (!$xml) {
|
||||
throw new RuntimeException(sprintf('File "%s" could not be parsed.'));
|
||||
throw new RuntimeException(sprintf('File "%s" could not be parsed.', $file));
|
||||
}
|
||||
|
||||
$conf = array();
|
||||
|
@@ -412,7 +412,7 @@ abstract class base implements cache_cacheableInterface
|
||||
{
|
||||
$field_stmt = $defaults_stmt = [];
|
||||
|
||||
$create_stmt = "CREATE TABLE `" . $table['name'] . "` (";
|
||||
$create_stmt = "CREATE TABLE IF NOT EXISTS `" . $table['name'] . "` (";
|
||||
|
||||
foreach ($table->fields->field as $field) {
|
||||
$isnull = trim($field->null) == "" ? "NOT NULL" : "NULL";
|
||||
|
37
lib/classes/connection/pdoStatement.php
Normal file
37
lib/classes/connection/pdoStatement.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class connection_pdoStatement implements \connection_statement
|
||||
{
|
||||
protected $statement;
|
||||
|
||||
public function __construct(\PDOStatement $statement)
|
||||
{
|
||||
$this->statement = $statement;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQueryString()
|
||||
{
|
||||
return $this->statement->queryString;
|
||||
}
|
||||
|
||||
public function execute($params = array())
|
||||
{
|
||||
return $this->statement->execute($params);
|
||||
}
|
||||
|
||||
public function __call($function_name, $parameters)
|
||||
{
|
||||
return call_user_func_array(array($this->statement, $function_name), $parameters);
|
||||
}
|
||||
}
|
52
lib/classes/connection/pdoStatementReconnectable.php
Normal file
52
lib/classes/connection/pdoStatementReconnectable.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
class connection_pdoStatementReconnectable implements \connection_statement
|
||||
{
|
||||
protected $queryString;
|
||||
protected $statement;
|
||||
protected $conn;
|
||||
|
||||
public function __construct(\connection_statement $statement, \connection_pdo $conn)
|
||||
{
|
||||
$this->statement = $statement;
|
||||
$this->conn = $conn;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQueryString()
|
||||
{
|
||||
return $this->statement->getQueryString();
|
||||
}
|
||||
|
||||
public function execute($params = array())
|
||||
{
|
||||
try {
|
||||
return $this->statement->execute($params);
|
||||
} catch (\Exception $e) {
|
||||
$unreachable = ($e->getCode() === 2006) || (false !== strpos($e->getMessage(), 'MySQL server has gone away')) || (false !== strpos($e->getMessage(), 'errno=32 Broken pipe'));
|
||||
if (!$unreachable) {
|
||||
throw $e;
|
||||
}
|
||||
$this->conn->connect();
|
||||
}
|
||||
// retry query with update statement
|
||||
$this->statement = $this->conn->prepare($this->getQueryString());
|
||||
|
||||
return $this->statement->execute($params);
|
||||
}
|
||||
|
||||
public function __call($function_name, $parameters)
|
||||
{
|
||||
return call_user_func_array(array($this->statement, $function_name), $parameters);
|
||||
}
|
||||
}
|
16
lib/classes/connection/statement.php
Normal file
16
lib/classes/connection/statement.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2014 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
interface connection_statement
|
||||
{
|
||||
public function execute($params = array());
|
||||
public function getQueryString();
|
||||
}
|
@@ -641,8 +641,9 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE log.site = :site_id
|
||||
AND log_date.action = 'download'
|
||||
AND (" . $datefilter['sql'] . ")
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
AND (" . $datefilter['sql'] . ")" .
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. "
|
||||
) AS tt
|
||||
LEFT JOIN subdef AS s ON (s.record_id = tt.record_id)
|
||||
WHERE s.name = tt.final
|
||||
@@ -715,9 +716,9 @@ class module_report_activity extends module_report
|
||||
SELECT DISTINCT(log_date.id), log_date.date AS heures
|
||||
FROM log AS log_date FORCE INDEX (date_site)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND " . $collfilter['sql'] . "
|
||||
AND log_date.site = :site_id
|
||||
WHERE " . $datefilter['sql'] . "" .
|
||||
(('' !== $collfilter['sql']) ? "AND (" . $collfilter['sql'] . ")" : '')
|
||||
. " AND log_date.site = :site_id
|
||||
) AS tt";
|
||||
|
||||
$stmt = $conn->prepare($sql);
|
||||
@@ -747,12 +748,10 @@ class module_report_activity extends module_report
|
||||
{
|
||||
$databox = $app['phraseanet.appbox']->get_databox($sbas_id);
|
||||
$conn = $databox->get_connection();
|
||||
$result = [];
|
||||
$res = [];
|
||||
$datefilter =
|
||||
module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter =
|
||||
module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
$result = array();
|
||||
$res = array();
|
||||
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
|
||||
$collfilter = module_report_sqlfilter::constructCollectionFilter($app, $list_coll_id);
|
||||
|
||||
$params = [':site_id' => $app['conf']->get(['main', 'key'])];
|
||||
$params = array_merge($params, $datefilter['params'], $collfilter['params']);
|
||||
@@ -763,9 +762,9 @@ class module_report_activity extends module_report
|
||||
SELECT DISTINCT(log_date.id), DATE_FORMAT( log_date.date, '%Y-%m-%d' ) AS ddate
|
||||
FROM log AS log_date FORCE INDEX (date_site) INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? (" AND (" . $collfilter['sql'] . ")") : '')
|
||||
. ") AS tt
|
||||
GROUP by tt.ddate
|
||||
ORDER BY tt.ddate ASC";
|
||||
|
||||
@@ -807,9 +806,9 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.usrid
|
||||
ORDER BY nb DESC";
|
||||
|
||||
@@ -848,9 +847,9 @@ class module_report_activity extends module_report
|
||||
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_search.log_id = log_date.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND log_date.site = :site_id
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
AND log_date.site = :site_id" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.search
|
||||
ORDER BY nb DESC";
|
||||
|
||||
@@ -889,9 +888,9 @@ class module_report_activity extends module_report
|
||||
FROM (log_view)
|
||||
INNER JOIN log AS log_date FORCE INDEX (date_site) ON (log_view.log_id = log_date.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log_date.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . "
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
WHERE " . $datefilter['sql'] . "" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY referrer
|
||||
ORDER BY nb_view DESC ";
|
||||
|
||||
@@ -933,8 +932,9 @@ class module_report_activity extends module_report
|
||||
FROM (log_docs AS log_date)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add' " .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. "
|
||||
) AS tt
|
||||
GROUP BY tt.ddate
|
||||
ORDER BY activity ASC ";
|
||||
@@ -969,9 +969,9 @@ class module_report_activity extends module_report
|
||||
FROM (log_docs AS log_date)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'edit'
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'edit'" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.ddate
|
||||
ORDER BY activity ASC ";
|
||||
|
||||
@@ -1006,9 +1006,9 @@ class module_report_activity extends module_report
|
||||
FROM (log_docs AS log_date)
|
||||
INNER JOIN log FORCE INDEX (date_site) ON (log_date.log_id = log.id)
|
||||
INNER JOIN log_colls FORCE INDEX (couple) ON (log.id = log_colls.log_id)
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'
|
||||
AND (" . $collfilter['sql'] . ")
|
||||
) AS tt
|
||||
WHERE " . $datefilter['sql'] . " AND log_date.action = 'add'" .
|
||||
(('' !== $collfilter['sql']) ? " AND (" . $collfilter['sql'] . ")" : '')
|
||||
. ") AS tt
|
||||
GROUP BY tt.usrid
|
||||
ORDER BY nb ASC ";
|
||||
|
||||
|
@@ -50,7 +50,11 @@ class module_report_sqlfilter
|
||||
$coll_filter[] = 'log_colls.coll_id = ' . $val;
|
||||
}
|
||||
}
|
||||
$ret['sql'] = ' (' . implode(' OR ', array_unique($coll_filter)) . ') ';
|
||||
$collections = array_unique($coll_filter);
|
||||
|
||||
if (count($collections) > 0) {
|
||||
$ret['sql'] = ' (' . implode(' OR ', $collections) . ') ';
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
@@ -66,15 +70,15 @@ class module_report_sqlfilter
|
||||
|
||||
$params = [':log_site' => $this->app['conf']->get(['main', 'key'])];
|
||||
|
||||
if ($this->filter['date']) {
|
||||
if ($this->filter['date'] && $this->filter['date']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['date']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['date']['params']);
|
||||
}
|
||||
if ($this->filter['user']) {
|
||||
if ($this->filter['user'] && $this->filter['user']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['user']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['user']['params']);
|
||||
}
|
||||
if ($this->filter['collection']) {
|
||||
if ($this->filter['collection'] && $this->filter['collection']['sql'] !== '') {
|
||||
$finalfilter .= $this->filter['collection']['sql'] . ' AND ';
|
||||
$params = array_merge($params, $this->filter['collection']['params']);
|
||||
}
|
||||
@@ -174,9 +178,12 @@ class module_report_sqlfilter
|
||||
|
||||
$n ++;
|
||||
}
|
||||
$filter_user = ['sql' => implode(' AND ', $filter), 'params' => $params];
|
||||
|
||||
$this->filter['user'] = $filter_user;
|
||||
if (count($filter) > 0) {
|
||||
$filter_user = array('sql' => implode(' AND ', $filter), 'params' => $params);
|
||||
$this->filter['user'] = $filter_user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -201,7 +208,11 @@ class module_report_sqlfilter
|
||||
}
|
||||
}
|
||||
|
||||
$this->filter['collection'] = ['sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => []];
|
||||
$collections = array_unique($coll_filter);
|
||||
|
||||
if (count($collections) > 0) {
|
||||
$this->filter['collection'] = array('sql' => ' (' . implode(' OR ', array_unique($coll_filter)) . ') ', 'params' => array());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -219,7 +230,9 @@ class module_report_sqlfilter
|
||||
$params[":record_fil" . $n] = phrasea::collFromBas($this->app, $val);
|
||||
$n ++;
|
||||
}
|
||||
$this->filter['record'] = ['sql' => implode(' OR ', $dl_coll_filter), 'params' => $params];
|
||||
if (count($dl_coll_filter) > 0) {
|
||||
$this->filter['record'] = array('sql' => implode(' OR ', $dl_coll_filter), 'params' => $params);
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
|
@@ -340,7 +340,7 @@ function T_acceptCandidates_OK()
|
||||
+ j.parm['sbid'] + '\\.'
|
||||
+ j.parm['id'].replace(new RegExp("\\.", "g"), "\\."); // escape les '.' pour jquery
|
||||
|
||||
$(z).replaceWith(j.html);
|
||||
$(z).children('ul').eq(0).replaceWith(j.html);
|
||||
}
|
||||
, "json");
|
||||
}
|
||||
@@ -634,12 +634,7 @@ function Xclick(e)
|
||||
{
|
||||
if(is_ctrl_key(e))
|
||||
{
|
||||
var oldField = ul.attr('field');
|
||||
ul.remove();
|
||||
if(oldField)
|
||||
li.append('<ul field="'+oldField+'">{{ 'prod::thesaurusTab:tree:loading' | trans }}</ul>');
|
||||
else
|
||||
li.append('<ul>{{ 'prod::thesaurusTab:tree:loading' | trans }}</ul>');
|
||||
ul.text("{{ 'prod::thesaurusTab:tree:loading' | trans }}");
|
||||
li.removeAttr('loaded');
|
||||
}
|
||||
|
||||
@@ -654,7 +649,8 @@ function Xclick(e)
|
||||
zurl += "&sortsy=1";
|
||||
$.get(zurl, [], function(j)
|
||||
{
|
||||
li.replaceWith(j.html);
|
||||
ul.replaceWith(j.html);
|
||||
li.attr('loaded', '1');
|
||||
}
|
||||
, "json");
|
||||
}
|
||||
|
@@ -30,23 +30,20 @@ class InstallerTest extends \PhraseanetTestCase
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Setup\Installer
|
||||
*/
|
||||
public function testInstall()
|
||||
{
|
||||
$app = new Application('test');
|
||||
$app->bindRoutes();
|
||||
|
||||
$parser = new Parser();
|
||||
$connDatas = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/configuration.yml'));
|
||||
$credentials = $connDatas['main']['database'];
|
||||
$config = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/configuration.yml'));
|
||||
$credentials = $config['main']['database'];
|
||||
|
||||
$config = __DIR__ . '/configuration.yml';
|
||||
$compiled = __DIR__ . '/configuration.yml.php';
|
||||
$configFile = __DIR__ . '/configuration.yml';
|
||||
$compiledFile = __DIR__ . '/configuration.yml.php';
|
||||
|
||||
@unlink($config);
|
||||
@unlink($compiled);
|
||||
@unlink($configFile);
|
||||
@unlink($compiledFile);
|
||||
|
||||
$app['configuration.store'] = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true);
|
||||
|
||||
@@ -67,7 +64,13 @@ class InstallerTest extends \PhraseanetTestCase
|
||||
]);
|
||||
$dbConn->connect();
|
||||
|
||||
$template = 'en';
|
||||
// empty databases
|
||||
$stmt = $abConn->prepare('DROP DATABASE ab_unitTests; CREATE DATABASE ab_unitTests');
|
||||
$stmt->execute();
|
||||
$stmt = $abConn->prepare('DROP DATABASE db_unitTests; CREATE DATABASE db_unitTests');
|
||||
$stmt->execute();
|
||||
unset($stmt);
|
||||
|
||||
$dataPath = __DIR__ . '/../../../../../datas/';
|
||||
|
||||
$installer = new Installer($app);
|
||||
@@ -85,7 +88,7 @@ class InstallerTest extends \PhraseanetTestCase
|
||||
$this->assertArrayHasKey('key', $conf['main']);
|
||||
$this->assertGreaterThan(10, strlen($conf['main']['key']));
|
||||
|
||||
@unlink($config);
|
||||
@unlink($compiled);
|
||||
@unlink($configFile);
|
||||
@unlink($compiledFile);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user