mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 13:03:20 +00:00
Merge with 3.6
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,5 +1,6 @@
|
|||||||
/nbproject/*
|
/nbproject/*
|
||||||
/config/*
|
/config/*
|
||||||
|
.DS_Store
|
||||||
!.gitignore
|
!.gitignore
|
||||||
.DS_Store
|
.DS_Store
|
||||||
/vendor/.composer/
|
/vendor/.composer/
|
||||||
|
15
README.md
15
README.md
@@ -5,25 +5,16 @@ Phraseanet 3.5 - Digital Asset Management application
|
|||||||
|
|
||||||
Metadatas Management (include Thesaurus and DublinCore Mapping)
|
Metadatas Management (include Thesaurus and DublinCore Mapping)
|
||||||
Search Engine (Sphinx Search Integration)
|
Search Engine (Sphinx Search Integration)
|
||||||
RestFull APIS (See Developer Documentation http://docs.phraseanet.com/Devel)
|
RestFull APIS (See Developer Documentation https://docs.phraseanet.com/3.6/Devel)
|
||||||
Bridge to Youtube/Dailymotion/Flickr
|
Bridge to Youtube/Dailymotion/Flickr
|
||||||
|
|
||||||
#Documentation :
|
#Documentation :
|
||||||
|
|
||||||
http://docs.phraseanet.com
|
https://docs.phraseanet.com/3.6/
|
||||||
|
|
||||||
#Easy Installation
|
#Easy Installation
|
||||||
|
|
||||||
**Fetch Sources**
|
Get the latests sources here https://github.com/alchemy-fr/Phraseanet/downloads
|
||||||
|
|
||||||
<pre>
|
|
||||||
|
|
||||||
git clone git://github.com/alchemy-fr/Phraseanet.git Phraseanet
|
|
||||||
cd Phraseanet
|
|
||||||
./vendors.php
|
|
||||||
|
|
||||||
</pre>
|
|
||||||
|
|
||||||
|
|
||||||
**Setup your webserver**
|
**Setup your webserver**
|
||||||
|
|
||||||
|
@@ -1,308 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
require_once __DIR__ . "/../lib/bootstrap.php";
|
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
require($registry->get('GV_RootPath') . "lib/classes/deprecated/getargs.php"); // le parser d'arguments de la ligne de commande
|
|
||||||
|
|
||||||
function printHelp(&$argt, &$conn)
|
|
||||||
{
|
|
||||||
print_usage($argt);
|
|
||||||
}
|
|
||||||
|
|
||||||
$argt = array(
|
|
||||||
"--help" => array("set" => false, "values" => array(), "usage" => " : this help")
|
|
||||||
, "--sbas-id" => array("set" => false, "values" => array(), "usage" => "=sbas_id : sbas_id to check")
|
|
||||||
, "--field" => array("set" => false, "values" => array(), "usage" => "(=field | : delete this field from records")
|
|
||||||
, "--showstruct" => array("set" => false, "values" => array(), "usage" => "")
|
|
||||||
);
|
|
||||||
|
|
||||||
function help()
|
|
||||||
{
|
|
||||||
global $argv;
|
|
||||||
printf("usage: %s [options]\n", $argv[0]);
|
|
||||||
print("options:\n");
|
|
||||||
print("\t--help : this help\n");
|
|
||||||
print("\t--sbas=sbas_id : sbas to change (if --help, list fields)\n");
|
|
||||||
print("\t--showstruct : show structure changes and quit\n");
|
|
||||||
print("\t--field=fieldname : delete fieldname from records\n");
|
|
||||||
print("\t--field=\"oldname:newname\" : rename field oldname to newname into records\n");
|
|
||||||
print("\t[--field=...] : --field=... can be repeated\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
// on commence par se conncter e application box
|
|
||||||
$allbas = array();
|
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM sbas";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $tmprow)
|
|
||||||
{
|
|
||||||
$allbas["B" . $tmprow["sbas_id"]] = $tmprow;
|
|
||||||
}
|
|
||||||
|
|
||||||
$error = false;
|
|
||||||
|
|
||||||
if (!parse_cmdargs($argt, $err))
|
|
||||||
{
|
|
||||||
help();
|
|
||||||
print($err);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($argt["--help"]["set"])
|
|
||||||
{
|
|
||||||
help();
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$argt['--sbas-id']['set'])
|
|
||||||
{
|
|
||||||
print("missing option 'sbas-id'.\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields = null;
|
|
||||||
if ($argt['--field']['set'])
|
|
||||||
{
|
|
||||||
foreach ($argt["--field"]["values"] as $f)
|
|
||||||
{
|
|
||||||
$f = explode(':', $f);
|
|
||||||
$f[] = null;
|
|
||||||
$fields[] = array('from' => $f[0], 'to' => $f[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$domstruct = null;
|
|
||||||
|
|
||||||
if ($argt["--sbas-id"]["set"])
|
|
||||||
{
|
|
||||||
$sbas_id = $argt["--sbas-id"]["values"][0];
|
|
||||||
// sauf erreur, on a l'adresse du serveur distant
|
|
||||||
$row = null;
|
|
||||||
if (array_key_exists("B" . $sbas_id, $allbas))
|
|
||||||
$row = $allbas["B" . $sbas_id];
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$databox = databox::get_instance($sbas_id);
|
|
||||||
$tfields = array();
|
|
||||||
|
|
||||||
if ($argt["--help"]["set"])
|
|
||||||
echo("fields of sbas=" . $sbas_id . " :\n");
|
|
||||||
|
|
||||||
$domstruct = $databox->get_dom_structure();
|
|
||||||
$xp = $databox->get_xpath_structure();
|
|
||||||
|
|
||||||
if ($domstruct)
|
|
||||||
{
|
|
||||||
$xp = new DOMXPath($domstruct);
|
|
||||||
|
|
||||||
$xf = @$xp->query('/record/description/*');
|
|
||||||
foreach ($xf as $f)
|
|
||||||
{
|
|
||||||
$tfields[] = $f->nodeName;
|
|
||||||
if ($argt["--help"]["set"])
|
|
||||||
printf("\t%s \n", $f->nodeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($argt["--showstruct"]["set"])
|
|
||||||
printf("structure, before:\n...\n%s\n...\n", $domstruct->saveXML($xp->query('/record/description')->item(0)));
|
|
||||||
|
|
||||||
if (is_array($fields))
|
|
||||||
{
|
|
||||||
foreach ($fields as $f)
|
|
||||||
{
|
|
||||||
$fok = true;
|
|
||||||
$ff = $tf = null;
|
|
||||||
if (!($ff = @$xp->query('/record/description/' . $f['from'])))
|
|
||||||
{
|
|
||||||
echo("ERROR : bad xml fieldname '" . $f['from'] . "'\n");
|
|
||||||
$error = true;
|
|
||||||
$fok = false;
|
|
||||||
}
|
|
||||||
if ($f['to'] && !($tf = @$xp->query('/record/description/' . $f['to'])))
|
|
||||||
{
|
|
||||||
echo("ERROR : bad xml fieldname '" . $f['to'] . "'\n");
|
|
||||||
$error = true;
|
|
||||||
$fok = false;
|
|
||||||
}
|
|
||||||
if ($fok)
|
|
||||||
{
|
|
||||||
if (in_array($f['from'], $tfields))
|
|
||||||
{
|
|
||||||
if ($f['to'])
|
|
||||||
{
|
|
||||||
if ($tf->length == 0)
|
|
||||||
{
|
|
||||||
$oldf = $ff->item(0);
|
|
||||||
$newf = $domstruct->createElement($f['to']);
|
|
||||||
foreach ($oldf->attributes as $atn => $atv)
|
|
||||||
{
|
|
||||||
$newf->setAttribute($atn, $atv->value);
|
|
||||||
}
|
|
||||||
$oldf->parentNode->replaceChild($newf, $oldf);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo("WARNING : field '" . $f['to'] . "' exists into structure, will be replace by '" . $f['from'] . "\n");
|
|
||||||
foreach ($tf as $n)
|
|
||||||
$n->parentNode->removeChild($n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach ($ff as $n)
|
|
||||||
$n->parentNode->removeChild($n);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo("WARNING : unknown field '" . $f['from'] . "' in structure\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($argt["--showstruct"]["set"])
|
|
||||||
printf("structure, after:\n...\n%s\n...\n", $domstruct->saveXML($xp->query('/record/description')->item(0)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo("ERROR : sql reading structure\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Excpetion $e)
|
|
||||||
{
|
|
||||||
echo("ERROR accessing database\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
echo("ERROR : unknown sbas_id " . $sbas_id . "\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($argt["--help"]["set"])
|
|
||||||
{
|
|
||||||
print("BASES :\n");
|
|
||||||
foreach ($allbas as $bas)
|
|
||||||
printf("%5d : %s @ %s:%s\n", $bas["sbas_id"], $bas["dbname"], $bas["host"], $bas["port"]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($error || $argt["--showstruct"]["set"])
|
|
||||||
{
|
|
||||||
flush();
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!$argt['--field']['set'])
|
|
||||||
{
|
|
||||||
print("ERROR : missing option 'field'\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($domstruct instanceof DOMDocument)
|
|
||||||
{
|
|
||||||
$databox->saveStructure($domstruct);
|
|
||||||
}
|
|
||||||
|
|
||||||
$dom = new DOMDocument();
|
|
||||||
$dom->formatOutput = true;
|
|
||||||
$dom->preserveWhiteSpace = false;
|
|
||||||
|
|
||||||
$recChanged = 0;
|
|
||||||
|
|
||||||
$sql = 'SELECT record_id, xml FROM record ORDER BY record_id DESC';
|
|
||||||
$connbas = $databox->get_connection();
|
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $row)
|
|
||||||
{
|
|
||||||
printf("%d \r", $row['record_id']);
|
|
||||||
|
|
||||||
if ($dom->loadXML($row['xml']))
|
|
||||||
{
|
|
||||||
$oldxml = $dom->saveXML();
|
|
||||||
|
|
||||||
$xp = new DOMXPath($dom);
|
|
||||||
foreach ($fields as $f)
|
|
||||||
{
|
|
||||||
if (($tn = @$xp->query('/record/description/' . $f['from'])))
|
|
||||||
{
|
|
||||||
foreach ($tn as $oldn)
|
|
||||||
{
|
|
||||||
if ($f['to'])
|
|
||||||
{
|
|
||||||
$newn = $dom->createElement($f['to']);
|
|
||||||
foreach ($oldn->childNodes as $n)
|
|
||||||
$newn->appendChild($n);
|
|
||||||
$oldn->parentNode->replaceChild($newn, $oldn);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$oldn->parentNode->removeChild($oldn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$newxml = $dom->saveXML();
|
|
||||||
|
|
||||||
if ($newxml != $oldxml)
|
|
||||||
{
|
|
||||||
// printf("apres :\n%s\n", $dom->saveXML());
|
|
||||||
|
|
||||||
$sql = 'UPDATE record SET xml=:xml, moddate=NOW()
|
|
||||||
WHERE record_id = :record_id';
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute(array(':xml' => $newxml, ':record_id' => $row['record_id']));
|
|
||||||
$stmt->closeCursor();
|
|
||||||
$recChanged++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("ERR (rid=%s) : bad xml \n", $row['record_id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($recChanged > 0)
|
|
||||||
printf("%s record(s) changed, please reindex database\n", $recChanged);
|
|
||||||
else
|
|
||||||
printf("no record(s) changed\n");
|
|
||||||
|
|
19
bin/console
19
bin/console
@@ -52,11 +52,19 @@ try
|
|||||||
|
|
||||||
$app->add(new module_console_aboutAuthors('about:authors'));
|
$app->add(new module_console_aboutAuthors('about:authors'));
|
||||||
$app->add(new module_console_aboutLicense('about:license'));
|
$app->add(new module_console_aboutLicense('about:license'));
|
||||||
|
|
||||||
|
$app->add(new module_console_checkExtension('check:extension'));
|
||||||
|
|
||||||
$app->add(new module_console_systemUpgrade('system:upgrade'));
|
$app->add(new module_console_systemUpgrade('system:upgrade'));
|
||||||
|
|
||||||
|
$app->add(new module_console_sphinxGenerateSuggestion('sphinx:generate-suggestions'));
|
||||||
|
|
||||||
$app->add(new module_console_systemMailCheck('system:mailCheck'));
|
$app->add(new module_console_systemMailCheck('system:mailCheck'));
|
||||||
$app->add(new module_console_systemBackupDB('system:backupDB'));
|
$app->add(new module_console_systemBackupDB('system:backupDB'));
|
||||||
$app->add(new module_console_systemClearCache('system:clearCache'));
|
$app->add(new module_console_systemClearCache('system:clearCache'));
|
||||||
$app->add(new module_console_systemTemplateGenerator('system:templateGenerator'));
|
$app->add(new module_console_systemTemplateGenerator('system:templateGenerator'));
|
||||||
|
$app->add(new module_console_systemExport('system:export'));
|
||||||
|
|
||||||
$app->add(new module_console_taskrun('task:run'));
|
$app->add(new module_console_taskrun('task:run'));
|
||||||
$app->add(new module_console_tasklist('task:list'));
|
$app->add(new module_console_tasklist('task:list'));
|
||||||
$app->add(new module_console_schedulerState('scheduler:state'));
|
$app->add(new module_console_schedulerState('scheduler:state'));
|
||||||
@@ -64,12 +72,21 @@ try
|
|||||||
$app->add(new module_console_schedulerStart('scheduler:start'));
|
$app->add(new module_console_schedulerStart('scheduler:start'));
|
||||||
$app->add(new module_console_fileConfigCheck('check:config'));
|
$app->add(new module_console_fileConfigCheck('check:config'));
|
||||||
$app->add(new module_console_fileEnsureProductionSetting('check:ensureProductionSettings'));
|
$app->add(new module_console_fileEnsureProductionSetting('check:ensureProductionSettings'));
|
||||||
|
$app->add(new module_console_fileEnsureDevSetting('check:ensureDevSettings'));
|
||||||
$app->add(new module_console_systemConfigCheck('check:system'));
|
$app->add(new module_console_systemConfigCheck('check:system'));
|
||||||
|
|
||||||
|
|
||||||
|
$app->add(new module_console_fieldsList('fields:list'));
|
||||||
|
$app->add(new module_console_fieldsDelete('fields:delete'));
|
||||||
|
$app->add(new module_console_fieldsRename('fields:rename'));
|
||||||
|
$app->add(new module_console_fieldsMerge('fields:merge'));
|
||||||
|
|
||||||
|
|
||||||
$result_code = $app->run();
|
$result_code = $app->run();
|
||||||
}
|
}
|
||||||
catch (Exception $e)
|
catch (Exception $e)
|
||||||
{
|
{
|
||||||
echo "an error occured";
|
echo "an error occured";var_dump($e->getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
exit($result_code);
|
exit($result_code);
|
@@ -1,290 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
require_once __DIR__ . "/../lib/bootstrap.php";
|
|
||||||
define('DOCPERDIR', 100);
|
|
||||||
|
|
||||||
|
|
||||||
$tfields = array(
|
|
||||||
'Titre' => array('field_out' => 'Titre')
|
|
||||||
, 'Categories' => array('field_out' => 'Categories')
|
|
||||||
, 'MotsCles' => array('field_out' => 'MotsCles')
|
|
||||||
, 'Date' => array('field_out' => 'Date')
|
|
||||||
, 'Photographe' => array('field_out' => 'Photographe')
|
|
||||||
, 'Ville' => array('field_out' => 'Ville')
|
|
||||||
, 'Pays' => array('field_out' => 'Pays')
|
|
||||||
, 'Reference' => array('field_out' => 'Reference')
|
|
||||||
, 'Credit' => array('field_out' => 'Credit')
|
|
||||||
, 'Legende' => array('field_out' => 'Legende')
|
|
||||||
);
|
|
||||||
|
|
||||||
$status = array(
|
|
||||||
'4' => '4'
|
|
||||||
, '5' => '5'
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
require($registry->get('GV_RootPath') . "lib/classes/deprecated/getargs.php"); // le parser d'arguments de la ligne de commande
|
|
||||||
|
|
||||||
function printHelp(&$argt, &$conn)
|
|
||||||
{
|
|
||||||
print_usage($argt);
|
|
||||||
}
|
|
||||||
|
|
||||||
$argt = array(
|
|
||||||
"--help" => array("set" => false, "values" => array(), "usage" => " : cette aide")
|
|
||||||
, "--sbas-id" => array("set" => false, "values" => array(), "usage" => "=sbas_id : sbas_id de la base a ventiler")
|
|
||||||
, "--coll-id" => array("set" => false, "values" => array(), "usage" => "=coll_id : coll_id a ventiler")
|
|
||||||
, "--out" => array("set" => false, "values" => array(), "usage" => "=path : repertoire d'export")
|
|
||||||
, "--limit" => array("set" => false, "values" => array(), "usage" => "=n : nombre max de records a exporter (pour test)")
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$allbas = array();
|
|
||||||
|
|
||||||
$conn = connection::getPDOConnection();
|
|
||||||
|
|
||||||
$sql = "SELECT * FROM sbas";
|
|
||||||
$stmt = $conn->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
foreach ($rs as $tmprow)
|
|
||||||
{
|
|
||||||
$allbas["B" . $tmprow["sbas_id"]] = $tmprow;
|
|
||||||
}
|
|
||||||
|
|
||||||
$error = false;
|
|
||||||
|
|
||||||
if (!parse_cmdargs($argt, $err) || $argt["--help"]["set"])
|
|
||||||
{
|
|
||||||
print($err);
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$argt["--sbas-id"]["set"])
|
|
||||||
{
|
|
||||||
print("parametre 'sbas-id' obligatoire.\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!$argt["--out"]["set"])
|
|
||||||
{
|
|
||||||
print("parametre 'out' obligatoire.\n");
|
|
||||||
$error = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($error)
|
|
||||||
{
|
|
||||||
print_usage($argt);
|
|
||||||
print("BASES :\n");
|
|
||||||
foreach ($allbas as $bas)
|
|
||||||
printf("%5d : %s @ %s:%s\n", $bas["sbas_id"], $bas["dbname"], $bas["host"], $bas["port"]);
|
|
||||||
flush();
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$root = p4string::addEndSlash($argt["--out"]["values"][0]);
|
|
||||||
if (!is_dir($root))
|
|
||||||
{
|
|
||||||
print("repertoire out '" . $root . "' absent.\nABANDON\n");
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if ($argt["--limit"]["set"])
|
|
||||||
{
|
|
||||||
$limit = (int) ($argt["--limit"]["values"][0]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$limit = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sbas_id = $argt["--sbas-id"]["values"][0];
|
|
||||||
// sauf erreur, on a l'adresse du serveur distant
|
|
||||||
|
|
||||||
$row = null;
|
|
||||||
if (array_key_exists("B" . $sbas_id, $allbas))
|
|
||||||
$row = $allbas["B" . $sbas_id];
|
|
||||||
if ($row)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$connbas = connection::getPDOConnection($sbas_id);
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
echo("\n\nerreur d'acces a la base\n\nABANDON ! :(\n\n");
|
|
||||||
flush();
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
echo("Connexion a la base ok\n\n");
|
|
||||||
|
|
||||||
|
|
||||||
$root .= $row["dbname"];
|
|
||||||
@mkdir($root);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$ndig = ceil(log10(DOCPERDIR - 1));
|
|
||||||
define('DIRFMT1', '%0' . (8 - $ndig) . 'd');
|
|
||||||
define('DIRFMT2', '%0' . $ndig . 'd');
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$sql = 'SELECT xml, path, file, record.record_id
|
|
||||||
FROM record
|
|
||||||
INNER JOIN subdef
|
|
||||||
ON subdef.record_id=record.record_id AND subdef.name="document"';
|
|
||||||
|
|
||||||
$params = array();
|
|
||||||
|
|
||||||
if ($argt["--coll-id"]["set"])
|
|
||||||
{
|
|
||||||
$sql .= ' WHERE coll_id = :coll_id';
|
|
||||||
$params[':coll_id'] = (int) ($argt["--coll-id"]["values"][0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$sql .= ' ORDER BY record.record_id ASC';
|
|
||||||
|
|
||||||
if ($limit !== NULL)
|
|
||||||
$sql .= ' LIMIT ' . (int) $limit;
|
|
||||||
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute($params);
|
|
||||||
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$idir = -1;
|
|
||||||
$idoc = DOCPERDIR - 1;
|
|
||||||
$nrec = count($rs);
|
|
||||||
|
|
||||||
foreach ($rs as $row)
|
|
||||||
{
|
|
||||||
printf("%d \r", --$nrec);
|
|
||||||
|
|
||||||
if (($sxml = simplexml_load_string($row['xml'])))
|
|
||||||
{
|
|
||||||
if (($orgdocname = (string) ($sxml->doc['originalname'])) != '')
|
|
||||||
{
|
|
||||||
if (file_exists($phfile = p4string::addEndSlash($row['path']) . $row['file']))
|
|
||||||
{
|
|
||||||
if (++$idoc == DOCPERDIR)
|
|
||||||
{
|
|
||||||
$idir++;
|
|
||||||
$dir1name = sprintf(DIRFMT1, $idir);
|
|
||||||
@mkdir($root . '/' . $dir1name);
|
|
||||||
$idoc = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// $dir2name = sprintf(DIRFMT2, $idoc);
|
|
||||||
$dir2name = sprintf('rid_%08d', $row['record_id']);
|
|
||||||
@mkdir($outdir = ($root . '/' . $dir1name . '/' . $dir2name));
|
|
||||||
|
|
||||||
// print($phfile . "\n");
|
|
||||||
if (copy($phfile, $outdir . '/' . $orgdocname))
|
|
||||||
{
|
|
||||||
|
|
||||||
// file_put_contents($outdir . '/' . $orgdocname . '-old.xml', $row['xml']);
|
|
||||||
|
|
||||||
foreach ($tfields as $fname => $field)
|
|
||||||
$tfields[$fname]['values'] = array();
|
|
||||||
|
|
||||||
foreach ($sxml->description->children() as $fname => $fvalue)
|
|
||||||
{
|
|
||||||
// printf("%s : %s\n", $fname, $fvalue);
|
|
||||||
if (isset($tfields[$fname]))
|
|
||||||
$tfields[$fname]['values'][] = $fvalue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$domout = new DOMDocument('1.0', 'UTF-8');
|
|
||||||
$domout->standalone = true;
|
|
||||||
$domout->preserveWhiteSpace = false;
|
|
||||||
|
|
||||||
$element = $domout->createElement('record');
|
|
||||||
|
|
||||||
$domrec = $domout->appendChild($element);
|
|
||||||
$domdesc = $domrec->appendChild($domout->createElement('description'));
|
|
||||||
foreach ($tfields as $kfield => $field)
|
|
||||||
{
|
|
||||||
foreach ($field['values'] as $value)
|
|
||||||
{
|
|
||||||
$domfield = $domdesc->appendChild($domout->createElement($field['field_out']));
|
|
||||||
$domfield->appendChild($domout->createTextNode($value));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$sqlS = 'SELECT bin(status) as statin FROM record
|
|
||||||
WHERE record_id = :record_id"' . $row['record_id'] . '"';
|
|
||||||
$stmt = $connbas->prepare($sqlS);
|
|
||||||
$stmt->execute(array(':record_id' => $row['record_id']));
|
|
||||||
$statin = $stmt->fetch(PDO::FETCH_ASSOC);
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$statin = $statin ? strrev($statin['statin']) : false;
|
|
||||||
|
|
||||||
$statout = '0000000000000000000000000000000000000000000000000000000000001111';
|
|
||||||
if ($statin)
|
|
||||||
{
|
|
||||||
foreach ($status as $sIn => $sOut)
|
|
||||||
{
|
|
||||||
if (substr($statin, $sIn, 1) == '1')
|
|
||||||
{
|
|
||||||
$statout = substr_replace($statout, '1', (63 - (int) $sOut), 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$domstatus = $domrec->appendChild($domout->createElement('status'));
|
|
||||||
$domstatus->appendChild($domout->createTextNode($statout));
|
|
||||||
|
|
||||||
|
|
||||||
$domout->save($outdir . '/' . $orgdocname . '.xml');
|
|
||||||
unset($domout);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("\nERR (rid=%s) : erreur de copie du document '%s'\n", $row['record_id'], $phfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("\nERR (rid=%s) : document '%s' manquant\n", $row['record_id'], $phfile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("\nERR (rid=%s) : orgdocname manquant\n", $row['record_id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
printf("\nERR (rid=%s) : xml illisible manquant\n", $row['record_id']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@@ -1,104 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
include __DIR__ . '/../lib/bootstrap.php';
|
|
||||||
define('FREQ_THRESHOLD', 10);
|
|
||||||
define('SUGGEST_DEBUG', 0);
|
|
||||||
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
|
|
||||||
function test_number($number)
|
|
||||||
{
|
|
||||||
$datas = preg_match('/^[0-9]+$/', $number, $matches);
|
|
||||||
|
|
||||||
return (count($matches) > 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/// build a list of trigrams for a given keywords
|
|
||||||
function BuildTrigrams($keyword)
|
|
||||||
{
|
|
||||||
$t = "__" . $keyword . "__";
|
|
||||||
|
|
||||||
$trigrams = "";
|
|
||||||
for ($i = 0; $i < strlen($t) - 2; $i++)
|
|
||||||
$trigrams .= substr($t, $i, 3) . " ";
|
|
||||||
|
|
||||||
return $trigrams;
|
|
||||||
}
|
|
||||||
|
|
||||||
function BuildDictionarySQL($in)
|
|
||||||
{
|
|
||||||
$out = '';
|
|
||||||
|
|
||||||
|
|
||||||
$n = 0;
|
|
||||||
$lines = explode("\n", $in);
|
|
||||||
foreach ($lines as $line)
|
|
||||||
{
|
|
||||||
if (trim($line) === '')
|
|
||||||
continue;
|
|
||||||
list ( $keyword, $freq ) = split(" ", trim($line));
|
|
||||||
|
|
||||||
if ($freq < FREQ_THRESHOLD || strstr($keyword, "_") !== false || strstr($keyword, "'") !== false)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (test_number($keyword))
|
|
||||||
{
|
|
||||||
echo "dismiss number keyword : $keyword\n";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (mb_strlen($keyword) < 3)
|
|
||||||
{
|
|
||||||
echo "dismiss too short keyword : $keyword \n";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$trigrams = BuildTrigrams($keyword);
|
|
||||||
|
|
||||||
if ($n++)
|
|
||||||
$out .= ",\n";
|
|
||||||
$out .= "( $n, '$keyword', '$trigrams', $freq )";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (trim($out) !== '')
|
|
||||||
{
|
|
||||||
$out = "INSERT INTO suggest VALUES " . $out . ";";
|
|
||||||
}
|
|
||||||
|
|
||||||
return $out;
|
|
||||||
}
|
|
||||||
|
|
||||||
$params = phrasea::sbas_params();
|
|
||||||
|
|
||||||
foreach ($params as $sbas_id => $p)
|
|
||||||
{
|
|
||||||
$index = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname'])));
|
|
||||||
$tmp_file = $registry->get('GV_RootPath') . 'tmp/dict' . $index . '.txt';
|
|
||||||
|
|
||||||
echo "process $index " . $sbas_id . " \n";
|
|
||||||
|
|
||||||
$cmd = '/usr/local/bin/indexer metadatas' . $index . ' --buildstops ' . $tmp_file . ' 1000000 --buildfreqs';
|
|
||||||
exec($cmd);
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$connbas = connection::getPDOConnection($sbas_id);
|
|
||||||
}
|
|
||||||
catch (Exception $e)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$sql = 'TRUNCATE suggest';
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$stmt->closeCursor();
|
|
||||||
|
|
||||||
$sql = BuildDictionarySQL(file_get_contents($tmp_file));
|
|
||||||
|
|
||||||
if (trim($sql) !== '')
|
|
||||||
{
|
|
||||||
$stmt = $connbas->prepare($sql);
|
|
||||||
$stmt->execute();
|
|
||||||
$stmt->closeCursor();
|
|
||||||
}
|
|
||||||
unlink($tmp_file);
|
|
||||||
}
|
|
@@ -1,493 +0,0 @@
|
|||||||
<?php
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
define('USR_ID', 4);
|
|
||||||
|
|
||||||
set_time_limit(300);
|
|
||||||
|
|
||||||
require(__DIR__ . "/../lib/bootstrap.php");
|
|
||||||
|
|
||||||
phrasea::headers();
|
|
||||||
$registry = registry::get_instance();
|
|
||||||
|
|
||||||
|
|
||||||
$request = http_request::getInstance();
|
|
||||||
$parm = $request->get_parms("qry");
|
|
||||||
if (!$parm['qry'])
|
|
||||||
$parm['qry'] = 'last';
|
|
||||||
?>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<title>Test extension</title>
|
|
||||||
<style type="text/css">
|
|
||||||
DIV.code
|
|
||||||
{
|
|
||||||
position:relative;
|
|
||||||
background-color:#eeeeee;
|
|
||||||
margin:6px;
|
|
||||||
margin-top:60px;
|
|
||||||
border:3px black dotted;
|
|
||||||
font-size:16px;
|
|
||||||
padding:5px;
|
|
||||||
}
|
|
||||||
DIV.var
|
|
||||||
{
|
|
||||||
position:relative;
|
|
||||||
overflow:auto;
|
|
||||||
background-color:#eeeeee;
|
|
||||||
margin:3px;
|
|
||||||
max-height:250px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
</head>
|
|
||||||
<body style="margin:20px;">
|
|
||||||
<a href="#SEARCHFORM">...recherche...</a>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
print("<br><b>Fonction de la DLL : </b>");
|
|
||||||
$result = "";
|
|
||||||
$allfunc = get_extension_funcs("phrasea2");
|
|
||||||
foreach ($allfunc as $oneFunc)
|
|
||||||
$result.= $oneFunc . "\n";
|
|
||||||
print("<br><textarea style=\"width:400px;height:150px;\">$result</textarea> ");
|
|
||||||
|
|
||||||
|
|
||||||
$sessid = null;
|
|
||||||
|
|
||||||
function showtime()
|
|
||||||
{
|
|
||||||
static $last_t = false;
|
|
||||||
$t = microtime(true);
|
|
||||||
if ($last_t !== false)
|
|
||||||
printf("Durée : %0.5f", $t - $last_t);
|
|
||||||
$last_t = $t;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
// ------------------ phrasea_testutf8 --------------------
|
|
||||||
|
|
||||||
$code = '$ret = phrasea_testutf8();' ;
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
die();
|
|
||||||
*/
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_usebase --------------------
|
|
||||||
/*
|
|
||||||
$code = '$ret = phrasea_usebase("'.GV_db.'");' ;
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
*/
|
|
||||||
// ------------------ phrasea_list_bases --------------------
|
|
||||||
|
|
||||||
/*
|
|
||||||
// ------------------ phrasea_conn --------------------
|
|
||||||
$code = '$ret = phrasea_conn("127.0.0.1", "3306", "root", "", "'.GV_db.'");' ;
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//// ------------------ phrasea_list_bases --------------------
|
|
||||||
//
|
|
||||||
//$code = '$lb = phrasea_list_bases();';
|
|
||||||
//
|
|
||||||
//dumpcode($code);
|
|
||||||
//eval($code);
|
|
||||||
//dumpvar($lb, '$lb');
|
|
||||||
//
|
|
||||||
//showtime();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_open_session --------------------
|
|
||||||
|
|
||||||
$code = '$sessid = phrasea_create_session(' . USR_ID . ');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
print("<i> il faut que ca renvoie une valeur de session </i>");
|
|
||||||
dumpvar($sessid, '$sessid');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
// ------------------ phrasea_open_session --------------------
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$code = '$ph_session = phrasea_open_session($sessid, ' . USR_ID . ');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
print("<i> il faut que ca renvoie un tableau session </i>");
|
|
||||||
dumpvar($ph_session, '$ph_session');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
//die();
|
|
||||||
|
|
||||||
|
|
||||||
if ($ph_session)
|
|
||||||
{
|
|
||||||
$sessid = $ph_session["session_id"];
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_open_session --------------------
|
|
||||||
|
|
||||||
$code = '$ph_session = phrasea_open_session(' . $sessid . ', ' . USR_ID . ');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
print("<i> il faut que ca renvoie la meme valeur de session </i>");
|
|
||||||
dumpvar($ph_session, '$ph_session');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
// pour interroger plus bas, on doit avoir un usr_id et avoir injecte ses 'mask' (droits dans appbox/xbascollusr) dans les dbox/collusr
|
|
||||||
// !!!!! pour simplifier, on injecte un usr bidon (id=0) avec des mask '0' (tout voir) !!!!!
|
|
||||||
// on se register sur 4 collections
|
|
||||||
// $rmax = 99999;
|
|
||||||
// $basok = 0;
|
|
||||||
// foreach ($lb["bases"] as $base)
|
|
||||||
// {
|
|
||||||
// if ($base["online"] == true)
|
|
||||||
// {
|
|
||||||
// $connbas = connection::getPDOConnection($base['sbas_id']);
|
|
||||||
//
|
|
||||||
// foreach ($base["collections"] as $coll_id => $coll)
|
|
||||||
// {
|
|
||||||
// if ($rmax-- > 0)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// // ------------------ phrasea_register_base --------------------
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// $code = '$rb = phrasea_register_base(' . $sessid . ', ' . $coll['base_id'] . ', "", "");';
|
|
||||||
//
|
|
||||||
// dumpcode($code);
|
|
||||||
// eval($code);
|
|
||||||
// print("<i> register sur base connue doit retourner 'true' </i>");
|
|
||||||
// dumpvar($rb, '$rb');
|
|
||||||
//
|
|
||||||
// if ($rb)
|
|
||||||
// {
|
|
||||||
// echo "<font color=#00BB00>TRUE (comportement normal)</font><br><br>";
|
|
||||||
//
|
|
||||||
// showtime();
|
|
||||||
//
|
|
||||||
// $sql = "REPLACE INTO collusr (site, usr_id, coll_id, mask_and, mask_xor)
|
|
||||||
// VALUES (:site, :usr_id, :coll_id, 0, 0)";
|
|
||||||
//
|
|
||||||
// $params = array(
|
|
||||||
// ':site' => $registry->get('GV_sit')
|
|
||||||
// , ':usr_id' => USR_ID
|
|
||||||
// , ':coll_id' => $coll['coll_id']
|
|
||||||
// );
|
|
||||||
//
|
|
||||||
// $stmt = $connbas->prepare($sql);
|
|
||||||
// $stmt->execute($params);
|
|
||||||
// $stmt->closeCursor();
|
|
||||||
//
|
|
||||||
// $basok++;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// echo "<font color=#FF0000>FALSE (comportement anormal)</font><br><br>";
|
|
||||||
//
|
|
||||||
// showtime();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
if ($basok == 0)
|
|
||||||
{
|
|
||||||
printf("pas de base/coll ok, fin");
|
|
||||||
phrasea_close_session($sessid);
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// // ------------------ phrasea_register_base (fake) --------------------
|
|
||||||
//
|
|
||||||
// $code = '$rb = phrasea_register_base(' . $sessid . ', 123456, "", "");';
|
|
||||||
//
|
|
||||||
// dumpcode($code);
|
|
||||||
// eval($code);
|
|
||||||
// print("<i> register sur xbas bidon connue doit retourner 'false' </i>");
|
|
||||||
// dumpvar($rb, '$rb');
|
|
||||||
//
|
|
||||||
// if (!$rb)
|
|
||||||
// echo "<font color=#00BB00>FALSE (comportement normal)</font><br><br>";
|
|
||||||
// else
|
|
||||||
// echo "<font color=#FF0000>TRUE (comportement anormal)</font><br><br>";
|
|
||||||
//
|
|
||||||
// showtime();
|
|
||||||
|
|
||||||
$basok += $rb ? 1 : 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_open_session --------------------
|
|
||||||
|
|
||||||
$code = '$ph_session = phrasea_open_session(' . $sessid . ', ' . USR_ID . ');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
print("<i> phrasea_open_session(...) apres $basok phrasea_register_base(...) doit retourner les bases/collections registered </i>");
|
|
||||||
dumpvar($ph_session, '$ph_session');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_subdefs --------------------
|
|
||||||
//
|
|
||||||
// $code = '$subdef = phrasea_subdefs(' . $sessid . ', 58, 18863);';
|
|
||||||
//
|
|
||||||
// dumpcode($code);
|
|
||||||
// eval($code);
|
|
||||||
// dumpvar($subdef, '$subdef');
|
|
||||||
//
|
|
||||||
// showtime();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_clear_cache --------------------
|
|
||||||
|
|
||||||
$code = '$ret = phrasea_clear_cache(' . $sessid . ');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
?>
|
|
||||||
<a name="SEARCHFORM"></a>
|
|
||||||
<hr>
|
|
||||||
<form method="POST">
|
|
||||||
recherche : <input type="text" name="qry" value="<?php echo $parm['qry'] ?>">
|
|
||||||
<input type="submit" value="ok">
|
|
||||||
</form>
|
|
||||||
<?php
|
|
||||||
$result = "";
|
|
||||||
|
|
||||||
/*
|
|
||||||
$tbases = array();
|
|
||||||
foreach($ph_session["bases"] as $base)
|
|
||||||
{
|
|
||||||
$tcoll = array();
|
|
||||||
foreach($phbase["collections"] as $coll)
|
|
||||||
$tcoll[] = $coll["coll_id"];
|
|
||||||
if(sizeof($tcoll) > 0) // au - une coll de la base etait dispo
|
|
||||||
{
|
|
||||||
$kbase = "S" . $phbase["xbas_id"];
|
|
||||||
$tbases[$kbase] = array();
|
|
||||||
$tbases[$kbase]["xbas_id"] = $phbase["xbas_id"];
|
|
||||||
$tbases[$kbase]["searchcoll"] = $tcoll;
|
|
||||||
|
|
||||||
$qp = new searchEngine_adapter_phrasea_queryParser();
|
|
||||||
$treeq = $qp->parsequery($parm['qry']);
|
|
||||||
$arrayq = $qp->makequery($treeq);
|
|
||||||
|
|
||||||
$tbases[$kbase]["arrayq"] = $arrayq;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
$tbases = array();
|
|
||||||
foreach ($ph_session["bases"] as $kphbase => $phbase)
|
|
||||||
{
|
|
||||||
$tcoll = array();
|
|
||||||
foreach ($phbase["collections"] as $coll)
|
|
||||||
{
|
|
||||||
$tcoll[] = 0 + $coll["base_id"]; // le tableau de colls doit contenir des int
|
|
||||||
}
|
|
||||||
if (sizeof($tcoll) > 0) // au - une coll de la base etait cochee
|
|
||||||
{
|
|
||||||
$kbase = "S" . $phbase["sbas_id"];
|
|
||||||
$tbases[$kbase] = array();
|
|
||||||
$tbases[$kbase]["sbas_id"] = $phbase["sbas_id"];
|
|
||||||
$tbases[$kbase]["searchcoll"] = $tcoll;
|
|
||||||
$tbases[$kbase]["mask_xor"] = $tbases[$kbase]["mask_and"] = 0;
|
|
||||||
|
|
||||||
$qp = new searchEngine_adapter_phrasea_queryParser();
|
|
||||||
$treeq = $qp->parsequery($parm['qry']);
|
|
||||||
$arrayq = $qp->makequery($treeq);
|
|
||||||
|
|
||||||
$tbases[$kbase]["arrayq"] = $arrayq;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_query2 --------------------
|
|
||||||
/*
|
|
||||||
$nbanswers = 0;
|
|
||||||
foreach($tbases as $kb=>$base)
|
|
||||||
{
|
|
||||||
$tbases[$kb]["results"] = NULL;
|
|
||||||
|
|
||||||
set_time_limit(120);
|
|
||||||
//$tbases[$kb]["results"] = phrasea_query2($ph_session["session_id"], $base["base_id"], $base["searchcoll"], $base["arrayq"], GV_sit, USR_ID, TRUE);
|
|
||||||
$tbases[$kb]["results"] = phrasea_query2($ph_session["session_id"], $base["base_id"], $base["searchcoll"], $base["arrayq"], GV_sit, (string)(USR_ID) , TRUE , (0) );
|
|
||||||
|
|
||||||
if($tbases[$kb]["results"])
|
|
||||||
{
|
|
||||||
$nbanswers += $tbases[$kb]["results"]["nbanswers"];
|
|
||||||
|
|
||||||
$result .= var_export($tbases[$kb]["results"],true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var_dump($result);
|
|
||||||
*/
|
|
||||||
$nbanswers = 0;
|
|
||||||
foreach ($tbases as $kb => $base)
|
|
||||||
{
|
|
||||||
$ret = null;
|
|
||||||
$tbases[$kb]["results"] = NULL;
|
|
||||||
|
|
||||||
set_time_limit(120);
|
|
||||||
|
|
||||||
$code = "\$ret = phrasea_query2(\n";
|
|
||||||
$code .= "\t\t\t" . $ph_session["session_id"] . "\t\t// ses_id \n";
|
|
||||||
$code .= "\t\t\t, " . $base["sbas_id"] . "\t\t// bsas_id \n";
|
|
||||||
$code .= "\t\t\t, " . my_var_export($base["searchcoll"]) . "\t\t// coll_id's \n";
|
|
||||||
$code .= "\t\t\t, " . my_var_export($base["arrayq"]) . "\t\t// arrayq \n";
|
|
||||||
$code .= "\t\t\t, '" . $registry->get('GV_sit') . "'\t\t// site \n";
|
|
||||||
$code .= "\t\t\t, " . USR_ID . " \t\t// usr_id ! \n";
|
|
||||||
$code .= "\t\t\t, FALSE \t\t// nocache \n";
|
|
||||||
$code .= "\t\t\t, PHRASEA_MULTIDOC_DOCONLY\n";
|
|
||||||
// $code .= "\t\t\t, PHRASEA_MULTIDOC_REGONLY\n" ;
|
|
||||||
// $code .= "\t\t\t, array('DATE') \t\t// sort fields \n" ;
|
|
||||||
$code .= "\t\t);";
|
|
||||||
// $code .= '$base["arrayq"], "'.GV_sit.'", '.USR_ID.', FALSE, PHRASEA_MULTIDOC_DOCONLY, array("DATE")); // USR_ID=0...' ;
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
print("<br><i>si les bases ne sont pas vides on devrait obtenir le nb de resultats en face de \"nbanswers\"</i>");
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
|
|
||||||
// $tbases[$kb]["results"] = phrasea_query2($ph_session["session_id"], $base["xbas_id"], $base["searchcoll"], $base["arrayq"], GV_sit, USR_ID, FALSE, PHRASEA_MULTIDOC_DOCONLY, array('DATE')); // USR_ID=0...
|
|
||||||
|
|
||||||
if ($ret)
|
|
||||||
{
|
|
||||||
$tbases[$kb]["results"] = $ret;
|
|
||||||
|
|
||||||
$nbanswers += $tbases[$kb]["results"]["nbanswers"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
if (function_exists('phrasea_save_cache'))
|
|
||||||
{
|
|
||||||
// ------------------ phrasea_save_cache --------------------
|
|
||||||
|
|
||||||
$code = '$ret = phrasea_save_cache(' . $ph_session["session_id"] . ');';
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// die();
|
|
||||||
// ------------------ phrasea_fetch_results --------------------
|
|
||||||
|
|
||||||
$code = '$rs = phrasea_fetch_results(' . $ph_session["session_id"] . ', 1, 20, true, \'[[em]]\', \'[[/em]]\');';
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($rs, '$rs');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------ phrasea_close_session --------------------
|
|
||||||
/*
|
|
||||||
$code = '$ret = phrasea_close_session('.$ph_session["session_id"].');' ;
|
|
||||||
|
|
||||||
dumpcode($code);
|
|
||||||
eval($code);
|
|
||||||
dumpvar($ret, '$ret');
|
|
||||||
|
|
||||||
showtime();
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
function dumpcode($code)
|
|
||||||
{
|
|
||||||
print("\n" . '<div class="code">');
|
|
||||||
$h = highlight_string('<?' . 'php ' . $code . '?' . '>', true);
|
|
||||||
$h = str_replace('<?php', '', $h);
|
|
||||||
$h = str_replace('?>', '', $h);
|
|
||||||
print($h);
|
|
||||||
print('</div>' . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function dumpvar($var, $varname)
|
|
||||||
{
|
|
||||||
print("\n" . '<div class="var">');
|
|
||||||
$h = highlight_string('<?' . 'php ' . var_export($var, true) . '?' . '>', true);
|
|
||||||
$h = str_replace('<?php', '', $h);
|
|
||||||
$h = str_replace('?>', '', $h);
|
|
||||||
print('<b>' . $varname . ' is : </b>' . $h);
|
|
||||||
print('</div>' . "\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
function my_var_export($var)
|
|
||||||
{
|
|
||||||
$var = str_replace("\n", "", var_export($var, true));
|
|
||||||
$var = str_replace(" ", " ", $var);
|
|
||||||
$var = str_replace(" ", " ", $var);
|
|
||||||
$var = str_replace(" ", " ", $var);
|
|
||||||
$var = str_replace(" ", " ", $var);
|
|
||||||
$var = str_replace(" => ", "=>", $var);
|
|
||||||
$var = str_replace("array ( ", "array(", $var);
|
|
||||||
$var = str_replace(", )", ",)", $var);
|
|
||||||
$var = str_replace(",)", ")", $var);
|
|
||||||
|
|
||||||
return($var);
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
@@ -34,8 +34,9 @@ $finder
|
|||||||
->name('.gitmodules')
|
->name('.gitmodules')
|
||||||
->name('.gitignore')
|
->name('.gitignore')
|
||||||
->name('check_cs.php')
|
->name('check_cs.php')
|
||||||
|
->name('cleaner.php')
|
||||||
->name('launchpadToLocales.php')
|
->name('launchpadToLocales.php')
|
||||||
->name('localesToLaunchpad.php')
|
->name('localesToLaunchPad.php')
|
||||||
->name('pom.xml')
|
->name('pom.xml')
|
||||||
->name('vendors.php')
|
->name('vendors.php')
|
||||||
->name('builder.php')
|
->name('builder.php')
|
||||||
|
@@ -41,8 +41,8 @@ prod:
|
|||||||
|
|
||||||
template_engine: twig
|
template_engine: twig
|
||||||
orm: doctrine_prod
|
orm: doctrine_prod
|
||||||
cache: memcache_cache
|
cache: array_cache
|
||||||
opcodecache: apc_cache
|
opcodecache: array_cache
|
||||||
|
|
||||||
##############
|
##############
|
||||||
# TEST #
|
# TEST #
|
||||||
|
@@ -52,11 +52,11 @@ Orm:
|
|||||||
dbal: main_connexion
|
dbal: main_connexion
|
||||||
cache:
|
cache:
|
||||||
query:
|
query:
|
||||||
service: Cache\apc_cache
|
service: Cache\array_cache
|
||||||
result:
|
result:
|
||||||
service: Cache\memcache_cache
|
service: Cache\array_cache
|
||||||
metadata:
|
metadata:
|
||||||
service: Cache\apc_cache
|
service: Cache\array_cache
|
||||||
|
|
||||||
TemplateEngine:
|
TemplateEngine:
|
||||||
#Define a template engine service
|
#Define a template engine service
|
||||||
|
@@ -38,7 +38,7 @@ echo "ok !";
|
|||||||
# Valid link ?
|
# Valid link ?
|
||||||
|
|
||||||
echo -n "Check link validity : ";
|
echo -n "Check link validity : ";
|
||||||
wget --no-check-certificate $instance -o /dev/null
|
wget --no-check-certificate $instance --output-document=/dev/null
|
||||||
if [ ! $? -eq 0 ]
|
if [ ! $? -eq 0 ]
|
||||||
then
|
then
|
||||||
echo "Link does not exists.";
|
echo "Link does not exists.";
|
||||||
|
@@ -307,7 +307,7 @@ return call_user_func(function()
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$route = '/records/search/';
|
$route = '/records/search/';
|
||||||
$app->post(
|
$app->match(
|
||||||
$route, function() use ($app)
|
$route, function() use ($app)
|
||||||
{
|
{
|
||||||
$result = $app['api']->search_records($app['request']);
|
$result = $app['api']->search_records($app['request']);
|
||||||
@@ -317,6 +317,19 @@ return call_user_func(function()
|
|||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
$route = '/records/{databox_id}/{record_id}/caption/';
|
||||||
|
$app->get(
|
||||||
|
$route, function($databox_id, $record_id) use ($app)
|
||||||
|
{
|
||||||
|
$result = $app['api']->caption_records($app['request'], $databox_id, $record_id);
|
||||||
|
|
||||||
|
return $app['response']($result);
|
||||||
|
}
|
||||||
|
)->assert('databox_id', '\d+')->assert('record_id', '\d+');
|
||||||
|
|
||||||
|
$app->get('/records/{any_id}/{anyother_id}/caption/', $bad_request_exception);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
* Route : /records/DATABOX_ID/RECORD_ID/metadatas/FORMAT/
|
||||||
*
|
*
|
||||||
|
@@ -232,7 +232,7 @@ return call_user_func(
|
|||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
$basket_collection = $repository->findActiveByUser(
|
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||||
$app['Core']->getAuthenticatedUser()
|
$app['Core']->getAuthenticatedUser()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -290,7 +290,7 @@ return call_user_func(
|
|||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
$basket_collection = $repository->findActiveByUser(
|
$basket_collection = $repository->findActiveValidationAndBasketByUser(
|
||||||
$app['Core']->getAuthenticatedUser()
|
$app['Core']->getAuthenticatedUser()
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -570,7 +570,7 @@ return call_user_func(
|
|||||||
$expires = new \DateTime('+10 days');
|
$expires = new \DateTime('+10 days');
|
||||||
$url = $appbox->get_registry()->get('GV_ServerName')
|
$url = $appbox->get_registry()->get('GV_ServerName')
|
||||||
. 'lightbox/index.php?LOG=' . \random::getUrlToken(
|
. 'lightbox/index.php?LOG=' . \random::getUrlToken(
|
||||||
'validate'
|
\random::TYPE_VALIDATE
|
||||||
, $basket->getValidation()->getInitiator()->get_id()
|
, $basket->getValidation()->getInitiator()->get_id()
|
||||||
, $expires
|
, $expires
|
||||||
, $basket->getId()
|
, $basket->getId()
|
||||||
|
@@ -207,6 +207,7 @@ return call_user_func(function()
|
|||||||
if ($oauth2_adapter->isNativeApp($params['redirect_uri']))
|
if ($oauth2_adapter->isNativeApp($params['redirect_uri']))
|
||||||
{
|
{
|
||||||
$params = $oauth2_adapter->finishNativeClientAuthorization($app_authorized, $params);
|
$params = $oauth2_adapter->finishNativeClientAuthorization($app_authorized, $params);
|
||||||
|
$params['user'] = $app['user'];
|
||||||
$html = $twig->render("api/auth/native_app_access_token.twig", $params);
|
$html = $twig->render("api/auth/native_app_access_token.twig", $params);
|
||||||
|
|
||||||
return new Response($html, 200, array("content-type" => "text/html"));
|
return new Response($html, 200, array("content-type" => "text/html"));
|
||||||
|
@@ -67,8 +67,10 @@ return call_user_func(function()
|
|||||||
$app->get('/', function() use ($app)
|
$app->get('/', function() use ($app)
|
||||||
{
|
{
|
||||||
if ($app['install'] === true)
|
if ($app['install'] === true)
|
||||||
|
|
||||||
return $app->redirect('/setup/installer/');
|
return $app->redirect('/setup/installer/');
|
||||||
if ($app['upgrade'] === true)
|
if ($app['upgrade'] === true)
|
||||||
|
|
||||||
return $app->redirect('/setup/upgrader/');
|
return $app->redirect('/setup/upgrader/');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -34,6 +34,7 @@ class ArrayCache extends DoctrineArray implements Cache
|
|||||||
{
|
{
|
||||||
throw new Exception(sprintf('Unable to find key %s', $id));
|
throw new Exception(sprintf('Unable to find key %s', $id));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->fetch($id);
|
return $this->fetch($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -71,6 +71,8 @@ class Manager
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
$configuration = $this->core->getConfiguration()->getService($service_name);
|
$configuration = $this->core->getConfiguration()->getService($service_name);
|
||||||
|
$service = Builder::create($this->core, $service_name, $configuration);
|
||||||
|
$driver = $service->getDriver();
|
||||||
$write = true;
|
$write = true;
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
@@ -78,14 +80,14 @@ class Manager
|
|||||||
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||||
array('type' => 'Cache\\ArrayCache')
|
array('type' => 'Cache\\ArrayCache')
|
||||||
);
|
);
|
||||||
|
$service = Builder::create($this->core, $service_name, $configuration);
|
||||||
|
$driver = $service->getDriver();
|
||||||
$write = false;
|
$write = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$service = Builder::create($this->core, $service_name, $configuration);
|
|
||||||
|
|
||||||
if ($this->hasChange($cacheKey, $service_name))
|
if ($this->hasChange($cacheKey, $service_name))
|
||||||
{
|
{
|
||||||
$service->getDriver()->flushAll();
|
$service->getDriver()->flush();
|
||||||
if ($write)
|
if ($write)
|
||||||
{
|
{
|
||||||
$this->registry[$cacheKey] = $service_name;
|
$this->registry[$cacheKey] = $service_name;
|
||||||
@@ -108,7 +110,7 @@ class Manager
|
|||||||
$this->registry[$name] = $driver;
|
$this->registry[$name] = $driver;
|
||||||
|
|
||||||
$datas = sprintf("#LastUpdate: %s\n", $date->format(DATE_ISO8601))
|
$datas = sprintf("#LastUpdate: %s\n", $date->format(DATE_ISO8601))
|
||||||
. $this->parser->dump($this->registry);
|
. $this->parser->dump($this->registry, 6);
|
||||||
|
|
||||||
file_put_contents($this->cacheFile->getPathname(), $datas);
|
file_put_contents($this->cacheFile->getPathname(), $datas);
|
||||||
}
|
}
|
||||||
|
@@ -99,18 +99,6 @@ class Description implements ControllerProviderInterface
|
|||||||
$field->set_dces_element($dces_element);
|
$field->set_dces_element($dces_element);
|
||||||
$field->save();
|
$field->save();
|
||||||
|
|
||||||
if ($request->get('regname') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regname();
|
|
||||||
}
|
|
||||||
if ($request->get('regdate') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regdate();
|
|
||||||
}
|
|
||||||
if ($request->get('regdesc') == $field->get_id())
|
|
||||||
{
|
|
||||||
$field->set_regdesc();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
@@ -413,10 +413,24 @@ class Basket implements ControllerProviderInterface
|
|||||||
|
|
||||||
$basket->addBasketElement($basket_element);
|
$basket->addBasketElement($basket_element);
|
||||||
|
|
||||||
|
if(null !== $validationSession = $basket->getValidation())
|
||||||
|
{
|
||||||
|
|
||||||
|
$participants = $validationSession->getParticipants();
|
||||||
|
|
||||||
|
foreach($participants as $participant)
|
||||||
|
{
|
||||||
|
$validationData = new \Entities\ValidationData();
|
||||||
|
$validationData->setParticipant($participant);
|
||||||
|
$validationData->setBasketElement($basket_element);
|
||||||
|
|
||||||
|
$em->persist($validationData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$n++;
|
$n++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->merge($basket);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@@ -183,10 +183,12 @@ class Push implements ControllerProviderInterface
|
|||||||
|
|
||||||
$appbox = \appbox::get_instance($app['Core']);
|
$appbox = \appbox::get_instance($app['Core']);
|
||||||
|
|
||||||
$push_name = $request->get(
|
$push_name = $request->get('name');
|
||||||
'name'
|
|
||||||
, sprintf(_('Push from %s'), $user->get_display_name())
|
if (trim($push_name) === '')
|
||||||
);
|
{
|
||||||
|
$push_name = sprintf(_('Push from %s'), $user->get_display_name());
|
||||||
|
}
|
||||||
|
|
||||||
$push_description = $request->get('push_description');
|
$push_description = $request->get('push_description');
|
||||||
|
|
||||||
@@ -231,6 +233,9 @@ class Push implements ControllerProviderInterface
|
|||||||
$BasketElement->setRecord($element);
|
$BasketElement->setRecord($element);
|
||||||
$BasketElement->setBasket($Basket);
|
$BasketElement->setBasket($Basket);
|
||||||
|
|
||||||
|
$em->persist($BasketElement);
|
||||||
|
|
||||||
|
$Basket->addBasketElement($BasketElement);
|
||||||
|
|
||||||
if ($receiver['HD'])
|
if ($receiver['HD'])
|
||||||
{
|
{
|
||||||
@@ -248,15 +253,13 @@ class Push implements ControllerProviderInterface
|
|||||||
, \ACL::GRANT_ACTION_PUSH
|
, \ACL::GRANT_ACTION_PUSH
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->persist($BasketElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$url = $registry->get('GV_ServerName')
|
$url = $registry->get('GV_ServerName')
|
||||||
. 'lightbox/index.php?LOG='
|
. 'lightbox/index.php?LOG='
|
||||||
. \random::getUrlToken('view', $user_receiver->get_id(), null, $Basket->getId());
|
. \random::getUrlToken(\random::TYPE_VIEW, $user_receiver->get_id(), null, $Basket->getId());
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'from' => $user->get_id()
|
'from' => $user->get_id()
|
||||||
@@ -322,10 +325,12 @@ class Push implements ControllerProviderInterface
|
|||||||
|
|
||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
$validation_name = $request->get(
|
$validation_name = $request->get('name');
|
||||||
'name'
|
|
||||||
, sprintf(_('Validation from %s'), $user->get_display_name())
|
if (trim($validation_name) === '')
|
||||||
);
|
{
|
||||||
|
$validation_name = sprintf(_('Validation from %s'), $user->get_display_name());
|
||||||
|
}
|
||||||
|
|
||||||
$validation_description = $request->get('validation_description');
|
$validation_description = $request->get('validation_description');
|
||||||
|
|
||||||
@@ -362,6 +367,8 @@ class Push implements ControllerProviderInterface
|
|||||||
$BasketElement->setBasket($Basket);
|
$BasketElement->setBasket($Basket);
|
||||||
|
|
||||||
$em->persist($BasketElement);
|
$em->persist($BasketElement);
|
||||||
|
|
||||||
|
$Basket->addBasketElement($BasketElement);
|
||||||
}
|
}
|
||||||
$em->flush();
|
$em->flush();
|
||||||
}
|
}
|
||||||
@@ -485,7 +492,7 @@ class Push implements ControllerProviderInterface
|
|||||||
|
|
||||||
$url = $registry->get('GV_ServerName')
|
$url = $registry->get('GV_ServerName')
|
||||||
. 'lightbox/index.php?LOG='
|
. 'lightbox/index.php?LOG='
|
||||||
. \random::getUrlToken('view', $participant_user->get_id(), null, $Basket->getId());
|
. \random::getUrlToken(\random::TYPE_VIEW, $participant_user->get_id(), null, $Basket->getId());
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
'from' => $user->get_id()
|
'from' => $user->get_id()
|
||||||
|
@@ -205,11 +205,9 @@ class Query implements ControllerProviderInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$json['results'] = $twig->render($template, array(
|
$json['results'] = $twig->render($template, array(
|
||||||
'results' => $result,
|
'results' => $result,
|
||||||
'GV_social_tools' => $registry->get('GV_social_tools'),
|
'GV_social_tools' => $registry->get('GV_social_tools'),
|
||||||
'array_selected' => explode(';', $request->get('sel')),
|
|
||||||
'highlight' => $search_engine->get_query(),
|
'highlight' => $search_engine->get_query(),
|
||||||
'searchEngine' => $search_engine,
|
'searchEngine' => $search_engine,
|
||||||
'suggestions' => $prop
|
'suggestions' => $prop
|
||||||
|
@@ -18,6 +18,7 @@ use Symfony\Component\HttpFoundation\Request,
|
|||||||
Symfony\Component\HttpFoundation\Response,
|
Symfony\Component\HttpFoundation\Response,
|
||||||
Symfony\Component\HttpFoundation\RedirectResponse,
|
Symfony\Component\HttpFoundation\RedirectResponse,
|
||||||
Symfony\Component\HttpKernel\Exception\HttpException,
|
Symfony\Component\HttpKernel\Exception\HttpException,
|
||||||
|
Symfony\Component\Finder\Finder,
|
||||||
Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||||
use Alchemy\Phrasea\Helper;
|
use Alchemy\Phrasea\Helper;
|
||||||
|
|
||||||
@@ -40,49 +41,56 @@ class Root implements ControllerProviderInterface
|
|||||||
\User_Adapter::updateClientInfos(1);
|
\User_Adapter::updateClientInfos(1);
|
||||||
|
|
||||||
$appbox = \appbox::get_instance($app['Core']);
|
$appbox = \appbox::get_instance($app['Core']);
|
||||||
$css = array();
|
|
||||||
$cssfile = false;
|
|
||||||
$registry = $app['Core']->getRegistry();
|
$registry = $app['Core']->getRegistry();
|
||||||
|
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = $app['Core']->getAuthenticatedUser();
|
$user = $app['Core']->getAuthenticatedUser();
|
||||||
|
|
||||||
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
$cssPath = $registry->get('GV_RootPath') . 'www/skins/prod/';
|
||||||
|
|
||||||
if ($hdir = opendir($cssPath))
|
$css = array();
|
||||||
|
$cssfile = false;
|
||||||
|
|
||||||
|
$finder = new Finder();
|
||||||
|
|
||||||
|
$iterator = $finder
|
||||||
|
->directories()
|
||||||
|
->depth(0)
|
||||||
|
->filter(function(\SplFileInfo $fileinfo)
|
||||||
{
|
{
|
||||||
while (false !== ($file = readdir($hdir)))
|
return ctype_xdigit($fileinfo->getBasename());
|
||||||
|
})
|
||||||
|
->in($cssPath);
|
||||||
|
|
||||||
|
foreach ($iterator as $dir)
|
||||||
{
|
{
|
||||||
if (substr($file, 0, 1) == "." || mb_strtolower($file) == "cvs")
|
$baseName = $dir->getBaseName();
|
||||||
continue;
|
$css[$baseName] = $baseName;
|
||||||
if (is_dir($cssPath . $file))
|
|
||||||
{
|
|
||||||
$css[$file] = $file;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir($hdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$cssfile = $user->getPrefs('css');
|
$cssfile = $user->getPrefs('css');
|
||||||
|
|
||||||
if (!$cssfile && isset($css['000000']))
|
if (!$cssfile && isset($css['000000']))
|
||||||
|
{
|
||||||
$cssfile = '000000';
|
$cssfile = '000000';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$user_feeds = \Feed_Collection::load_all($appbox, $user);
|
$user_feeds = \Feed_Collection::load_all($appbox, $user);
|
||||||
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
$feeds = array_merge(array($user_feeds->get_aggregate()), $user_feeds->get_feeds());
|
||||||
|
|
||||||
$srt = 'name asc';
|
|
||||||
|
|
||||||
|
|
||||||
$thjslist = "";
|
$thjslist = "";
|
||||||
|
|
||||||
$queries_topics = '';
|
$queries_topics = '';
|
||||||
|
|
||||||
if ($registry->get('GV_client_render_topics') == 'popups')
|
if ($registry->get('GV_client_render_topics') == 'popups')
|
||||||
$queries_topics = queries::dropdown_topics();
|
{
|
||||||
|
$queries_topics = \queries::dropdown_topics();
|
||||||
|
}
|
||||||
elseif ($registry->get('GV_client_render_topics') == 'tree')
|
elseif ($registry->get('GV_client_render_topics') == 'tree')
|
||||||
|
{
|
||||||
$queries_topics = \queries::tree_topics();
|
$queries_topics = \queries::tree_topics();
|
||||||
|
}
|
||||||
|
|
||||||
$sbas = $bas2sbas = array();
|
$sbas = $bas2sbas = array();
|
||||||
|
|
||||||
foreach ($appbox->get_databoxes() as $databox)
|
foreach ($appbox->get_databoxes() as $databox)
|
||||||
{
|
{
|
||||||
$sbas_id = $databox->get_sbas_id();
|
$sbas_id = $databox->get_sbas_id();
|
||||||
@@ -131,8 +139,6 @@ class Root implements ControllerProviderInterface
|
|||||||
'GV_bitly_key' => $registry->get('GV_bitly_key')
|
'GV_bitly_key' => $registry->get('GV_bitly_key')
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return new Response($out);
|
return new Response($out);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -56,7 +56,9 @@ class Story implements ControllerProviderInterface
|
|||||||
|
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord'))
|
if (!$user->ACL()->has_right_on_base($collection->get_base_id(), 'canaddrecord'))
|
||||||
|
{
|
||||||
throw new \Exception_Forbidden('You can not create a story on this collection');
|
throw new \Exception_Forbidden('You can not create a story on this collection');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$system_file = new \system_file(
|
$system_file = new \system_file(
|
||||||
@@ -66,26 +68,53 @@ class Story implements ControllerProviderInterface
|
|||||||
|
|
||||||
$Story = \record_adapter::create($collection, $system_file, false, true);
|
$Story = \record_adapter::create($collection, $system_file, false, true);
|
||||||
|
|
||||||
|
foreach (explode(';', $request->get('lst')) as $sbas_rec)
|
||||||
|
{
|
||||||
|
$sbas_rec = explode('_', $sbas_rec);
|
||||||
|
|
||||||
|
if (count($sbas_rec) !== 2)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$record = new \record_adapter($sbas_rec[0], $sbas_rec[1]);
|
||||||
|
|
||||||
|
if (!$user->ACL()->has_access_to_base($record->get_base_id())
|
||||||
|
&& !$user->ACL()->has_hd_grant($record)
|
||||||
|
&& !$user->ACL()->has_preview_grant($record))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Story->hasChild($record))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$Story->appendChild($record);
|
||||||
|
}
|
||||||
|
|
||||||
$metadatas = array();
|
$metadatas = array();
|
||||||
|
|
||||||
foreach ($collection->get_databox()->get_meta_structure() as $meta)
|
foreach ($collection->get_databox()->get_meta_structure() as $meta)
|
||||||
{
|
{
|
||||||
if ($meta->is_regname())
|
if ($meta->get_thumbtitle())
|
||||||
|
{
|
||||||
$value = $request->get('name');
|
$value = $request->get('name');
|
||||||
elseif ($meta->is_regdesc())
|
}
|
||||||
$value = $request->get('description');
|
|
||||||
else
|
else
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$metadatas[] = array(
|
$metadatas[] = array(
|
||||||
'meta_struct_id' => $meta->get_id()
|
'meta_struct_id' => $meta->get_id()
|
||||||
, 'meta_id' => null
|
, 'meta_id' => null
|
||||||
, 'value' => $value
|
, 'value' => $value
|
||||||
);
|
);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$Story->set_metadatas($metadatas)
|
$Story->set_metadatas($metadatas)->rebuild_subdefs();
|
||||||
->rebuild_subdefs();
|
|
||||||
|
|
||||||
$StoryWZ = new \Entities\StoryWZ();
|
$StoryWZ = new \Entities\StoryWZ();
|
||||||
$StoryWZ->setUser($user);
|
$StoryWZ->setUser($user);
|
||||||
|
@@ -286,7 +286,6 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
|
|
||||||
$list->setName($list_name);
|
$list->setName($list_name);
|
||||||
|
|
||||||
$em->merge($list);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
@@ -459,7 +458,7 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
$list->addUsrListEntry($entry);
|
$list->addUsrListEntry($entry);
|
||||||
|
|
||||||
$em->persist($entry);
|
$em->persist($entry);
|
||||||
$em->merge($list);
|
|
||||||
$inserted_usr_ids[] = $user_entry->get_id();
|
$inserted_usr_ids[] = $user_entry->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,14 +584,12 @@ class UsrLists implements ControllerProviderInterface
|
|||||||
$list->addUsrListOwner($owner);
|
$list->addUsrListOwner($owner);
|
||||||
|
|
||||||
$em->persist($owner);
|
$em->persist($owner);
|
||||||
$em->merge($list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$role = $app['request']->get('role');
|
$role = $app['request']->get('role');
|
||||||
|
|
||||||
$owner->setRole($role);
|
$owner->setRole($role);
|
||||||
|
|
||||||
$em->merge($owner);
|
|
||||||
$em->flush();
|
$em->flush();
|
||||||
|
|
||||||
$datas = array(
|
$datas = array(
|
||||||
|
@@ -104,6 +104,35 @@ class Installer implements ControllerProviderInterface
|
|||||||
$request = $app['request'];
|
$request = $app['request'];
|
||||||
|
|
||||||
$warnings = array();
|
$warnings = array();
|
||||||
|
|
||||||
|
$php_constraint = \setup::check_php_version();
|
||||||
|
$writability_constraints = \setup::check_writability(new \Setup_Registry());
|
||||||
|
$extension_constraints = \setup::check_php_extension();
|
||||||
|
$opcode_constraints = \setup::check_cache_opcode();
|
||||||
|
$php_conf_constraints = \setup::check_php_configuration();
|
||||||
|
$locales_constraints = \setup::check_system_locales();
|
||||||
|
|
||||||
|
$constraints_coll = array(
|
||||||
|
'php_constraint' => $php_constraint
|
||||||
|
, 'writability_constraints' => $writability_constraints
|
||||||
|
, 'extension_constraints' => $extension_constraints
|
||||||
|
, 'opcode_constraints' => $opcode_constraints
|
||||||
|
, 'php_conf_constraints' => $php_conf_constraints
|
||||||
|
, 'locales_constraints' => $locales_constraints
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($constraints_coll as $key => $constraints)
|
||||||
|
{
|
||||||
|
$unset = true;
|
||||||
|
foreach ($constraints as $constraint)
|
||||||
|
{
|
||||||
|
if (!$constraint->is_ok() && !$constraint->is_blocker())
|
||||||
|
{
|
||||||
|
$warnings[] = $constraint->get_message();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($request->getScheme() == 'http')
|
if ($request->getScheme() == 'http')
|
||||||
{
|
{
|
||||||
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
$warnings[] = _('It is not recommended to install Phraseanet without HTTPS support');
|
||||||
@@ -118,6 +147,7 @@ class Installer implements ControllerProviderInterface
|
|||||||
, 'version_number' => $app['Core']['Version']->getNumber()
|
, 'version_number' => $app['Core']['Version']->getNumber()
|
||||||
, 'version_name' => $app['Core']['Version']->getName()
|
, 'version_name' => $app['Core']['Version']->getName()
|
||||||
, 'warnings' => $warnings
|
, 'warnings' => $warnings
|
||||||
|
, 'error' => $request->get('error')
|
||||||
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
, 'current_servername' => $request->getScheme() . '://' . $request->getHttpHost() . '/'
|
||||||
, 'discovered_binaries' => \setup::discover_binaries()
|
, 'discovered_binaries' => \setup::discover_binaries()
|
||||||
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
, 'rootpath' => dirname(dirname(dirname(dirname(__DIR__)))) . '/'
|
||||||
|
@@ -275,9 +275,14 @@ class Core extends \Pimple
|
|||||||
$appbox = \appbox::get_instance($this);
|
$appbox = \appbox::get_instance($this);
|
||||||
$session = \Session_Handler::getInstance($appbox);
|
$session = \Session_Handler::getInstance($appbox);
|
||||||
|
|
||||||
|
if($session->get_usr_id())
|
||||||
|
{
|
||||||
return \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
return \User_Adapter::getInstance($session->get_usr_id(), $appbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Getter
|
* Getter
|
||||||
*
|
*
|
||||||
|
@@ -49,6 +49,7 @@ class Configuration
|
|||||||
{
|
{
|
||||||
$specifications = new Configuration\ApplicationSpecification();
|
$specifications = new Configuration\ApplicationSpecification();
|
||||||
}
|
}
|
||||||
|
|
||||||
return new self($specifications, $environment);
|
return new self($specifications, $environment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,15 +84,6 @@ class Configuration
|
|||||||
|
|
||||||
$cacheService = "array_cache";
|
$cacheService = "array_cache";
|
||||||
|
|
||||||
if (extension_loaded('apc'))
|
|
||||||
{
|
|
||||||
$cacheService = "apc_cache";
|
|
||||||
}
|
|
||||||
elseif (extension_loaded('xcache'))
|
|
||||||
{
|
|
||||||
$cacheService = "xcache_cache";
|
|
||||||
}
|
|
||||||
|
|
||||||
$retrieve_old_credentials = function(\SplFileObject $connexionInc)
|
$retrieve_old_credentials = function(\SplFileObject $connexionInc)
|
||||||
{
|
{
|
||||||
require $connexionInc->getPathname();
|
require $connexionInc->getPathname();
|
||||||
|
@@ -31,21 +31,21 @@ class ApplicationSpecification implements Specification
|
|||||||
public function setConfigurations($configurations)
|
public function setConfigurations($configurations)
|
||||||
{
|
{
|
||||||
return file_put_contents(
|
return file_put_contents(
|
||||||
$this->getConfigurationsPathFile(), $this->parser->dump($configurations, 5)
|
$this->getConfigurationsPathFile(), $this->parser->dump($configurations, 7)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setConnexions($connexions)
|
public function setConnexions($connexions)
|
||||||
{
|
{
|
||||||
return file_put_contents(
|
return file_put_contents(
|
||||||
$this->getConnexionsPathFile(), $this->parser->dump($connexions, 5)
|
$this->getConnexionsPathFile(), $this->parser->dump($connexions, 7)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setServices($services)
|
public function setServices($services)
|
||||||
{
|
{
|
||||||
return file_put_contents(
|
return file_put_contents(
|
||||||
$this->getServicesPathFile(), $this->parser->dump($services, 5)
|
$this->getServicesPathFile(), $this->parser->dump($services, 7)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,12 +134,14 @@ class ApplicationSpecification implements Specification
|
|||||||
$this->getConfigurationsFile();
|
$this->getConfigurationsFile();
|
||||||
$this->getConnexionsFile();
|
$this->getConnexionsFile();
|
||||||
$this->getServicesFile();
|
$this->getServicesFile();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -67,16 +67,15 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
if (isset($stats[$key]))
|
if (isset($stats[$key]))
|
||||||
{
|
{
|
||||||
$service = new CacheDriver\MemcacheCache();
|
$this->cache = new CacheDriver\MemcacheCache();
|
||||||
$service->setMemcache($memcache);
|
$this->cache->setMemcache($memcache);
|
||||||
|
|
||||||
|
$this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
throw new \Exception(sprintf("Memcache instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache = $service;
|
|
||||||
$this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
|
@@ -71,16 +71,15 @@ class RedisCache extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
if ($redis->connect($this->host, $this->port))
|
if ($redis->connect($this->host, $this->port))
|
||||||
{
|
{
|
||||||
$service = new CacheDriver\RedisCache();
|
$this->cache = new CacheDriver\RedisCache();
|
||||||
$service->setRedis($redis);
|
$this->cache->setRedis($redis);
|
||||||
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
throw new \Exception(sprintf("Redis instance with host '%s' and port '%s' is not reachable", $this->host, $this->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->cache = $service;
|
|
||||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
|
@@ -42,9 +42,9 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
|
|||||||
|
|
||||||
if (!$this->cache)
|
if (!$this->cache)
|
||||||
{
|
{
|
||||||
$service = new CacheDriver\XcacheCache();
|
$this->cache = new CacheDriver\XcacheCache();
|
||||||
|
|
||||||
$service->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
|
@@ -66,7 +66,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
|||||||
, $handler
|
, $handler
|
||||||
, $this->name
|
, $this->name
|
||||||
, $this->getScope()
|
, $this->getScope()
|
||||||
, implode(", ", $this->handler)
|
, implode(", ", $this->handlers)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@ namespace Alchemy\Phrasea\Core;
|
|||||||
class Version
|
class Version
|
||||||
{
|
{
|
||||||
|
|
||||||
protected static $number = '3.6.0.0a2';
|
protected static $number = '3.6.0.0RC1';
|
||||||
protected static $name = 'Brachiosaure';
|
protected static $name = 'Brachiosaure';
|
||||||
|
|
||||||
public static function getNumber()
|
public static function getNumber()
|
||||||
|
@@ -32,10 +32,13 @@ class Prod extends Helper
|
|||||||
);
|
);
|
||||||
|
|
||||||
$bases = $fields = $dates = array();
|
$bases = $fields = $dates = array();
|
||||||
$appbox = \appbox::get_instance($this->core);
|
|
||||||
$session = $appbox->get_session();
|
|
||||||
$user = $this->getCore()->getAuthenticatedUser();
|
$user = $this->getCore()->getAuthenticatedUser();
|
||||||
|
|
||||||
|
if(!$user instanceof \User_Adapter)
|
||||||
|
{
|
||||||
|
return $search_datas;
|
||||||
|
}
|
||||||
|
|
||||||
$searchSet = $user->getPrefs('search');
|
$searchSet = $user->getPrefs('search');
|
||||||
|
|
||||||
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
foreach ($user->ACL()->get_granted_sbas() as $databox)
|
||||||
|
@@ -422,27 +422,6 @@ class Edit extends RecordHelper
|
|||||||
{
|
{
|
||||||
$i = count($this->javascript_fields);
|
$i = count($this->javascript_fields);
|
||||||
|
|
||||||
switch ($meta->get_type())
|
|
||||||
{
|
|
||||||
case 'datetime':
|
|
||||||
$format = _('phraseanet::technique::datetime-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::datetime-edit-explain');
|
|
||||||
break;
|
|
||||||
case 'date':
|
|
||||||
$format = _('phraseanet::technique::date-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::date-edit-explain');
|
|
||||||
break;
|
|
||||||
case 'time':
|
|
||||||
$format = _('phraseanet::technique::time-edit-format');
|
|
||||||
$explain = _('phraseanet::technique::time-edit-explain');
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
$format = $explain = "";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$regfield = ($meta->is_regname() || $meta->is_regdesc() || $meta->is_regdate());
|
|
||||||
|
|
||||||
$source = $meta->get_source();
|
$source = $meta->get_source();
|
||||||
$separator = $meta->get_separator();
|
$separator = $meta->get_separator();
|
||||||
|
|
||||||
@@ -455,12 +434,11 @@ class Edit extends RecordHelper
|
|||||||
, 'required' => $meta->is_required()
|
, 'required' => $meta->is_required()
|
||||||
, 'readonly' => $meta->is_readonly()
|
, 'readonly' => $meta->is_readonly()
|
||||||
, 'type' => $meta->get_type()
|
, 'type' => $meta->get_type()
|
||||||
, 'format' => $format
|
, 'format' => ''
|
||||||
, 'explain' => $explain
|
, 'explain' => ''
|
||||||
, 'tbranch' => $meta->get_tbranch()
|
, 'tbranch' => $meta->get_tbranch()
|
||||||
, 'maxLength' => $source ? $source->maxlength() : 0
|
, 'maxLength' => $source ? $source->maxlength() : 0
|
||||||
, 'minLength' => $source ? $source->minLength() : 0
|
, 'minLength' => $source ? $source->minLength() : 0
|
||||||
, 'regfield' => $regfield
|
|
||||||
, 'multi' => $meta->is_multi()
|
, 'multi' => $meta->is_multi()
|
||||||
, 'separator' => $separator
|
, 'separator' => $separator
|
||||||
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
, 'vocabularyControl' => $meta->getVocabularyControl() ? $meta->getVocabularyControl()->getType() : null
|
||||||
@@ -615,55 +593,6 @@ class Edit extends RecordHelper
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
// foreach ($trecchanges as $fname => $fchange)
|
|
||||||
// {
|
|
||||||
// $bool = false;
|
|
||||||
// if ($regfields && $parm['act_option'] == 'SAVEGRP'
|
|
||||||
// && $fname == $regfields['regname'])
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->name = implode(' ', $fchange['values']);
|
|
||||||
// $basket->save();
|
|
||||||
// $bool = true;
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
// echo $e->getMessage();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ($regfields && $parm['act_option'] == 'SAVEGRP'
|
|
||||||
// && $fname == $regfields['regdesc'])
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->desc = implode(' ', $fchange['values']);
|
|
||||||
// $basket->save();
|
|
||||||
// $bool = true;
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
// echo $e->getMessage();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if ($bool)
|
|
||||||
// {
|
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// $basket = basket_adapter::getInstance($parm['ssel']);
|
|
||||||
// $basket->delete_cache();
|
|
||||||
// }
|
|
||||||
// catch (Exception $e)
|
|
||||||
// {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return $this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -131,10 +131,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
sum(remain_dwnld) as remain_dwnld,
|
sum(remain_dwnld) as remain_dwnld,
|
||||||
sum(month_dwnld_max) as month_dwnld_max,
|
sum(month_dwnld_max) as month_dwnld_max,
|
||||||
|
|
||||||
mask_xor as maskxordec,
|
sum(mask_and + mask_xor) as masks
|
||||||
bin(mask_xor) as maskxorbin,
|
|
||||||
mask_and as maskanddec,
|
|
||||||
bin(mask_and) as maskandbin
|
|
||||||
|
|
||||||
FROM (usr u, bas b, sbas s)
|
FROM (usr u, bas b, sbas s)
|
||||||
LEFT JOIN (basusr bu)
|
LEFT JOIN (basusr bu)
|
||||||
@@ -206,8 +203,6 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
|
|||||||
{
|
{
|
||||||
$this->base_id = (int) $this->request->get('base_id');
|
$this->base_id = (int) $this->request->get('base_id');
|
||||||
|
|
||||||
// $this->base_id = (int) $parm['base_id'];
|
|
||||||
|
|
||||||
$sql = "SELECT u.usr_id, restrict_dwnld, remain_dwnld, month_dwnld_max
|
$sql = "SELECT u.usr_id, restrict_dwnld, remain_dwnld, month_dwnld_max
|
||||||
FROM (usr u INNER JOIN basusr bu ON u.usr_id = bu.usr_id)
|
FROM (usr u INNER JOIN basusr bu ON u.usr_id = bu.usr_id)
|
||||||
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
WHERE u.usr_id = " . implode(' OR u.usr_id = ', $this->users) . "
|
||||||
|
@@ -184,8 +184,10 @@ class PDF
|
|||||||
$fimg = $subdef->get_pathfile();
|
$fimg = $subdef->get_pathfile();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
||||||
&& $subdef->get_type() == media_subdef::TYPE_IMAGE)
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
|
||||||
$fimg = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
{
|
||||||
|
$fimg = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
||||||
|
}
|
||||||
|
|
||||||
$wimg = $himg = $ImgSize;
|
$wimg = $himg = $ImgSize;
|
||||||
if ($subdef->get_height() > 0 && $subdef->get_width() > 0)
|
if ($subdef->get_height() > 0 && $subdef->get_width() > 0)
|
||||||
@@ -479,8 +481,8 @@ class PDF
|
|||||||
$f = $subdef->get_pathfile();
|
$f = $subdef->get_pathfile();
|
||||||
|
|
||||||
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
if (!$user->ACL()->has_right_on_base($rec->get_base_id(), "nowatermark")
|
||||||
&& $subdef->get_type() == media_subdef::TYPE_IMAGE)
|
&& $subdef->get_type() == \media_subdef::TYPE_IMAGE)
|
||||||
$f = recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
$f = \recordutils_image::watermark($rec->get_base_id(), $rec->get_record_id());
|
||||||
|
|
||||||
$wimg = $himg = 150; // preview dans un carre de 150 mm
|
$wimg = $himg = 150; // preview dans un carre de 150 mm
|
||||||
if ($subdef->get_width() > 0 && $subdef->get_height() > 0)
|
if ($subdef->get_width() > 0 && $subdef->get_height() > 0)
|
||||||
|
@@ -17,7 +17,7 @@ class BasketElementRepository extends EntityRepository
|
|||||||
|
|
||||||
public function findUserElement($element_id, \User_Adapter $user)
|
public function findUserElement($element_id, \User_Adapter $user)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT e, b, s, p, vd
|
$dql = 'SELECT e
|
||||||
FROM Entities\BasketElement e
|
FROM Entities\BasketElement e
|
||||||
JOIN e.basket b
|
JOIN e.basket b
|
||||||
LEFT JOIN e.validation_datas vd
|
LEFT JOIN e.validation_datas vd
|
||||||
@@ -35,9 +35,6 @@ class BasketElementRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $cacheId = "_user_basket_element_" . $element_id . "_" . $user->get_id() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $cacheId);
|
|
||||||
|
|
||||||
$element = $query->getOneOrNullResult();
|
$element = $query->getOneOrNullResult();
|
||||||
|
|
||||||
/* @var $element \Entities\BasketElement */
|
/* @var $element \Entities\BasketElement */
|
||||||
@@ -51,7 +48,7 @@ class BasketElementRepository extends EntityRepository
|
|||||||
|
|
||||||
public function findElementsByRecord(\record_adapter $record)
|
public function findElementsByRecord(\record_adapter $record)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT e, b, s, p
|
$dql = 'SELECT e
|
||||||
FROM Entities\BasketElement e
|
FROM Entities\BasketElement e
|
||||||
JOIN e.basket b
|
JOIN e.basket b
|
||||||
LEFT JOIN b.validation s
|
LEFT JOIN b.validation s
|
||||||
@@ -67,9 +64,6 @@ class BasketElementRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $cacheId = "_basket_element_by_record_" . $record->get_serialize_key() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $cacheId);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +75,7 @@ class BasketElementRepository extends EntityRepository
|
|||||||
*/
|
*/
|
||||||
public function findReceivedElementsByRecord(\record_adapter $record, \User_Adapter $user)
|
public function findReceivedElementsByRecord(\record_adapter $record, \User_Adapter $user)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT e, b, s, p
|
$dql = 'SELECT e
|
||||||
FROM Entities\BasketElement e
|
FROM Entities\BasketElement e
|
||||||
JOIN e.basket b
|
JOIN e.basket b
|
||||||
LEFT JOIN b.validation s
|
LEFT JOIN b.validation s
|
||||||
@@ -100,15 +94,12 @@ class BasketElementRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $cacheId = "_receveid_element_by_record_" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $cacheId);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findReceivedValidationElementsByRecord(\record_adapter $record, \User_Adapter $user)
|
public function findReceivedValidationElementsByRecord(\record_adapter $record, \User_Adapter $user)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT e, b, v, p
|
$dql = 'SELECT e
|
||||||
FROM Entities\BasketElement e
|
FROM Entities\BasketElement e
|
||||||
JOIN e.basket b
|
JOIN e.basket b
|
||||||
JOIN b.validation v
|
JOIN b.validation v
|
||||||
@@ -126,9 +117,6 @@ class BasketElementRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $cacheId = "_receveid_validation_element_by_record" . $record->get_serialize_key() . "_" . $user->getId() . Entities\BasketElement::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $cacheId);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -37,11 +37,9 @@ class BasketRepository extends EntityRepository
|
|||||||
*/
|
*/
|
||||||
public function findActiveByUser(\User_Adapter $user, $sort = null)
|
public function findActiveByUser(\User_Adapter $user, $sort = null)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT b, e, s, p
|
$dql = 'SELECT b
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
LEFT JOIN b.elements e
|
LEFT JOIN b.elements e
|
||||||
LEFT JOIN b.validation s
|
|
||||||
LEFT JOIN s.participants p
|
|
||||||
WHERE b.usr_id = :usr_id
|
WHERE b.usr_id = :usr_id
|
||||||
AND b.archived = false';
|
AND b.archived = false';
|
||||||
|
|
||||||
@@ -57,9 +55,6 @@ class BasketRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array('usr_id' => $user->get_id()));
|
$query->setParameters(array('usr_id' => $user->get_id()));
|
||||||
|
|
||||||
// $idCache = "_active_by_user_" . ($sort === null ? "" : $sort. "_" ) . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +66,7 @@ class BasketRepository extends EntityRepository
|
|||||||
*/
|
*/
|
||||||
public function findUnreadActiveByUser(\User_Adapter $user)
|
public function findUnreadActiveByUser(\User_Adapter $user)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT b, e, s, p
|
$dql = 'SELECT b
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
JOIN b.elements e
|
||||||
LEFT JOIN b.validation s
|
LEFT JOIN b.validation s
|
||||||
@@ -79,9 +74,11 @@ class BasketRepository extends EntityRepository
|
|||||||
WHERE b.archived = false
|
WHERE b.archived = false
|
||||||
AND (
|
AND (
|
||||||
(b.usr_id = :usr_id_owner AND b.is_read = false)
|
(b.usr_id = :usr_id_owner AND b.is_read = false)
|
||||||
OR (b.usr_id != :usr_id_ownertwo AND p.usr_id = :usr_id_participant
|
OR (b.usr_id != :usr_id_ownertwo
|
||||||
|
AND p.usr_id = :usr_id_participant
|
||||||
AND p.is_aware = false)
|
AND p.is_aware = false)
|
||||||
)
|
)
|
||||||
|
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP())
|
||||||
ORDER BY e.ord ASC';
|
ORDER BY e.ord ASC';
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
@@ -93,9 +90,6 @@ class BasketRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $idCache = "findUnreadActiveByUser" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +102,7 @@ class BasketRepository extends EntityRepository
|
|||||||
*/
|
*/
|
||||||
public function findActiveValidationByUser(\User_Adapter $user, $sort = null)
|
public function findActiveValidationByUser(\User_Adapter $user, $sort = null)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT b, e, s, p, v
|
$dql = 'SELECT b
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
JOIN b.elements e
|
||||||
JOIN e.validation_datas v
|
JOIN e.validation_datas v
|
||||||
@@ -129,9 +123,6 @@ class BasketRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id()));
|
$query->setParameters(array(1 => $user->get_id(), 2 => $user->get_id()));
|
||||||
|
|
||||||
// $idCache = "_active_validation_by_user_" . $user->get_id() . "_" . $sort . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,21 +137,15 @@ class BasketRepository extends EntityRepository
|
|||||||
*/
|
*/
|
||||||
public function findUserBasket($basket_id, \User_Adapter $user, $requireOwner)
|
public function findUserBasket($basket_id, \User_Adapter $user, $requireOwner)
|
||||||
{
|
{
|
||||||
$dql = 'SELECT b, e, s, p, v
|
$dql = 'SELECT b, e
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
LEFT JOIN b.elements e
|
LEFT JOIN b.elements e
|
||||||
LEFT JOIN e.validation_datas v
|
|
||||||
LEFT JOIN b.validation s
|
|
||||||
LEFT JOIN s.participants p
|
|
||||||
WHERE b.id = :basket_id
|
WHERE b.id = :basket_id
|
||||||
ORDER BY e.ord ASC';
|
ORDER BY e.ord ASC';
|
||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters(array('basket_id' => $basket_id));
|
$query->setParameters(array('basket_id' => $basket_id));
|
||||||
|
|
||||||
// $cacheId = "_find_user_" . $basket_id . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $cacheId);
|
|
||||||
|
|
||||||
$basket = $query->getOneOrNullResult();
|
$basket = $query->getOneOrNullResult();
|
||||||
|
|
||||||
/* @var $basket \Entities\Basket */
|
/* @var $basket \Entities\Basket */
|
||||||
@@ -173,7 +158,6 @@ class BasketRepository extends EntityRepository
|
|||||||
{
|
{
|
||||||
$participant = false;
|
$participant = false;
|
||||||
|
|
||||||
$basket = $this->_em->merge($basket);
|
|
||||||
if ($basket->getValidation() && !$requireOwner)
|
if ($basket->getValidation() && !$requireOwner)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -213,9 +197,6 @@ class BasketRepository extends EntityRepository
|
|||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
|
|
||||||
// $idCache = "_containing_record_" . $record->get_serialize_key() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $query->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
return $query->getResult();
|
return $query->getResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +216,7 @@ class BasketRepository extends EntityRepository
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::VALIDATION_DONE:
|
case self::VALIDATION_DONE:
|
||||||
$dql = 'SELECT b, e, s
|
$dql = 'SELECT b, e
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
JOIN b.elements e
|
||||||
JOIN b.validation s
|
JOIN b.validation s
|
||||||
@@ -247,7 +228,7 @@ class BasketRepository extends EntityRepository
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case self::VALIDATION_SENT:
|
case self::VALIDATION_SENT:
|
||||||
$dql = 'SELECT b, v, e
|
$dql = 'SELECT b, e
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
JOIN b.elements e
|
||||||
JOIN b.validation v
|
JOIN b.validation v
|
||||||
@@ -257,9 +238,9 @@ class BasketRepository extends EntityRepository
|
|||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
$dql = 'SELECT b, e, s, p
|
$dql = 'SELECT b, e
|
||||||
FROM Entities\Basket b
|
FROM Entities\Basket b
|
||||||
JOIN b.elements e
|
LEFT JOIN b.elements e
|
||||||
LEFT JOIN b.validation s
|
LEFT JOIN b.validation s
|
||||||
LEFT JOIN s.participants p
|
LEFT JOIN s.participants p
|
||||||
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)';
|
WHERE (b.usr_id = :usr_id OR p.usr_id = :validating_usr_id)';
|
||||||
@@ -268,6 +249,17 @@ class BasketRepository extends EntityRepository
|
|||||||
'validating_usr_id' => $user->get_id()
|
'validating_usr_id' => $user->get_id()
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
case self::MYBASKETS:
|
||||||
|
$dql = 'SELECT b, e
|
||||||
|
FROM Entities\Basket b
|
||||||
|
LEFT JOIN b.elements e
|
||||||
|
LEFT JOIN b.validation s
|
||||||
|
LEFT JOIN s.participants p
|
||||||
|
WHERE (b.usr_id = :usr_id)';
|
||||||
|
$params = array(
|
||||||
|
'usr_id' => $user->get_id()
|
||||||
|
);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctype_digit($year) && strlen($year) == 4)
|
if (ctype_digit($year) && strlen($year) == 4)
|
||||||
@@ -286,7 +278,7 @@ class BasketRepository extends EntityRepository
|
|||||||
$params['description'] = '%' . $query . '%';
|
$params['description'] = '%' . $query . '%';
|
||||||
}
|
}
|
||||||
|
|
||||||
$dql .= ' ORDER BY e.ord ASC';
|
$dql .= ' ORDER BY b.id DESC, e.ord ASC';
|
||||||
|
|
||||||
$query = $this->_em->createQuery($dql);
|
$query = $this->_em->createQuery($dql);
|
||||||
$query->setParameters($params);
|
$query->setParameters($params);
|
||||||
@@ -294,12 +286,41 @@ class BasketRepository extends EntityRepository
|
|||||||
$count = Paginate::getTotalQueryResults($query);
|
$count = Paginate::getTotalQueryResults($query);
|
||||||
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $perPage);
|
$paginateQuery = Paginate::getPaginateQuery($query, $offset, $perPage);
|
||||||
|
|
||||||
// $idCache = "_" . $type . "_workzone_basket_" . $user->get_id() . Entities\Basket::CACHE_SUFFIX;
|
|
||||||
// $paginateQuery->useResultCache(true, 1800, $idCache);
|
|
||||||
|
|
||||||
$result = $paginateQuery->getResult();
|
$result = $paginateQuery->getResult();
|
||||||
|
|
||||||
return array('count' => $count, 'result' => $result);
|
return array('count' => $count, 'result' => $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return all actives validation where current user is involved and user basket
|
||||||
|
* @param \User_Adapter $user
|
||||||
|
* @param type $sort
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function findActiveValidationAndBasketByUser(\User_Adapter $user, $sort = null)
|
||||||
|
{
|
||||||
|
$dql = 'SELECT b, e
|
||||||
|
FROM Entities\Basket b
|
||||||
|
LEFT JOIN b.elements e
|
||||||
|
LEFT JOIN b.validation s
|
||||||
|
LEFT JOIN s.participants p
|
||||||
|
WHERE (b.usr_id = :usr_id
|
||||||
|
AND b.archived = false) OR (b.usr_id != :usr_id AND p.usr_id = :usr_id
|
||||||
|
AND (s.expires IS NULL OR s.expires > CURRENT_TIMESTAMP()))';
|
||||||
|
|
||||||
|
if ($sort == 'date')
|
||||||
|
{
|
||||||
|
$dql .= ' ORDER BY b.created DESC, e.ord ASC';
|
||||||
|
}
|
||||||
|
elseif ($sort == 'name')
|
||||||
|
{
|
||||||
|
$dql .= ' ORDER BY b.name ASC, e.ord ASC';
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = $this->_em->createQuery($dql);
|
||||||
|
$query->setParameters(array('usr_id' => $user->get_id()));
|
||||||
|
|
||||||
|
return $query->getResult();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,26 @@ class StoryWZRepository extends EntityRepository
|
|||||||
|
|
||||||
if ($sort == 'name')
|
if ($sort == 'name')
|
||||||
{
|
{
|
||||||
uasort($stories, array('\\Repositories\\StoryWZRepository', 'title_compare'));
|
$sortedStories = array();
|
||||||
|
foreach ($stories as $story)
|
||||||
|
{
|
||||||
|
$sortedStories[] = $story->getRecord()->get_title();
|
||||||
|
}
|
||||||
|
|
||||||
|
uasort($sortedStories, function($a, $b)
|
||||||
|
{
|
||||||
|
if ($a == $b)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ($a < $b) ? -1 : 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
foreach ($sortedStories as $idStory => $titleStory)
|
||||||
|
{
|
||||||
|
$sortedStories[$idStory] = $stories[$idStory];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $stories;
|
return $stories;
|
||||||
@@ -79,16 +98,6 @@ class StoryWZRepository extends EntityRepository
|
|||||||
return $story;
|
return $story;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function title_compare(\Entities\StoryWZ $a, \Entities\StoryWZ $b)
|
|
||||||
{
|
|
||||||
if ($a->getRecord()->get_title() == $b->getRecord()->get_title())
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ($a->getRecord()->get_title() < $b->getRecord()->get_title()) ? -1 : 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function findUserStory(\User_Adapter $user, \record_adapter $Story)
|
public function findUserStory(\User_Adapter $user, \record_adapter $Story)
|
||||||
{
|
{
|
||||||
$story = $this->findOneBy(
|
$story = $this->findOneBy(
|
||||||
|
@@ -152,6 +152,7 @@ class API_OAuth2_Form_DevAppDesktop
|
|||||||
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));
|
$metadata->addPropertyConstraint('description', new Constraints\NotBlank($blank));
|
||||||
$metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank));
|
$metadata->addPropertyConstraint('urlwebsite', new Constraints\NotBlank($blank));
|
||||||
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
|
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -159,6 +159,7 @@ class API_OAuth2_Form_DevAppInternet
|
|||||||
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
|
$metadata->addPropertyConstraint('urlwebsite', new Constraints\Url($url));
|
||||||
$metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank($blank));
|
$metadata->addPropertyConstraint('urlcallback', new Constraints\NotBlank($blank));
|
||||||
$metadata->addPropertyConstraint('urlcallback', new Constraints\Url($url));
|
$metadata->addPropertyConstraint('urlcallback', new Constraints\Url($url));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -204,6 +204,26 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function caption_records(Request $request, $databox_id, $record_id)
|
||||||
|
{
|
||||||
|
$result = new API_V1_result($request, $this);
|
||||||
|
|
||||||
|
$record = $this->appbox->get_databox($databox_id)->get_record($record_id);
|
||||||
|
$fields = $record->get_caption()->get_fields();
|
||||||
|
$ret = array();
|
||||||
|
foreach ($fields as $field)
|
||||||
|
{
|
||||||
|
$ret[$field->get_meta_struct_id()] = array(
|
||||||
|
'meta_structure_id' => $field->get_meta_struct_id()
|
||||||
|
, 'name' => $field->get_name()
|
||||||
|
, 'value' => $field->get_serialized_values(";")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$result->set_datas($ret);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an API_V1_result containing the results of a records search
|
* Get an API_V1_result containing the results of a records search
|
||||||
*
|
*
|
||||||
@@ -274,7 +294,7 @@ class API_V1_adapter extends API_V1_Abstract
|
|||||||
$options->set_sort($params['sort'], $params['ord']);
|
$options->set_sort($params['sort'], $params['ord']);
|
||||||
$options->set_use_stemming($params['stemme']);
|
$options->set_use_stemming($params['stemme']);
|
||||||
|
|
||||||
$perPage = $params['per_page'];
|
$perPage = (int) $params['per_page'];
|
||||||
$search_engine = new searchEngine_adapter($registry);
|
$search_engine = new searchEngine_adapter($registry);
|
||||||
$search_engine->set_options($options);
|
$search_engine->set_options($options);
|
||||||
|
|
||||||
|
@@ -131,4 +131,18 @@ class Bridge_Api_Dailymotion_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->url;
|
return $this->url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -377,6 +377,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
|
|||||||
if (!$response->isOk())
|
if (!$response->isOk())
|
||||||
{
|
{
|
||||||
if ($response->err_code === 3) //Already exists in photoset
|
if ($response->err_code === 3) //Already exists in photoset
|
||||||
|
|
||||||
return;
|
return;
|
||||||
throw new Bridge_Exception_ApiConnectorRequestFailed();
|
throw new Bridge_Exception_ApiConnectorRequestFailed();
|
||||||
}
|
}
|
||||||
@@ -663,12 +664,15 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (!$this->registry->get('GV_flickr_api'))
|
if (!$this->registry->get('GV_flickr_api'))
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_flickr_client_id')) === '')
|
if (trim($this->registry->get('GV_flickr_client_id')) === '')
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (trim($this->registry->get('GV_flickr_client_secret')) === '')
|
if (trim($this->registry->get('GV_flickr_client_secret')) === '')
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@@ -138,4 +138,19 @@ class Bridge_Api_Flickr_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -210,7 +210,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
*/
|
*/
|
||||||
public function get_category()
|
public function get_category()
|
||||||
{
|
{
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -219,7 +219,7 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
*/
|
*/
|
||||||
public function get_duration()
|
public function get_duration()
|
||||||
{
|
{
|
||||||
return null;
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -279,5 +279,4 @@ class Bridge_Api_Flickr_Element implements Bridge_Api_ElementInterface
|
|||||||
{
|
{
|
||||||
return $this->entry["tags"];
|
return $this->entry["tags"];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -117,4 +117,20 @@ class Bridge_Api_Youtube_Container implements Bridge_Api_ContainerInterface
|
|||||||
return $this->type;
|
return $this->type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_duration()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function get_category()
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function is_private()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -411,7 +411,6 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
|
|||||||
public function get_content()
|
public function get_content()
|
||||||
{
|
{
|
||||||
if ($this->items)
|
if ($this->items)
|
||||||
|
|
||||||
return $this->items;
|
return $this->items;
|
||||||
|
|
||||||
$rs = $this->retrieve_elements();
|
$rs = $this->retrieve_elements();
|
||||||
@@ -531,7 +530,12 @@ class Feed_Entry_Adapter implements Feed_Entry_Interface, cache_cacheableInterfa
|
|||||||
|
|
||||||
$feed->delete_data_from_cache();
|
$feed->delete_data_from_cache();
|
||||||
|
|
||||||
return new self($appbox, $feed, $entry_id);
|
$entry = new self($appbox, $feed, $entry_id);
|
||||||
|
|
||||||
|
$eventsmanager = \eventsmanager_broker::getInstance($appbox);
|
||||||
|
$eventsmanager->trigger('__FEED_ENTRY_CREATE__', array('entry_id' => $entry_id), $entry);
|
||||||
|
|
||||||
|
return $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -558,7 +558,7 @@ class Session_Handler
|
|||||||
$browser = Browser::getInstance();
|
$browser = Browser::getInstance();
|
||||||
|
|
||||||
if($this->is_authenticated())
|
if($this->is_authenticated())
|
||||||
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance ());
|
$user = User_Adapter::getInstance ($this->get_usr_id (), appbox::get_instance (\bootstrap::getCore()));
|
||||||
|
|
||||||
return Session_Logger::create($databox, $browser, $this, $user);
|
return Session_Logger::create($databox, $browser, $this, $user);
|
||||||
}
|
}
|
||||||
|
@@ -466,7 +466,7 @@ class User_Adapter implements User_Interface, cache_cacheableInterface
|
|||||||
}
|
}
|
||||||
if ($token === false)
|
if ($token === false)
|
||||||
{
|
{
|
||||||
$token = random::getUrlToken('rss', $this->id);
|
$token = random::getUrlToken(\random::TYPE_RSS, $this->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new system_url($registry->get('GV_ServerName') . 'atom/' . $token);
|
return new system_url($registry->get('GV_ServerName') . 'atom/' . $token);
|
||||||
|
@@ -136,10 +136,12 @@ class appbox extends base
|
|||||||
$custom_path.= $collection->get_base_id();
|
$custom_path.= $collection->get_base_id();
|
||||||
|
|
||||||
if (is_null($pathfile))
|
if (is_null($pathfile))
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$datas = file_get_contents($pathfile->getPathname());
|
$datas = file_get_contents($pathfile->getPathname());
|
||||||
if (is_null($datas))
|
if (is_null($datas))
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
file_put_contents($file, $datas);
|
file_put_contents($file, $datas);
|
||||||
@@ -191,10 +193,12 @@ class appbox extends base
|
|||||||
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
|
$custom_path.= $pic_type . '_' . $databox->get_sbas_id();
|
||||||
|
|
||||||
if (is_null($pathfile))
|
if (is_null($pathfile))
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
$datas = file_get_contents($pathfile->getPathname());
|
$datas = file_get_contents($pathfile->getPathname());
|
||||||
if (is_null($datas))
|
if (is_null($datas))
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
|
||||||
file_put_contents($file, $datas);
|
file_put_contents($file, $datas);
|
||||||
@@ -456,15 +460,6 @@ class appbox extends base
|
|||||||
|
|
||||||
$cacheService = "array_cache";
|
$cacheService = "array_cache";
|
||||||
|
|
||||||
if (extension_loaded('apc'))
|
|
||||||
{
|
|
||||||
$cacheService = "apc_cache";
|
|
||||||
}
|
|
||||||
elseif (extension_loaded('xcache'))
|
|
||||||
{
|
|
||||||
$cacheService = "xcache_cache";
|
|
||||||
}
|
|
||||||
|
|
||||||
$Core->getConfiguration()->setConnexions($connexion);
|
$Core->getConfiguration()->setConnexions($connexion);
|
||||||
|
|
||||||
$services = $Core->getConfiguration()->getConfigurations();
|
$services = $Core->getConfiguration()->getConfigurations();
|
||||||
@@ -549,6 +544,7 @@ class appbox extends base
|
|||||||
public function get_databoxes()
|
public function get_databoxes()
|
||||||
{
|
{
|
||||||
if ($this->databoxes)
|
if ($this->databoxes)
|
||||||
|
|
||||||
return $this->databoxes;
|
return $this->databoxes;
|
||||||
|
|
||||||
$ret = array();
|
$ret = array();
|
||||||
|
@@ -60,6 +60,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const APPLICATION_BOX = 'APPLICATION_BOX';
|
const APPLICATION_BOX = 'APPLICATION_BOX';
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -167,6 +168,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
{
|
{
|
||||||
$this->cache = $this->Core->getCache();
|
$this->cache = $this->Core->getCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->cache;
|
return $this->cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -288,6 +290,18 @@ abstract class base implements cache_cacheableInterface
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
|
||||||
|
$ORMTables = array(
|
||||||
|
'BasketElements',
|
||||||
|
'Baskets',
|
||||||
|
'StoryWZ',
|
||||||
|
'UsrListOwners',
|
||||||
|
'UsrLists',
|
||||||
|
'UsrListsContent',
|
||||||
|
'ValidationDatas',
|
||||||
|
'ValidationParticipants',
|
||||||
|
'ValidationSessions',
|
||||||
|
);
|
||||||
|
|
||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$tname = $row["Name"];
|
$tname = $row["Name"];
|
||||||
@@ -322,7 +336,7 @@ abstract class base implements cache_cacheableInterface
|
|||||||
unset($allTables[$tname]);
|
unset($allTables[$tname]);
|
||||||
$upgrader->add_steps_complete(1);
|
$upgrader->add_steps_complete(1);
|
||||||
}
|
}
|
||||||
else
|
elseif (!in_array($tname, $ORMTables))
|
||||||
{
|
{
|
||||||
$recommends[] = array(
|
$recommends[] = array(
|
||||||
'message' => 'Une table pourrait etre supprime',
|
'message' => 'Une table pourrait etre supprime',
|
||||||
|
1
lib/classes/cache/databox.class.php
vendored
1
lib/classes/cache/databox.class.php
vendored
@@ -59,6 +59,7 @@ class cache_databox
|
|||||||
if ($date <= $last_update)
|
if ($date <= $last_update)
|
||||||
{
|
{
|
||||||
self::$refreshing = false;
|
self::$refreshing = false;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -403,6 +403,58 @@ class caption_field
|
|||||||
return $values;
|
return $values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function rename_all_metadatas(databox_field $databox_field)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT count(id) as count_id FROM metadatas
|
||||||
|
WHERE meta_struct_id = :meta_struct_id';
|
||||||
|
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
|
||||||
|
$params = array(
|
||||||
|
':meta_struct_id' => $databox_field->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt->execute($params);
|
||||||
|
$rowcount = $stmt->rowCount();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$n = 0;
|
||||||
|
$increment = 500;
|
||||||
|
|
||||||
|
while ($n < $rowcount)
|
||||||
|
{
|
||||||
|
$sql = 'SELECT record_id, id FROM metadatas
|
||||||
|
WHERE meta_struct_id = :meta_struct_id LIMIT ' . $n . ', ' . $increment;
|
||||||
|
|
||||||
|
$params = array(
|
||||||
|
':meta_struct_id' => $databox_field->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
$rowcount = $stmt->rowCount();
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
unset($stmt);
|
||||||
|
|
||||||
|
foreach ($rs as $row)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$record = $databox_field->get_databox()->get_record($row['record_id']);
|
||||||
|
$record->set_metadatas(array());
|
||||||
|
unset($record);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$n += $increment;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
public static function delete_all_metadatas(databox_field $databox_field)
|
public static function delete_all_metadatas(databox_field $databox_field)
|
||||||
{
|
{
|
||||||
$sql = 'SELECT count(id) as count_id FROM metadatas
|
$sql = 'SELECT count(id) as count_id FROM metadatas
|
||||||
@@ -444,6 +496,7 @@ class caption_field
|
|||||||
$record = $databox_field->get_databox()->get_record($row['record_id']);
|
$record = $databox_field->get_databox()->get_record($row['record_id']);
|
||||||
$caption_field = new caption_field($databox_field, $record);
|
$caption_field = new caption_field($databox_field, $record);
|
||||||
$caption_field->delete();
|
$caption_field->delete();
|
||||||
|
$record->set_metadatas(array());
|
||||||
unset($caption_field);
|
unset($caption_field);
|
||||||
unset($record);
|
unset($record);
|
||||||
}
|
}
|
||||||
|
@@ -50,10 +50,6 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
$this->record = $record;
|
$this->record = $record;
|
||||||
$this->databox = $databox;
|
$this->databox = $databox;
|
||||||
|
|
||||||
|
|
||||||
$this->retrieve_fields();
|
|
||||||
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,7 +178,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
|
|||||||
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
|
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null)
|
||||||
{
|
{
|
||||||
$fields = array();
|
$fields = array();
|
||||||
foreach ($this->fields as $meta_struct_id => $field)
|
foreach ($this->retrieve_fields() as $meta_struct_id => $field)
|
||||||
{
|
{
|
||||||
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
|
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
|
||||||
continue;
|
continue;
|
||||||
|
@@ -514,15 +514,15 @@ class collection implements cache_cacheableInterface
|
|||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
$new_bas = $conn->lastInsertId();
|
$new_bas = $conn->lastInsertId();
|
||||||
|
|
||||||
phrasea::reset_baseDatas();
|
|
||||||
self::set_admin($new_bas, $user);
|
|
||||||
$databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
|
$databox->delete_data_from_cache(databox::CACHE_COLLECTIONS);
|
||||||
|
|
||||||
$appbox->delete_data_from_cache(appbox::CACHE_LIST_BASES);
|
$appbox->delete_data_from_cache(appbox::CACHE_LIST_BASES);
|
||||||
cache_databox::update($sbas_id, 'structure');
|
cache_databox::update($sbas_id, 'structure');
|
||||||
|
|
||||||
|
|
||||||
|
phrasea::reset_baseDatas();
|
||||||
|
self::set_admin($new_bas, $user);
|
||||||
|
|
||||||
return self::get_from_coll_id($databox, $new_id);
|
return self::get_from_coll_id($databox, $new_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -991,13 +991,6 @@ class databox extends base
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($field['regname']))
|
|
||||||
$meta_struct_field->set_regname();
|
|
||||||
if (isset($field['regdate']))
|
|
||||||
$meta_struct_field->set_regdate();
|
|
||||||
if (isset($field['regdesc']))
|
|
||||||
$meta_struct_field->set_regdesc();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
@@ -98,23 +98,15 @@ class databox_field implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
protected $thumbtitle;
|
protected $thumbtitle;
|
||||||
|
|
||||||
/**
|
protected $renamed = false;
|
||||||
*
|
|
||||||
* @var <type>
|
|
||||||
*/
|
|
||||||
protected $regdate;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @var <type>
|
|
||||||
*/
|
|
||||||
protected $regdesc;
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
*
|
||||||
* @var <type>
|
* To implement : change multi
|
||||||
|
* Change vocab Id
|
||||||
|
*
|
||||||
*/
|
*/
|
||||||
protected $regname;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -163,7 +155,7 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$connbas = $this->get_connection();
|
$connbas = $this->get_connection();
|
||||||
|
|
||||||
$sql = "SELECT `regdate`, `regdesc`, `regname`, `thumbtitle`, `separator`
|
$sql = "SELECT `thumbtitle`, `separator`
|
||||||
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
|
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
|
||||||
, `readonly`, `indexable`, `name`, `src`
|
, `readonly`, `indexable`, `name`, `src`
|
||||||
, `VocabularyControlType`, `RestrictToVocabularyControl`
|
, `VocabularyControlType`, `RestrictToVocabularyControl`
|
||||||
@@ -216,10 +208,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$this->separator = $separator;
|
$this->separator = $separator;
|
||||||
$this->thumbtitle = $row['thumbtitle'];
|
$this->thumbtitle = $row['thumbtitle'];
|
||||||
|
|
||||||
$this->regdesc = !!$row['regdesc'];
|
|
||||||
$this->regname = !!$row['regname'];
|
|
||||||
$this->regdate = !!$row['regdate'];
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,6 +355,12 @@ class databox_field implements cache_cacheableInterface
|
|||||||
$stmt = $connbas->prepare($sql);
|
$stmt = $connbas->prepare($sql);
|
||||||
$stmt->execute($params);
|
$stmt->execute($params);
|
||||||
|
|
||||||
|
if ($this->renamed)
|
||||||
|
{
|
||||||
|
caption_field::rename_all_metadatas($this);
|
||||||
|
$this->renamed = false;
|
||||||
|
}
|
||||||
|
|
||||||
$dom_struct = $this->databox->get_dom_structure();
|
$dom_struct = $this->databox->get_dom_structure();
|
||||||
$xp_struct = $this->databox->get_xpath_structure();
|
$xp_struct = $this->databox->get_xpath_structure();
|
||||||
|
|
||||||
@@ -421,8 +415,15 @@ class databox_field implements cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function set_name($name)
|
public function set_name($name)
|
||||||
{
|
{
|
||||||
|
$previous_name = $this->name;
|
||||||
|
|
||||||
$this->name = self::generateName($name);
|
$this->name = self::generateName($name);
|
||||||
|
|
||||||
|
if ($this->name !== $previous_name)
|
||||||
|
{
|
||||||
|
$this->renamed = true;
|
||||||
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -621,39 +622,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regdate()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('date');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regdesc()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('desc');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return databox_field
|
|
||||||
*/
|
|
||||||
public function set_regname()
|
|
||||||
{
|
|
||||||
$this->set_reg_attr('name');
|
|
||||||
|
|
||||||
return $this;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param string $attr
|
* @param string $attr
|
||||||
@@ -683,33 +651,6 @@ class databox_field implements cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regname()
|
|
||||||
{
|
|
||||||
return $this->regname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regdesc()
|
|
||||||
{
|
|
||||||
return $this->regdesc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return boolean
|
|
||||||
*/
|
|
||||||
public function is_regdate()
|
|
||||||
{
|
|
||||||
return $this->regdate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
@@ -870,10 +811,10 @@ class databox_field implements cache_cacheableInterface
|
|||||||
|
|
||||||
$sql = "INSERT INTO metadatas_structure
|
$sql = "INSERT INTO metadatas_structure
|
||||||
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
|
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
|
||||||
`thumbtitle`, `multi`, `regname`, `regdesc`, `regdate` ,
|
`thumbtitle`, `multi`,
|
||||||
`report`, `sorter`)
|
`report`, `sorter`)
|
||||||
VALUES (null, :name, '', 0, 1, 'text', '',
|
VALUES (null, :name, '', 0, 1, 'text', '',
|
||||||
null, 0, null, null, null,
|
null, 0,
|
||||||
1, :sorter)";
|
1, :sorter)";
|
||||||
|
|
||||||
$stmt = $databox->get_connection()->prepare($sql);
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
@@ -1,96 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This file is part of Phraseanet
|
|
||||||
*
|
|
||||||
* (c) 2005-2010 Alchemy
|
|
||||||
*
|
|
||||||
* For the full copyright and license information, please view the LICENSE
|
|
||||||
* file that was distributed with this source code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @package
|
|
||||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
|
||||||
* @link www.phraseanet.com
|
|
||||||
*/
|
|
||||||
function print_usage(&$argt)
|
|
||||||
{
|
|
||||||
global $argc, $argv;
|
|
||||||
printf("usage: %s [options]\noptions:\n", $argv[0]);
|
|
||||||
foreach ($argt as $n => $v)
|
|
||||||
printf("\t%s%s\n", $n, $v["usage"]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parse_cmdargs(&$argt, &$err)
|
|
||||||
{
|
|
||||||
$err = "";
|
|
||||||
global $argc, $argv;
|
|
||||||
|
|
||||||
for ($a = 1; $a < $argc; $a++)
|
|
||||||
{
|
|
||||||
//echo "parse_cmdargs :: $a\n";
|
|
||||||
|
|
||||||
$arg = $argv[$a];
|
|
||||||
|
|
||||||
|
|
||||||
if ($arg == "--" || $arg == "-")
|
|
||||||
continue;
|
|
||||||
if (($p = strpos($arg, "=")) === false)
|
|
||||||
{
|
|
||||||
parse_arg($arg, $argt, $err);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
parse_arg(substr($arg, 0, $p), $argt, $err);
|
|
||||||
parse_arg("=", $argt, $err);
|
|
||||||
parse_arg(substr($arg, $p + 1), $argt, $err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach ($argt as $n => $v)
|
|
||||||
{
|
|
||||||
if (!isset($v["values"][0]) && isset($v["default"]))
|
|
||||||
{
|
|
||||||
$argt[$n]["set"] = true;
|
|
||||||
$argt[$n]["values"][] = $v["default"];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return($err == "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function parse_arg($arg, &$argt, &$err)
|
|
||||||
{
|
|
||||||
static $last_arg = "";
|
|
||||||
static $curopt = null;
|
|
||||||
|
|
||||||
if ($arg != "=")
|
|
||||||
{
|
|
||||||
if ($last_arg != "=")
|
|
||||||
{
|
|
||||||
if (isset($argt[$arg]))
|
|
||||||
$argt[$curopt = $arg]["set"] = true;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$err .= "option '" . $arg . "' inconnue.\n";
|
|
||||||
if (isset($argt["--help"]))
|
|
||||||
$argt["--help"]["set"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($curopt)
|
|
||||||
$argt[$curopt]["values"][] = $arg;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$err .= "'=' doit suivre un nom d'option.\n";
|
|
||||||
if (isset($argt["--help"]))
|
|
||||||
$argt["--help"]["set"] = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$last_arg = $arg;
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
@@ -27,7 +27,7 @@ class eventsmanager_broker
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return eventsmanager
|
* @return \eventsmanager_broker
|
||||||
*/
|
*/
|
||||||
public static function getInstance(appbox &$appbox, \Alchemy\Phrasea\Core $core)
|
public static function getInstance(appbox &$appbox, \Alchemy\Phrasea\Core $core)
|
||||||
{
|
{
|
||||||
|
177
lib/classes/eventsmanager/notify/downloadmailfail.class.php
Normal file
177
lib/classes/eventsmanager/notify/downloadmailfail.class.php
Normal file
@@ -0,0 +1,177 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class eventsmanager_notify_downloadmailfail extends eventsmanager_notifyAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
const MAIL_NO_VALID = 1;
|
||||||
|
const MAIL_FAIL = 2;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $events = array('__EXPORT_MAIL_FAIL__');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function icon_url()
|
||||||
|
{
|
||||||
|
return '/skins/icons/user.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $event
|
||||||
|
* @param Array $params
|
||||||
|
* @param mixed content $object
|
||||||
|
* @return Void
|
||||||
|
*/
|
||||||
|
public function fire($event, $params, &$object)
|
||||||
|
{
|
||||||
|
$default = array(
|
||||||
|
'usr_id' => null
|
||||||
|
, 'lst' => ''
|
||||||
|
, 'ssttid' => ''
|
||||||
|
, 'dest' => ''
|
||||||
|
, 'reason' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
$params = array_merge($default, $params);
|
||||||
|
|
||||||
|
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
$dom_xml->preserveWhiteSpace = false;
|
||||||
|
$dom_xml->formatOutput = true;
|
||||||
|
|
||||||
|
$root = $dom_xml->createElement('datas');
|
||||||
|
|
||||||
|
$lst = $dom_xml->createElement('lst');
|
||||||
|
$ssttid = $dom_xml->createElement('ssttid');
|
||||||
|
$dest = $dom_xml->createElement('dest');
|
||||||
|
$reason = $dom_xml->createElement('reason');
|
||||||
|
|
||||||
|
$lst->appendChild($dom_xml->createTextNode($params['lst']));
|
||||||
|
$ssttid->appendChild($dom_xml->createTextNode($params['ssttid']));
|
||||||
|
$dest->appendChild($dom_xml->createTextNode($params['dest']));
|
||||||
|
$reason->appendChild($dom_xml->createTextNode($params['reason']));
|
||||||
|
|
||||||
|
$root->appendChild($lst);
|
||||||
|
$root->appendChild($ssttid);
|
||||||
|
$root->appendChild($dest);
|
||||||
|
$root->appendChild($reason);
|
||||||
|
|
||||||
|
$dom_xml->appendChild($root);
|
||||||
|
|
||||||
|
$datas = $dom_xml->saveXml();
|
||||||
|
|
||||||
|
$mailed = false;
|
||||||
|
|
||||||
|
$send_notif = ($this->get_prefs(__CLASS__, $params['usr_id']) != '0');
|
||||||
|
|
||||||
|
if ($send_notif)
|
||||||
|
{
|
||||||
|
$user = User_Adapter::getInstance($params['usr_id'], $this->appbox);
|
||||||
|
$name = $user->get_display_name();
|
||||||
|
|
||||||
|
$to = array('email' => $user->get_email(), 'name' => $name);
|
||||||
|
|
||||||
|
$from = array(
|
||||||
|
'email' => $this->registry->get('GV_defaulmailsenderaddr'),
|
||||||
|
'name' => $this->registry->get('GV_homeTitle')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (parent::email())
|
||||||
|
$mailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->broker->notify($params['usr_id'], __CLASS__, $datas, $mailed);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Array $datas
|
||||||
|
* @param boolean $unread
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function datas($datas, $unread)
|
||||||
|
{
|
||||||
|
$sx = simplexml_load_string($datas);
|
||||||
|
$usr_id = (int) $sx->usr_id;
|
||||||
|
$reason = (int) $sx->reason;
|
||||||
|
$lst = (string) $sx->lst;
|
||||||
|
$ssttid = (int) $sx->ssttid;
|
||||||
|
$dest = (string) $sx->dest;
|
||||||
|
|
||||||
|
if ($reason == self::MAIL_NO_VALID)
|
||||||
|
{
|
||||||
|
$reason = _('email is not valid');
|
||||||
|
}
|
||||||
|
elseif ($reason == self::MAIL_FAIL)
|
||||||
|
{
|
||||||
|
$reason = _('failed to send mail');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$reason = _('an error occured while exporting records');
|
||||||
|
}
|
||||||
|
|
||||||
|
$text = sprintf(
|
||||||
|
_("The delivery to %s failed for the following reason : %s")
|
||||||
|
, $dest
|
||||||
|
, $reason
|
||||||
|
);
|
||||||
|
|
||||||
|
$ret = array(
|
||||||
|
'text' => $text
|
||||||
|
, 'class' => ''
|
||||||
|
);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_name()
|
||||||
|
{
|
||||||
|
return _('Email export fails');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_description()
|
||||||
|
{
|
||||||
|
return _('Get a notification when a mail export fails');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function is_available()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
208
lib/classes/eventsmanager/notify/feed.class.php
Normal file
208
lib/classes/eventsmanager/notify/feed.class.php
Normal file
@@ -0,0 +1,208 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class eventsmanager_notify_feed extends eventsmanager_notifyAbstract
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
public $events = array('__FEED_ENTRY_CREATE__');
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function icon_url()
|
||||||
|
{
|
||||||
|
return '/skins/icons/rss16.png';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param string $event
|
||||||
|
* @param Array $params
|
||||||
|
* @param mixed content $object
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function fire($event, $params, &$entry)
|
||||||
|
{
|
||||||
|
$params = array(
|
||||||
|
'entry_id' => $entry->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$dom_xml = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
|
||||||
|
$dom_xml->preserveWhiteSpace = false;
|
||||||
|
$dom_xml->formatOutput = true;
|
||||||
|
|
||||||
|
$root = $dom_xml->createElement('datas');
|
||||||
|
|
||||||
|
$entry_id = $dom_xml->createElement('entry_id');
|
||||||
|
|
||||||
|
$entry_id->appendChild($dom_xml->createTextNode($params['entry_id']));
|
||||||
|
|
||||||
|
$root->appendChild($entry_id);
|
||||||
|
|
||||||
|
$dom_xml->appendChild($root);
|
||||||
|
|
||||||
|
$datas = $dom_xml->saveXml();
|
||||||
|
|
||||||
|
$Query = new \User_Query($this->appbox);
|
||||||
|
|
||||||
|
$Query->include_phantoms(true)->include_invite(false)->include_templates(false);
|
||||||
|
|
||||||
|
if ($entry->get_feed()->get_collection())
|
||||||
|
{
|
||||||
|
$Query->on_base_ids(array($entry->get_feed()->get_collection()->get_base_id()));
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = 0;
|
||||||
|
$perLoop = 100;
|
||||||
|
|
||||||
|
$from = array(
|
||||||
|
'email' => $entry->get_author_email(),
|
||||||
|
'name' => $entry->get_author_name()
|
||||||
|
);
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$results = $Query->limit($start, $perLoop)->execute()->get_results();
|
||||||
|
|
||||||
|
foreach ($results as $user_to_notif)
|
||||||
|
{
|
||||||
|
/* @var $user_to_notif \User_Adapter */
|
||||||
|
$mailed = false;
|
||||||
|
|
||||||
|
$send_notif = ($this->get_prefs(__CLASS__, $user_to_notif->get_id()) != '0');
|
||||||
|
if ($send_notif)
|
||||||
|
{
|
||||||
|
$email = array(
|
||||||
|
'email' => $user_to_notif->get_email(),
|
||||||
|
'name' => $user_to_notif->get_display_name()
|
||||||
|
);
|
||||||
|
|
||||||
|
$token = \random::getUrlToken(
|
||||||
|
\random::TYPE_FEED_ENTRY
|
||||||
|
, $user_to_notif->get_id()
|
||||||
|
, null
|
||||||
|
, $entry->get_id()
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = $this->appbox->get_registry()->get('GV_ServerName') . 'lightbox/index.php?LOG=' . $token;
|
||||||
|
|
||||||
|
if (self::mail($email, $from, $url, $entry))
|
||||||
|
$mailed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->broker->notify($user_to_notif->get_id(), __CLASS__, $datas, $mailed);
|
||||||
|
}
|
||||||
|
$start += $perLoop;
|
||||||
|
}
|
||||||
|
while (count($results) > 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Array $datas
|
||||||
|
* @param boolean $unread
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
public function datas($datas, $unread)
|
||||||
|
{
|
||||||
|
$sx = simplexml_load_string($datas);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$entry = \Feed_Entry_Adapter::load_from_id($this->appbox, (int) $sx->entry_id);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
$ret = array(
|
||||||
|
'text' => sprintf(
|
||||||
|
_('%1$s has published %2$s')
|
||||||
|
, $entry->get_author_name()
|
||||||
|
, '<a href="/lightbox/feeds/entry/' . $entry->get_id() . '/" target="_blank">' . $entry->get_title() . '</a>'
|
||||||
|
)
|
||||||
|
, 'class' => ($unread == 1 ? 'reload_baskets' : '')
|
||||||
|
);
|
||||||
|
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_name()
|
||||||
|
{
|
||||||
|
return _('Feeds');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function get_description()
|
||||||
|
{
|
||||||
|
return _('Recevoir des notifications lorsqu\'on me push quelque chose');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function is_available()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param Array $to
|
||||||
|
* @param Array $from
|
||||||
|
* @param string $message
|
||||||
|
* @param string $url
|
||||||
|
* @param boolean $accuse
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
function mail($to, $from, $url, \Feed_Entry_Adapter $entry)
|
||||||
|
{
|
||||||
|
$subject = sprintf(_('Nouvelle publication : %s'), $entry->get_title());
|
||||||
|
|
||||||
|
$body = "<div>"
|
||||||
|
. sprintf('%s vient de publier %s', $entry->get_author_name(), $entry->get_title())
|
||||||
|
. _('Connectez vous a l\'adresse suivante pour la consulter')
|
||||||
|
. "</div>\n";
|
||||||
|
|
||||||
|
$body .= '<div><a href="' . $url . '">' . $url . "</a></div>\n";
|
||||||
|
|
||||||
|
$body .= " <br/> ";
|
||||||
|
|
||||||
|
$body .= "<br/>\n<br/>\n<br/>\n"
|
||||||
|
. _('push::atention: ce lien est unique et son contenu confidentiel, ne divulguez pas');
|
||||||
|
|
||||||
|
return mail::send_mail($subject, $body, $to, $from, array());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -131,6 +131,7 @@ class gatekeeper
|
|||||||
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|
if ($this->_PHP_SELF == '/thesaurus2/xmlhttp/getterm.x.php'
|
||||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/searchcandidate.x.php'
|
||||||
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|
|| $this->_PHP_SELF == '/thesaurus2/xmlhttp/getsy.x.php')
|
||||||
|
|
||||||
return;
|
return;
|
||||||
phrasea::redirect('/login/?redirect=/thesaurus2');
|
phrasea::redirect('/login/?redirect=/thesaurus2');
|
||||||
break;
|
break;
|
||||||
@@ -292,7 +293,19 @@ class gatekeeper
|
|||||||
{
|
{
|
||||||
$datas = random::helloToken($parm['LOG']);
|
$datas = random::helloToken($parm['LOG']);
|
||||||
|
|
||||||
|
switch ($datas['type'])
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return $this;
|
||||||
|
break;
|
||||||
|
case \random::TYPE_FEED_ENTRY:
|
||||||
|
return phrasea::redirect("/lightbox/feeds/entry/" . $datas['datas'] . "/");
|
||||||
|
break;
|
||||||
|
case \random::TYPE_VALIDATE:
|
||||||
|
case \random::TYPE_VIEW:
|
||||||
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
|
return phrasea::redirect("/lightbox/validate/" . $datas['datas'] . "/");
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception_NotFound $e)
|
catch (Exception_NotFound $e)
|
||||||
{
|
{
|
||||||
|
@@ -127,7 +127,7 @@ class mail
|
|||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$date = new DateTime('1 day');
|
$date = new DateTime('1 day');
|
||||||
$token = random::getUrlToken('email', $usr_id, $date, $email);
|
$token = random::getUrlToken(\random::TYPE_EMAIL, $usr_id, $date, $email);
|
||||||
|
|
||||||
$url = $registry->get('GV_ServerName') . 'login/reset-email.php?token=' . $token;
|
$url = $registry->get('GV_ServerName') . 'login/reset-email.php?token=' . $token;
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ class mail
|
|||||||
{
|
{
|
||||||
$registry = registry::get_instance();
|
$registry = registry::get_instance();
|
||||||
$expire = new DateTime('+3 days');
|
$expire = new DateTime('+3 days');
|
||||||
$token = random::getUrlToken('password', $usr_id, $expire, $email);
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expire, $email);
|
||||||
|
|
||||||
$subject = _('login::register: sujet email : confirmation de votre adresse email');
|
$subject = _('login::register: sujet email : confirmation de votre adresse email');
|
||||||
|
|
||||||
@@ -208,8 +208,9 @@ class mail
|
|||||||
|
|
||||||
$body = eregi_replace("[\]", '', $body);
|
$body = eregi_replace("[\]", '', $body);
|
||||||
|
|
||||||
$body .= "<br/>\n"._('Si le lien n\'est pas cliquable, copiez-collez le dans votre navigateur.')."<br/>\n";
|
|
||||||
$body .= "<br/><br/><br/><br/>\n\n\n\n";
|
$body .= "<br/><br/><br/><br/>\n\n\n\n";
|
||||||
|
$body .= '<div style="font-style:italic;">'._('si cet email contient des liens non cliquables copiez/collez ces liens dans votre navigateur.').'</div>';
|
||||||
|
$body .= "<br/>\n";
|
||||||
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
|
$body .= '<div style="font-style:italic;">' . _('phraseanet::signature automatique des notifications par mail, infos a l\'url suivante') . "</div>\n";
|
||||||
$body .= '<div><a href="' . $registry->get('GV_ServerName') . '">' . $registry->get('GV_ServerName') . "</a></div>\n";
|
$body .= '<div><a href="' . $registry->get('GV_ServerName') . '">' . $registry->get('GV_ServerName') . "</a></div>\n";
|
||||||
$body = '<body>' . $body . '</body>';
|
$body = '<body>' . $body . '</body>';
|
||||||
@@ -258,7 +259,7 @@ class mail
|
|||||||
$mail->ConfirmReadingTo = $reading_confirm_to;
|
$mail->ConfirmReadingTo = $reading_confirm_to;
|
||||||
}
|
}
|
||||||
|
|
||||||
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li>'));
|
$mail->MsgHTML(strip_tags($body, '<div><br><ul><li><em><strong><span><br>'));
|
||||||
|
|
||||||
foreach ($files as $f)
|
foreach ($files as $f)
|
||||||
{
|
{
|
||||||
|
248
lib/classes/module/console/checkExtension.class.php
Normal file
248
lib/classes/module/console/checkExtension.class.php
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_checkExtension extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Delete a documentation field from a Databox');
|
||||||
|
|
||||||
|
$this->addOption('usr_id', 'u', InputOption::VALUE_OPTIONAL, 'Usr_id to use. If no user, get the first available');
|
||||||
|
|
||||||
|
$this->addOption('query', '', InputOption::VALUE_OPTIONAL, 'The query', 'last');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!extension_loaded('phrasea2'))
|
||||||
|
printf("Missing Extension php-phrasea");
|
||||||
|
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$registry = $appbox->get_registry();
|
||||||
|
|
||||||
|
$usr_id = $input->getOption('usr_id');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$TestUser = \User_Adapter::getInstance($usr_id, $appbox);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Wrong user !</error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"\nWill do the check with user <info>%s</info> (%s)\n"
|
||||||
|
, $TestUser->get_display_name()
|
||||||
|
, $TestUser->get_email()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$output->writeln("PHRASEA FUNCTIONS");
|
||||||
|
|
||||||
|
foreach (get_extension_funcs("phrasea2") as $function)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>$function</info>");
|
||||||
|
}
|
||||||
|
|
||||||
|
require (__DIR__ . '/../../../../config/connexion.inc');
|
||||||
|
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_conn --");
|
||||||
|
|
||||||
|
if (phrasea_conn($hostname, $port, $user, $password, $dbname) !== true)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> got no connection");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got connection");
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("");
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_info --");
|
||||||
|
|
||||||
|
foreach (phrasea_info() as $key => $value)
|
||||||
|
{
|
||||||
|
$output->writeln("\t$key => $value");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$output->writeln("");
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_create_session --");
|
||||||
|
|
||||||
|
$sessid = phrasea_create_session((string) $TestUser->get_id());
|
||||||
|
|
||||||
|
if (ctype_digit((string) $sessid))
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got session id $sessid");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> got no session id");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_open_session --");
|
||||||
|
|
||||||
|
$ph_session = phrasea_open_session($sessid, $usr_id);
|
||||||
|
|
||||||
|
if ($ph_session)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got session ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> got no session ");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_clear_cache --");
|
||||||
|
|
||||||
|
$ret = phrasea_clear_cache($sessid);
|
||||||
|
|
||||||
|
if ($sessid)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got session ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> got no session ");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tbases = array();
|
||||||
|
|
||||||
|
foreach ($ph_session["bases"] as $phbase)
|
||||||
|
{
|
||||||
|
$tcoll = array();
|
||||||
|
foreach ($phbase["collections"] as $coll)
|
||||||
|
{
|
||||||
|
$tcoll[] = 0 + $coll["base_id"];
|
||||||
|
}
|
||||||
|
if (sizeof($tcoll) > 0)
|
||||||
|
{
|
||||||
|
$kbase = "S" . $phbase["sbas_id"];
|
||||||
|
$tbases[$kbase] = array();
|
||||||
|
$tbases[$kbase]["sbas_id"] = $phbase["sbas_id"];
|
||||||
|
$tbases[$kbase]["searchcoll"] = $tcoll;
|
||||||
|
$tbases[$kbase]["mask_xor"] = $tbases[$kbase]["mask_and"] = 0;
|
||||||
|
|
||||||
|
$qp = new searchEngine_adapter_phrasea_queryParser();
|
||||||
|
$treeq = $qp->parsequery($input->getOption('query'));
|
||||||
|
$arrayq = $qp->makequery($treeq);
|
||||||
|
|
||||||
|
$tbases[$kbase]["arrayq"] = $arrayq;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_query --");
|
||||||
|
|
||||||
|
$nbanswers = 0;
|
||||||
|
foreach ($tbases as $kb => $base)
|
||||||
|
{
|
||||||
|
$tbases[$kb]["results"] = NULL;
|
||||||
|
|
||||||
|
$ret = phrasea_query2(
|
||||||
|
$ph_session["session_id"]
|
||||||
|
, $base["sbas_id"]
|
||||||
|
, $base["searchcoll"]
|
||||||
|
, $base["arrayq"]
|
||||||
|
, $registry->get('GV_sit')
|
||||||
|
, $usr_id
|
||||||
|
, FALSE
|
||||||
|
, PHRASEA_MULTIDOC_DOCONLY
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if ($ret)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got result on sbas_id " . $base["sbas_id"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> No results on sbas_id " . $base["sbas_id"]);
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tbases[$kb]["results"] = $ret;
|
||||||
|
|
||||||
|
$nbanswers += $tbases[$kb]["results"]["nbanswers"];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$output->writeln("Got a total of <info>$nbanswers</info> answers");
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_fetch_results --");
|
||||||
|
|
||||||
|
$rs = phrasea_fetch_results($sessid, $usr_id, 1, true, '[[em]]', '[[/em]]');
|
||||||
|
|
||||||
|
if ($rs)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> got result ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> got no result ");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("\n-- phrasea_close_session --");
|
||||||
|
|
||||||
|
$rs = phrasea_close_session($sessid);
|
||||||
|
|
||||||
|
if ($rs)
|
||||||
|
{
|
||||||
|
$output->writeln("<info>Succes ! </info> closed ! ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Failed ! </error> not closed ");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
97
lib/classes/module/console/fieldsDelete.class.php
Normal file
97
lib/classes/module/console/fieldsDelete.class.php
Normal file
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_fieldsDelete extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Delete a documentation field from a Databox');
|
||||||
|
|
||||||
|
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||||
|
|
||||||
|
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$input->getOption('sbas_id'))
|
||||||
|
throw new \Exception('Missing argument sbas_id');
|
||||||
|
|
||||||
|
if (!$input->getOption('meta_struct_id'))
|
||||||
|
throw new \Exception('Missing argument meta_struct_id');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Invalid databox id </error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$field = $databox->get_meta_structure()->get_element((int) $input->getOption('meta_struct_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Invalid meta struct id </error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
|
$continue = mb_strtolower(
|
||||||
|
$dialog->ask(
|
||||||
|
$output
|
||||||
|
, "<question>About to delete " . $field->get_name() . " (y/N)</question>"
|
||||||
|
, 'n'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if($continue != 'y')
|
||||||
|
{
|
||||||
|
$output->writeln("Request canceled by user");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("Deleting ... ");
|
||||||
|
|
||||||
|
$field->delete();
|
||||||
|
|
||||||
|
$output->writeln("Done with success !");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
70
lib/classes/module/console/fieldsList.class.php
Normal file
70
lib/classes/module/console/fieldsList.class.php
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_fieldsList extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('List all databox fields');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
|
||||||
|
foreach ($appbox->get_databoxes() as $databox)
|
||||||
|
{
|
||||||
|
/* @var $databox \databox */
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"\n ---------------- \nOn databox %s (sbas_id %d) :\n"
|
||||||
|
, $databox->get_viewname()
|
||||||
|
, $databox->get_sbas_id()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
foreach ($databox->get_meta_structure()->get_elements() as $field)
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
" %2d - <info>%s</info> (%s) %s"
|
||||||
|
, $field->get_id()
|
||||||
|
, $field->get_name()
|
||||||
|
, $field->get_type()
|
||||||
|
, ($field->is_multi() ? '<comment>multi</comment>' : '')
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
284
lib/classes/module/console/fieldsMerge.class.php
Normal file
284
lib/classes/module/console/fieldsMerge.class.php
Normal file
@@ -0,0 +1,284 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_fieldsMerge extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Merge databox structure fields');
|
||||||
|
|
||||||
|
$this->addOption(
|
||||||
|
'source'
|
||||||
|
, 'f'
|
||||||
|
, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||||
|
, 'Metadata structure ids for source'
|
||||||
|
, array()
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addOption(
|
||||||
|
'destination'
|
||||||
|
, 'd'
|
||||||
|
, InputOption::VALUE_REQUIRED
|
||||||
|
, 'Metadata structure id destination'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addOption(
|
||||||
|
'sbas_id'
|
||||||
|
, 's'
|
||||||
|
, InputOption::VALUE_REQUIRED
|
||||||
|
, 'Databox sbas_id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->addOption(
|
||||||
|
'separator'
|
||||||
|
, ''
|
||||||
|
, InputOption::VALUE_OPTIONAL
|
||||||
|
, 'Separator for concatenation (if destination is monovalued)'
|
||||||
|
, ';'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$output->writeln("");
|
||||||
|
|
||||||
|
if (!$input->getOption('sbas_id'))
|
||||||
|
throw new \Exception('Missing argument sbas_id');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Invalid databox id </error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sources = array();
|
||||||
|
|
||||||
|
foreach ($input->getOption('source') as $source_id)
|
||||||
|
{
|
||||||
|
$sources[] = $databox->get_meta_structure()->get_element($source_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($sources) === 0)
|
||||||
|
throw new \Exception('No sources to proceed');
|
||||||
|
|
||||||
|
if (!$input->getOption('destination'))
|
||||||
|
throw new \Exception('Missing argument destination');
|
||||||
|
|
||||||
|
$separator = ' ' . $input->getOption('separator') . ' ';
|
||||||
|
|
||||||
|
$destination = $databox->get_meta_structure()->get_element($input->getOption('destination'));
|
||||||
|
|
||||||
|
$types = $multis = array();
|
||||||
|
|
||||||
|
foreach ($sources as $source)
|
||||||
|
{
|
||||||
|
array_push($types, $source->get_type());
|
||||||
|
array_push($multis, $source->is_multi());
|
||||||
|
}
|
||||||
|
|
||||||
|
$types = array_unique($types);
|
||||||
|
$multis = array_unique($multis);
|
||||||
|
|
||||||
|
if (count(array_unique($types)) > 1)
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf("Warning, trying to merge inconsistent types : <comment>%s</comment>\n"
|
||||||
|
, implode(', ', $types)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count(array_unique($multis)) > 1)
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"Warning, trying to merge <comment>mono and multi</comment> values fields\n"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$field_names = array();
|
||||||
|
foreach ($sources as $source)
|
||||||
|
{
|
||||||
|
$field_names[] = $source->get_name();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($multis) == 1)
|
||||||
|
{
|
||||||
|
if ($multis[0] === false && !$destination->is_multi())
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>mono valued fields</info> in a "
|
||||||
|
. "<info>monovalued field</info>, fields will be "
|
||||||
|
. "<comment>concatenated</comment> in the following order : %s"
|
||||||
|
, implode($separator, $field_names)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->displayHelpConcatenation($output);
|
||||||
|
}
|
||||||
|
elseif ($multis[0] === true && !$destination->is_multi())
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>multi valued</info> fields in a "
|
||||||
|
. "<info>monovalued field</info>, fields will be "
|
||||||
|
. "<comment>concatenated</comment> in the following order : %s"
|
||||||
|
, implode(' ', $field_names)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->displayHelpConcatenation($output);
|
||||||
|
}
|
||||||
|
elseif ($multis[0] === false && $destination->is_multi())
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>mono valued fields</info> in a "
|
||||||
|
. "<info>multivalued field</info>"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($multis[0] === true && $destination->is_multi())
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>multi valued fields</info> in a "
|
||||||
|
. "<info>multivalued field</info>"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($destination->is_multi())
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>mixed valued</info> fields in a "
|
||||||
|
. "<info>multivalued</info> field"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln(
|
||||||
|
sprintf(
|
||||||
|
"You are going to merge <info>mixed valued</info> fields in a "
|
||||||
|
. "<info>monovalued field</info>, fields will be "
|
||||||
|
. "<comment>concatenated</comment> in the following order : %s"
|
||||||
|
, implode($separator, $field_names)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$this->displayHelpConcatenation($output);
|
||||||
|
}
|
||||||
|
|
||||||
|
$start = 0;
|
||||||
|
$quantity = 100;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
$sql = 'SELECT record_id FROM record
|
||||||
|
ORDER BY record_id LIMIT ' . $start . ', ' . $quantity;
|
||||||
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$results = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
foreach ($results as $row)
|
||||||
|
{
|
||||||
|
$record = $databox->get_record($row['record_id']);
|
||||||
|
|
||||||
|
$datas = array();
|
||||||
|
|
||||||
|
foreach ($sources as $source)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$value = $record->get_caption()->get_field($source->get_name())->get_value();
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$value = array();
|
||||||
|
}
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$value = array($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array_merge($datas, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
$datas = array_unique($datas);
|
||||||
|
|
||||||
|
if (!$destination->is_multi())
|
||||||
|
{
|
||||||
|
$datas = array(implode($separator, $datas));
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$record->get_caption()->get_field($destination->get_name())->set_value($datas);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$record->set_metadatas(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'meta_struct_id' => $destination->get_id()
|
||||||
|
, 'meta_id' => null
|
||||||
|
, 'value' => $datas
|
||||||
|
)
|
||||||
|
)
|
||||||
|
, true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
unset($record);
|
||||||
|
}
|
||||||
|
|
||||||
|
$start += $quantity;
|
||||||
|
}
|
||||||
|
while (count($results) > 0);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function displayHelpConcatenation(OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
$output->writeln("\nYou can choose the concatenation order in the "
|
||||||
|
. "commandline (first option is first value) and set a separator "
|
||||||
|
. "with the --separator option)");
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
105
lib/classes/module/console/fieldsRename.class.php
Normal file
105
lib/classes/module/console/fieldsRename.class.php
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_fieldsRename extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Rename a documentation field from a Databox');
|
||||||
|
|
||||||
|
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED, 'Databox sbas_id');
|
||||||
|
|
||||||
|
$this->addOption('meta_struct_id', 'm', InputOption::VALUE_REQUIRED, 'Databox meta structure Id');
|
||||||
|
|
||||||
|
$this->addOption('name', 'n', InputOption::VALUE_REQUIRED, 'The new name');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$input->getOption('sbas_id'))
|
||||||
|
throw new \Exception('Missing argument sbas_id');
|
||||||
|
|
||||||
|
if (!$input->getOption('meta_struct_id'))
|
||||||
|
throw new \Exception('Missing argument meta_struct_id');
|
||||||
|
|
||||||
|
if (!$input->getOption('name'))
|
||||||
|
throw new \Exception('Missing argument name');
|
||||||
|
|
||||||
|
$new_name = $input->getOption('name');
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$databox = \databox::get_instance((int) $input->getOption('sbas_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Invalid databox id </error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$field = $databox->get_meta_structure()->get_element((int) $input->getArgument('meta_struct_id'));
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$output->writeln("<error>Invalid meta struct id </error>");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$dialog = $this->getHelperSet()->get('dialog');
|
||||||
|
$continue = mb_strtolower(
|
||||||
|
$dialog->ask(
|
||||||
|
$output
|
||||||
|
, "<question>About to rename " . $field->get_name() . " into ".$new_name." (y/N)</question>"
|
||||||
|
, 'n'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
if($continue != 'y')
|
||||||
|
{
|
||||||
|
$output->writeln("Request canceled by user");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("Renaming ... ");
|
||||||
|
|
||||||
|
$field->set_name($new_name);
|
||||||
|
$field->save();
|
||||||
|
|
||||||
|
$output->writeln("Done with success !");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
922
lib/classes/module/console/fileEnsureDevSetting.class.php
Normal file
922
lib/classes/module/console/fileEnsureDevSetting.class.php
Normal file
@@ -0,0 +1,922 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Input\InputArgument,
|
||||||
|
Symfony\Component\Console\Input\InputInterface,
|
||||||
|
Symfony\Component\Console\Input\InputOption,
|
||||||
|
Symfony\Component\Console\Output\OutputInterface,
|
||||||
|
Symfony\Component\Console\Command\Command;
|
||||||
|
use Alchemy\Phrasea\Core;
|
||||||
|
use Symfony\Component\Yaml;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo write tests
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class module_console_fileEnsureDevSetting extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
const ALERT = 1;
|
||||||
|
const ERROR = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Alchemy\Phrasea\Core\Configuration
|
||||||
|
*/
|
||||||
|
protected $configuration;
|
||||||
|
protected $testSuite = array(
|
||||||
|
'checkPhraseanetScope'
|
||||||
|
, 'checkDatabaseScope'
|
||||||
|
, 'checkTeamplateEngineService'
|
||||||
|
, 'checkOrmService'
|
||||||
|
, 'checkCacheService'
|
||||||
|
, 'checkOpcodeCacheService'
|
||||||
|
);
|
||||||
|
protected $errors = 0;
|
||||||
|
protected $alerts = 0;
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Ensure development settings');
|
||||||
|
|
||||||
|
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
||||||
|
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$specifications = new \Alchemy\Phrasea\Core\Configuration\ApplicationSpecification();
|
||||||
|
|
||||||
|
$environnement = $input->getArgument('conf');
|
||||||
|
|
||||||
|
$this->configuration = \Alchemy\Phrasea\Core\Configuration::build($specifications, $environnement);
|
||||||
|
|
||||||
|
if (!$this->configuration->isInstalled())
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("\nPhraseanet is not installed\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->checkParse($output);
|
||||||
|
$output->writeln(sprintf("Will Ensure Production Settings on <info>%s</info>", $this->configuration->getEnvironnement()));
|
||||||
|
|
||||||
|
$this->runTests($output);
|
||||||
|
|
||||||
|
$retval = $this->errors;
|
||||||
|
if ($input->getOption('strict'))
|
||||||
|
{
|
||||||
|
$retval += $this->alerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($retval > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Some errors found in your conf</error>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<info>Your dev settings are setted correctly ! Enjoy</info>");
|
||||||
|
}
|
||||||
|
$output->writeln('End');
|
||||||
|
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function runTests(OutputInterface $output)
|
||||||
|
{
|
||||||
|
foreach ($this->testSuite as $test)
|
||||||
|
{
|
||||||
|
$display = "";
|
||||||
|
switch ($test)
|
||||||
|
{
|
||||||
|
case 'checkPhraseanetScope' :
|
||||||
|
$display = "Phraseanet Configuration";
|
||||||
|
break;
|
||||||
|
case 'checkDatabaseScope' :
|
||||||
|
$display = "Database";
|
||||||
|
break;
|
||||||
|
case 'checkTeamplateEngineService' :
|
||||||
|
$display = "Template Engine";
|
||||||
|
break;
|
||||||
|
case 'checkOrmService' :
|
||||||
|
$display = "ORM";
|
||||||
|
break;
|
||||||
|
case 'checkCacheService' :
|
||||||
|
$display = "Cache";
|
||||||
|
break;
|
||||||
|
case 'checkOpcodeCacheService' :
|
||||||
|
$display = "Opcode";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new \Exception('Unknown test');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\n||| %s", mb_strtoupper($display)));
|
||||||
|
|
||||||
|
call_user_func(array($this, $test), $output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkParse(OutputInterface $output)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!$this->configuration->getConfigurations())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load configurations\n");
|
||||||
|
}
|
||||||
|
if (!$this->configuration->getConnexions())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load connexions\n");
|
||||||
|
}
|
||||||
|
if (!$this->configuration->getServices())
|
||||||
|
{
|
||||||
|
throw new \Exception("Unable to load services\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkCacheService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$cache = $this->configuration->getCache();
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->probeCacheService($output, $cache))
|
||||||
|
{
|
||||||
|
if ($this->recommendedCacheService($output, $cache, true))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'MainCache', $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkOpcodeCacheService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$cache = $this->configuration->getOpcodeCache();
|
||||||
|
|
||||||
|
|
||||||
|
if ($this->probeCacheService($output, $cache))
|
||||||
|
{
|
||||||
|
if ($this->recommendedCacheService($output, $cache, false))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>No cache required</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", 'OpcodeCache', $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . 'service', $cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkPhraseanetScope(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$required = array('servername', 'maintenance', 'debug', 'display_errors', 'database');
|
||||||
|
|
||||||
|
$phraseanet = $this->configuration->getPhraseanet();
|
||||||
|
|
||||||
|
foreach ($phraseanet->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
case 'servername':
|
||||||
|
$url = $value;
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
|
||||||
|
$parseUrl = parse_url($url);
|
||||||
|
|
||||||
|
if (empty($url))
|
||||||
|
{
|
||||||
|
$message = "<error>should not be empty</error>";
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($url == 'http://sub.domain.tld/')
|
||||||
|
{
|
||||||
|
$this->alerts++;
|
||||||
|
$message = "<comment>may be wrong</comment>";
|
||||||
|
}
|
||||||
|
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
||||||
|
{
|
||||||
|
$message = "<error>not valid</error>";
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message = "<info>OK</info>";
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'maintenance':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
case 'display_errors':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'database':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$service = $this->configuration->getConnexion($value);
|
||||||
|
if ($this->verifyDatabaseConnexion($service))
|
||||||
|
{
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$message = '<error>Connection not available</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$message = '<error>Unknown connection</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkDatabaseScope(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$connexionName = $this->configuration->getPhraseanet()->get('database');
|
||||||
|
$connexion = $this->configuration->getConnexion($connexionName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if ($this->verifyDatabaseConnexion($connexion))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify connection <info>%s</info> : %s", $connexionName, $work_message));
|
||||||
|
|
||||||
|
$required = array('driver');
|
||||||
|
|
||||||
|
if (!$connexion->has('driver'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Connection has no driver</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($connexion->get('driver') == 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$required = array('driver', 'dbname', 'charset', 'password', 'user', 'port', 'host');
|
||||||
|
}
|
||||||
|
elseif ($connexion->get('driver') == 'pdo_sqlite')
|
||||||
|
{
|
||||||
|
$required = array('driver', 'path', 'charset');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your driver is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($connexion->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
case 'charset':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
if ($value !== 'UTF8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'path':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = is_writable(dirname($value)) ? '<info>OK</info>' : '<error>Not writeable</error>';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'dbname':
|
||||||
|
case 'user':
|
||||||
|
case 'host':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'port':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be ctype_digit</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'password':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = '***********';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'driver':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$message = '<error>MySQL recommended</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function verifyDatabaseConnexion(\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag $connexion)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$config = new \Doctrine\DBAL\Configuration();
|
||||||
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkTeamplateEngineService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$templateEngineName = $this->configuration->getTemplating();
|
||||||
|
$configuration = $this->configuration->getService($templateEngineName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration);
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not load template engine !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify Template engine <info>%s</info> : %s", $templateEngineName, $work_message));
|
||||||
|
|
||||||
|
if (!$configuration->has('type'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Configuration has no type</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($configuration->get('type') == 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$required = array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your type is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'type':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$message = '<error>Not recognized</error>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'options':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($configuration->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'debug';
|
||||||
|
case 'strict_variables';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'autoescape';
|
||||||
|
case 'optimizer';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'charset';
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'utf-8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function checkOrmService(OutputInterface $output)
|
||||||
|
{
|
||||||
|
$ormName = $this->configuration->getOrm();
|
||||||
|
$configuration = $this->configuration->getService($ormName);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration);
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("\t--> Verify ORM engine <info>%s</info> : %s", $ormName, $work_message));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!$configuration->has('type'))
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Configuration has no type</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
elseif ($configuration->get('type') == 'Orm\\Doctrine')
|
||||||
|
{
|
||||||
|
$required = array('debug', 'dbal', 'cache');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Your type is not managed</error>");
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->all() as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'type':
|
||||||
|
$message = $value == 'Orm\\Doctrine' ? '<info>OK</info>' : '<error>Not recognized</error>';
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'options':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach ($configuration->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'log':
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'cache':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be Array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
|
||||||
|
$required_caches = array('query', 'result', 'metadata');
|
||||||
|
foreach ($value as $name => $cache_type)
|
||||||
|
{
|
||||||
|
$required_caches = array_diff($required_caches, array($name));
|
||||||
|
|
||||||
|
foreach ($cache_type as $key_cache => $value_cache)
|
||||||
|
{
|
||||||
|
switch ($key_cache)
|
||||||
|
{
|
||||||
|
case 'service':
|
||||||
|
if ($this->probeCacheService($output, $value_cache))
|
||||||
|
{
|
||||||
|
$server = $name === 'result';
|
||||||
|
if ($this->recommendedCacheService($output, $value_cache, $server))
|
||||||
|
{
|
||||||
|
$work_message = '<info>Works !</info>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->errors++;
|
||||||
|
$work_message = '<error>No cache required</error>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$work_message = '<error>Failed - could not connect !</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verification = sprintf("\t--> Verify <info>%s</info> : %s", $name, $work_message);
|
||||||
|
|
||||||
|
|
||||||
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, $verification);
|
||||||
|
$this->verifyCacheOptions($output, $value_cache);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!isset($cache_type['service']))
|
||||||
|
{
|
||||||
|
$output->writeln('<error>Miss service for %s</error>', $cache_type);
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required_caches) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required caches %s</error>', implode(', ', $required_caches)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'debug':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'dbal':
|
||||||
|
$required = array_diff($required, array($conf));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$connexion = $this->configuration->getConnexion($value);
|
||||||
|
$this->verifyDatabaseConnexion($connexion);
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$message = '<error>Failed</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function verifyCacheOptions(OutputInterface $output, $ServiceName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$conf = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $conf
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$required_options = array();
|
||||||
|
|
||||||
|
switch ($Service->getType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
case 'memcache':
|
||||||
|
$required_options = array('host', 'port');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($required_options)
|
||||||
|
{
|
||||||
|
foreach ($conf->get('options') as $conf => $value)
|
||||||
|
{
|
||||||
|
switch ($conf)
|
||||||
|
{
|
||||||
|
case 'host';
|
||||||
|
$required_options = array_diff($required_options, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
case 'port';
|
||||||
|
$required_options = array_diff($required_options, array($conf));
|
||||||
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$this->alerts++;
|
||||||
|
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count($required_options) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required_options)));
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function probeCacheService(OutputInterface $output, $ServiceName)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($Service->getDriver()->isServer())
|
||||||
|
{
|
||||||
|
switch ($Service->getType())
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 'memcache':
|
||||||
|
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function recommendedCacheService(OutputInterface $output, $ServiceName, $server)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||||
|
|
||||||
|
$Service = Core\Service\Builder::create(
|
||||||
|
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||||
|
);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $Service->getType() === 'array';
|
||||||
|
}
|
||||||
|
|
||||||
|
private function printConf($output, $scope, $value, $scopage = false, $message = '')
|
||||||
|
{
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
foreach ($value as $key => $val)
|
||||||
|
{
|
||||||
|
if ($scopage)
|
||||||
|
$key = $scope . ":" . $key;
|
||||||
|
$this->printConf($output, $key, $val, $scopage, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif (is_bool($value))
|
||||||
|
{
|
||||||
|
if ($value === false)
|
||||||
|
{
|
||||||
|
$value = 'false';
|
||||||
|
}
|
||||||
|
elseif ($value === true)
|
||||||
|
{
|
||||||
|
$value = 'true';
|
||||||
|
}
|
||||||
|
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
|
||||||
|
}
|
||||||
|
elseif (!empty($value))
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("\t%s: %s %s", $scope, $value, $message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -44,6 +44,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
, 'checkOpcodeCacheService'
|
, 'checkOpcodeCacheService'
|
||||||
);
|
);
|
||||||
protected $errors = 0;
|
protected $errors = 0;
|
||||||
|
protected $alerts = 0;
|
||||||
|
|
||||||
public function __construct($name = null)
|
public function __construct($name = null)
|
||||||
{
|
{
|
||||||
@@ -52,6 +53,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->setDescription('Ensure production settings');
|
$this->setDescription('Ensure production settings');
|
||||||
|
|
||||||
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
$this->addArgument('conf', InputArgument::OPTIONAL, 'The file to check', null);
|
||||||
|
$this->addOption('strict', 's', InputOption::VALUE_NONE, 'Wheter to fail on alerts or not');
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -74,8 +76,23 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
|
|
||||||
$this->runTests($output);
|
$this->runTests($output);
|
||||||
|
|
||||||
|
$retval = $this->errors;
|
||||||
|
if ($input->getOption('strict'))
|
||||||
|
{
|
||||||
|
$retval += $this->alerts;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($retval > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("\n<error>Some errors found in your conf</error>");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
|
||||||
|
}
|
||||||
$output->writeln('End');
|
$output->writeln('End');
|
||||||
return 0;
|
|
||||||
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function runTests(OutputInterface $output)
|
private function runTests(OutputInterface $output)
|
||||||
@@ -112,15 +129,6 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
|
|
||||||
call_user_func(array($this, $test), $output);
|
call_user_func(array($this, $test), $output);
|
||||||
}
|
}
|
||||||
if ($this->errors)
|
|
||||||
{
|
|
||||||
$output->writeln("\n<error>Some errors found in your conf</error>");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$output->writeln("\n<info>Your production settings are setted correctly ! Enjoy</info>");
|
|
||||||
}
|
|
||||||
return $this->errors;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkParse(OutputInterface $output)
|
private function checkParse(OutputInterface $output)
|
||||||
@@ -156,6 +164,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Cache server recommended</comment>';
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -185,6 +194,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Opcode recommended</comment>';
|
$work_message = '<comment>Opcode recommended</comment>';
|
||||||
|
$this->alerts++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -211,6 +221,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
case 'servername':
|
case 'servername':
|
||||||
@@ -226,6 +237,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
elseif ($url == 'http://sub.domain.tld/')
|
elseif ($url == 'http://sub.domain.tld/')
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
$message = "<comment>may be wrong</comment>";
|
$message = "<comment>may be wrong</comment>";
|
||||||
}
|
}
|
||||||
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
elseif (!filter_var($url, FILTER_VALIDATE_URL))
|
||||||
@@ -235,6 +247,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
elseif ($parseUrl["scheme"] !== "https")
|
elseif ($parseUrl["scheme"] !== "https")
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
$message = "<comment>should be https</comment>";
|
$message = "<comment>should be https</comment>";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -247,7 +260,14 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'debug':
|
case 'debug':
|
||||||
case 'display_errors':
|
case 'display_errors':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value ? '<error>Should be false</error>' : '<info>OK</info>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'database':
|
case 'database':
|
||||||
@@ -280,6 +300,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
$output->writeln(sprintf('<error>Miss required keys %s</error>', implode(', ', $required)));
|
||||||
$this->errors++;
|
$this->errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -335,11 +356,17 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
case 'charset':
|
case 'charset':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == 'UTF8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
if ($value !== 'UTF8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'path':
|
case 'path':
|
||||||
@@ -351,23 +378,50 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'user':
|
case 'user':
|
||||||
case 'host':
|
case 'host':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'port':
|
case 'port':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = ctype_digit($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be ctype_digit</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'password':
|
case 'password':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$value = '***********';
|
$value = '***********';
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'driver':
|
case 'driver':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value === 'pdo_mysql' ? '<info>OK</info>' : '<error>MySQL recommended</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'pdo_mysql')
|
||||||
|
{
|
||||||
|
$message = '<error>MySQL recommended</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -388,6 +442,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
{
|
{
|
||||||
$config = new \Doctrine\DBAL\Configuration();
|
$config = new \Doctrine\DBAL\Configuration();
|
||||||
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
|
$conn = \Doctrine\DBAL\DriverManager::getConnection($connexion->all(), $config);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
@@ -410,7 +465,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$work_message = '<error>Failed - could not connect !</error>';
|
$work_message = '<error>Failed - could not load template engine !</error>';
|
||||||
$this->errors++;
|
$this->errors++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,14 +493,29 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
case 'type':
|
case 'type':
|
||||||
$message = $value == 'TemplateEngine\\Twig' ? '<info>OK</info>' : '<error>Not recognized</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if($value !== 'TemplateEngine\\Twig')
|
||||||
|
{
|
||||||
|
$message = '<error>Not recognized</error>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'options':
|
case 'options':
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -458,21 +528,43 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
case 'debug';
|
case 'debug';
|
||||||
case 'strict_variables';
|
case 'strict_variables';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'autoescape';
|
case 'autoescape';
|
||||||
case 'optimizer';
|
case 'optimizer';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == true ? '<info>OK</info>' : '<error>Should be true</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== true)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be true</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'charset';
|
case 'charset';
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == 'utf-8' ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== 'utf-8')
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -533,10 +625,18 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'options':
|
case 'options':
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, 'unknown', false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -548,12 +648,26 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
switch ($conf)
|
switch ($conf)
|
||||||
{
|
{
|
||||||
case 'log':
|
case 'log':
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be deactivated</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be deactivated</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'cache':
|
case 'cache':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = is_array($value) ? '<info>OK</info>' : '<error>Should be Array</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_array($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be Array</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, 'array()', false, $message);
|
$this->printConf($output, $conf, 'array()', false, $message);
|
||||||
|
|
||||||
$required_caches = array('query', 'result', 'metadata');
|
$required_caches = array('query', 'result', 'metadata');
|
||||||
@@ -575,6 +689,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->alerts++;
|
||||||
if ($server)
|
if ($server)
|
||||||
{
|
{
|
||||||
$work_message = '<comment>Cache server recommended</comment>';
|
$work_message = '<comment>Cache server recommended</comment>';
|
||||||
@@ -598,6 +713,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->verifyCacheOptions($output, $value_cache);
|
$this->verifyCacheOptions($output, $value_cache);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t" . $key_cache, $value_cache, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -617,7 +733,14 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
break;
|
break;
|
||||||
case 'debug':
|
case 'debug':
|
||||||
$required = array_diff($required, array($conf));
|
$required = array_diff($required, array($conf));
|
||||||
$message = $value == false ? '<info>OK</info>' : '<error>Should be false</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if ($value !== false)
|
||||||
|
{
|
||||||
|
$message = '<error>Should be false</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'dbal':
|
case 'dbal':
|
||||||
@@ -636,6 +759,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
$this->printConf($output, $conf, $value, false, $message);
|
$this->printConf($output, $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -684,15 +808,30 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
{
|
{
|
||||||
case 'host';
|
case 'host';
|
||||||
$required_options = array_diff($required_options, array($conf));
|
$required_options = array_diff($required_options, array($conf));
|
||||||
$message = is_scalar($value) ? '<info>OK</info>' : '<error>Should be scalar</error>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!is_scalar($value))
|
||||||
|
{
|
||||||
|
$message = '<error>Should be scalar</error>';
|
||||||
|
$this->errors++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
case 'port';
|
case 'port';
|
||||||
$required_options = array_diff($required_options, array($conf));
|
$required_options = array_diff($required_options, array($conf));
|
||||||
$message = ctype_digit($value) ? '<info>OK</info>' : '<comment>Not recognized</comment>';
|
$message = '<info>OK</info>';
|
||||||
|
|
||||||
|
if (!ctype_digit($value))
|
||||||
|
{
|
||||||
|
$message = '<comment>Not recognized</comment>';
|
||||||
|
$this->alerts++;
|
||||||
|
}
|
||||||
|
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
$this->printConf($output, "\t\t" . $conf, $value, false, $message);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$this->alerts++;
|
||||||
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
$this->printConf($output, "\t\t" . $conf, $value, false, '<comment>Not recognized</comment>');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -729,7 +868,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
return false;
|
return false;
|
||||||
break;
|
break;
|
||||||
case 'memcache':
|
case 'memcache':
|
||||||
if (!memcache_connect($Service->getHost(), $Service->getPort()))
|
if (!@memcache_connect($Service->getHost(), $Service->getPort()))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -759,6 +898,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $server === $Service->getDriver()->isServer();
|
return $server === $Service->getDriver()->isServer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
148
lib/classes/module/console/sphinxGenerateSuggestion.class.php
Normal file
148
lib/classes/module/console/sphinxGenerateSuggestion.class.php
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_sphinxGenerateSuggestion extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Generate suggestions for Sphinx Search Engine');
|
||||||
|
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
define('FREQ_THRESHOLD', 10);
|
||||||
|
define('SUGGEST_DEBUG', 0);
|
||||||
|
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
$registry = $appbox->get_registry();
|
||||||
|
|
||||||
|
$params = phrasea::sbas_params();
|
||||||
|
|
||||||
|
foreach ($params as $sbas_id => $p)
|
||||||
|
{
|
||||||
|
$index = crc32(
|
||||||
|
str_replace(
|
||||||
|
array('.', '%')
|
||||||
|
, '_'
|
||||||
|
, sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname'])
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$tmp_file = $registry->get('GV_RootPath') . 'tmp/dict' . $index . '.txt';
|
||||||
|
|
||||||
|
$databox = databox::get_instance($sbas_id);
|
||||||
|
|
||||||
|
$output->writeln("process Databox " . $databox->get_viewname() . " / $index\n");
|
||||||
|
|
||||||
|
$cmd = '/usr/local/bin/indexer metadatas' . $index . ' --buildstops ' . $tmp_file . ' 1000000 --buildfreqs';
|
||||||
|
exec($cmd);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$connbas = connection::getPDOConnection($sbas_id);
|
||||||
|
}
|
||||||
|
catch (Exception $e)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = 'TRUNCATE suggest';
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
$sql = $this->BuildDictionarySQL($output, file_get_contents($tmp_file));
|
||||||
|
|
||||||
|
if (trim($sql) !== '')
|
||||||
|
{
|
||||||
|
$stmt = $connbas->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
|
||||||
|
unlink($tmp_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function BuildTrigrams($keyword)
|
||||||
|
{
|
||||||
|
$t = "__" . $keyword . "__";
|
||||||
|
|
||||||
|
$trigrams = "";
|
||||||
|
for ($i = 0; $i < strlen($t) - 2; $i++)
|
||||||
|
$trigrams .= substr($t, $i, 3) . " ";
|
||||||
|
|
||||||
|
return $trigrams;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function BuildDictionarySQL(OutputInterface $output, $in)
|
||||||
|
{
|
||||||
|
$out = '';
|
||||||
|
|
||||||
|
$n = 0;
|
||||||
|
$lines = explode("\n", $in);
|
||||||
|
foreach ($lines as $line)
|
||||||
|
{
|
||||||
|
if (trim($line) === '')
|
||||||
|
continue;
|
||||||
|
list ( $keyword, $freq ) = explode(" ", trim($line));
|
||||||
|
|
||||||
|
if ($freq < FREQ_THRESHOLD || strstr($keyword, "_") !== false || strstr($keyword, "'") !== false)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (ctype_digit($keyword))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (mb_strlen($keyword) < 3)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$trigrams = $this->BuildTrigrams($keyword);
|
||||||
|
|
||||||
|
if ($n++)
|
||||||
|
$out .= ",\n";
|
||||||
|
$out .= "( $n, '$keyword', '$trigrams', $freq )";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (trim($out) !== '')
|
||||||
|
{
|
||||||
|
$out = "INSERT INTO suggest VALUES " . $out . ";";
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln(sprintf("Generated <info>%d</info> suggestions", $n));
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
311
lib/classes/module/console/systemExport.class.php
Normal file
311
lib/classes/module/console/systemExport.class.php
Normal file
@@ -0,0 +1,311 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package KonsoleKomander
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
|
||||||
|
class module_console_systemExport extends Command
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct($name = null)
|
||||||
|
{
|
||||||
|
parent::__construct($name);
|
||||||
|
|
||||||
|
$this->setDescription('Export all phraseanet records to a directory');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement
|
||||||
|
*/
|
||||||
|
// $this->addOption('useoriginalname', 'o', InputOption::VALUE_OPTIONAL
|
||||||
|
// , 'Use original name for dest files', false);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement
|
||||||
|
*/
|
||||||
|
// $this->addOption('excludefield', 'f', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||||
|
// , 'Exclude field from XML', array());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To implement
|
||||||
|
*/
|
||||||
|
// $this->addOption('excludestatus', '', InputOption::VALUE_OPTIONAL
|
||||||
|
// , 'Exclude Status', false);
|
||||||
|
|
||||||
|
$this->addOption('docperdir', 'd', InputOption::VALUE_OPTIONAL
|
||||||
|
, 'Maximum number of files per dir', 100);
|
||||||
|
|
||||||
|
$this->addOption('caption', 'c', InputOption::VALUE_OPTIONAL
|
||||||
|
, 'Export Caption (XML)', false);
|
||||||
|
|
||||||
|
$this->addOption('limit', 'l', InputOption::VALUE_OPTIONAL
|
||||||
|
, 'Limit files quantity (for test purposes)', false);
|
||||||
|
|
||||||
|
$this->addOption('base_id', 'b', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||||
|
, 'Restrict on base_ids', array());
|
||||||
|
|
||||||
|
$this->addOption('sbas_id', 's', InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
|
||||||
|
, 'Restrict on sbas_ids', array());
|
||||||
|
|
||||||
|
$this->addArgument('directory', InputOption::VALUE_REQUIRED
|
||||||
|
, 'The directory where to export');
|
||||||
|
|
||||||
|
$this->addOption('sanitize', '', InputOption::VALUE_REQUIRED
|
||||||
|
, 'Sanitize filenames. Set to 0 to disable', true);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function execute(InputInterface $input, OutputInterface $output)
|
||||||
|
{
|
||||||
|
$docPerDir = max(1, (int) $input->getOption('docperdir'));
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* To implement
|
||||||
|
*
|
||||||
|
$useOriginalName = !!$input->getOption('useoriginalname');
|
||||||
|
$excludeFields = $input->getOption('excludefield');
|
||||||
|
$exportStatus = !$input->getOption('excludestatus');
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
$Caption = $input->getOption('caption');
|
||||||
|
|
||||||
|
$limit = ctype_digit($input->getOption('limit')) ? max(0, (int) $input->getOption('limit')) : false;
|
||||||
|
|
||||||
|
$restrictBaseIds = $input->getOption('base_id');
|
||||||
|
|
||||||
|
$restrictSbasIds = $input->getOption('sbas_id');
|
||||||
|
|
||||||
|
$sanitize = $input->getOption('sanitize');
|
||||||
|
|
||||||
|
|
||||||
|
$export_directory = $input->getArgument('directory');
|
||||||
|
|
||||||
|
if (!$export_directory)
|
||||||
|
{
|
||||||
|
throw new Exception('Missing directory argument');
|
||||||
|
}
|
||||||
|
|
||||||
|
$export_directory = realpath(substr($export_directory, 0, 1) === '/' ? $export_directory : getcwd() . '/' . $export_directory . '/');
|
||||||
|
|
||||||
|
if (!$export_directory)
|
||||||
|
{
|
||||||
|
throw new Exception('Export directory does not exists or is not accessible');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_writable($export_directory))
|
||||||
|
{
|
||||||
|
throw new Exception('Export directory is not writable');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sanitize
|
||||||
|
*/
|
||||||
|
foreach ($restrictBaseIds as $key => $base_id)
|
||||||
|
{
|
||||||
|
$restrictBaseIds[$key] = (int) $base_id;
|
||||||
|
}
|
||||||
|
foreach ($restrictSbasIds as $key => $sbas_id)
|
||||||
|
{
|
||||||
|
$restrictSbasIds[$key] = (int) $sbas_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (count($restrictSbasIds) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("Export datas from selected sbas_ids");
|
||||||
|
}
|
||||||
|
elseif (count($restrictBaseIds) > 0)
|
||||||
|
{
|
||||||
|
$output->writeln("Export datas from selected base_ids");
|
||||||
|
}
|
||||||
|
|
||||||
|
$appbox = \appbox::get_instance();
|
||||||
|
|
||||||
|
$total = $errors = 0;
|
||||||
|
|
||||||
|
$unicode = new \unicode();
|
||||||
|
|
||||||
|
foreach ($appbox->get_databoxes() as $databox)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("Processing <info>%s</info>", $databox->get_viewname()));
|
||||||
|
|
||||||
|
if (count($restrictSbasIds) > 0 && !in_array($databox->get_sbas_id(), $restrictSbasIds))
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("Databox not selected, bypassing ..."));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$go = true;
|
||||||
|
$coll_ids = array();
|
||||||
|
|
||||||
|
if (count($restrictBaseIds) > 0)
|
||||||
|
{
|
||||||
|
$go = false;
|
||||||
|
foreach ($databox->get_collections() as $collection)
|
||||||
|
{
|
||||||
|
if (in_array($collection->get_base_id(), $restrictBaseIds))
|
||||||
|
{
|
||||||
|
|
||||||
|
$go = true;
|
||||||
|
$coll_ids[] = $collection->get_coll_id();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$go)
|
||||||
|
{
|
||||||
|
$output->writeln(sprintf("Collections not selected, bypassing ..."));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$local_export = $export_directory
|
||||||
|
. '/' . $unicode->remove_nonazAZ09($databox->get_viewname(), true, true)
|
||||||
|
. '/';
|
||||||
|
|
||||||
|
system_file::mkdir($local_export);
|
||||||
|
|
||||||
|
$sql = 'SELECT record_id FROM record WHERE parent_record_id = 0 ';
|
||||||
|
|
||||||
|
if (count($coll_ids) > 0)
|
||||||
|
{
|
||||||
|
$sql .= ' AND coll_id IN (' . implode(', ', $coll_ids) . ') ';
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql .= ' ORDER BY record_id ASC ';
|
||||||
|
|
||||||
|
if ($limit)
|
||||||
|
{
|
||||||
|
$sql .= ' LIMIT 0, ' . $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
|
||||||
|
$done = 0;
|
||||||
|
$current_total = count($rs);
|
||||||
|
$total += $current_total;
|
||||||
|
$l = strlen((string) $current_total) + 1;
|
||||||
|
|
||||||
|
$dir_format = 'datas%' . strlen((string) ceil($current_total / $docPerDir)) . 'd';
|
||||||
|
|
||||||
|
$dir_increment = 0;
|
||||||
|
foreach ($rs as $row)
|
||||||
|
{
|
||||||
|
$record = $databox->get_record($row['record_id']);
|
||||||
|
if (($done % $docPerDir) === 0)
|
||||||
|
{
|
||||||
|
$dir_increment++;
|
||||||
|
$in_dir_files = array();
|
||||||
|
$current_dir = $local_export . sprintf($dir_format, $dir_increment) . '/';
|
||||||
|
system_file::mkdir($current_dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($sanitize)
|
||||||
|
{
|
||||||
|
$filename = $unicode->remove_nonazAZ09($record->get_original_name(), true, true, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$filename = $record->get_original_name();
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->generateDefinitiveFilename($in_dir_files, $filename);
|
||||||
|
|
||||||
|
$output_file = $current_dir . $filename;
|
||||||
|
|
||||||
|
if (!$this->processRecords($record, $output_file, $Caption))
|
||||||
|
{
|
||||||
|
$errors++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$done++;
|
||||||
|
|
||||||
|
$output->write(sprintf("\r#%" . $l . "d record remaining", $current_total - $done));
|
||||||
|
}
|
||||||
|
$output->writeln(" | " . $current_total . " records done\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
$output->writeln("$total records done, $errors errors occured");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function generateDefinitiveFilename(array &$existing, &$filename)
|
||||||
|
{
|
||||||
|
$definitive_filename = $filename;
|
||||||
|
$suffix = 2;
|
||||||
|
while (array_key_exists($definitive_filename, $existing))
|
||||||
|
{
|
||||||
|
$pathinfo = pathinfo($filename);
|
||||||
|
|
||||||
|
$definitive_filename = $pathinfo['filename'] . '_' . $suffix .
|
||||||
|
(isset($pathinfo['extension']) ? '.' . $pathinfo['extension'] : '');
|
||||||
|
$suffix++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$existing[$filename] = $filename;
|
||||||
|
$filename = $definitive_filename;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function processRecords(\record_adapter $record, $outfile, $caption)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$file = new system_file($record->get_subdef('document')->get_pathfile());
|
||||||
|
}
|
||||||
|
catch (\Exception_Media_SubdefNotFound $e)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
copy($file->getPathname(), $outfile);
|
||||||
|
|
||||||
|
$dest_file = new system_file($outfile);
|
||||||
|
|
||||||
|
touch(
|
||||||
|
$dest_file->getPathname()
|
||||||
|
, $record->get_creation_date()->format('U')
|
||||||
|
, $record->get_modification_date()->format('U')
|
||||||
|
);
|
||||||
|
|
||||||
|
switch (strtolower($caption))
|
||||||
|
{
|
||||||
|
case 'xml':
|
||||||
|
$pathinfo = pathinfo($dest_file->getPathname());
|
||||||
|
$xml_file = dirname($outfile) . '/' . $pathinfo['filename'] . '.xml';
|
||||||
|
file_put_contents($xml_file, $record->get_xml());
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -453,7 +453,6 @@ class module_report_activity extends module_report
|
|||||||
$this->result[$i]['total'] += 1;
|
$this->result[$i]['total'] += 1;
|
||||||
|
|
||||||
$total['tot_dl'] += 1;
|
$total['tot_dl'] += 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$nb_row = $i + 1;
|
$nb_row = $i + 1;
|
||||||
@@ -638,19 +637,37 @@ class module_report_activity extends module_report
|
|||||||
foreach ($rs as $row)
|
foreach ($rs as $row)
|
||||||
{
|
{
|
||||||
$user = $row[$on];
|
$user = $row[$on];
|
||||||
if (($save_user != $user) && !is_null($user))
|
if (($save_user != $user) && !is_null($user) && !empty($user))
|
||||||
|
{
|
||||||
|
if ($i >= 0)
|
||||||
|
{
|
||||||
|
if (($this->result[$i]['nbprev'] + $this->result[$i]['nbdoc']) == 0 || ($this->result[$i]['poiddoc'] + $this->result[$i]['poidprev']) == 0)
|
||||||
|
{
|
||||||
|
unset($this->result[$i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->result[$i]['poiddoc']) && isset($this->result[$i]['poidprev']))
|
||||||
|
{
|
||||||
|
$this->result[$i]['poiddoc'] = p4string::format_octets($this->result[$i]['poiddoc']);
|
||||||
|
$this->result[$i]['poidprev'] = p4string::format_octets($this->result[$i]['poidprev']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$i++;
|
$i++;
|
||||||
|
|
||||||
|
$this->result[$i]['nbprev'] = 0;
|
||||||
|
$this->result[$i]['poidprev'] = 0;
|
||||||
|
$this->result[$i]['nbdoc'] = 0;
|
||||||
|
$this->result[$i]['poiddoc'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
//doc info
|
//doc info
|
||||||
if ($row['final'] == 'document' &&
|
if ($row['final'] == 'document' &&
|
||||||
!is_null($user) && !is_null($row['usrid']))
|
!is_null($user) && !is_null($row['usrid']))
|
||||||
{
|
{
|
||||||
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ?
|
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
p4string::format_octets($row['poid']) : 0);
|
|
||||||
if (!isset($this->result[$i]['nbprev']))
|
|
||||||
$this->result[$i]['nbprev'] = 0;
|
|
||||||
if (!isset($this->result[$i]['poidprev']))
|
|
||||||
$this->result[$i]['poidprev'] = 0;
|
|
||||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||||
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
||||||
$total['nbdoc'] += $this->result[$i]['nbdoc'];
|
$total['nbdoc'] += $this->result[$i]['nbdoc'];
|
||||||
@@ -658,26 +675,25 @@ class module_report_activity extends module_report
|
|||||||
$this->result[$i]['usrid'] = $row['usrid'];
|
$this->result[$i]['usrid'] = $row['usrid'];
|
||||||
}
|
}
|
||||||
//preview info
|
//preview info
|
||||||
if ($row['final'] == 'preview' &&
|
if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
|
||||||
!is_null($user) &&
|
!is_null($user) &&
|
||||||
!is_null($row['usrid']))
|
!is_null($row['usrid']))
|
||||||
{
|
{
|
||||||
if (!isset($this->result[$i]['nbdoc']))
|
|
||||||
$this->result[$i]['nbdoc'] = 0;
|
$this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
if (!isset($this->result[$i]['poiddoc']))
|
$this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
$this->result[$i]['poiddoc'] = 0;
|
|
||||||
$this->result[$i]['nbprev'] = (!is_null($row['nb']) ? $row['nb'] : 0);
|
|
||||||
$this->result[$i]['poidprev'] = (!is_null($row['poid']) ?
|
|
||||||
p4string::format_octets($row['poid']) : 0);
|
|
||||||
$this->result[$i]['user'] = empty($row[$on]) ?
|
$this->result[$i]['user'] = empty($row[$on]) ?
|
||||||
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
|
||||||
$total['nbprev'] += $this->result[$i]['nbprev'];
|
$total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
|
||||||
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
|
||||||
$this->result[$i]['usrid'] = $row['usrid'];
|
$this->result[$i]['usrid'] = $row['usrid'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$save_user = $user;
|
$save_user = $user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unset($this->result[$i]);
|
||||||
$nb_row = $i + 1;
|
$nb_row = $i + 1;
|
||||||
$this->total = $nb_row;
|
$this->total = $nb_row;
|
||||||
|
|
||||||
|
66
lib/classes/patch/320h.class.php
Normal file
66
lib/classes/patch/320h.class.php
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Phraseanet
|
||||||
|
*
|
||||||
|
* (c) 2005-2010 Alchemy
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package
|
||||||
|
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||||
|
* @link www.phraseanet.com
|
||||||
|
*/
|
||||||
|
class patch_320h implements patchInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $release = '3.2.0.0.a8';
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var Array
|
||||||
|
*/
|
||||||
|
private $concern = array(base::APPLICATION_BOX);
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function get_release()
|
||||||
|
{
|
||||||
|
return $this->release;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function require_all_upgrades()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return Array
|
||||||
|
*/
|
||||||
|
function concern()
|
||||||
|
{
|
||||||
|
return $this->concern;
|
||||||
|
}
|
||||||
|
|
||||||
|
function apply(base &$appbox)
|
||||||
|
{
|
||||||
|
$sql = 'DELETE FROM basusr WHERE actif = "0"';
|
||||||
|
|
||||||
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
|
$stmt->execute();
|
||||||
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -59,7 +59,7 @@ class patch_360 implements patchInterface
|
|||||||
|
|
||||||
foreach ($tables as $table)
|
foreach ($tables as $table)
|
||||||
{
|
{
|
||||||
$sql = 'TRUNCATE ' . $table;
|
$sql = 'DELETE FROM ' . $table;
|
||||||
$stmt = $appbox->get_connection()->prepare($sql);
|
$stmt = $appbox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
@@ -54,12 +54,18 @@ class patch_3602 implements patchInterface
|
|||||||
|
|
||||||
function apply(base &$databox)
|
function apply(base &$databox)
|
||||||
{
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
|
$sql = 'ALTER TABLE `metadatas` DROP INDEX `unique`';
|
||||||
|
|
||||||
$stmt = $databox->get_connection()->prepare($sql);
|
$stmt = $databox->get_connection()->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
}
|
||||||
|
catch(\PDOException $e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@@ -11,9 +11,11 @@
|
|||||||
|
|
||||||
class random
|
class random
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const NUMBERS = "0123456789";
|
const NUMBERS = "0123456789";
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -23,6 +25,14 @@ class random
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const LETTERS_AND_NUMBERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
const LETTERS_AND_NUMBERS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
const TYPE_FEED_ENTRY = 'FEED_ENTRY';
|
||||||
|
const TYPE_PASSWORD = 'password';
|
||||||
|
const TYPE_DOWNLOAD = 'download';
|
||||||
|
const TYPE_MAIL_DOWNLOAD = 'mail-download';
|
||||||
|
const TYPE_EMAIL = 'email';
|
||||||
|
const TYPE_VIEW = 'view';
|
||||||
|
const TYPE_VALIDATE = 'validate';
|
||||||
|
const TYPE_RSS = 'rss';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -112,8 +122,22 @@ class random
|
|||||||
$conn = connection::getPDOConnection();
|
$conn = connection::getPDOConnection();
|
||||||
$token = $test = false;
|
$token = $test = false;
|
||||||
|
|
||||||
if (!in_array($type, array('password', 'download', 'mail-download', 'email', 'view', 'validate', 'rss')))
|
switch ($type)
|
||||||
|
{
|
||||||
|
case self::TYPE_DOWNLOAD:
|
||||||
|
case self::TYPE_PASSWORD:
|
||||||
|
case self::TYPE_MAIL_DOWNLOAD:
|
||||||
|
case self::TYPE_EMAIL:
|
||||||
|
case self::TYPE_VALIDATE:
|
||||||
|
case self::TYPE_VIEW:
|
||||||
|
case self::TYPE_RSS:
|
||||||
|
case self::TYPE_FEED_ENTRY:
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
throw new Exception_InvalidArgument();
|
throw new Exception_InvalidArgument();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
$n = 1;
|
$n = 1;
|
||||||
|
|
||||||
|
@@ -95,8 +95,6 @@ interface record_Interface
|
|||||||
|
|
||||||
public function set_binary_status($status);
|
public function set_binary_status($status);
|
||||||
|
|
||||||
public function get_reg_name();
|
|
||||||
|
|
||||||
public function get_hd_file();
|
public function get_hd_file();
|
||||||
|
|
||||||
public function delete();
|
public function delete();
|
||||||
|
@@ -140,8 +140,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
const CACHE_GROUPING = 'grouping';
|
const CACHE_GROUPING = 'grouping';
|
||||||
const CACHE_STATUS = 'status';
|
const CACHE_STATUS = 'status';
|
||||||
|
|
||||||
protected static $_regfields;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param <int> $base_id
|
* @param <int> $base_id
|
||||||
@@ -895,16 +893,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
*/
|
*/
|
||||||
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null)
|
||||||
{
|
{
|
||||||
$sbas_id = $this->get_sbas_id();
|
|
||||||
$record_id = $this->get_record_id();
|
|
||||||
|
|
||||||
if ($this->is_grouping())
|
|
||||||
{
|
|
||||||
$regfield = self::getRegFields($sbas_id, $this->get_caption());
|
|
||||||
|
|
||||||
return $regfield['regname'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$title = '';
|
$title = '';
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
$appbox = appbox::get_instance(\bootstrap::getCore());
|
||||||
$session = $appbox->get_session();
|
$session = $appbox->get_session();
|
||||||
@@ -944,98 +932,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $title;
|
return $title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get_description()
|
|
||||||
{
|
|
||||||
|
|
||||||
if (!$this->is_grouping())
|
|
||||||
throw new \Exception('This record is not a story');
|
|
||||||
|
|
||||||
$regfield = self::getRegFields($this->get_sbas_id(), $this->get_caption());
|
|
||||||
|
|
||||||
return $regfield['regdesc'];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param <type> $sbas_id
|
|
||||||
* @param caption_record $desc
|
|
||||||
* @return <type>
|
|
||||||
*/
|
|
||||||
protected static function getRegFields($sbas_id, caption_record $desc)
|
|
||||||
{
|
|
||||||
if (!self::$_regfields)
|
|
||||||
self::load_regfields();
|
|
||||||
|
|
||||||
$arrayRegFields = self::$_regfields[$sbas_id];
|
|
||||||
|
|
||||||
$array = array();
|
|
||||||
|
|
||||||
foreach ($arrayRegFields as $k => $f)
|
|
||||||
{
|
|
||||||
$array[$f] = $k;
|
|
||||||
}
|
|
||||||
|
|
||||||
$fields = array();
|
|
||||||
$fields["regname"] = "";
|
|
||||||
$fields["regdesc"] = "";
|
|
||||||
$fields["regdate"] = "";
|
|
||||||
|
|
||||||
foreach ($desc->get_fields() as $caption_field)
|
|
||||||
{
|
|
||||||
/* @var $caption_field caption_field */
|
|
||||||
$meta_struct_id = $caption_field->get_meta_struct_id();
|
|
||||||
if (array_key_exists($meta_struct_id, $array))
|
|
||||||
{
|
|
||||||
$fields[$array[$meta_struct_id]] = $caption_field->get_serialized_values();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get databox reg fields
|
|
||||||
*
|
|
||||||
* @todo change this shit
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
protected static function load_regfields()
|
|
||||||
{
|
|
||||||
$appbox = appbox::get_instance(\bootstrap::getCore());
|
|
||||||
self::$_regfields = array();
|
|
||||||
foreach ($appbox->get_databoxes() as $databox)
|
|
||||||
{
|
|
||||||
self::$_regfields[$databox->get_sbas_id()] = self::searchRegFields($databox->get_meta_structure());
|
|
||||||
}
|
|
||||||
|
|
||||||
return self::$_regfields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param databox_descriptionStructure $meta_struct
|
|
||||||
* @return <type>
|
|
||||||
*/
|
|
||||||
protected function searchRegFields(databox_descriptionStructure $meta_struct)
|
|
||||||
{
|
|
||||||
$fields = null;
|
|
||||||
$fields["regname"] = "";
|
|
||||||
$fields["regdesc"] = "";
|
|
||||||
$fields["regdate"] = "";
|
|
||||||
|
|
||||||
foreach ($meta_struct as $meta)
|
|
||||||
{
|
|
||||||
if ($meta->is_regname())
|
|
||||||
$fields["regname"] = $meta->get_id();
|
|
||||||
elseif ($meta->is_regdesc())
|
|
||||||
$fields["regdesc"] = $meta->get_id();
|
|
||||||
elseif ($meta->is_regdate())
|
|
||||||
$fields['regdate'] = $meta->get_id();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $fields;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @return media_subdef
|
* @return media_subdef
|
||||||
@@ -1487,42 +1383,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function get_reg_name()
|
|
||||||
{
|
|
||||||
if (!$this->is_grouping())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
$balisename = '';
|
|
||||||
|
|
||||||
$struct = $this->databox->get_structure();
|
|
||||||
|
|
||||||
if ($sxe = simplexml_load_string($struct))
|
|
||||||
{
|
|
||||||
$z = $sxe->xpath('/record/description');
|
|
||||||
if ($z && is_array($z))
|
|
||||||
{
|
|
||||||
foreach ($z[0] as $ki => $vi)
|
|
||||||
{
|
|
||||||
if ($vi['regname'] == '1')
|
|
||||||
{
|
|
||||||
$balisename = $ki;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$regname = '';
|
|
||||||
if ($sxe = simplexml_load_string($this->get_xml()))
|
|
||||||
$regname = (string) $sxe->description->$balisename;
|
|
||||||
|
|
||||||
return $regname;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@@ -631,7 +631,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
|
|||||||
return array();
|
return array();
|
||||||
$rs = $res['results'];
|
$rs = $res['results'];
|
||||||
$res = array_shift($rs);
|
$res = array_shift($rs);
|
||||||
if (!$res['xml'])
|
if (! isset($res['xml']))
|
||||||
|
|
||||||
return array();
|
return array();
|
||||||
$sxe = simplexml_load_string($res['xml']);
|
$sxe = simplexml_load_string($res['xml']);
|
||||||
@@ -645,7 +645,8 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
|
|||||||
{
|
{
|
||||||
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
|
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
|
||||||
}
|
}
|
||||||
$val = implode(' '.$field['separator'].' ', $val);
|
$separator = $field['separator'] ? $field['separator'][0] : '';
|
||||||
|
$val = implode(' '.$separator.' ', $val);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -222,14 +222,26 @@ class set_order extends set_abstract
|
|||||||
$core = \bootstrap::getCore();
|
$core = \bootstrap::getCore();
|
||||||
|
|
||||||
$em = $core->getEntityManager();
|
$em = $core->getEntityManager();
|
||||||
|
|
||||||
|
$Basket = null;
|
||||||
|
/* @var $repository \Repositories\BasketRepository */
|
||||||
|
if($this->ssel_id)
|
||||||
|
{
|
||||||
$repository = $em->getRepository('\Entities\Basket');
|
$repository = $em->getRepository('\Entities\Basket');
|
||||||
|
|
||||||
/* @var $repository \Repositories\BasketRepository */
|
try
|
||||||
|
{
|
||||||
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
|
$Basket = $repository->findUserBasket($this->ssel_id, $core->getAuthenticatedUser(), false);
|
||||||
|
}
|
||||||
|
catch(\Exception $e)
|
||||||
|
{
|
||||||
|
$Basket = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!$Basket)
|
if(!$Basket)
|
||||||
{
|
{
|
||||||
$Basket = new Basket();
|
$Basket = new \Entities\Basket();
|
||||||
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
|
$Basket->setName(sprintf(_('Commande du %s'), $this->created_on->format('Y-m-d')));
|
||||||
$Basket->setOwner($this->user);
|
$Basket->setOwner($this->user);
|
||||||
$Basket->setPusher($core->getAuthenticatedUser());
|
$Basket->setPusher($core->getAuthenticatedUser());
|
||||||
@@ -265,7 +277,7 @@ class set_order extends set_abstract
|
|||||||
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
|
$sbas_id = phrasea::sbasFromBas($basrec['base_id']);
|
||||||
$record = new record_adapter($sbas_id, $basrec['record_id']);
|
$record = new record_adapter($sbas_id, $basrec['record_id']);
|
||||||
|
|
||||||
$BasketElement = new BasketElement();
|
$BasketElement = new \Entities\BasketElement();
|
||||||
$BasketElement->setRecord($record);
|
$BasketElement->setRecord($record);
|
||||||
$BasketElement->setBasket($Basket);
|
$BasketElement->setBasket($Basket);
|
||||||
|
|
||||||
@@ -273,7 +285,6 @@ class set_order extends set_abstract
|
|||||||
|
|
||||||
$em->persist($BasketElement);
|
$em->persist($BasketElement);
|
||||||
|
|
||||||
$em->merge($Basket);
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
':usr_id' => $session->get_usr_id()
|
':usr_id' => $session->get_usr_id()
|
||||||
|
@@ -608,18 +608,16 @@ class setup
|
|||||||
{
|
{
|
||||||
$stats = $Core->getCache()->getStats();
|
$stats = $Core->getCache()->getStats();
|
||||||
|
|
||||||
foreach ($stats as $name => $stat)
|
|
||||||
{
|
|
||||||
echo '<li>Statistics given by `' . $name . '`</li>';
|
|
||||||
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
|
echo '<li>' . sprintf(_('setup::Serveur actif sur %s'), $registry->get('GV_cache_server_host') . ':' . $registry->get('GV_cache_server_port')) . '</li>';
|
||||||
echo "<table>";
|
echo "<table>";
|
||||||
foreach ($stat as $key => $value)
|
|
||||||
|
foreach ($stats as $name => $stat)
|
||||||
{
|
{
|
||||||
echo "<tr class='even'><td>" . $key . "</td><td> " . $value . "</td></tr>";
|
echo "<tr class='even'><td>" . $name . "</td><td> " . $stat . "</td></tr>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>";
|
echo "</table>";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
echo '<li class="non-blocker">' . sprintf(_('setup::Aucun serveur memcached rattache.')) . '</li>';
|
echo '<li class="non-blocker">' . sprintf(_('setup::Aucun serveur memcached rattache.')) . '</li>';
|
||||||
@@ -643,9 +641,9 @@ class setup
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($found > 1)
|
if ($found > 1)
|
||||||
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, 'Many opcode cache load is forbidden', true);
|
$constraints[] = new Setup_Constraint('Multiple opcode caches', false, _('Many opcode cache load is forbidden'), true);
|
||||||
if ($found === 0)
|
if ($found === 0)
|
||||||
$constraints[] = new Setup_Constraint('No opcode cache', false, 'No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.', false);
|
$constraints[] = new Setup_Constraint('No opcode cache', false, _('No opcode cache were detected. Phraseanet strongly recommends the use of XCache or APC.'), false);
|
||||||
|
|
||||||
return new Setup_ConstraintsIterator($constraints);
|
return new Setup_ConstraintsIterator($constraints);
|
||||||
}
|
}
|
||||||
|
@@ -76,6 +76,8 @@ class sphinx_configuration
|
|||||||
|
|
||||||
$options = array_merge($defaults, $options);
|
$options = array_merge($defaults, $options);
|
||||||
|
|
||||||
|
$options['charset_tables'] = array_unique($options['charset_tables']);
|
||||||
|
|
||||||
$lb = phrasea::sbas_params();
|
$lb = phrasea::sbas_params();
|
||||||
|
|
||||||
$conf = '';
|
$conf = '';
|
||||||
@@ -593,6 +595,9 @@ searchd
|
|||||||
# optional, default is 256
|
# optional, default is 256
|
||||||
#
|
#
|
||||||
max_filters = 512
|
max_filters = 512
|
||||||
|
|
||||||
|
compat_sphinxql_magics = 0
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
';
|
';
|
||||||
|
@@ -122,7 +122,7 @@ class sphinxrt
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, Array $content, DateTime $created)
|
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created)
|
||||||
{
|
{
|
||||||
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
|
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
|
||||||
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
|
||||||
@@ -131,11 +131,9 @@ class sphinxrt
|
|||||||
|
|
||||||
$this->connection->beginTransaction();
|
$this->connection->beginTransaction();
|
||||||
|
|
||||||
// foreach ($content as $value)
|
|
||||||
// {
|
|
||||||
$sql = "REPLACE INTO " . $rt_id . " VALUES (
|
$sql = "REPLACE INTO " . $rt_id . " VALUES (
|
||||||
'" . (int) $meta_id . "'
|
'" . (int) $meta_id . "'
|
||||||
,'" . str_replace("'", "\'", implode(' ', $content)) . "'
|
,'" . str_replace("'", "\'", $content) . "'
|
||||||
,'" . (int) $tag_id . "'
|
,'" . (int) $tag_id . "'
|
||||||
," . (int) $record_id . "
|
," . (int) $record_id . "
|
||||||
," . (int) $sbas_id . "
|
," . (int) $sbas_id . "
|
||||||
@@ -149,7 +147,6 @@ class sphinxrt
|
|||||||
," . (int) $created->format('U') . " )";
|
," . (int) $created->format('U') . " )";
|
||||||
$stmt = $this->connection->prepare($sql);
|
$stmt = $this->connection->prepare($sql);
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
// }
|
|
||||||
|
|
||||||
$stmt->closeCursor();
|
$stmt->closeCursor();
|
||||||
|
|
||||||
|
@@ -1391,7 +1391,7 @@ class unicode
|
|||||||
return $no_diacritics;
|
return $no_diacritics;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove_nonazAZ09($string, $keep_underscores = true, $keep_minus = true)
|
public function remove_nonazAZ09($string, $keep_underscores = true, $keep_minus = true, $keep_dot = false)
|
||||||
{
|
{
|
||||||
$regexp = '/[a-zA-Z0-9';
|
$regexp = '/[a-zA-Z0-9';
|
||||||
if ($keep_minus === true)
|
if ($keep_minus === true)
|
||||||
@@ -1402,6 +1402,11 @@ class unicode
|
|||||||
{
|
{
|
||||||
$regexp .= '_';
|
$regexp .= '_';
|
||||||
}
|
}
|
||||||
|
if ($keep_dot === true)
|
||||||
|
{
|
||||||
|
$regexp .= '\.';
|
||||||
|
}
|
||||||
|
|
||||||
$regexp .= ']{1}/';
|
$regexp .= ']{1}/';
|
||||||
|
|
||||||
$string = $this->remove_diacritics($string);
|
$string = $this->remove_diacritics($string);
|
||||||
|
@@ -10,8 +10,10 @@ $GV_sit = md5(time() . '--' . mt_rand(1000000, 9999999));
|
|||||||
|
|
||||||
include_once dirname(__FILE__) . "/../../lib/classes/User/Interface.class.php";
|
include_once dirname(__FILE__) . "/../../lib/classes/User/Interface.class.php";
|
||||||
include_once dirname(__FILE__) . "/../../lib/classes/User/Adapter.class.php";
|
include_once dirname(__FILE__) . "/../../lib/classes/User/Adapter.class.php";
|
||||||
|
|
||||||
$lngs = User_Adapter::avLanguages();
|
$lngs = User_Adapter::avLanguages();
|
||||||
$avLanguages = array();
|
$avLanguages = array();
|
||||||
|
|
||||||
foreach ($lngs as $lng => $locales)
|
foreach ($lngs as $lng => $locales)
|
||||||
{
|
{
|
||||||
foreach ($locales as $loc => $locname)
|
foreach ($locales as $loc => $locname)
|
||||||
@@ -20,7 +22,27 @@ foreach ($lngs as $lng => $locales)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance(\bootstrap::getCore()), bootstrap::getCore());
|
$Core = \bootstrap::getCore();
|
||||||
|
|
||||||
|
$extractDateFields = function(\Alchemy\Phrasea\Core $Core) {
|
||||||
|
$date_sort_fields = array(''=>'');
|
||||||
|
if ($Core->getConfiguration()->isInstalled())
|
||||||
|
{
|
||||||
|
$ProdHelper = new Alchemy\Phrasea\Helper\Prod($Core, Symfony\Component\HttpFoundation\Request::createFromGlobals());
|
||||||
|
$datas = $ProdHelper->get_search_datas();
|
||||||
|
foreach ($datas['dates'] as $date)
|
||||||
|
{
|
||||||
|
$date_sort_fields[$date['fieldname']] = $date['fieldname'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $date_sort_fields;
|
||||||
|
};
|
||||||
|
|
||||||
|
$date_sort_fields = $extractDateFields($Core);
|
||||||
|
|
||||||
|
|
||||||
|
$eventsmanager = eventsmanager_broker::getInstance(appbox::get_instance($Core), $Core);
|
||||||
|
|
||||||
$PHP_CONF = array(
|
$PHP_CONF = array(
|
||||||
'output_buffering' => '4096' //INI_ALL
|
'output_buffering' => '4096' //INI_ALL
|
||||||
@@ -296,38 +318,6 @@ $GV = array(
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
// , array(
|
|
||||||
// 'section' => _('GV::section:: Serveurs de cache'),
|
|
||||||
// 'vars' => array(
|
|
||||||
// array(
|
|
||||||
// 'type' => 'boolean',
|
|
||||||
// 'name' => 'GV_use_cache',
|
|
||||||
// 'comment' => _('reglages:: Utiliser un serveur de cache'),
|
|
||||||
// 'default' => false,
|
|
||||||
// 'required' => true
|
|
||||||
// ),
|
|
||||||
// array(
|
|
||||||
// 'type' => 'enum',
|
|
||||||
// 'name' => 'GV_cache_server_type',
|
|
||||||
// 'comment' => _('reglages:: Utiliser un serveur de cache'),
|
|
||||||
// 'default' => '',
|
|
||||||
// 'available' => array(''=>_('Aucun'),'redis' => 'Redis', 'memcached' => 'Memcached')
|
|
||||||
// ),
|
|
||||||
// array(
|
|
||||||
// 'type' => 'string',
|
|
||||||
// 'name' => 'GV_cache_server_host',
|
|
||||||
// 'comment' => _('setup:: Hote du Serveur de cache'),
|
|
||||||
// 'default' => '127.0.0.1',
|
|
||||||
// 'required' => false
|
|
||||||
// ),
|
|
||||||
// array(
|
|
||||||
// 'type' => 'integer',
|
|
||||||
// 'name' => 'GV_cache_server_port',
|
|
||||||
// 'comment' => _('reglages:: port du serveur de cache'),
|
|
||||||
// 'default' => 11211
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
// )
|
|
||||||
, array(
|
, array(
|
||||||
'section' => _('GV::section:: Serveur Sphinx'),
|
'section' => _('GV::section:: Serveur Sphinx'),
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
@@ -362,6 +352,18 @@ $GV = array(
|
|||||||
'default' => 9308
|
'default' => 9308
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
, array(
|
||||||
|
'section' => _('Phrasea Engine'),
|
||||||
|
'vars' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'enum',
|
||||||
|
'name' => 'GV_phrasea_sort',
|
||||||
|
'comment' => _('Default results sort'),
|
||||||
|
'default' => '',
|
||||||
|
'available' => $date_sort_fields
|
||||||
|
)
|
||||||
|
)
|
||||||
), array(
|
), array(
|
||||||
'section' => _('GV::section:: Executables externes'),
|
'section' => _('GV::section:: Executables externes'),
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
@@ -811,13 +813,12 @@ $GV = array(
|
|||||||
), array(
|
), array(
|
||||||
'section' => _('GV::section:: Configuration du client'),
|
'section' => _('GV::section:: Configuration du client'),
|
||||||
'vars' => array(
|
'vars' => array(
|
||||||
// array(
|
array(
|
||||||
// 'type' => 'enum',
|
'type' => 'integer',
|
||||||
// 'name' => 'GV_bandeauHome',
|
'name' => 'GV_download_max',
|
||||||
// 'comment' => _('reglages:: Affichage par defaut de la home du client'),
|
'comment' => _('Maximum megabytes allowed in download (if request is bigger, then mail is still available)'),
|
||||||
// 'available' => array('QUERY' => _('Question'), 'PUBLI' => _('Publications'), 'HELP' => _('Aide')),
|
'default' => 120
|
||||||
// 'default' => 'QUERY'
|
),
|
||||||
// ),
|
|
||||||
array(
|
array(
|
||||||
'type' => 'integer',
|
'type' => 'integer',
|
||||||
'name' => 'GV_ong_search',
|
'name' => 'GV_ong_search',
|
||||||
|
@@ -3816,7 +3816,7 @@
|
|||||||
</field>
|
</field>
|
||||||
<field>
|
<field>
|
||||||
<name>type</name>
|
<name>type</name>
|
||||||
<type>enum('view','validate','password','rss','email','download')</type>
|
<type>enum('FEED_ENTRY', 'view','validate','password','rss','email','download')</type>
|
||||||
<null></null>
|
<null></null>
|
||||||
<extra></extra>
|
<extra></extra>
|
||||||
<collation>ascii_bin</collation>
|
<collation>ascii_bin</collation>
|
||||||
@@ -5160,30 +5160,6 @@
|
|||||||
<default></default>
|
<default></default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
</field>
|
</field>
|
||||||
<field>
|
|
||||||
<name>regdate</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>regname</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
|
||||||
<name>regdesc</name>
|
|
||||||
<type>tinyint(1) unsigned</type>
|
|
||||||
<null>YES</null>
|
|
||||||
<extra></extra>
|
|
||||||
<default></default>
|
|
||||||
<comment></comment>
|
|
||||||
</field>
|
|
||||||
<field>
|
<field>
|
||||||
<name>report</name>
|
<name>report</name>
|
||||||
<type>tinyint(1) unsigned</type>
|
<type>tinyint(1) unsigned</type>
|
||||||
@@ -5261,27 +5237,6 @@
|
|||||||
<field>required</field>
|
<field>required</field>
|
||||||
</fields>
|
</fields>
|
||||||
</index>
|
</index>
|
||||||
<index>
|
|
||||||
<name>regname</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regname</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
|
||||||
<name>regdate</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regdate</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
|
||||||
<name>regdesc</name>
|
|
||||||
<type>UNIQUE</type>
|
|
||||||
<fields>
|
|
||||||
<field>regdesc</field>
|
|
||||||
</fields>
|
|
||||||
</index>
|
|
||||||
<index>
|
<index>
|
||||||
<name>sorter</name>
|
<name>sorter</name>
|
||||||
<type>UNIQUE</type>
|
<type>UNIQUE</type>
|
||||||
@@ -5826,7 +5781,7 @@
|
|||||||
<field>
|
<field>
|
||||||
<name>results</name>
|
<name>results</name>
|
||||||
<type>int(11) unsigned</type>
|
<type>int(11) unsigned</type>
|
||||||
<null></null>
|
<null>YES</null>
|
||||||
<extra></extra>
|
<extra></extra>
|
||||||
<default>0</default>
|
<default>0</default>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
|
@@ -149,7 +149,7 @@
|
|||||||
<SpecialInstruct src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
<SpecialInstruct src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
||||||
|
|
||||||
<!-- 2:55 -->
|
<!-- 2:55 -->
|
||||||
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" regdate="1" />
|
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" />
|
||||||
|
|
||||||
<!-- 2:80 -->
|
<!-- 2:80 -->
|
||||||
<Byline src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
<Byline src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
||||||
@@ -170,7 +170,7 @@
|
|||||||
<OriginalRef src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
<OriginalRef src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
||||||
|
|
||||||
<!-- 2:105 -->
|
<!-- 2:105 -->
|
||||||
<Headline src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" regname="1" />
|
<Headline src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" />
|
||||||
|
|
||||||
<!-- 2:110 -->
|
<!-- 2:110 -->
|
||||||
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
||||||
|
|
||||||
<!-- 2:120 -->
|
<!-- 2:120 -->
|
||||||
<Caption src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" regdesc="1" />
|
<Caption src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" />
|
||||||
|
|
||||||
<!-- 2:122 -->
|
<!-- 2:122 -->
|
||||||
<CaptionWriter src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
<CaptionWriter src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
||||||
|
@@ -149,7 +149,7 @@
|
|||||||
<Observations src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
<Observations src="/rdf:RDF/rdf:Description/IPTC:SpecialInstructions"/>
|
||||||
|
|
||||||
<!-- 2:55 -->
|
<!-- 2:55 -->
|
||||||
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" regdate="1" />
|
<Date src="/rdf:RDF/rdf:Description/IPTC:DateCreated" type="date" />
|
||||||
|
|
||||||
<!-- 2:80 -->
|
<!-- 2:80 -->
|
||||||
<Signature src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
<Signature src="/rdf:RDF/rdf:Description/IPTC:By-line"/>
|
||||||
@@ -170,7 +170,7 @@
|
|||||||
<ReferencesOriginales src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
<ReferencesOriginales src="/rdf:RDF/rdf:Description/IPTC:OriginalTransmissionReference" />
|
||||||
|
|
||||||
<!-- 2:105 -->
|
<!-- 2:105 -->
|
||||||
<Titre src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" regname="1" />
|
<Titre src="/rdf:RDF/rdf:Description/IPTC:Headline" report="1" />
|
||||||
|
|
||||||
<!-- 2:110 -->
|
<!-- 2:110 -->
|
||||||
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
<Credit src="/rdf:RDF/rdf:Description/IPTC:Credit" report="1" />
|
||||||
@@ -179,7 +179,7 @@
|
|||||||
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
<Source src="/rdf:RDF/rdf:Description/IPTC:Source" />
|
||||||
|
|
||||||
<!-- 2:120 -->
|
<!-- 2:120 -->
|
||||||
<Legende src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" regdesc="1" />
|
<Legende src="/rdf:RDF/rdf:Description/IPTC:Caption-Abstract" />
|
||||||
|
|
||||||
<!-- 2:122 -->
|
<!-- 2:122 -->
|
||||||
<Redacteur src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
<Redacteur src="/rdf:RDF/rdf:Description/IPTC:Writer-Editor" />
|
||||||
|
@@ -32,6 +32,13 @@
|
|||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
<filter>
|
||||||
|
<blacklist>
|
||||||
|
<directory>./vendor</directory>
|
||||||
|
<directory>./unitTest</directory>
|
||||||
|
</blacklist>
|
||||||
|
</filter>
|
||||||
|
|
||||||
<listeners>
|
<listeners>
|
||||||
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener>
|
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener>
|
||||||
</listeners>
|
</listeners>
|
||||||
|
@@ -363,6 +363,39 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRecordsCaptionRoute()
|
||||||
|
{
|
||||||
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
|
{
|
||||||
|
$databox = databox::get_instance($databox_id);
|
||||||
|
|
||||||
|
$collection = array_shift($databox->get_collections());
|
||||||
|
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
|
||||||
|
|
||||||
|
$record = record_adapter::create($collection, $system_file);
|
||||||
|
|
||||||
|
$record_id = $record->get_record_id();
|
||||||
|
|
||||||
|
$route = '/records/' . $databox_id . '/' . $record_id . '/caption/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
|
||||||
|
$crawler = $this->client->request('GET', $route);
|
||||||
|
$content = json_decode($this->client->getResponse()->getContent());
|
||||||
|
|
||||||
|
$this->evaluateResponse200($this->client->getResponse());
|
||||||
|
$this->evaluateMetaJson200($content);
|
||||||
|
|
||||||
|
$this->evaluateRecordsCaptionResponse($content);
|
||||||
|
$record->delete();
|
||||||
|
}
|
||||||
|
$route = '/records/24892534/51654651553/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateNotFoundRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
$route = '/records/any_bad_id/sfsd5qfsd5/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateBadRequestRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testRecordsMetadatasRoute()
|
public function testRecordsMetadatasRoute()
|
||||||
{
|
{
|
||||||
foreach (static::$databoxe_ids as $databox_id)
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
@@ -1160,6 +1193,20 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function evaluateRecordsCaptionResponse($content)
|
||||||
|
{
|
||||||
|
foreach ($content->response as $field)
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_object($field), 'Un bloc field est un objet');
|
||||||
|
$this->assertObjectHasAttribute('meta_structure_id', $meta);
|
||||||
|
$this->assertTrue(is_int($field->meta_structure_id));
|
||||||
|
$this->assertObjectHasAttribute('name', $field);
|
||||||
|
$this->assertTrue(is_string($meta->name));
|
||||||
|
$this->assertObjectHasAttribute('value', $field);
|
||||||
|
$this->assertTrue(is_string($meta->value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function evaluateRecordsMetadataResponse($content)
|
protected function evaluateRecordsMetadataResponse($content)
|
||||||
{
|
{
|
||||||
$this->assertObjectHasAttribute("metadatas", $content->response);
|
$this->assertObjectHasAttribute("metadatas", $content->response);
|
||||||
|
@@ -369,6 +369,39 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRecordsCaptionRoute()
|
||||||
|
{
|
||||||
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
|
{
|
||||||
|
$databox = databox::get_instance($databox_id);
|
||||||
|
|
||||||
|
$collection = array_shift($databox->get_collections());
|
||||||
|
$system_file = new system_file(__DIR__ . '/../../../testfiles/cestlafete.jpg');
|
||||||
|
|
||||||
|
$record = record_adapter::create($collection, $system_file);
|
||||||
|
|
||||||
|
$record_id = $record->get_record_id();
|
||||||
|
|
||||||
|
$route = '/records/' . $databox_id . '/' . $record_id . '/caption/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
|
||||||
|
$crawler = $this->client->request('GET', $route , array(), array(), array("HTTP_ACCEPT" => "application/yaml"));
|
||||||
|
$content = self::$yaml->parse($this->client->getResponse()->getContent());
|
||||||
|
|
||||||
|
$this->evaluateResponse200($this->client->getResponse());
|
||||||
|
$this->evaluateMetaYaml200($content);
|
||||||
|
|
||||||
|
$this->evaluateRecordsCaptionResponse($content);
|
||||||
|
$record->delete();
|
||||||
|
}
|
||||||
|
$route = '/records/24892534/51654651553/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateNotFoundRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
$route = '/records/any_bad_id/sfsd5qfsd5/metadatas/?oauth_token=' . self::$token;
|
||||||
|
$this->evaluateBadRequestRoute($route, array('GET'));
|
||||||
|
$this->evaluateMethodNotAllowedRoute($route, array('POST', 'PUT', 'DELETE'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testRecordsMetadatasRoute()
|
public function testRecordsMetadatasRoute()
|
||||||
{
|
{
|
||||||
foreach (static::$databoxe_ids as $databox_id)
|
foreach (static::$databoxe_ids as $databox_id)
|
||||||
@@ -1197,6 +1230,20 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function evaluateRecordsCaptionResponse($content)
|
||||||
|
{
|
||||||
|
foreach ($content["response"] as $field)
|
||||||
|
{
|
||||||
|
$this->assertTrue(is_array($field), 'Un bloc field est un objet');
|
||||||
|
$this->assertArrayHasKey('meta_structure_id', $meta);
|
||||||
|
$this->assertTrue(is_int($field["meta_structure_id"]));
|
||||||
|
$this->assertArrayHasKey('name', $field);
|
||||||
|
$this->assertTrue(is_string($meta["name"]));
|
||||||
|
$this->assertArrayHasKey('value', $field);
|
||||||
|
$this->assertTrue(is_string($meta["value"]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function evaluateRecordsMetadataResponse($content)
|
protected function evaluateRecordsMetadataResponse($content)
|
||||||
{
|
{
|
||||||
$this->assertArrayHasKey("metadatas", $content["response"]);
|
$this->assertArrayHasKey("metadatas", $content["response"]);
|
||||||
|
@@ -59,9 +59,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'User'
|
, 'vocabulary_' . $id => 'User'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -149,9 +146,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -169,9 +163,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -194,9 +185,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -220,9 +208,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
, 'vocabulary_' . $id => 'Unknow_Vocabulary'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isRedirect());
|
$this->assertTrue($this->client->getResponse()->isRedirect());
|
||||||
@@ -251,9 +236,6 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
, 'readonly_' . $id => 0
|
, 'readonly_' . $id => 0
|
||||||
, 'type_' . $id => 'string'
|
, 'type_' . $id => 'string'
|
||||||
, 'vocabulary_' . $id => 'User'
|
, 'vocabulary_' . $id => 'User'
|
||||||
, 'regname' => $id
|
|
||||||
, 'regdate' => $id
|
|
||||||
, 'regdesc' => $id
|
|
||||||
));
|
));
|
||||||
$this->assertTrue($this->client->getResponse()->isOk());
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
$this->assertEquals("You are not allowed to access this zone", $this->client->getResponse()->getContent());
|
||||||
|
@@ -461,6 +461,74 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->assertEquals(2, $basket->getElements()->count());
|
$this->assertEquals(2, $basket->getElements()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function testAddElementToValidationPost()
|
||||||
|
{
|
||||||
|
|
||||||
|
$em = self::$core->getEntityManager();
|
||||||
|
|
||||||
|
$datas = $em->getRepository('Entities\ValidationData')->findAll();
|
||||||
|
$countDatas = count($datas);
|
||||||
|
|
||||||
|
$validationSession = new \Entities\ValidationSession();
|
||||||
|
|
||||||
|
$validationSession->setDescription('Une description au hasard');
|
||||||
|
$validationSession->setName('Un nom de validation');
|
||||||
|
$expires = new \DateTime();
|
||||||
|
$expires->modify('+1 week');
|
||||||
|
$validationSession->setExpires($expires);
|
||||||
|
$validationSession->setInitiator(self::$user);
|
||||||
|
|
||||||
|
$basket = new \Entities\Basket();
|
||||||
|
$basket->setName('test');
|
||||||
|
$basket->setDescription('description');
|
||||||
|
$basket->setOwner(self::$user);
|
||||||
|
$basket->setValidation($validationSession);
|
||||||
|
$validationSession->setBasket($basket);
|
||||||
|
|
||||||
|
|
||||||
|
$validationParticipant = new \Entities\ValidationParticipant();
|
||||||
|
$validationParticipant->setSession($validationSession);
|
||||||
|
$validationParticipant->setUser(self::$user_alt1);
|
||||||
|
$validationSession->addValidationParticipant($validationParticipant);
|
||||||
|
|
||||||
|
$em->persist($validationParticipant);
|
||||||
|
$em->persist($basket);
|
||||||
|
$em->persist($validationSession);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
$route = sprintf('/baskets/%s/addElements/', $basket->getId());
|
||||||
|
|
||||||
|
$records = array(
|
||||||
|
self::$record_1->get_serialize_key(),
|
||||||
|
self::$record_2->get_serialize_key(),
|
||||||
|
' ',
|
||||||
|
'42',
|
||||||
|
'abhak',
|
||||||
|
self::$record_no_access->get_serialize_key(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$lst = implode(';', $records);
|
||||||
|
|
||||||
|
$this->client->request('POST', $route, array('lst' => $lst));
|
||||||
|
|
||||||
|
$response = $this->client->getResponse();
|
||||||
|
|
||||||
|
$this->assertEquals(302, $response->getStatusCode());
|
||||||
|
|
||||||
|
$em = self::$core->getEntityManager();
|
||||||
|
/* @var $em \Doctrine\ORM\EntityManager */
|
||||||
|
$basket = $em->getRepository('Entities\Basket')->find($basket->getId());
|
||||||
|
|
||||||
|
$this->assertEquals(2, $basket->getElements()->count());
|
||||||
|
|
||||||
|
$datas = $em->getRepository('Entities\ValidationData')->findAll();
|
||||||
|
|
||||||
|
$this->assertTrue($countDatas < count($datas), 'assert that '.count($datas).' > '.$countDatas );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testAddElementPostJSON()
|
public function testAddElementPostJSON()
|
||||||
{
|
{
|
||||||
$basket = $this->insertOneBasket();
|
$basket = $this->insertOneBasket();
|
||||||
|
@@ -163,16 +163,6 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
|
self::$account = Bridge_Account::create(appbox::get_instance(\bootstrap::getCore()), self::$api, self::$user, 'kirikoo', 'coucou');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLogoutDeconnected()
|
|
||||||
{
|
|
||||||
$this->client->followRedirects();
|
|
||||||
$url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
|
|
||||||
$crawler = $this->client->request('GET', $url);
|
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
|
||||||
$this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
|
|
||||||
$this->deconnected($crawler, $pageContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLogout()
|
public function testLogout()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
||||||
@@ -193,16 +183,6 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
|
$this->assertNotContains(self::$account->get_api()->generate_login_url(registry::get_instance(), self::$account->get_api()->get_connector()->get_name()), $this->client->getResponse()->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testLoadElementsDisconnected()
|
|
||||||
{
|
|
||||||
$url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
|
||||||
$this->assertTrue($this->client->getResponse()->isOk());
|
|
||||||
$pageContent = $this->client->getResponse()->getContent();
|
|
||||||
$this->assertContains($url, $pageContent);
|
|
||||||
$this->deconnected($crawler, $pageContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testLoadRecords()
|
public function testLoadRecords()
|
||||||
{
|
{
|
||||||
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
self::$account->get_settings()->set("auth_token", "somethingNotNull"); //connected
|
||||||
@@ -216,6 +196,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testLoadRecordsDisconnected()
|
public function testLoadRecordsDisconnected()
|
||||||
{
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
self::$account->get_settings()->set("auth_token", null); //deconnected
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
|
$url = sprintf("/bridge/adapter/%s/load-records/", self::$account->get_id());
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
@@ -236,6 +217,7 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testLoadContainersDisconnected()
|
public function testLoadContainersDisconnected()
|
||||||
{
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
self::$account->get_settings()->set("auth_token", null); //deconnected
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
|
$url = sprintf("/bridge/adapter/%s/load-containers/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_container_type());
|
||||||
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
@@ -244,8 +226,32 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$this->deconnected($crawler, $pageContent);
|
$this->deconnected($crawler, $pageContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testLoadElementsDisconnected()
|
||||||
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
|
$url = sprintf("/bridge/adapter/%s/load-elements/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
||||||
|
$crawler = $this->client->request('GET', $url, array("page" => 1));
|
||||||
|
$this->assertTrue($this->client->getResponse()->isOk());
|
||||||
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
|
$this->assertContains($url, $pageContent);
|
||||||
|
$this->deconnected($crawler, $pageContent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testLogoutDeconnected()
|
||||||
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
|
$url = sprintf('/bridge/adapter/%d/logout/', self::$account->get_id());
|
||||||
|
$crawler = $this->client->request('GET', $url);
|
||||||
|
$pageContent = $this->client->getResponse()->getContent();
|
||||||
|
$this->assertContains("/adapter/" . self::$account->get_id() . "/logout/", $pageContent);
|
||||||
|
$this->deconnected($crawler, $pageContent);
|
||||||
|
}
|
||||||
|
|
||||||
public function testActionDeconnected()
|
public function testActionDeconnected()
|
||||||
{
|
{
|
||||||
|
$this->client->followRedirects();
|
||||||
self::$account->get_settings()->set("auth_token", null); //deconnected
|
self::$account->get_settings()->set("auth_token", null); //deconnected
|
||||||
$url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
$url = sprintf("/bridge/action/%s/une action/%s/", self::$account->get_id(), self::$account->get_api()->get_connector()->get_default_element_type());
|
||||||
$crawler = $this->client->request('GET', $url);
|
$crawler = $this->client->request('GET', $url);
|
||||||
|
@@ -61,8 +61,8 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$crawler = $this->client->request(
|
$crawler = $this->client->request(
|
||||||
'POST', $route, array(
|
'POST', $route, array(
|
||||||
'base_id' => $collection->get_base_id(),
|
'base_id' => $collection->get_base_id(),
|
||||||
'name' => 'test story',
|
'name' => 'test story'
|
||||||
'description' => 'test_description')
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$response = $this->client->getResponse();
|
$response = $this->client->getResponse();
|
||||||
@@ -91,8 +91,7 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$crawler = $this->client->request(
|
$crawler = $this->client->request(
|
||||||
'POST', $route, array(
|
'POST', $route, array(
|
||||||
'base_id' => $collection->get_base_id(),
|
'base_id' => $collection->get_base_id(),
|
||||||
'name' => 'test story',
|
'name' => 'test story'), array(), array(
|
||||||
'description' => 'test_description'), array(), array(
|
|
||||||
"HTTP_ACCEPT" => "application/json")
|
"HTTP_ACCEPT" => "application/json")
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -117,9 +116,6 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
$filter = "form[action='/prod/story/'] input[name='name']";
|
$filter = "form[action='/prod/story/'] input[name='name']";
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
$this->assertEquals(1, $crawler->filter($filter)->count());
|
||||||
|
|
||||||
$filter = "form[action='/prod/story/'] textarea[name='description']";
|
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
|
||||||
|
|
||||||
$filter = "form[action='/prod/story/'] select[name='base_id']";
|
$filter = "form[action='/prod/story/'] select[name='base_id']";
|
||||||
$this->assertEquals(1, $crawler->filter($filter)->count());
|
$this->assertEquals(1, $crawler->filter($filter)->count());
|
||||||
}
|
}
|
||||||
@@ -229,7 +225,4 @@ class ControllerStoryTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -300,72 +300,6 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regdate().
|
|
||||||
*/
|
|
||||||
public function testSet_regdate()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regdesc().
|
|
||||||
*/
|
|
||||||
public function testSet_regdesc()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testSet_regname().
|
|
||||||
*/
|
|
||||||
public function testSet_regname()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regname().
|
|
||||||
*/
|
|
||||||
public function testIs_regname()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regdesc().
|
|
||||||
*/
|
|
||||||
public function testIs_regdesc()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @todo Implement testIs_regdate().
|
|
||||||
*/
|
|
||||||
public function testIs_regdate()
|
|
||||||
{
|
|
||||||
// Remove the following lines when you implement this test.
|
|
||||||
$this->markTestIncomplete(
|
|
||||||
'This test has not been implemented yet.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Implement testGet_thumbtitle().
|
* @todo Implement testGet_thumbtitle().
|
||||||
*/
|
*/
|
||||||
|
@@ -13,7 +13,7 @@ class randomTest extends PhraseanetPHPUnitAbstract
|
|||||||
{
|
{
|
||||||
$expires_on = new DateTime('-5 minutes');
|
$expires_on = new DateTime('-5 minutes');
|
||||||
$usr_id = self::$user->get_id();
|
$usr_id = self::$user->get_id();
|
||||||
$token = random::getUrlToken('password', $usr_id, $expires_on, 'some nice datas');
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expires_on, 'some nice datas');
|
||||||
random::cleanTokens();
|
random::cleanTokens();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -76,7 +76,7 @@ class randomTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function testGetUrlToken()
|
public function testGetUrlToken()
|
||||||
{
|
{
|
||||||
$usr_id = self::$user->get_id();
|
$usr_id = self::$user->get_id();
|
||||||
$token = random::getUrlToken('password', $usr_id, null, 'some nice datas');
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, null, 'some nice datas');
|
||||||
$datas = random::helloToken($token);
|
$datas = random::helloToken($token);
|
||||||
$this->assertEquals('some nice datas', $datas['datas']);
|
$this->assertEquals('some nice datas', $datas['datas']);
|
||||||
random::updateToken($token, 'some very nice datas');
|
random::updateToken($token, 'some very nice datas');
|
||||||
@@ -101,7 +101,7 @@ class randomTest extends PhraseanetPHPUnitAbstract
|
|||||||
public function testHelloToken()
|
public function testHelloToken()
|
||||||
{
|
{
|
||||||
$usr_id = self::$user->get_id();
|
$usr_id = self::$user->get_id();
|
||||||
$token = random::getUrlToken('password', $usr_id, null, 'some nice datas');
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, null, 'some nice datas');
|
||||||
$datas = random::helloToken($token);
|
$datas = random::helloToken($token);
|
||||||
$this->assertEquals('some nice datas', $datas['datas']);
|
$this->assertEquals('some nice datas', $datas['datas']);
|
||||||
$this->assertNull($datas['expire_on']);
|
$this->assertNull($datas['expire_on']);
|
||||||
@@ -125,7 +125,7 @@ class randomTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
$expires_on = new DateTime('+5 minutes');
|
$expires_on = new DateTime('+5 minutes');
|
||||||
$usr_id = self::$user->get_id();
|
$usr_id = self::$user->get_id();
|
||||||
$token = random::getUrlToken('password', $usr_id, $expires_on, 'some nice datas');
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expires_on, 'some nice datas');
|
||||||
$datas = random::helloToken($token);
|
$datas = random::helloToken($token);
|
||||||
$this->assertEquals('some nice datas', $datas['datas']);
|
$this->assertEquals('some nice datas', $datas['datas']);
|
||||||
$sql_expires = new DateTime($datas['expire_on']);
|
$sql_expires = new DateTime($datas['expire_on']);
|
||||||
@@ -151,7 +151,7 @@ class randomTest extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
$expires_on = new DateTime('-5 minutes');
|
$expires_on = new DateTime('-5 minutes');
|
||||||
$usr_id = self::$user->get_id();
|
$usr_id = self::$user->get_id();
|
||||||
$token = random::getUrlToken('password', $usr_id, $expires_on, 'some nice datas');
|
$token = random::getUrlToken(\random::TYPE_PASSWORD, $usr_id, $expires_on, 'some nice datas');
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user