This commit is contained in:
Nicolas Le Goff
2012-01-19 16:22:06 +01:00
77 changed files with 1436 additions and 1101 deletions

View File

@@ -44,9 +44,9 @@ doctrine_dev:
#Metadata cache : is used to cache entity class metadatas #Metadata cache : is used to cache entity class metadatas
#If No cache is provided all cache are setted to default_cache which is an array cache type #If No cache is provided all cache are setted to default_cache which is an array cache type
cache: cache:
query: array query: array_cache
result: array result: array_cache
metadata: array metadata: array_cache
# Assign a service to log doctrine queries # Assign a service to log doctrine queries
log: query_logger log: query_logger
@@ -59,9 +59,9 @@ doctrine_test:
dbal: test_connexion dbal: test_connexion
orm: orm:
cache: cache:
query: array query: array_cache
result: array result: array_cache
metadata: array metadata: array_cache
log: query_logger log: query_logger
# Doctrine production service options # Doctrine production service options
@@ -72,9 +72,9 @@ doctrine_prod:
dbal: main_connexion dbal: main_connexion
orm: orm:
cache: cache:
query: apc query: apc_cache
result: apc result: apc_cache
metadata: apc metadata: apc_cache
log: query_logger log: query_logger

View File

@@ -122,11 +122,14 @@ return call_user_func(
/* @var $repository \Repositories\BasketElementRepository */ /* @var $repository \Repositories\BasketElementRepository */
if ($repository->findReceivedValidationElementsByRecord($record, $user)->count() > 0) $ValidationByRecord = $repository->findReceivedValidationElementsByRecord($record, $user);
$ReceptionByRecord = $repository->findReceivedElementsByRecord($record, $user);
if ($ValidationByRecord && $ValidationByRecord->count() > 0)
{ {
$watermark = false; $watermark = false;
} }
elseif ($repository->findReceivedElementsByRecord($record, $user)->count() > 0) elseif ($ReceptionByRecord && $ReceptionByRecord->count() > 0)
{ {
$watermark = false; $watermark = false;
} }

View File

@@ -79,7 +79,7 @@ class Story implements ControllerProviderInterface
$metadatas[] = array( $metadatas[] = array(
'meta_struct_id' => $meta->get_id() 'meta_struct_id' => $meta->get_id()
, 'meta_id' => null , 'meta_id' => null
, 'value' => array($value) , 'value' => $value
); );
} }

View File

@@ -102,19 +102,14 @@ class Tooltip implements ControllerProviderInterface
$record = new \record_adapter($sbas_id, $record_id, $number); $record = new \record_adapter($sbas_id, $record_id, $number);
$search_engine = null; $search_engine = null;
$option = new \searchEngine_options();
$options_serial = $app['request']->get('options_serial'); if (($search_engine_options = unserialize($app['request']->get('options_serial'))) !== false)
if ($options_serial)
{ {
if (($search_engine_options = $option->unserialize($app['request']->get('options_serial'))) !== false) $search_engine = new \searchEngine_adapter($app['appbox']->get_registry());
{ $search_engine->set_options($search_engine_options);
$search_engine = new \searchEngine_adapter($app['appbox']->get_registry());
$search_engine->set_options($search_engine_options);
}
} }
/* @var $twig \Twig_Environment */ /* @var $twig \Twig_Environment */
$twig = $app['Core']->getTwig(); $twig = $app['Core']->getTwig();
return new Response( return new Response(

View File

@@ -19,8 +19,6 @@ use Silex\Application;
use Silex\ControllerProviderInterface; use Silex\ControllerProviderInterface;
use Silex\ControllerCollection; use Silex\ControllerCollection;
date_default_timezone_set('Europe/Berlin');
/** /**
* *
* @package * @package
@@ -80,7 +78,7 @@ class Installer implements ControllerProviderInterface
$twig = new \Twig_Environment($loader); $twig = new \Twig_Environment($loader);
$html = $twig->render( $html = $twig->render(
'/setup/index.twig' '/setup/index.html.twig'
, array_merge($constraints_coll, array( , array_merge($constraints_coll, array(
'locale' => Session_Handler::get_locale() 'locale' => Session_Handler::get_locale()
, 'available_locales' => $app['Core']::getAvailableLanguages() , 'available_locales' => $app['Core']::getAvailableLanguages()
@@ -112,7 +110,7 @@ class Installer implements ControllerProviderInterface
} }
$html = $twig->render( $html = $twig->render(
'/setup/step2.twig' '/setup/step2.html.twig'
, array( , array(
'locale' => \Session_Handler::get_locale() 'locale' => \Session_Handler::get_locale()
, 'available_locales' => $app['Core']::getAvailableLanguages() , 'available_locales' => $app['Core']::getAvailableLanguages()
@@ -134,6 +132,9 @@ class Installer implements ControllerProviderInterface
set_time_limit(360); set_time_limit(360);
\phrasea::use_i18n(\Session_Handler::get_locale()); \phrasea::use_i18n(\Session_Handler::get_locale());
$request = $app['request']; $request = $app['request'];
$setupRegistry = new \Setup_Registry();
$setupRegistry->set('GV_ServerName', $servername);
$conn = $connbas = null; $conn = $connbas = null;
@@ -147,7 +148,7 @@ class Installer implements ControllerProviderInterface
try try
{ {
$conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name); $conn = new \connection_pdo('appbox', $hostname, $port, $user_ab, $password, $appbox_name, array(), $setupRegistry);
} }
catch (\Exception $e) catch (\Exception $e)
{ {
@@ -158,13 +159,14 @@ class Installer implements ControllerProviderInterface
{ {
if ($databox_name) if ($databox_name)
{ {
$connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name); $connbas = new \connection_pdo('databox', $hostname, $port, $user_ab, $password, $databox_name, array(), $setupRegistry);
} }
} }
catch (\Exception $e) catch (\Exception $e)
{ {
return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable')); return $app->redirect('/setup/installer/step2/?error=' . _('Databox is unreachable'));
} }
\setup::rollback($conn, $connbas); \setup::rollback($conn, $connbas);
try try
@@ -208,6 +210,7 @@ class Installer implements ControllerProviderInterface
// Create SchemaTool // Create SchemaTool
$tool = new \Doctrine\ORM\Tools\SchemaTool($em); $tool = new \Doctrine\ORM\Tools\SchemaTool($em);
// Create schema // Create schema
$tool->dropSchema($metadatas);
$tool->createSchema($metadatas); $tool->createSchema($metadatas);
} }
} }
@@ -327,4 +330,4 @@ class Installer implements ControllerProviderInterface
return $controllers; return $controllers;
} }
} }

View File

@@ -41,7 +41,7 @@ class Upgrader implements ControllerProviderInterface
$twig = $app['Core']->getTwig(); $twig = $app['Core']->getTwig();
$html = $twig->render( $html = $twig->render(
'/setup/upgrader.twig' '/setup/upgrader.html.twig'
, array( , array(
'locale' => \Session_Handler::get_locale() 'locale' => \Session_Handler::get_locale()
, 'upgrade_status' => $upgrade_status , 'upgrade_status' => $upgrade_status

View File

@@ -166,7 +166,7 @@ class Core extends \Pimple
} }
return; return;
} }
/** /**
* Load Configuration * Load Configuration
* *
@@ -178,6 +178,7 @@ class Core extends \Pimple
{ {
ini_set('display_errors', 'on'); ini_set('display_errors', 'on');
error_reporting(E_ALL); error_reporting(E_ALL);
// \Symfony\Component\HttpKernel\Debug\ErrorHandler::register();
} }
else else
{ {

View File

@@ -29,7 +29,7 @@ class Application implements Specification
*/ */
public function getConfigurationFilePath() public function getConfigurationFilePath()
{ {
return __DIR__ . '/../../../../../config'; return realpath(__DIR__ . '/../../../../../config');
} }
/** /**
@@ -97,7 +97,7 @@ class Application implements Specification
*/ */
public function getServiceFile() public function getServiceFile()
{ {
return new \SplFileObject(__DIR__ . '/../../../../../config/services.yml'); return new \SplFileObject(realpath(__DIR__ . '/../../../../../config/services.yml'));
} }
/** /**
@@ -107,7 +107,7 @@ class Application implements Specification
*/ */
public function getConnexionFile() public function getConnexionFile()
{ {
return new \SplFileObject(__DIR__ . '/../../../../../config/connexions.yml'); return new \SplFileObject(realpath(__DIR__ . '/../../../../../config/connexions.yml'));
} }
} }

View File

@@ -87,7 +87,7 @@ class Edit extends RecordHelper
if ($this->is_single_grouping()) if ($this->is_single_grouping())
{ {
$record = array_pop($this->selection->get_elements()); $record = array_pop($this->selection->get_elements());
$children = $record->get_children(); $children = $record->get_children();
foreach ($children as $child) foreach ($children as $child)
{ {
@@ -100,9 +100,9 @@ class Edit extends RecordHelper
if ($this->is_possible()) if ($this->is_possible())
{ {
$this->generate_javascript_fields() $this->generate_javascript_fields()
->generate_javascript_sugg_values() ->generate_javascript_sugg_values()
->generate_javascript_status() ->generate_javascript_status()
->generate_javascript_elements(); ->generate_javascript_elements();
} }
return $this; return $this;
@@ -203,12 +203,12 @@ class Edit extends RecordHelper
foreach ($this->selection as $record) foreach ($this->selection as $record)
{ {
$indice = $record->get_number(); $indice = $record->get_number();
$_lst[$indice] = array( $_lst[$indice] = array(
'bid' => $record->get_base_id(), 'bid' => $record->get_base_id(),
'rid' => $record->get_record_id(), 'rid' => $record->get_record_id(),
'sselcont_id' => null, 'sselcont_id' => null,
'_selected' => false '_selected' => false
); );
$_lst[$indice]['statbits'] = array(); $_lst[$indice]['statbits'] = array();
@@ -216,12 +216,12 @@ class Edit extends RecordHelper
{ {
foreach ($this->javascript_status as $n => $s) foreach ($this->javascript_status as $n => $s)
{ {
$tmp_val = substr(strrev($record->get_status()), $n, 1); $tmp_val = substr(strrev($record->get_status()), $n, 1);
$_lst[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0'; $_lst[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0';
$_lst[$indice]['statbits'][$n]['dirty'] = false; $_lst[$indice]['statbits'][$n]['dirty'] = false;
} }
} }
$_lst[$indice]['fields'] = array(); $_lst[$indice]['fields'] = array();
$_lst[$indice]['originalname'] = ''; $_lst[$indice]['originalname'] = '';
$_lst[$indice]['originalname'] = $record->get_original_name(); $_lst[$indice]['originalname'] = $record->get_original_name();
@@ -234,23 +234,32 @@ class Edit extends RecordHelper
continue; continue;
} }
$values = array();
foreach ($field->get_values() as $value)
{
$values[$value->getId()] = array(
'meta_id' => $value->getId(),
'value' => $value->getValue()
);
}
$_lst[$indice]['fields'][$meta_struct_id] = array( $_lst[$indice]['fields'][$meta_struct_id] = array(
'dirty' => false, 'dirty' => false,
'meta_id' => $field->get_meta_id(), // 'meta_id' => $field->get_meta_id(),
'meta_struct_id' => $meta_struct_id, 'meta_struct_id' => $meta_struct_id,
'value' => $field->get_value() 'values' => $values
); );
} }
$_lst[$indice]['subdefs'] = array('thumbnail' => null, 'preview' => null); $_lst[$indice]['subdefs'] = array('thumbnail' => null, 'preview' => null);
$thumbnail = $record->get_thumbnail(); $thumbnail = $record->get_thumbnail();
$_lst[$indice]['subdefs']['thumbnail'] = array( $_lst[$indice]['subdefs']['thumbnail'] = array(
'url' => $thumbnail->get_url() 'url' => $thumbnail->get_url()
, 'w' => $thumbnail->get_width() , 'w' => $thumbnail->get_width()
, 'h' => $thumbnail->get_height() , 'h' => $thumbnail->get_height()
); );
$_lst[$indice]['preview'] = $twig->render('common/preview.html', array('record' => $record)); $_lst[$indice]['preview'] = $twig->render('common/preview.html', array('record' => $record));
@@ -283,9 +292,9 @@ class Edit extends RecordHelper
foreach ($this->selection as $record) foreach ($this->selection as $record)
{ {
/* @var $record record_adapter */ /* @var $record record_adapter */
$base_id = $record->get_base_id(); $base_id = $record->get_base_id();
$record_id = $record->get_record_id(); $record_id = $record->get_record_id();
$databox = $record->get_databox(); $databox = $record->get_databox();
if (isset($done[$base_id])) if (isset($done[$base_id]))
continue; continue;
@@ -313,12 +322,12 @@ class Edit extends RecordHelper
foreach ($vi->value as $oneValue) // les valeurs sug foreach ($vi->value as $oneValue) // les valeurs sug
{ {
$T_sgval['b' . $base_id][$field->get_id()][] = $T_sgval['b' . $base_id][$field->get_id()][] =
(string) $oneValue; (string) $oneValue;
} }
} }
} }
unset($collection); unset($collection);
$done[$base_id] = true; $done[$base_id] = true;
} }
$this->javascript_sugg_values = $T_sgval; $this->javascript_sugg_values = $T_sgval;
@@ -343,11 +352,11 @@ class Edit extends RecordHelper
foreach ($status[$this->get_sbas_id()] as $n => $statbit) foreach ($status[$this->get_sbas_id()] as $n => $statbit)
{ {
$_tstatbits[$n] = array(); $_tstatbits[$n] = array();
$_tstatbits[$n]['label0'] = $statbit['labeloff']; $_tstatbits[$n]['label0'] = $statbit['labeloff'];
$_tstatbits[$n]['label1'] = $statbit['labelon']; $_tstatbits[$n]['label1'] = $statbit['labelon'];
$_tstatbits[$n]['img_off'] = $statbit['img_off']; $_tstatbits[$n]['img_off'] = $statbit['img_off'];
$_tstatbits[$n]['img_on'] = $statbit['img_on']; $_tstatbits[$n]['img_on'] = $statbit['img_on'];
$_tstatbits[$n]['_value'] = 0; $_tstatbits[$n]['_value'] = 0;
} }
} }
} }
@@ -364,11 +373,11 @@ class Edit extends RecordHelper
*/ */
protected function generate_javascript_fields() protected function generate_javascript_fields()
{ {
$_tfields = $fields = array(); $_tfields = $fields = array();
$this->has_thesaurus = false; $this->has_thesaurus = false;
$databox = \databox::get_instance($this->get_sbas_id()); $databox = \databox::get_instance($this->get_sbas_id());
$meta_struct = $databox->get_meta_structure(); $meta_struct = $databox->get_meta_structure();
foreach ($meta_struct as $meta) foreach ($meta_struct as $meta)
@@ -389,19 +398,19 @@ class Edit extends RecordHelper
switch ($meta->get_type()) switch ($meta->get_type())
{ {
case 'datetime': case 'datetime':
$format = _('phraseanet::technique::datetime-edit-format'); $format = _('phraseanet::technique::datetime-edit-format');
$explain = _('phraseanet::technique::datetime-edit-explain'); $explain = _('phraseanet::technique::datetime-edit-explain');
break; break;
case 'date': case 'date':
$format = _('phraseanet::technique::date-edit-format'); $format = _('phraseanet::technique::date-edit-format');
$explain = _('phraseanet::technique::date-edit-explain'); $explain = _('phraseanet::technique::date-edit-explain');
break; break;
case 'time': case 'time':
$format = _('phraseanet::technique::time-edit-format'); $format = _('phraseanet::technique::time-edit-format');
$explain = _('phraseanet::technique::time-edit-explain'); $explain = _('phraseanet::technique::time-edit-explain');
break; break;
default: default:
$format = $explain = ""; $format = $explain = "";
break; break;
} }
@@ -411,22 +420,22 @@ class Edit extends RecordHelper
$separator = $meta->get_separator(); $separator = $meta->get_separator();
$datas = array( $datas = array(
'meta_struct_id' => $meta->get_id() 'meta_struct_id' => $meta->get_id()
, 'name' => $meta->get_name() , 'name' => $meta->get_name()
, '_status' => 0 , '_status' => 0
, '_value' => '' , '_value' => ''
, '_sgval' => array() , '_sgval' => array()
, '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' => $format
, 'explain' => $explain , 'explain' => $explain
, 'tbranch' => $meta->get_tbranch() , 'tbranch' => $meta->get_tbranch()
, 'maxLength' => $meta->get_source()->maxlength() , 'maxLength' => $meta->get_source()->maxlength()
, 'minLength' => $meta->get_source()->minLength() , 'minLength' => $meta->get_source()->minLength()
, 'regfield' => $regfield , 'regfield' => $regfield
, 'multi' => $meta->is_multi() , 'multi' => $meta->is_multi()
, 'separator' => $separator , 'separator' => $separator
); );
if (trim($meta->get_tbranch()) !== '') if (trim($meta->get_tbranch()) !== '')
@@ -448,7 +457,7 @@ class Edit extends RecordHelper
{ {
try try
{ {
$reg_record = $this->get_grouping_head(); $reg_record = $this->get_grouping_head();
$reg_sbas_id = $reg_record->get_sbas_id(); $reg_sbas_id = $reg_record->get_sbas_id();
$newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent')); $newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent'));
@@ -458,7 +467,7 @@ class Edit extends RecordHelper
foreach ($newsubdef_reg->get_subdefs() as $name => $value) foreach ($newsubdef_reg->get_subdefs() as $name => $value)
{ {
$pathfile = $value->get_pathfile(); $pathfile = $value->get_pathfile();
$system_file = new system_file($pathfile); $system_file = new system_file($pathfile);
$reg_record->substitute_subdef($name, $system_file); $reg_record->substitute_subdef($name, $system_file);
} }
@@ -472,11 +481,11 @@ class Edit extends RecordHelper
if (!is_array($request->get('mds'))) if (!is_array($request->get('mds')))
return $this; return $this;
$sbas_id = (int) $request->get('sbid'); $sbas_id = (int) $request->get('sbid');
$databox = \databox::get_instance($sbas_id); $databox = \databox::get_instance($sbas_id);
$meta_struct = $databox->get_meta_structure(); $meta_struct = $databox->get_meta_structure();
$write_edit_el = false; $write_edit_el = false;
$date_obj = new DateTime(); $date_obj = new DateTime();
foreach ($meta_struct->get_elements() as $meta_struct_el) foreach ($meta_struct->get_elements() as $meta_struct_el)
{ {
if ($meta_struct_el->get_metadata_namespace() == "PHRASEANET" && $meta_struct_el->get_metadata_tagname() == 'tf-editdate') if ($meta_struct_el->get_metadata_namespace() == "PHRASEANET" && $meta_struct_el->get_metadata_tagname() == 'tf-editdate')
@@ -502,7 +511,7 @@ class Edit extends RecordHelper
if (!array_key_exists($key, $elements)) if (!array_key_exists($key, $elements))
continue; continue;
$statbits = $rec['status']; $statbits = $rec['status'];
$editDirty = $rec['edit']; $editDirty = $rec['edit'];
if ($editDirty == '0') if ($editDirty == '0')
@@ -515,28 +524,38 @@ class Edit extends RecordHelper
$record->set_metadatas($rec['metadatas']); $record->set_metadatas($rec['metadatas']);
} }
if ($write_edit_el instanceof \Acmedatabox_field) /**
*todo : this should not work
*/
if ($write_edit_el instanceof \databox_field)
{ {
$fields = $record->get_caption()->get_fields(array($write_edit_el->get_name())); $fields = $record->get_caption()->get_fields(array($write_edit_el->get_name()));
$field = array_pop($fields); $field = array_pop($fields);
$meta_id = null;
if($field && !$field->is_multi())
{
$meta_id = array_pop($field->get_values())->getId();
}
$metas = array( $metas = array(
array( array(
'meta_struct_id' => $write_edit_el->get_id() 'meta_struct_id' => $write_edit_el->get_id()
, 'meta_id' => ($field ? $field->get_meta_id() : null) , 'meta_id' => $meta_id
, 'value' => array($date_obj->format('Y-m-d h:i:s')) , 'value' => $date_obj->format('Y-m-d h:i:s')
) )
); );
$record->set_metadatas($metas); $record->set_metadatas($metas);
} }
$newstat = $record->get_status(); $newstat = $record->get_status();
$statbits = ltrim($statbits, 'x'); $statbits = ltrim($statbits, 'x');
if (!in_array($statbits, array('', 'null'))) if (!in_array($statbits, array('', 'null')))
{ {
$mask_and = ltrim(str_replace( $mask_and = ltrim(str_replace(
array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0'); array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
if ($mask_and != '') if ($mask_and != '')
$newstat = \databox_status::operation_and_not($newstat, $mask_and); $newstat = \databox_status::operation_and_not($newstat, $mask_and);
@@ -553,14 +572,14 @@ class Edit extends RecordHelper
if ($statbits != '') if ($statbits != '')
{ {
$appbox->get_session() $appbox->get_session()
->get_logger($record->get_databox()) ->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_STATUS, '', ''); ->log($record, Session_Logger::EVENT_STATUS, '', '');
} }
if ($editDirty) if ($editDirty)
{ {
$appbox->get_session() $appbox->get_session()
->get_logger($record->get_databox()) ->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_EDIT, '', ''); ->log($record, Session_Logger::EVENT_EDIT, '', '');
} }
} }

View File

@@ -543,7 +543,7 @@ class Edit extends \Alchemy\Phrasea\Helper\Helper
$users = $this->users; $users = $this->users;
$user = \User_adapter::getInstance(array_pop($users), appbox::get_instance()); $user = \User_adapter::getInstance(array_pop($users), \appbox::get_instance());
if ($user->is_template()) if ($user->is_template())
{ {

View File

@@ -39,16 +39,9 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
*/ */
protected $usr_id; protected $usr_id;
public function __construct(Symfony\Component\HttpFoundation\Request $request) public function export()
{
$this->request = $request;
return $this;
}
public function export(Symfony\Component\HttpFoundation\Request $request)
{ {
$request = $this->request;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
@@ -84,8 +77,9 @@ class Manage extends \Alchemy\Phrasea\Helper\Helper
return $this->results->get_results(); return $this->results->get_results();
} }
public function search(Symfony\Component\HttpFoundation\Request $request) public function search()
{ {
$request = $this->request;
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
$offset_start = (int) $this->request->get('offset_start'); $offset_start = (int) $this->request->get('offset_start');

View File

@@ -317,7 +317,7 @@ class PDF
$this->pdf->Write(5, $field->get_name() . " : "); $this->pdf->Write(5, $field->get_name() . " : ");
$this->pdf->SetFont(PhraseaPDF::FONT, '', 12); $this->pdf->SetFont(PhraseaPDF::FONT, '', 12);
$this->pdf->Write(5, $field->get_value(true)); $this->pdf->Write(5, $field->get_serialized_values());
$this->pdf->Write(6, "\n"); $this->pdf->Write(6, "\n");
$nf++; $nf++;
@@ -512,7 +512,7 @@ class PDF
$t = str_replace( $t = str_replace(
array("<", ">", "&") array("<", ">", "&")
, array("<", ">", "&") , array("<", ">", "&")
, $field->get_value(true) , $field->get_serialized_values()
); );
$this->pdf->Write(5, $t); $this->pdf->Write(5, $t);

View File

@@ -59,26 +59,26 @@ class ACL implements cache_cacheableInterface
* @var Array * @var Array
*/ */
protected $_global_rights = array( protected $_global_rights = array(
'taskmanager' => false, 'taskmanager' => false,
'manageusers' => false, 'manageusers' => false,
'order' => false, 'order' => false,
'report' => false, 'report' => false,
'push' => false, 'push' => false,
'addrecord' => false, 'addrecord' => false,
'modifyrecord' => false, 'modifyrecord' => false,
'changestatus' => false, 'changestatus' => false,
'doctools' => false, 'doctools' => false,
'deleterecord' => false, 'deleterecord' => false,
'addtoalbum' => false, 'addtoalbum' => false,
'coll_modify_struct' => false, 'coll_modify_struct' => false,
'coll_manage' => false, 'coll_manage' => false,
'order_master' => false, 'order_master' => false,
'bas_modif_th' => false, 'bas_modif_th' => false,
'bas_modify_struct' => false, 'bas_modify_struct' => false,
'bas_manage' => false, 'bas_manage' => false,
'bas_chupub' => false, 'bas_chupub' => false,
'candwnldpreview' => true, 'candwnldpreview' => true,
'candwnldhd' => true 'candwnldhd' => true
); );
/** /**
@@ -87,9 +87,9 @@ class ACL implements cache_cacheableInterface
*/ */
protected $appbox; protected $appbox;
const CACHE_RIGHTS_BAS = 'rights_bas'; const CACHE_RIGHTS_BAS = 'rights_bas';
const CACHE_LIMITS_BAS = 'limits_bas'; const CACHE_LIMITS_BAS = 'limits_bas';
const CACHE_RIGHTS_SBAS = 'rights_sbas'; const CACHE_RIGHTS_SBAS = 'rights_sbas';
const CACHE_RIGHTS_RECORDS = 'rights_records'; const CACHE_RIGHTS_RECORDS = 'rights_records';
const CACHE_GLOBAL_RIGHTS = 'global_rights'; const CACHE_GLOBAL_RIGHTS = 'global_rights';
@@ -137,11 +137,11 @@ class ACL implements cache_cacheableInterface
(null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)';
$params = array( $params = array(
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
, ':sbas_id' => $record->get_sbas_id() , ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id() , ':record_id' => $record->get_record_id()
, ':case' => $action , ':case' => $action
, ':pusher' => $pusher->get_id() , ':pusher' => $pusher->get_id()
); );
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
@@ -161,11 +161,11 @@ class ACL implements cache_cacheableInterface
(null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)'; (null, :usr_id, :sbas_id, :record_id, 1, :case, :pusher)';
$params = array( $params = array(
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
, ':sbas_id' => $record->get_sbas_id() , ':sbas_id' => $record->get_sbas_id()
, ':record_id' => $record->get_record_id() , ':record_id' => $record->get_record_id()
, ':case' => $action , ':case' => $action
, ':pusher' => $pusher->get_id() , ':pusher' => $pusher->get_id()
); );
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
@@ -201,8 +201,8 @@ class ACL implements cache_cacheableInterface
try try
{ {
$subdef_class = $record->get_databox()->get_subdef_structure() $subdef_class = $record->get_databox()->get_subdef_structure()
->get_subdef($record->get_type(), $subdef_name) ->get_subdef($record->get_type(), $subdef_name)
->get_class(); ->get_class();
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -230,7 +230,7 @@ class ACL implements cache_cacheableInterface
{ {
$granted = true; $granted = true;
} }
return $granted; return $granted;
} }
@@ -290,16 +290,15 @@ class ACL implements cache_cacheableInterface
} }
$bas_rights = array('canputinalbum', 'candwnldhd' $bas_rights = array('canputinalbum', 'candwnldhd'
, 'candwnldpreview', 'cancmd' , 'candwnldpreview', 'cancmd'
, 'canadmin', 'actif', 'canreport', 'canpush' , 'canadmin', 'actif', 'canreport', 'canpush'
, 'canaddrecord', 'canmodifrecord', 'candeleterecord' , 'canaddrecord', 'canmodifrecord', 'candeleterecord'
, 'chgstatus', 'imgtools' , 'chgstatus', 'imgtools'
, 'manage', 'modify_struct' , 'manage', 'modify_struct'
, 'nowatermark', 'order_master' , 'nowatermark', 'order_master'
); );
$bas_to_acces = array(); $bas_to_acces = $masks_to_give = $rights_to_give = array();
$rights_to_give = array();
/** /**
* map masks (and+xor) of template to masks to apply to user on base * map masks (and+xor) of template to masks to apply to user on base
@@ -355,11 +354,22 @@ class ACL implements cache_cacheableInterface
$m[$k] .= $sbmap[$ax][$k]; $m[$k] .= $sbmap[$ax][$k];
} }
} }
$this->set_masks_on_base($base_id, $m['aa'], $m['ao'], $m['xa'], $m['xo']);
$masks_to_give[$base_id] = array(
'aa' => $m['aa']
, 'ao' => $m['ao']
, 'xa' => $m['xa']
, 'xo' => $m['xo']
);
} }
$this->give_access_to_base($bas_to_acces); $this->give_access_to_base($bas_to_acces);
foreach ($masks_to_give as $base_id => $mask)
{
$this->set_masks_on_base($base_id, $mask['aa'], $mask['ao'], $mask['xa'], $mask['xo']);
}
foreach ($rights_to_give as $base_id => $rights) foreach ($rights_to_give as $base_id => $rights)
{ {
$this->update_rights_to_base($base_id, $rights); $this->update_rights_to_base($base_id, $rights);
@@ -513,10 +523,10 @@ class ACL implements cache_cacheableInterface
return false; return false;
$this->_rights_bas[$base_id]['remain_dwnld'] = $this->_rights_bas[$base_id]['remain_dwnld'] =
$this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n; $this->_rights_bas[$base_id]['remain_dwnld'] - (int) $n;
$v = $this->_rights_bas[$base_id]['remain_dwnld']; $v = $this->_rights_bas[$base_id]['remain_dwnld'];
$this->_rights_bas[$base_id]['remain_dwnld'] = $this->_rights_bas[$base_id]['remain_dwnld'] =
$this->_rights_bas[$base_id]['remain_dwnld'] < 0 ? 0 : $v; $this->_rights_bas[$base_id]['remain_dwnld'] < 0 ? 0 : $v;
return $this; return $this;
} }
@@ -601,7 +611,7 @@ class ACL implements cache_cacheableInterface
$this->load_rights_bas(); $this->load_rights_bas();
return (isset($this->_rights_bas[$base_id]) && return (isset($this->_rights_bas[$base_id]) &&
$this->_rights_bas[$base_id]['actif'] === true); $this->_rights_bas[$base_id]['actif'] === true);
} }
/** /**
@@ -628,33 +638,43 @@ class ACL implements cache_cacheableInterface
{ {
$this->load_rights_bas(); $this->load_rights_bas();
$ret = array(); $ret = array();
foreach ($this->_rights_bas as $base_id => $datas) foreach($this->appbox->get_databoxes() as $databox)
{ {
$continue = false; if ($sbas_ids && !in_array($databox->get_sbas_id(), $sbas_ids))
if ($sbas_ids && !in_array(phrasea::sbasFromBas($base_id), $sbas_ids))
{ {
continue; continue;
} }
foreach ($rights as $right)
foreach ($databox->get_collections() as $collection)
{ {
if (!$this->has_right_on_base($base_id, $right)) $continue = false;
{
$continue = true;
break;
}
}
if ($continue || $this->is_limited($base_id))
continue;
try if(!array_key_exists($collection->get_base_id(), $this->_rights_bas))
{ continue;
$ret[$base_id] = collection::get_from_base_id($base_id);
}
catch (Exception $e)
{
$base_id = $collection->get_base_id();
$datas = $this->_rights_bas[$base_id];
foreach ($rights as $right)
{
if (!$this->has_right_on_base($base_id, $right))
{
$continue = true;
break;
}
}
if ($continue || $this->is_limited($base_id))
continue;
try
{
$ret[$base_id] = collection::get_from_base_id($base_id);
}
catch (Exception $e)
{
}
} }
} }
@@ -735,7 +755,7 @@ class ACL implements cache_cacheableInterface
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id())); $stmt->execute(array(':usr_id' => $this->user->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
unset($stmt); unset($stmt);
@@ -751,8 +771,8 @@ class ACL implements cache_cacheableInterface
} }
$datas = array( $datas = array(
'preview' => $this->_rights_records_preview 'preview' => $this->_rights_records_preview
, 'document' => $this->_rights_records_document , 'document' => $this->_rights_records_document
); );
$this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS); $this->set_data_to_cache($datas, self::CACHE_RIGHTS_RECORDS);
@@ -789,7 +809,7 @@ class ACL implements cache_cacheableInterface
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id())); $stmt->execute(array(':usr_id' => $this->user->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$this->_rights_sbas = array(); $this->_rights_sbas = array();
@@ -853,7 +873,7 @@ class ACL implements cache_cacheableInterface
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id())); $stmt->execute(array(':usr_id' => $this->user->get_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$this->_rights_bas = $this->_limited = array(); $this->_rights_bas = $this->_limited = array();
@@ -918,54 +938,54 @@ class ACL implements cache_cacheableInterface
&& ($row['limited_from'] !== '' || $row['limited_to'] !== '')) && ($row['limited_from'] !== '' || $row['limited_to'] !== ''))
{ {
$this->_limited[$row['base_id']] = array( $this->_limited[$row['base_id']] = array(
'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null 'dmin' => $row['limited_from'] ? new DateTime($row['limited_from']) : null
, 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null , 'dmax' => $row['limited_to'] ? new DateTime($row['limited_to']) : null
); );
} }
$this->_rights_bas[$row['base_id']]['imgtools'] $this->_rights_bas[$row['base_id']]['imgtools']
= $row['imgtools'] == '1'; = $row['imgtools'] == '1';
$this->_rights_bas[$row['base_id']]['chgstatus'] $this->_rights_bas[$row['base_id']]['chgstatus']
= $row['chgstatus'] == '1'; = $row['chgstatus'] == '1';
$this->_rights_bas[$row['base_id']]['cancmd'] $this->_rights_bas[$row['base_id']]['cancmd']
= $row['cancmd'] == '1'; = $row['cancmd'] == '1';
$this->_rights_bas[$row['base_id']]['canaddrecord'] $this->_rights_bas[$row['base_id']]['canaddrecord']
= $row['canaddrecord'] == '1'; = $row['canaddrecord'] == '1';
$this->_rights_bas[$row['base_id']]['canpush'] $this->_rights_bas[$row['base_id']]['canpush']
= $row['canpush'] == '1'; = $row['canpush'] == '1';
$this->_rights_bas[$row['base_id']]['candeleterecord'] $this->_rights_bas[$row['base_id']]['candeleterecord']
= $row['candeleterecord'] == '1'; = $row['candeleterecord'] == '1';
$this->_rights_bas[$row['base_id']]['canadmin'] $this->_rights_bas[$row['base_id']]['canadmin']
= $row['canadmin'] == '1'; = $row['canadmin'] == '1';
$this->_rights_bas[$row['base_id']]['chgstatus'] $this->_rights_bas[$row['base_id']]['chgstatus']
= $row['chgstatus'] == '1'; = $row['chgstatus'] == '1';
$this->_rights_bas[$row['base_id']]['candwnldpreview'] $this->_rights_bas[$row['base_id']]['candwnldpreview']
= $row['candwnldpreview'] == '1'; = $row['candwnldpreview'] == '1';
$this->_rights_bas[$row['base_id']]['candwnldhd'] $this->_rights_bas[$row['base_id']]['candwnldhd']
= $row['candwnldhd'] == '1'; = $row['candwnldhd'] == '1';
$this->_rights_bas[$row['base_id']]['nowatermark'] $this->_rights_bas[$row['base_id']]['nowatermark']
= $row['nowatermark'] == '1'; = $row['nowatermark'] == '1';
$this->_rights_bas[$row['base_id']]['restrict_dwnld'] $this->_rights_bas[$row['base_id']]['restrict_dwnld']
= $row['restrict_dwnld'] == '1'; = $row['restrict_dwnld'] == '1';
$this->_rights_bas[$row['base_id']]['remain_dwnld'] $this->_rights_bas[$row['base_id']]['remain_dwnld']
= (int) $row['remain_dwnld']; = (int) $row['remain_dwnld'];
$this->_rights_bas[$row['base_id']]['canmodifrecord'] $this->_rights_bas[$row['base_id']]['canmodifrecord']
= $row['canmodifrecord'] == '1'; = $row['canmodifrecord'] == '1';
$this->_rights_bas[$row['base_id']]['canputinalbum'] $this->_rights_bas[$row['base_id']]['canputinalbum']
= $row['canputinalbum'] == '1'; = $row['canputinalbum'] == '1';
$this->_rights_bas[$row['base_id']]['canreport'] $this->_rights_bas[$row['base_id']]['canreport']
= $row['canreport'] == '1'; = $row['canreport'] == '1';
$this->_rights_bas[$row['base_id']]['mask_and'] $this->_rights_bas[$row['base_id']]['mask_and']
= $row['mask_and']; = $row['mask_and'];
$this->_rights_bas[$row['base_id']]['mask_xor'] $this->_rights_bas[$row['base_id']]['mask_xor']
= $row['mask_xor']; = $row['mask_xor'];
$this->_rights_bas[$row['base_id']]['modify_struct'] $this->_rights_bas[$row['base_id']]['modify_struct']
= $row['modify_struct'] == '1'; = $row['modify_struct'] == '1';
$this->_rights_bas[$row['base_id']]['manage'] $this->_rights_bas[$row['base_id']]['manage']
= $row['manage'] == '1'; = $row['manage'] == '1';
$this->_rights_bas[$row['base_id']]['order_master'] $this->_rights_bas[$row['base_id']]['order_master']
= $row['order_master'] == '1'; = $row['order_master'] == '1';
} }
$this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS); $this->set_data_to_cache($this->_global_rights, self::CACHE_GLOBAL_RIGHTS);
@@ -1001,12 +1021,12 @@ class ACL implements cache_cacheableInterface
{ {
case 'admin': case 'admin':
return ( return (
($this->has_right('bas_modify_struct') || ($this->has_right('bas_modify_struct') ||
$this->has_right('coll_modify_struct') || $this->has_right('coll_modify_struct') ||
$this->has_right('bas_manage') || $this->has_right('bas_manage') ||
$this->has_right('coll_manage') || $this->has_right('coll_manage') ||
$this->has_right('manageusers') || $this->has_right('manageusers') ||
$this->user->is_admin()) ); $this->user->is_admin()) );
break; break;
case 'thesaurus': case 'thesaurus':
return ($this->has_right('bas_modif_th') === true ); return ($this->has_right('bas_modif_th') === true );
@@ -1031,14 +1051,14 @@ class ACL implements cache_cacheableInterface
*/ */
public function revoke_access_from_bases(Array $base_ids) public function revoke_access_from_bases(Array $base_ids)
{ {
$sql_del = 'DELETE FROM basusr WHERE base_id = :base_id AND usr_id = :usr_id'; $sql_del = 'DELETE FROM basusr WHERE base_id = :base_id AND usr_id = :usr_id';
$stmt_del = $this->appbox->get_connection()->prepare($sql_del); $stmt_del = $this->appbox->get_connection()->prepare($sql_del);
$usr_id = $this->user->get_id(); $usr_id = $this->user->get_id();
foreach ($base_ids as $base_id) foreach ($base_ids as $base_id)
{ {
if (!$stmt_del->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id))) if (!$stmt_del->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id)))
{ {
throw new Exception('Error while deleteing some rights'); throw new Exception('Error while deleteing some rights');
} }
@@ -1055,10 +1075,10 @@ class ACL implements cache_cacheableInterface
*/ */
public function give_access_to_base(Array $base_ids) public function give_access_to_base(Array $base_ids)
{ {
$sql_ins = 'INSERT INTO basusr (id, base_id, usr_id, actif) $sql_ins = 'INSERT INTO basusr (id, base_id, usr_id, actif)
VALUES (null, :base_id, :usr_id, "1")'; VALUES (null, :base_id, :usr_id, "1")';
$stmt_ins = $this->appbox->get_connection()->prepare($sql_ins); $stmt_ins = $this->appbox->get_connection()->prepare($sql_ins);
$usr_id = $this->user->get_id(); $usr_id = $this->user->get_id();
$to_update = array(); $to_update = array();
$this->load_rights_bas(); $this->load_rights_bas();
@@ -1066,7 +1086,7 @@ class ACL implements cache_cacheableInterface
{ {
if (!isset($this->_rights_bas[$base_id])) if (!isset($this->_rights_bas[$base_id]))
{ {
$stmt_ins->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id)); $stmt_ins->execute(array(':base_id' => $base_id, ':usr_id' => $usr_id));
} }
elseif ($this->_rights_bas[$base_id]['actif'] === false) elseif ($this->_rights_bas[$base_id]['actif'] === false)
{ {
@@ -1075,12 +1095,12 @@ class ACL implements cache_cacheableInterface
} }
$stmt_ins->closeCursor(); $stmt_ins->closeCursor();
$sql_upd = 'UPDATE basusr SET actif="1" $sql_upd = 'UPDATE basusr SET actif="1"
WHERE usr_id = :usr_id AND base_id = :base_id'; WHERE usr_id = :usr_id AND base_id = :base_id';
$stmt_upd = $this->appbox->get_connection()->prepare($sql_upd); $stmt_upd = $this->appbox->get_connection()->prepare($sql_upd);
foreach ($to_update as $base_id) foreach ($to_update as $base_id)
{ {
$stmt_upd->execute(array(':usr_id' => $usr_id, ':base_id' => $base_id)); $stmt_upd->execute(array(':usr_id' => $usr_id, ':base_id' => $base_id));
} }
$stmt_upd->closeCursor(); $stmt_upd->closeCursor();
@@ -1097,7 +1117,7 @@ class ACL implements cache_cacheableInterface
*/ */
public function give_access_to_sbas(Array $sbas_ids) public function give_access_to_sbas(Array $sbas_ids)
{ {
$sql_ins = 'INSERT INTO sbasusr (sbasusr_id, sbas_id, usr_id) VALUES (null, :sbas_id, :usr_id)'; $sql_ins = 'INSERT INTO sbasusr (sbasusr_id, sbas_id, usr_id) VALUES (null, :sbas_id, :usr_id)';
$stmt_ins = $this->appbox->get_connection()->prepare($sql_ins); $stmt_ins = $this->appbox->get_connection()->prepare($sql_ins);
$usr_id = $this->user->get_id(); $usr_id = $this->user->get_id();
@@ -1105,7 +1125,7 @@ class ACL implements cache_cacheableInterface
foreach ($sbas_ids as $sbas_id) foreach ($sbas_ids as $sbas_id)
{ {
if (!$this->has_access_to_sbas($sbas_id)) if (!$this->has_access_to_sbas($sbas_id))
$stmt_ins->execute(array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id)); $stmt_ins->execute(array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id));
} }
$this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS); $this->delete_data_from_cache(self::CACHE_RIGHTS_SBAS);
@@ -1130,7 +1150,7 @@ class ACL implements cache_cacheableInterface
$sql_up = "UPDATE basusr SET "; $sql_up = "UPDATE basusr SET ";
$sql_args = $params = array(); $sql_args = $params = array();
foreach ($rights as $right => $v) foreach ($rights as $right => $v)
{ {
$sql_args[] = " " . $right . " = :" . $right; $sql_args[] = " " . $right . " = :" . $right;
@@ -1157,8 +1177,8 @@ class ACL implements cache_cacheableInterface
AND usr_id = :usr_id'; AND usr_id = :usr_id';
$params = array_merge( $params = array_merge(
$params $params
, array(':base_id' => $base_id, ':usr_id' => $usr_id) , array(':base_id' => $base_id, ':usr_id' => $usr_id)
); );
$stmt_up = $this->appbox->get_connection()->prepare($sql_up); $stmt_up = $this->appbox->get_connection()->prepare($sql_up);
@@ -1216,11 +1236,11 @@ class ACL implements cache_cacheableInterface
$sql_args = array(); $sql_args = array();
$usr_id = $this->user->get_id(); $usr_id = $this->user->get_id();
$params = array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id); $params = array(':sbas_id' => $sbas_id, ':usr_id' => $usr_id);
foreach ($rights as $right => $v) foreach ($rights as $right => $v)
{ {
$sql_args[] = " " . $right . " = :" . $right; $sql_args[] = " " . $right . " = :" . $right;
$params[':' . $right] = $v ? '1' : '0'; $params[':' . $right] = $v ? '1' : '0';
} }
@@ -1255,7 +1275,7 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id AND base_id = :base_id '; WHERE usr_id = :usr_id AND base_id = :base_id ';
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id(), ':base_id' => $base_id)); $stmt->execute(array(':usr_id' => $this->user->get_id(), ':base_id' => $base_id));
$stmt->closeCursor(); $stmt->closeCursor();
unset($stmt); unset($stmt);
@@ -1266,7 +1286,7 @@ class ACL implements cache_cacheableInterface
public function update_download_restrictions() public function update_download_restrictions()
{ {
$sql = 'UPDATE basusr SET remain_dwnld = month_dwnld_max $sql = 'UPDATE basusr SET remain_dwnld = month_dwnld_max
WHERE actif = 1 WHERE actif = 1
AND usr_id = :usr_id AND usr_id = :usr_id
AND MONTH(lastconn) != MONTH(NOW()) AND restrict_dwnld = 1'; AND MONTH(lastconn) != MONTH(NOW()) AND restrict_dwnld = 1';
@@ -1275,7 +1295,7 @@ class ACL implements cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "UPDATE basusr SET lastconn=now() $sql = "UPDATE basusr SET lastconn=now()
WHERE usr_id = :usr_id AND actif = 1"; WHERE usr_id = :usr_id AND actif = 1";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':usr_id' => $this->user->get_id())); $stmt->execute(array(':usr_id' => $this->user->get_id()));
@@ -1301,10 +1321,10 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id AND base_id = :base_id '; WHERE usr_id = :usr_id AND base_id = :base_id ';
$params = array( $params = array(
':usr_id' => $this->user->get_id(), ':usr_id' => $this->user->get_id(),
':base_id' => $base_id, ':base_id' => $base_id,
':restes' => $restes, ':restes' => $restes,
':droits' => $droits ':droits' => $droits
); );
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
@@ -1323,13 +1343,13 @@ class ACL implements cache_cacheableInterface
WHERE base_id = :base_from AND usr_id = :usr_id'; WHERE base_id = :base_from AND usr_id = :usr_id';
$params = array( $params = array(
':base_from' => $base_id_from, ':base_from' => $base_id_from,
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
); );
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
@@ -1339,35 +1359,35 @@ class ACL implements cache_cacheableInterface
$rights = array(); $rights = array();
if ($row['canputinalbum']) if ($row['canputinalbum'])
$rights['canputinalbum'] = true; $rights['canputinalbum'] = true;
if ($row['candwnldhd']) if ($row['candwnldhd'])
$rights['candwnldhd'] = true; $rights['candwnldhd'] = true;
if ($row['candwnldpreview']) if ($row['candwnldpreview'])
$rights['candwnldpreview'] = true; $rights['candwnldpreview'] = true;
if ($row['cancmd']) if ($row['cancmd'])
$rights['cancmd'] = true; $rights['cancmd'] = true;
if ($row['canadmin']) if ($row['canadmin'])
$rights['canadmin'] = true; $rights['canadmin'] = true;
if ($row['canreport']) if ($row['canreport'])
$rights['canreport'] = true; $rights['canreport'] = true;
if ($row['canpush']) if ($row['canpush'])
$rights['canpush'] = true; $rights['canpush'] = true;
if ($row['nowatermark']) if ($row['nowatermark'])
$rights['nowatermark'] = true; $rights['nowatermark'] = true;
if ($row['canaddrecord']) if ($row['canaddrecord'])
$rights['canaddrecord'] = true; $rights['canaddrecord'] = true;
if ($row['canmodifrecord']) if ($row['canmodifrecord'])
$rights['canmodifrecord'] = true; $rights['canmodifrecord'] = true;
if ($row['candeleterecord']) if ($row['candeleterecord'])
$rights['candeleterecord'] = true; $rights['candeleterecord'] = true;
if ($row['chgstatus']) if ($row['chgstatus'])
$rights['chgstatus'] = true; $rights['chgstatus'] = true;
if ($row['imgtools']) if ($row['imgtools'])
$rights['imgtools'] = true; $rights['imgtools'] = true;
if ($row['manage']) if ($row['manage'])
$rights['manage'] = true; $rights['manage'] = true;
if ($row['modify_struct']) if ($row['modify_struct'])
$rights['modify_struct'] = true; $rights['modify_struct'] = true;
$this->update_rights_to_base($base_id_dest, $rights); $this->update_rights_to_base($base_id_dest, $rights);
@@ -1390,7 +1410,7 @@ class ACL implements cache_cacheableInterface
{ {
$this->delete_injected_rights_sbas($databox); $this->delete_injected_rights_sbas($databox);
$sql = "INSERT INTO collusr $sql = "INSERT INTO collusr
(site, usr_id, coll_id, mask_and, mask_xor, ord) (site, usr_id, coll_id, mask_and, mask_xor, ord)
VALUES (:site_id, :usr_id, :coll_id, :mask_and, :mask_xor, :ord)"; VALUES (:site_id, :usr_id, :coll_id, :mask_and, :mask_xor, :ord)";
$stmt = $databox->get_connection()->prepare($sql); $stmt = $databox->get_connection()->prepare($sql);
@@ -1399,12 +1419,12 @@ class ACL implements cache_cacheableInterface
foreach ($this->get_granted_base(array(), array($databox->get_sbas_id())) as $collection) foreach ($this->get_granted_base(array(), array($databox->get_sbas_id())) as $collection)
{ {
$stmt->execute(array( $stmt->execute(array(
':site_id' => $this->appbox->get_registry()->get('GV_sit'), ':site_id' => $this->appbox->get_registry()->get('GV_sit'),
':usr_id' => $this->user->get_id(), ':usr_id' => $this->user->get_id(),
':coll_id' => $collection->get_coll_id(), ':coll_id' => $collection->get_coll_id(),
':mask_and' => $this->get_mask_and($collection->get_base_id()), ':mask_and' => $this->get_mask_and($collection->get_base_id()),
':mask_xor' => $this->get_mask_xor($collection->get_base_id()), ':mask_xor' => $this->get_mask_xor($collection->get_base_id()),
':ord' => $iord++ ':ord' => $iord++
)); ));
} }
@@ -1425,12 +1445,12 @@ class ACL implements cache_cacheableInterface
public function delete_injected_rights_sbas(databox $databox) public function delete_injected_rights_sbas(databox $databox)
{ {
$sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site'; $sql = 'DELETE FROM collusr WHERE usr_id = :usr_id AND site = :site';
$params = array( $params = array(
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
, ':site' => $this->appbox->get_registry()->get('GV_sit') , ':site' => $this->appbox->get_registry()->get('GV_sit')
); );
$stmt = $databox->get_connection()->prepare($sql); $stmt = $databox->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1441,15 +1461,15 @@ class ACL implements cache_cacheableInterface
{ {
$vhex = array(); $vhex = array();
$datas = array( $datas = array(
'and_and' => $and_and, 'and_and' => $and_and,
'and_or' => $and_or, 'and_or' => $and_or,
'xor_and' => $xor_and, 'xor_and' => $xor_and,
'xor_or' => $xor_or 'xor_or' => $xor_or
); );
foreach ($datas as $name => $f) foreach ($datas as $name => $f)
{ {
$vhex[$name] = "0x"; $vhex[$name] = "0x";
while (strlen($datas[$name]) < 64) while (strlen($datas[$name]) < 64)
$datas[$name] = "0" . $datas[$name]; $datas[$name] = "0" . $datas[$name];
} }
@@ -1457,7 +1477,7 @@ class ACL implements cache_cacheableInterface
{ {
while (strlen($datas[$name]) > 0) while (strlen($datas[$name]) > 0)
{ {
$valtmp = substr($datas[$name], 0, 4); $valtmp = substr($datas[$name], 0, 4);
$datas[$name] = substr($datas[$name], 4); $datas[$name] = substr($datas[$name], 4);
$vhex[$name] .= dechex(bindec($valtmp)); $vhex[$name] .= dechex(bindec($valtmp));
} }
@@ -1469,7 +1489,7 @@ class ACL implements cache_cacheableInterface
WHERE usr_id = :usr_id and base_id = :base_id"; WHERE usr_id = :usr_id and base_id = :base_id";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(array(':base_id' => $base_id, ':usr_id' => $this->user->get_id())); $stmt->execute(array(':base_id' => $base_id, ':usr_id' => $this->user->get_id()));
$stmt->closeCursor(); $stmt->closeCursor();
unset($stmt); unset($stmt);
@@ -1523,10 +1543,10 @@ class ACL implements cache_cacheableInterface
} }
$params = array( $params = array(
':usr_id' => $this->user->get_id() ':usr_id' => $this->user->get_id()
, ':base_id' => $base_id , ':base_id' => $base_id
, 'limited_from' => ($limit_from ? $limit_from->format(DATE_ISO8601) : null) , 'limited_from' => ($limit_from ? $limit_from->format(DATE_ISO8601) : null)
, 'limited_to' => ($limit_to ? $limit_to->format(DATE_ISO8601) : null) , 'limited_to' => ($limit_to ? $limit_to->format(DATE_ISO8601) : null)
); );
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);

View File

@@ -1080,7 +1080,10 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array(); $ret = array();
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
$ret[$field->get_meta_id()] = $this->list_record_caption_field($field); foreach($field->get_values as $value)
{
$ret[$value->getId()] = $this->list_record_caption_field($value);
}
} }
return $ret; return $ret;
@@ -1092,17 +1095,17 @@ class API_V1_adapter extends API_V1_Abstract
* @param caption_field $field * @param caption_field $field
* @return array * @return array
*/ */
protected function list_record_caption_field(caption_field $field) protected function list_record_caption_field(caption_Field_Value $value, caption_field $field)
{ {
/** /**
* @todo ajouter une option pour avoir les values serialisées * @todo ajouter une option pour avoir les values serialisées
* dans un cas multi * dans un cas multi
*/ */
return array( return array(
'meta_id' => $field->get_meta_id() 'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id() , 'meta_structure_id' => $field->get_meta_struct_id()
, 'name' => $field->get_name() , 'name' => $field->get_name()
, 'value' => $field->get_value() , 'value' => $value->getValue()
); );
} }

View File

@@ -9,8 +9,12 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
$new_include_path = __DIR__ . "/../../../../vendor/" . PATH_SEPARATOR . get_include_path(); $include_path = realpath(__DIR__ . '/../../../../vendor/');
set_include_path($new_include_path); if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
/** /**
* *

View File

@@ -9,8 +9,13 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
$new_include_path = __DIR__ . "/../../../vendor/" . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path); $include_path = realpath(__DIR__ . '/../../../vendor/');
if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
use \Symfony\Component\HttpFoundation\Request; use \Symfony\Component\HttpFoundation\Request;

View File

@@ -9,8 +9,12 @@
* file that was distributed with this source code. * file that was distributed with this source code.
*/ */
$new_include_path = __DIR__ . '/../../../vendor/gdata/' . PATH_SEPARATOR . get_include_path(); $include_path = realpath(__DIR__ . '/../../../vendor/gdata/');
set_include_path($new_include_path); if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
require_once('Zend/Loader.php'); require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_YouTube');

View File

@@ -235,7 +235,7 @@ abstract class Feed_XML_Abstract
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title); $title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) if ($title_field)
{ {
$str_title = $title_field->get_value(true, ' '); $str_title = $title_field->get_serialized_values(' ');
$title = $this->addTag($document, $group, 'media:title', $str_title); $title = $this->addTag($document, $group, 'media:title', $str_title);
$title->setAttribute('type', 'plain'); $title->setAttribute('type', 'plain');
} }
@@ -243,7 +243,7 @@ abstract class Feed_XML_Abstract
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description); $desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
if ($desc_field) if ($desc_field)
{ {
$str_desc = $desc_field->get_value(true, ' '); $str_desc = $desc_field->get_serialized_values(' ');
$desc = $this->addTag($document, $group, 'media:description', $str_desc); $desc = $this->addTag($document, $group, 'media:description', $str_desc);
$desc->setAttribute('type', 'plain'); $desc->setAttribute('type', 'plain');
} }
@@ -251,7 +251,7 @@ abstract class Feed_XML_Abstract
$contrib_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Contributor); $contrib_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Contributor);
if ($contrib_field) if ($contrib_field)
{ {
$str_contrib = $contrib_field->get_value(true, ' '); $str_contrib = $contrib_field->get_serialized_values(' ');
$contrib = $this->addTag($document, $group, 'media:credit', $str_contrib); $contrib = $this->addTag($document, $group, 'media:credit', $str_contrib);
$contrib->setAttribute('role', 'contributor'); $contrib->setAttribute('role', 'contributor');
$contrib->setAttribute('scheme', 'urn:ebu'); $contrib->setAttribute('scheme', 'urn:ebu');
@@ -260,7 +260,7 @@ abstract class Feed_XML_Abstract
$director_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Creator); $director_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Creator);
if ($director_field) if ($director_field)
{ {
$str_director = $director_field->get_value(true, ' '); $str_director = $director_field->get_serialized_values(' ');
$director = $this->addTag($document, $group, 'media:credit', $str_director); $director = $this->addTag($document, $group, 'media:credit', $str_director);
$director->setAttribute('role', 'director'); $director->setAttribute('role', 'director');
$director->setAttribute('scheme', 'urn:ebu'); $director->setAttribute('scheme', 'urn:ebu');
@@ -269,7 +269,7 @@ abstract class Feed_XML_Abstract
$publisher_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Publisher); $publisher_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Publisher);
if ($publisher_field) if ($publisher_field)
{ {
$str_publisher = $publisher_field->get_value(true, ' '); $str_publisher = $publisher_field->get_serialized_values(' ');
$publisher = $this->addTag($document, $group, 'media:credit', $str_publisher); $publisher = $this->addTag($document, $group, 'media:credit', $str_publisher);
$publisher->setAttribute('role', 'publisher'); $publisher->setAttribute('role', 'publisher');
$publisher->setAttribute('scheme', 'urn:ebu'); $publisher->setAttribute('scheme', 'urn:ebu');
@@ -278,14 +278,14 @@ abstract class Feed_XML_Abstract
$rights_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Rights); $rights_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Rights);
if ($rights_field) if ($rights_field)
{ {
$str_rights = $rights_field->get_value(true, ' '); $str_rights = $rights_field->get_serialized_values(' ');
$rights = $this->addTag($document, $group, 'media:copyright', $str_rights); $rights = $this->addTag($document, $group, 'media:copyright', $str_rights);
} }
$keyword_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Subject); $keyword_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Subject);
if ($keyword_field) if ($keyword_field)
{ {
$str_keywords = $keyword_field->get_value(true, ', '); $str_keywords = $keyword_field->get_serialized_values(', ');
$keywords = $this->addTag($document, $group, 'media:keywords', $str_keywords); $keywords = $this->addTag($document, $group, 'media:keywords', $str_keywords);
} }

View File

@@ -381,7 +381,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
$title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title); $title_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Title);
if ($title_field) if ($title_field)
{ {
$str_title = $title_field->get_value(true, ' '); $str_title = $title_field->get_serialized_values(' ');
} }
else else
{ {
@@ -394,7 +394,7 @@ class Feed_XML_Cooliris extends Feed_XML_Abstract implements Feed_XML_Interface
$desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description); $desc_field = $content->get_record()->get_caption()->get_dc_field(databox_Field_DCESAbstract::Description);
if ($desc_field) if ($desc_field)
{ {
$str_desc = $desc_field->get_value(true, ' '); $str_desc = $desc_field->get_serialized_values(' ');
} }
else else
{ {

View File

@@ -299,7 +299,7 @@ class appbox extends base
public function forceUpgrade(Setup_Upgrade &$upgrader) public function forceUpgrade(Setup_Upgrade &$upgrader)
{ {
$upgrader->add_steps(7 + count($this->get_databoxes())); $upgrader->add_steps(8 + count($this->get_databoxes()));
$registry = $this->get_registry(); $registry = $this->get_registry();
@@ -313,6 +313,21 @@ class appbox extends base
} }
$upgrader->add_steps_complete(1); $upgrader->add_steps_complete(1);
$upgrader->set_current_message(_('Creating new tables'));
$core = bootstrap::getCore();
$em = $core->getEntityManager();
//create schema
if($em->getConnection()->getDatabasePlatform()->supportsAlterTable())
{
$tool = new \Doctrine\ORM\Tools\SchemaTool($em);
$metas = $em->getMetadataFactory()->getAllMetadata();
$tool->updateSchema($metas, true);
}
$upgrader->add_steps_complete(1);
/** /**
* Step 2 * Step 2
*/ */

View File

@@ -0,0 +1,236 @@
<?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 caption_Field_Value
{
/**
*
* @var int
*/
protected $id;
/**
*
* @var string
*/
protected $value;
/**
*
* @var databox_field
*/
protected $databox_field;
/**
*
* @var record_adapter
*/
protected $record;
/**
*
* @param databox_field $databox_field
* @param record_adapter $record
* @param type $id
* @return \caption_Field_Value
*/
public function __construct(databox_field $databox_field, record_adapter $record, $id)
{
$this->id = (int) $id;
$this->databox_field = $databox_field;
$this->record = $record;
$connbas = $databox_field->get_databox()->get_connection();
$sql = 'SELECT record_id, value FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$this->value = $row ? $row['value'] : null;
return $this;
}
public function getId() {
return $this->id;
}
public function getValue() {
return $this->value;
}
public function getDatabox_field() {
return $this->databox_field;
}
public function getRecord() {
return $this->record;
}
public function delete()
{
$connbas = $this->databox_field->get_connection();
$sql = 'DELETE FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
$this->delete_data_from_cache();
$sbas_id = $this->record->get_sbas_id();
$this->record->get_caption()->delete_data_from_cache();
try
{
$registry = registry::get_instance();
$sphinx_rt = sphinxrt::get_instance($registry);
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
}
}
catch (Exception $e)
{
unset($e);
}
return $this;
}
public function set_value($value)
{
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
$connbas = $this->databox_field->get_connection();
$params = array(
':meta_id' => $this->id
, ':value' => $value
);
$sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
$stmt_up = $connbas->prepare($sql_up);
$stmt_up->execute($params);
$stmt_up->closeCursor();
try
{
$registry = registry::get_instance();
$sphinx_rt = sphinxrt::get_instance($registry);
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->id);
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
}
}
catch (Exception $e)
{
}
$this->update_cache_value($value);
return $this;
}
/**
*
* @param array $value
* @return caption_field
*/
public function update_cache_value($value)
{
// $this->delete_data_from_cache();
$this->record->get_caption()->delete_data_from_cache();
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
try
{
$registry = registry::get_instance();
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt = sphinxrt::get_instance($registry);
$sphinx_rt->replace_in_metas(
"metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
);
$all_datas = array();
foreach ($this->record->get_caption()->get_fields() as $field)
{
if (!$field->is_indexable())
continue;
$all_datas[] = $field->get_serialized_values();
}
$all_datas = implode(' ', $all_datas);
$sphinx_rt->replace_in_documents(
"docs_realtime" . $sbas_crc, //$this->id,
$this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
);
}
}
catch (Exception $e)
{
unset($e);
}
return $this;
}
public static function create(databox_field &$databox_field, record_Interface $record, $value)
{
$sbas_id = $databox_field->get_databox()->get_sbas_id();
$connbas = $databox_field->get_connection();
$sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
VALUES
(null, :record_id, :field, :value)';
$stmt_ins = $connbas->prepare($sql_ins);
$stmt_ins->execute(
array(
':record_id' => $record->get_record_id(),
':field' => $databox_field->get_id(),
':value' => $value
)
);
$stmt_ins->closeCursor();
$meta_id = $connbas->lastInsertId();
$caption_field_value = new self($databox_field, $record, $meta_id);
$caption_field_value->update_cache_value($value);
// $record->get_caption()->delete_data_from_cache();
return $caption_field_value;
}
}

View File

@@ -15,7 +15,7 @@
* @license http://opensource.org/licenses/gpl-3.0 GPLv3 * @license http://opensource.org/licenses/gpl-3.0 GPLv3
* @link www.phraseanet.com * @link www.phraseanet.com
*/ */
class caption_field implements cache_cacheableInterface class caption_field //implements cache_cacheableInterface
{ {
/** /**
@@ -28,13 +28,13 @@ class caption_field implements cache_cacheableInterface
* *
* @var string * @var string
*/ */
protected $value; protected $values;
/** // /**
* // *
* @var int // * @var int
*/ // */
protected $id; // protected $id;
/** /**
* *
@@ -49,44 +49,52 @@ class caption_field implements cache_cacheableInterface
* @param int $id * @param int $id
* @return caption_field * @return caption_field
*/ */
public function __construct(databox_field &$databox_field, record_Interface $record, $id) public function __construct(databox_field &$databox_field, record_Interface $record)
{ {
$this->record = $record; $this->record = $record;
$this->id = (int) $id; // $this->id = (int) $id;
$row = false;
try
{
try
{
$row = $this->get_data_from_cache();
}
catch (Exception $e)
{
$connbas = $databox_field->get_connection();
$sql = 'SELECT record_id, value FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $id));
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
$this->set_data_to_cache($row);
unset($e);
}
}
catch (Exception $e)
{
unset($e);
}
if (!$row)
throw new Exception('Unknown metadata');
$this->databox_field = $databox_field; $this->databox_field = $databox_field;
$this->value = $row['value']; $this->values = array();
$connbas = $databox_field->get_connection();
$sql = 'SELECT id FROM metadatas
WHERE record_id = :record_id
AND meta_struct_id = :meta_struct_id';
$params = array(
':record_id' => $record->get_record_id()
, ':meta_struct_id' => $databox_field->get_id()
);
$stmt = $connbas->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
if (!$databox_field->is_multi() && count($rs) > 1)
{
/**
* TRIGG CORRECTION;
*/
}
foreach ($rs as $row)
{
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
}
return $this; return $this;
} }
/**
*
* @return record_adapter
*/
public function get_record()
{
return $this->record;
}
public function is_required() public function is_required()
{ {
@@ -103,208 +111,215 @@ class caption_field implements cache_cacheableInterface
return $this->databox_field->is_readonly(); return $this->databox_field->is_readonly();
} }
/** // /**
* // *
* @return caption_field // * @return caption_field
*/ // */
public function delete() // public function delete()
// {
// $connbas = $this->databox_field->get_connection();
//
// $sql = 'DELETE FROM metadatas WHERE id = :id';
// $stmt = $connbas->prepare($sql);
// $stmt->execute(array(':id' => $this->id));
// $stmt->closeCursor();
// $this->delete_data_from_cache();
//
// $sbas_id = $this->record->get_sbas_id();
// $this->record->get_caption()->delete_data_from_cache();
//
// try
// {
// $registry = registry::get_instance();
// $sphinx_rt = sphinxrt::get_instance($registry);
//
// $sbas_params = phrasea::sbas_params();
//
// if (isset($sbas_params[$sbas_id]))
// {
// $params = $sbas_params[$sbas_id];
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
// $sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
// $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
// }
// }
// catch (Exception $e)
// {
// unset($e);
// }
//
// return $this;
// }
//
// /**
// * Part of the cache_cacheableInterface
// *
// * @param string $option
// * @return string
// */
// public function get_cache_key($option = null)
// {
// return 'captionfield_' . $this->record->get_serialize_key()
// . $this->id . ($option ? '_' . $option : '');
// }
//
// /**
// * Part of the cache_cacheableInterface
// *
// * @param string $option
// * @return mixed
// */
// public function get_data_from_cache($option = null)
// {
// $databox = databox::get_instance($this->record->get_sbas_id());
//
// return $databox->get_data_from_cache($this->get_cache_key($option));
// }
//
// /**
// * Part of the cache_cacheableInterface
// *
// * @param mixed $value
// * @param string $option
// * @param int $duration
// * @return caption_field
// */
// public function set_data_to_cache($value, $option = null, $duration = 0)
// {
// $databox = databox::get_instance($this->record->get_sbas_id());
// $databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
//
// return $this;
// }
//
// /**
// * Part of the cache_cacheableInterface
// *
// * @param string $option
// * @return caption_field
// */
// public function delete_data_from_cache($option = null)
// {
// $databox = databox::get_instance($this->record->get_sbas_id());
// $databox->delete_data_from_cache($this->get_cache_key($option));
//
// return $this;
// }
//
// /**
// *
// * @param array $value
// * @param databox_field $databox_field
// * @return string
// */
protected static function serialize_value(Array $values, $separator)
{ {
$connbas = $this->databox_field->get_connection(); if (strlen($separator) > 1)
$sql = 'DELETE FROM metadatas WHERE id = :id';
$stmt = $connbas->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
$this->delete_data_from_cache();
$sbas_id = $this->record->get_sbas_id();
$this->record->get_caption()->delete_data_from_cache();
try
{
$registry = registry::get_instance();
$sphinx_rt = sphinxrt::get_instance($registry);
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "metas_realtime" . $sbas_crc, $this->id);
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "docs_realtime" . $sbas_crc, $this->record->get_record_id());
}
}
catch (Exception $e)
{
unset($e);
}
return $this;
}
/**
* Part of the cache_cacheableInterface
*
* @param string $option
* @return string
*/
public function get_cache_key($option = null)
{
return 'captionfield_' . $this->record->get_serialize_key()
. $this->id . ($option ? '_' . $option : '');
}
/**
* Part of the cache_cacheableInterface
*
* @param string $option
* @return mixed
*/
public function get_data_from_cache($option = null)
{
$databox = databox::get_instance($this->record->get_sbas_id());
return $databox->get_data_from_cache($this->get_cache_key($option));
}
/**
* Part of the cache_cacheableInterface
*
* @param mixed $value
* @param string $option
* @param int $duration
* @return caption_field
*/
public function set_data_to_cache($value, $option = null, $duration = 0)
{
$databox = databox::get_instance($this->record->get_sbas_id());
$databox->set_data_to_cache($value, $this->get_cache_key($option), $duration);
return $this;
}
/**
* Part of the cache_cacheableInterface
*
* @param string $option
* @return caption_field
*/
public function delete_data_from_cache($option = null)
{
$databox = databox::get_instance($this->record->get_sbas_id());
$databox->delete_data_from_cache($this->get_cache_key($option));
return $this;
}
/**
*
* @param array $value
* @param databox_field $databox_field
* @return string
*/
protected static function serialize_value(Array $value, $separator)
{
if(strlen($separator) > 1)
$separator = $separator[0]; $separator = $separator[0];
if (trim($separator) === '') if (trim($separator) === '')
$separator = ' '; $separator = ' ';
else else
$separator = ' ' . $separator . ' '; $separator = ' ' . $separator . ' ';
$array_values = array();
foreach($values as $value)
{
$array_values[] = $value->getValue();
}
return implode($separator, $value); return implode($separator, $array_values);
}
/**
*
* @param array $value
* @return caption_field
*/
public function set_value(Array $value)
{
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
$connbas = $this->databox_field->get_connection();
$sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
$stmt_up = $connbas->prepare($sql_up);
$stmt_up->execute(array(':meta_id' => $this->get_meta_id(), ':value' => self::serialize_value($value, $this->databox_field->get_separator())));
$stmt_up->closeCursor();
try
{
$registry = registry::get_instance();
$sphinx_rt = sphinxrt::get_instance($registry);
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->get_meta_id());
$sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
}
}
catch (Exception $e)
{
}
$this->update_cache_value($value);
return $this;
}
/**
*
* @param array $value
* @return caption_field
*/
public function update_cache_value(Array $value)
{
$this->delete_data_from_cache();
$this->record->get_caption()->delete_data_from_cache();
$sbas_id = $this->databox_field->get_databox()->get_sbas_id();
try
{
$registry = registry::get_instance();
$sbas_params = phrasea::sbas_params();
if (isset($sbas_params[$sbas_id]))
{
$params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx_rt = sphinxrt::get_instance($registry);
$sphinx_rt->replace_in_metas(
"metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
);
$all_datas = array();
foreach ($this->record->get_caption()->get_fields() as $field)
{
if (!$field->is_indexable())
continue;
$all_datas[] = $field->get_value(true);
}
$all_datas = implode(' ', $all_datas);
$sphinx_rt->replace_in_documents(
"docs_realtime" . $sbas_crc, //$this->id,
$this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
);
}
}
catch (Exception $e)
{
unset($e);
}
return $this;
} }
//
// /**
// *
// * @param array $value
// * @return caption_field
// */
// public function set_value(Array $value)
// {
// $sbas_id = $this->databox_field->get_databox()->get_sbas_id();
// $connbas = $this->databox_field->get_connection();
//
// $sql_up = 'UPDATE metadatas SET value = :value WHERE id = :meta_id';
// $stmt_up = $connbas->prepare($sql_up);
// $stmt_up->execute(array(':meta_id' => $this->get_meta_id(), ':value' => self::serialize_value($value, $this->databox_field->get_separator())));
// $stmt_up->closeCursor();
//
// try
// {
// $registry = registry::get_instance();
// $sphinx_rt = sphinxrt::get_instance($registry);
//
// $sbas_params = phrasea::sbas_params();
//
// if (isset($sbas_params[$sbas_id]))
// {
// $params = $sbas_params[$sbas_id];
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
// $sphinx_rt->delete(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_fr", "metadatas" . $sbas_crc . "_stemmed_en"), "", $this->get_meta_id());
// $sphinx_rt->delete(array("documents" . $sbas_crc, "documents" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc . "_stemmed_en"), "", $this->record->get_record_id());
// }
// }
// catch (Exception $e)
// {
//
// }
//
// $this->update_cache_value($value);
//
// return $this;
// }
//
// /**
// *
// * @param array $value
// * @return caption_field
// */
// public function update_cache_value(Array $value)
// {
// $this->delete_data_from_cache();
// $this->record->get_caption()->delete_data_from_cache();
// $sbas_id = $this->databox_field->get_databox()->get_sbas_id();
// try
// {
// $registry = registry::get_instance();
//
// $sbas_params = phrasea::sbas_params();
//
// if (isset($sbas_params[$sbas_id]))
// {
// $params = $sbas_params[$sbas_id];
// $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
//
// $sphinx_rt = sphinxrt::get_instance($registry);
// $sphinx_rt->replace_in_metas(
// "metas_realtime" . $sbas_crc, $this->id, $this->databox_field->get_id(), $this->record->get_record_id(), $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $value, $this->record->get_creation_date()
// );
//
// $all_datas = array();
// foreach ($this->record->get_caption()->get_fields() as $field)
// {
// if (!$field->is_indexable())
// continue;
// $all_datas[] = $field->get_value(true);
// }
// $all_datas = implode(' ', $all_datas);
//
// $sphinx_rt->replace_in_documents(
// "docs_realtime" . $sbas_crc, //$this->id,
// $this->record->get_record_id(), $all_datas, $sbas_id, phrasea::collFromBas($this->record->get_base_id()), ($this->record->is_grouping() ? '1' : '0'), $this->record->get_type(), $this->record->get_creation_date()
// );
// }
// }
// catch (Exception $e)
// {
// unset($e);
// }
//
// return $this;
// }
/** /**
* *
@@ -312,60 +327,91 @@ class caption_field implements cache_cacheableInterface
* @param record_Interface $record * @param record_Interface $record
* @param array $value * @param array $value
* @return caption_field * @return caption_field
*/ // */
public static function create(databox_field &$databox_field, record_Interface $record, Array $value) // public static function create(databox_field &$databox_field, record_Interface $record, Array $value)
// {
//
// $sbas_id = $databox_field->get_databox()->get_sbas_id();
// $connbas = $databox_field->get_connection();
// $sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
// VALUES
// (null, :record_id, :field, :value)';
// $stmt_ins = $connbas->prepare($sql_ins);
// $stmt_ins->execute(
// array(
// ':record_id' => $record->get_record_id(),
// ':field' => $databox_field->get_id(),
// ':value' => self::serialize_value($value, $databox_field->get_separator())
// )
// );
// $stmt_ins->closeCursor();
// $meta_id = $connbas->lastInsertId();
//
// $caption_field = new self($databox_field, $record, $meta_id);
// $caption_field->update_cache_value($value);
//
// $record->get_caption()->delete_data_from_cache();
//
// return $caption_field;
// }
// /**
// *
// * @return string
// */
// public function get_value($as_string = false, $custom_separator = false)
// {
// if ($this->databox_field->is_multi() === true)
// {
// if ($as_string === true && $custom_separator === false)
// {
// return $this->value;
// }
// $separator = $this->databox_field->get_separator();
// $array_values = self::get_multi_values($this->value, $separator);
//
// if ($as_string === true && $custom_separator !== false)
// return self::serialize_value($array_values, $custom_separator);
// else
// return $array_values;
// }
// else
// {
// return $this->value;
// }
// }
public function get_values()
{ {
return $this->values;
$sbas_id = $databox_field->get_databox()->get_sbas_id();
$connbas = $databox_field->get_connection();
$sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value)
VALUES
(null, :record_id, :field, :value)';
$stmt_ins = $connbas->prepare($sql_ins);
$stmt_ins->execute(
array(
':record_id' => $record->get_record_id(),
':field' => $databox_field->get_id(),
':value' => self::serialize_value($value, $databox_field->get_separator())
)
);
$stmt_ins->closeCursor();
$meta_id = $connbas->lastInsertId();
$caption_field = new self($databox_field, $record, $meta_id);
$caption_field->update_cache_value($value);
$record->get_caption()->delete_data_from_cache();
return $caption_field;
} }
/** public function get_value($meta_id)
* {
* @return string return $this->values[$meta_id];
*/ }
public function get_value($as_string = false, $custom_separator = false)
public function get_serialized_values($custom_separator = false)
{ {
if ($this->databox_field->is_multi() === true) if ($this->databox_field->is_multi() === true)
{ {
if ($as_string === true && $custom_separator === false) if($custom_separator !== false)
{ $separator = $custom_separator;
return $this->value;
}
$separator = $this->databox_field->get_separator();
$array_values = self::get_multi_values($this->value, $separator);
if ($as_string === true && $custom_separator !== false)
return self::serialize_value($array_values, $custom_separator);
else else
$separator = $this->databox_field->get_separator();
return $array_values; return self::serialize_value($this->values, $separator);
} }
else else
{ {
return $this->value; foreach($this->values as $value)
{
/* @var $value Caption_Field_Value */
return $value->getValue();
}
} }
return null;
} }
/** /**
@@ -395,14 +441,14 @@ class caption_field implements cache_cacheableInterface
return $this->databox_field->is_indexable(); return $this->databox_field->is_indexable();
} }
/** // /**
* // *
* @return int // * @return int
*/ // */
public function get_meta_id() // public function get_meta_id()
{ // {
return $this->id; // return $this->id;
} // }
/** /**
* *
@@ -426,7 +472,7 @@ class caption_field implements cache_cacheableInterface
$sbas_id = $this->databox_field->get_databox()->get_sbas_id(); $sbas_id = $this->databox_field->get_databox()->get_sbas_id();
$value = $this->get_value(true); $value = $this->get_serialized_values();
$databox = databox::get_instance($sbas_id); $databox = databox::get_instance($sbas_id);
$XPATH_thesaurus = $databox->get_xpath_thesaurus(); $XPATH_thesaurus = $databox->get_xpath_thesaurus();
@@ -619,7 +665,7 @@ class caption_field implements cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
} }

View File

@@ -85,7 +85,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
try try
{ {
$databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']); $databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']);
$metadata = new caption_field($databox_meta_struct, $this->record, $row['meta_id']); $metadata = new caption_field($databox_meta_struct, $this->record);
$rec_fields[$databox_meta_struct->get_id()] = $metadata; $rec_fields[$databox_meta_struct->get_id()] = $metadata;
$dces_element = $metadata->get_databox_field()->get_dces_element(); $dces_element = $metadata->get_databox_field()->get_dces_element();

View File

@@ -18,6 +18,7 @@
class connection_pdo extends connection_abstract implements connection_interface class connection_pdo extends connection_abstract implements connection_interface
{ {
protected $registry;
/** /**
* *
* @param string $name * @param string $name
@@ -29,8 +30,9 @@ class connection_pdo extends connection_abstract implements connection_interface
* @param array $options * @param array $options
* @return connection_pdo * @return connection_pdo
*/ */
public function __construct($name, $hostname, $port, $user, $passwd, $dbname=false, $options=array()) public function __construct($name, $hostname, $port, $user, $passwd, $dbname=false, $options=array(), registryInterface $registry = null)
{ {
$this->registry = $registry ? $registry : registry::get_instance();
$this->name = $name; $this->name = $name;
if ($dbname) if ($dbname)
$dsn = 'mysql:dbname=' . $dbname . ';host=' . $hostname . ';port=' . $port . ';'; $dsn = 'mysql:dbname=' . $dbname . ';host=' . $hostname . ';port=' . $port . ';';
@@ -63,13 +65,12 @@ class connection_pdo extends connection_abstract implements connection_interface
*/ */
public function prepare($statement, $driver_options = array()) public function prepare($statement, $driver_options = array())
{ {
$registry = registry::get_instance(); if ($this->registry->get('GV_debug'))
if ($registry->get('GV_debug'))
return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options)); return new connection_pdoStatementDebugger(parent::prepare($statement, $driver_options));
else else
return parent::prepare($statement, $driver_options); return parent::prepare($statement, $driver_options);
} }
/** /**

View File

@@ -95,9 +95,17 @@ function deleteRecord($lst, $del_children)
$ret[] = implode('_', array($oneson->get_sbas_id(), $oneson->get_record_id(), $oneson->get_base_id())); $ret[] = implode('_', array($oneson->get_sbas_id(), $oneson->get_record_id(), $oneson->get_base_id()));
} }
} }
$ret[] = implode('_', $rid);
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach($basket_elements as $basket_element)
{
$em->remove($basket_element);
}
$record->delete(); $record->delete();
unset($record); unset($record);
$ret[] = implode('_', $rid);
} }
} }
catch (Exception $e) catch (Exception $e)
@@ -106,12 +114,6 @@ function deleteRecord($lst, $del_children)
} }
} }
$basket_elements = $BE_repository->findElementsByRecord($record);
foreach($basket_elements as $basket_element)
{
$em->remove($basket_element);
}
$em->flush(); $em->flush();
return p4string::jsonencode($ret); return p4string::jsonencode($ret);

View File

@@ -39,7 +39,7 @@ class random
$registry = registry::get_instance(); $registry = registry::get_instance();
$sql = 'SELECT * FROM tokens WHERE expire_on < :date $sql = 'SELECT * FROM tokens WHERE expire_on < :date
AND datas IS NOT NULL AND type="download"'; AND datas IS NOT NULL AND (type="download" OR type="email")';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date)); $stmt->execute(array(':date' => $date));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -49,6 +49,7 @@ class random
switch ($row['type']) switch ($row['type'])
{ {
case 'download': case 'download':
case 'email':
$file = $registry->get('GV_RootPath') . 'tmp/download/' . $row['value'] . '.zip'; $file = $registry->get('GV_RootPath') . 'tmp/download/' . $row['value'] . '.zip';
if (is_file($file)) if (is_file($file))
unlink($file); unlink($file);
@@ -56,7 +57,7 @@ class random
} }
} }
$sql = 'DELETE FROM tokens WHERE expire_on < :date and type="download"'; $sql = 'DELETE FROM tokens WHERE expire_on < :date and (type="download" OR type="email")';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute(array(':date' => $date)); $stmt->execute(array(':date' => $date));
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -132,14 +132,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
protected $modification_date; protected $modification_date;
const CACHE_ORIGINAL_NAME = 'originalname'; const CACHE_ORIGINAL_NAME = 'originalname';
const CACHE_TECHNICAL_DATAS = 'technical_datas'; const CACHE_TECHNICAL_DATAS = 'technical_datas';
const CACHE_MIME = 'mime'; const CACHE_MIME = 'mime';
const CACHE_SHA256 = 'sha256'; const CACHE_SHA256 = 'sha256';
const CACHE_SUBDEFS = 'subdefs'; const CACHE_SUBDEFS = 'subdefs';
const CACHE_GROUPING = 'grouping'; const CACHE_GROUPING = 'grouping';
const CACHE_STATUS = 'status'; const CACHE_STATUS = 'status';
protected static $_regfields; protected static $_regfields;
@@ -187,12 +186,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
$connbas = $this->databox->get_connection(); $connbas = $this->databox->get_connection();
$sql = 'SELECT coll_id, record_id,credate , uuid, moddate, parent_record_id $sql = 'SELECT coll_id, record_id,credate , uuid, moddate, parent_record_id
, type, originalname, bitly, sha256, mime , type, originalname, bitly, sha256, mime
FROM record WHERE record_id = :record_id'; FROM record WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id)); $stmt->execute(array(':record_id' => $this->record_id));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
@@ -211,16 +210,16 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$this->mime = $row['mime']; $this->mime = $row['mime'];
$datas = array( $datas = array(
'mime' => $this->mime 'mime' => $this->mime
, 'sha256' => $this->sha256 , 'sha256' => $this->sha256
, 'bitly_link' => $this->bitly_link , 'bitly_link' => $this->bitly_link
, 'original_name' => $this->original_name , 'original_name' => $this->original_name
, 'type' => $this->type , 'type' => $this->type
, 'grouping' => $this->grouping , 'grouping' => $this->grouping
, 'uuid' => $this->uuid , 'uuid' => $this->uuid
, 'modification_date' => $this->modification_date , 'modification_date' => $this->modification_date
, 'creation_date' => $this->creation_date , 'creation_date' => $this->creation_date
, 'base_id' => $this->base_id , 'base_id' => $this->base_id
); );
$this->set_data_to_cache($datas); $this->set_data_to_cache($datas);
@@ -293,9 +292,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'UPDATE record SET type = :type WHERE record_id = :record_id'; $sql = 'UPDATE record SET type = :type WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':type' => $type, ':record_id' => $this->get_record_id())); $stmt->execute(array(':type' => $type, ':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
if ($old_type !== $type) if ($old_type !== $type)
@@ -372,9 +371,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$dstatus = databox_status::getDisplayStatus(); $dstatus = databox_status::getDisplayStatus();
$sbas_id = $this->get_sbas_id(); $sbas_id = $this->get_sbas_id();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$status = ''; $status = '';
@@ -383,24 +382,24 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($dstatus[$sbas_id] as $n => $statbit) foreach ($dstatus[$sbas_id] as $n => $statbit)
{ {
if ($statbit['printable'] == '0' && if ($statbit['printable'] == '0' &&
!$user->ACL()->has_right_on_base($this->base_id, 'chgstatus')) !$user->ACL()->has_right_on_base($this->base_id, 'chgstatus'))
continue; continue;
$x = (substr((strrev($this->get_status())), $n, 1)); $x = (substr((strrev($this->get_status())), $n, 1));
$source0 = "/skins/icons/spacer.gif"; $source0 = "/skins/icons/spacer.gif";
$style0 = "visibility:hidden;display:none;"; $style0 = "visibility:hidden;display:none;";
$source1 = "/skins/icons/spacer.gif"; $source1 = "/skins/icons/spacer.gif";
$style1 = "visibility:hidden;display:none;"; $style1 = "visibility:hidden;display:none;";
if ($statbit["img_on"]) if ($statbit["img_on"])
{ {
$source1 = $statbit["img_on"]; $source1 = $statbit["img_on"];
$style1 = "visibility:auto;display:none;"; $style1 = "visibility:auto;display:none;";
} }
if ($statbit["img_off"]) if ($statbit["img_off"])
{ {
$source0 = $statbit["img_off"]; $source0 = $statbit["img_off"];
$style0 = "visibility:auto;display:none;"; $style0 = "visibility:auto;display:none;";
} }
if ($x == '1') if ($x == '1')
{ {
@@ -417,19 +416,19 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
} }
$status .= '<img style="margin:1px;' . $style1 . '" ' . $status .= '<img style="margin:1px;' . $style1 . '" ' .
'class="STAT_' . $this->base_id . '_' 'class="STAT_' . $this->base_id . '_'
. $this->record_id . '_' . $n . '_1" ' . . $this->record_id . '_' . $n . '_1" ' .
'src="' . $source1 . '" title="' . 'src="' . $source1 . '" title="' .
(isset($statbit["labelon"]) ? (isset($statbit["labelon"]) ?
$statbit["labelon"] : $statbit["labelon"] :
$statbit["lib"]) . '"/>'; $statbit["lib"]) . '"/>';
$status .= '<img style="margin:1px;' . $style0 . '" ' . $status .= '<img style="margin:1px;' . $style0 . '" ' .
'class="STAT_' . $this->base_id . '_' 'class="STAT_' . $this->base_id . '_'
. $this->record_id . '_' . $n . '_0" ' . . $this->record_id . '_' . $n . '_0" ' .
'src="' . $source0 . '" title="' . 'src="' . $source0 . '" title="' .
(isset($statbit["labeloff"]) ? (isset($statbit["labeloff"]) ?
$statbit["labeloff"] : $statbit["labeloff"] :
("non-" . $statbit["lib"])) . '"/>'; ("non-" . $statbit["lib"])) . '"/>';
} }
} }
@@ -482,8 +481,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id"; $sql = "UPDATE record SET coll_id = :coll_id WHERE record_id =:record_id";
$params = array( $params = array(
':coll_id' => $collection->get_coll_id(), ':coll_id' => $collection->get_coll_id(),
':record_id' => $this->get_record_id() ':record_id' => $this->get_record_id()
); );
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
@@ -493,7 +492,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$this->base_id = $collection->get_base_id(); $this->base_id = $collection->get_base_id();
$appbox->get_session()->get_logger($this->get_databox()) $appbox->get_session()->get_logger($this->get_databox())
->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), ''); ->log($this, Session_Logger::EVENT_MOVE, $collection->get_coll_id(), '');
$this->delete_data_from_cache(); $this->delete_data_from_cache();
@@ -568,18 +567,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
} }
$sql = 'SELECT BIN(status) as status FROM record $sql = 'SELECT BIN(status) as status FROM record
WHERE record_id = :record_id'; WHERE record_id = :record_id';
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
throw new Exception('status not found'); throw new Exception('status not found');
$status = $row['status']; $status = $row['status'];
$n = strlen($status); $n = strlen($status);
while ($n < 64) while ($n < 64)
{ {
$status = '0' . $status; $status = '0' . $status;
@@ -653,7 +652,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$subdefs = array('preview', 'thumbnail'); $subdefs = array('preview', 'thumbnail');
@@ -662,7 +661,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$subdefs[] = $row['name']; $subdefs[] = $row['name'];
} }
$subdefs = array_unique($subdefs); $subdefs = array_unique($subdefs);
$this->set_data_to_cache($subdefs, self::CACHE_SUBDEFS); $this->set_data_to_cache($subdefs, self::CACHE_SUBDEFS);
return $subdefs; return $subdefs;
@@ -695,10 +694,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
{ {
$this->technical_datas = array(); $this->technical_datas = array();
$connbas = $this->get_databox()->get_connection(); $connbas = $this->get_databox()->get_connection();
$sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id'; $sql = 'SELECT name, value FROM technical_datas WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) foreach ($rs as $row)
@@ -774,7 +773,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$dom_doc->formatOutput = true; $dom_doc->formatOutput = true;
$dom_doc->standalone = true; $dom_doc->standalone = true;
$record = $dom_doc->createElement('record'); $record = $dom_doc->createElement('record');
$record->setAttribute('record_id', $this->get_record_id()); $record->setAttribute('record_id', $this->get_record_id());
$dom_doc->appendChild($record); $dom_doc->appendChild($record);
$description = $dom_doc->createElement('description'); $description = $dom_doc->createElement('description');
@@ -784,16 +783,17 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
if ($field->is_multi()) $values = $field->get_values();
$values = $field->get_value(); // if ($field->is_multi())
else // $values = $field->get_value();
$values = array($field->get_value()); // else
// $values = array($field->get_value());
foreach ($values as $value) foreach ($values as $value)
{ {
$elem = $dom_doc->createElement($field->get_name()); $elem = $dom_doc->createElement($field->get_name());
$elem->appendChild($dom_doc->createTextNode($value)); $elem->appendChild($dom_doc->createTextNode($value->getValue()));
$elem->setAttribute('meta_id', $field->get_meta_id()); $elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id()); $elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem); $description->appendChild($elem);
} }
@@ -836,21 +836,34 @@ class record_adapter implements record_Interface, cache_cacheableInterface
continue; continue;
} }
$this->set_metadatas( /* @var $field caption_field */
array( /**
'meta_struct_id' => $field->get_meta_struct_id() * Replacing original name in multi values is non sense
, 'meta_id' => get_meta_id */
, 'value' => array($original_name) if (!$field->is_multi())
) {
); continue;
}
else
{
$value = array_pop($field->get_values());
$this->set_metadatas(
array(
'meta_struct_id' => $field->get_meta_struct_id()
, 'meta_id' => $value->getId()
, 'value' => $original_name
)
);
}
} }
$sql = 'UPDATE record $sql = 'UPDATE record
SET originalname = :originalname WHERE record_id = :record_id'; SET originalname = :originalname WHERE record_id = :record_id';
$params = array( $params = array(
':originalname' => $original_name ':originalname' => $original_name
, ':record_id' => $this->get_record_id() , ':record_id' => $this->get_record_id()
); );
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
@@ -868,7 +881,7 @@ 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(); $sbas_id = $this->get_sbas_id();
$record_id = $this->get_record_id(); $record_id = $this->get_record_id();
if ($this->is_grouping()) if ($this->is_grouping())
@@ -878,8 +891,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $regfield['regname']; return $regfield['regname'];
} }
$title = ''; $title = '';
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$fields = $this->get_databox()->get_meta_structure(); $fields = $this->get_databox()->get_meta_structure();
@@ -897,14 +910,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (count($fields_to_retrieve) > 0) if (count($fields_to_retrieve) > 0)
{ {
$retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine); $retrieved_fields = $this->get_caption()->get_highlight_fields($highlight, $fields_to_retrieve, $searchEngine);
$titles = array(); $titles = array();
foreach ($retrieved_fields as $key => $value) foreach ($retrieved_fields as $key => $value)
{ {
if (trim($value['value'] === '')) if (trim($value['value'] === ''))
continue; continue;
$titles[] = $value['value']; $titles[] = $value['value'];
} }
$title = trim(implode(' - ', $titles)); $title = trim(implode(' - ', $titles));
} }
if (trim($title) === '') if (trim($title) === '')
@@ -955,9 +968,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
foreach ($desc->get_fields() as $caption_field) foreach ($desc->get_fields() as $caption_field)
{ {
/* @var $caption_field caption_field */
$meta_struct_id = $caption_field->get_meta_struct_id(); $meta_struct_id = $caption_field->get_meta_struct_id();
if (array_key_exists($meta_struct_id, $array)) if (array_key_exists($meta_struct_id, $array))
$fields[$array[$meta_struct_id]] = $caption_field->get_value(); {
$fields[$array[$meta_struct_id]] = $caption_field->get_serialized_values();
}
} }
return $fields; return $fields;
@@ -988,7 +1004,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
protected function searchRegFields(databox_descriptionStructure $meta_struct) protected function searchRegFields(databox_descriptionStructure $meta_struct)
{ {
$fields = null; $fields = null;
$fields["regname"] = ""; $fields["regname"] = "";
$fields["regdesc"] = ""; $fields["regdesc"] = "";
$fields["regdate"] = ""; $fields["regdate"] = "";
@@ -1062,11 +1078,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function substitute_subdef($name, system_file $pathfile) public function substitute_subdef($name, system_file $pathfile)
{ {
$newfilename = $this->record_id . '_0_' . $name $newfilename = $this->record_id . '_0_' . $name
. '.' . $pathfile->get_extension(); . '.' . $pathfile->get_extension();
$base_url = ''; $base_url = '';
$original_file = $subdef_def = false; $original_file = $subdef_def = false;
if ($name == 'document') if ($name == 'document')
{ {
@@ -1116,7 +1132,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
catch (Exception $e) catch (Exception $e)
{ {
$path = databox::dispatch($subdef_def->get_path()); $path = databox::dispatch($subdef_def->get_path());
system_file::mkdir($path); system_file::mkdir($path);
$original_file = $path . $newfilename; $original_file = $path . $newfilename;
} }
@@ -1126,9 +1142,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (trim($subdef_def->get_baseurl()) !== '') if (trim($subdef_def->get_baseurl()) !== '')
{ {
$base_url = str_replace( $base_url = str_replace(
array((string) $subdef_def->get_path(), $newfilename) array((string) $subdef_def->get_path(), $newfilename)
, array((string) $subdef_def->get_baseurl(), '') , array((string) $subdef_def->get_baseurl(), '')
, $path_file_dest , $path_file_dest
); );
} }
@@ -1145,18 +1161,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
try try
{ {
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name'; $sql = 'DELETE FROM subdef WHERE record_id= :record_id AND name=:name';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute( $stmt->execute(
array( array(
':record_id' => $this->record_id ':record_id' => $this->record_id
, ':name' => $name , ':name' => $name
) )
); );
$image_size = $system_file->get_technical_datas(); $image_size = $system_file->get_technical_datas();
@@ -1171,18 +1187,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array( $stmt->execute(array(
':record_id' => $this->record_id, ':record_id' => $this->record_id,
':name' => $name, ':name' => $name,
':baseurl' => $base_url, ':baseurl' => $base_url,
':filename' => $system_file->getFilename(), ':filename' => $system_file->getFilename(),
':width' => $image_size[system_file::TC_DATAS_WIDTH], ':width' => $image_size[system_file::TC_DATAS_WIDTH],
':height' => $image_size[system_file::TC_DATAS_HEIGHT], ':height' => $image_size[system_file::TC_DATAS_HEIGHT],
':mime' => $system_file->get_mime(), ':mime' => $system_file->get_mime(),
':path' => $system_file->getPath(), ':path' => $system_file->getPath(),
':filesize' => $system_file->getSize() ':filesize' => $system_file->getSize()
)); ));
$sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id'; $sql = 'UPDATE record SET moddate=NOW() WHERE record_id=:record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1201,7 +1217,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$type = $name == 'document' ? 'HD' : $name; $type = $name == 'document' ? 'HD' : $name;
$session->get_logger($this->get_databox()) $session->get_logger($this->get_databox())
->log($this, Session_Logger::EVENT_SUBSTITUTE, $type, ''); ->log($this, Session_Logger::EVENT_SUBSTITUTE, $type, '');
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -1219,13 +1235,13 @@ class record_adapter implements record_Interface, cache_cacheableInterface
protected function set_xml(DOMDocument $dom_doc) protected function set_xml(DOMDocument $dom_doc)
{ {
$connbas = $this->get_databox()->get_connection(); $connbas = $this->get_databox()->get_connection();
$sql = 'UPDATE record SET xml = :xml WHERE record_id= :record_id'; $sql = 'UPDATE record SET xml = :xml WHERE record_id= :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute( $stmt->execute(
array( array(
':xml' => $dom_doc->saveXML(), ':xml' => $dom_doc->saveXML(),
':record_id' => $this->record_id ':record_id' => $this->record_id
) )
); );
$this->reindex(); $this->reindex();
@@ -1251,29 +1267,32 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
} }
if (!is_array($params['value'])) if (!is_scalar($params['value']))
throw new Exception(); throw new Exception('Metadata value should be scalar');
$databox_field = databox_field::get_instance($databox, $params['meta_struct_id']); $databox_field = databox_field::get_instance($databox, $params['meta_struct_id']);
$caption_field = new caption_field($databox_field, $this);
if (trim($params['meta_id']) !== '') if (trim($params['meta_id']) !== '')
{ {
$tmp_val = trim(implode('', $params['value'])); $tmp_val = trim($params['value']);
$caption_field = new caption_field($databox_field, $this, $params['meta_id']);
$caption_field_value = $caption_field->get_value($params['meta_id']);
if ($tmp_val === '') if ($tmp_val === '')
{ {
$caption_field->delete(); $caption_field_value->delete();
unset($caption_field); unset($caption_field_value);
} }
else else
{ {
$caption_field->set_value($params['value']); $caption_field_value->set_value($params['value']);
} }
} }
else else
{ {
$caption_field = caption_field::create($databox_field, $this, $params['value']); $caption_field_value = caption_Field_Value::create($databox_field, $this, $params['value']);
} }
$this->caption_record = null; $this->caption_record = null;
@@ -1319,9 +1338,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function reindex() public function reindex()
{ {
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'UPDATE record SET status=(status & ~7 | 4) $sql = 'UPDATE record SET status=(status & ~7 | 4)
WHERE record_id= :record_id'; WHERE record_id= :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id)); $stmt->execute(array(':record_id' => $this->record_id));
$this->delete_data_from_cache(self::CACHE_STATUS); $this->delete_data_from_cache(self::CACHE_STATUS);
@@ -1335,8 +1354,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function rebuild_subdefs() public function rebuild_subdefs()
{ {
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id'; $sql = 'UPDATE record SET jeton=(jeton | ' . JETON_MAKE_SUBDEF . ') WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
return $this; return $this;
@@ -1349,10 +1368,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function write_metas() public function write_metas()
{ {
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$sql = 'UPDATE record $sql = 'UPDATE record
SET jeton = ' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . ' SET jeton = ' . (JETON_WRITE_META_DOC | JETON_WRITE_META_SUBDEF) . '
WHERE record_id= :record_id'; WHERE record_id= :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id)); $stmt->execute(array(':record_id' => $this->record_id));
return $this; return $this;
@@ -1368,21 +1387,21 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$connbas = connection::getPDOConnection($this->get_sbas_id()); $connbas = connection::getPDOConnection($this->get_sbas_id());
$registry = registry::get_instance(); $registry = registry::get_instance();
$sql = 'UPDATE record SET status = 0b' . $status . ' $sql = 'UPDATE record SET status = 0b' . $status . '
WHERE record_id= :record_id'; WHERE record_id= :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->record_id)); $stmt->execute(array(':record_id' => $this->record_id));
$sql = 'REPLACE INTO status (id, record_id, name, value) VALUES (null, :record_id, :name, :value)'; $sql = 'REPLACE INTO status (id, record_id, name, value) VALUES (null, :record_id, :name, :value)';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$status = strrev($status); $status = strrev($status);
for ($i = 4; $i < strlen($status); $i++) for ($i = 4; $i < strlen($status); $i++)
{ {
$stmt->execute(array( $stmt->execute(array(
':record_id' => $this->get_record_id(), ':record_id' => $this->get_record_id(),
':name' => $i, ':name' => $i,
':value' => $status[$i] ':value' => $status[$i]
)); ));
} }
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1392,10 +1411,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$sphinx = sphinxrt::get_instance($registry); $sphinx = sphinxrt::get_instance($registry);
$sbas_params = phrasea::sbas_params(); $sbas_params = phrasea::sbas_params();
$sbas_id = $this->get_sbas_id(); $sbas_id = $this->get_sbas_id();
if (isset($sbas_params[$sbas_id])) if (isset($sbas_params[$sbas_id]))
{ {
$params = $sbas_params[$sbas_id]; $params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname']))); $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
$sphinx->update_status(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_en", "metadatas" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc), $this->get_sbas_id(), $this->get_record_id(), strrev($status)); $sphinx->update_status(array("metadatas" . $sbas_crc, "metadatas" . $sbas_crc . "_stemmed_en", "metadatas" . $sbas_crc . "_stemmed_fr", "documents" . $sbas_crc), $this->get_sbas_id(), $this->get_record_id(), strrev($status));
} }
@@ -1438,9 +1457,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
} }
} }
} }
$regname = ''; $regname = '';
if ($sxe = simplexml_load_string($this->get_xml())) if ($sxe = simplexml_load_string($this->get_xml()))
$regname = (string) $sxe->description->$balisename; $regname = (string) $sxe->description->$balisename;
return $regname; return $regname;
} }
@@ -1459,7 +1478,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if ($is_grouping) if ($is_grouping)
{ {
$uuid = uuid::generate_v4(); $uuid = uuid::generate_v4();
$sha256 = null; $sha256 = null;
} }
else else
@@ -1467,7 +1486,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$uuid = $system_file->read_uuid(); $uuid = $system_file->read_uuid();
if (!uuid::is_valid($uuid)) if (!uuid::is_valid($uuid))
{ {
$uuid = uuid::generate_v4(); $uuid = uuid::generate_v4();
} }
$sha256 = $system_file->get_sha256(); $sha256 = $system_file->get_sha256();
} }
@@ -1491,32 +1510,32 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array( $stmt->execute(array(
':coll_id' => $coll_id ':coll_id' => $coll_id
, ':parent_record_id' => ($is_grouping ? 1 : 0) , ':parent_record_id' => ($is_grouping ? 1 : 0)
, ':type' => $type , ':type' => $type
, ':sha256' => $sha256 , ':sha256' => $sha256
, ':uuid' => $uuid , ':uuid' => $uuid
, ':originalname' => $original_name , ':originalname' => $original_name
, ':mime' => $system_file->get_mime() , ':mime' => $system_file->get_mime()
)); ));
$record_id = $connbas->lastInsertId(); $record_id = $connbas->lastInsertId();
$record = new self($sbas_id, $record_id); $record = new self($sbas_id, $record_id);
try try
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$session = $appbox->get_session(); $session = $appbox->get_session();
$log_id = $session->get_logger($databox)->get_id(); $log_id = $session->get_logger($databox)->get_id();
$sql = 'INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment) $sql = 'INSERT INTO log_docs (id, log_id, date, record_id, action, final, comment)
VALUES (null, :log_id, now(), VALUES (null, :log_id, now(),
:record_id, "add", :coll_id,"")'; :record_id, "add", :coll_id,"")';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array( $stmt->execute(array(
':log_id' => $log_id, ':log_id' => $log_id,
':record_id' => $record_id, ':record_id' => $record_id,
':coll_id' => $coll_id ':coll_id' => $coll_id
)); ));
$stmt->closeCursor(); $stmt->closeCursor();
} }
@@ -1545,7 +1564,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$tc_datas = $system_file->get_technical_datas(); $tc_datas = $system_file->get_technical_datas();
$sql = 'REPLACE INTO technical_datas (id, record_id, name, value) $sql = 'REPLACE INTO technical_datas (id, record_id, name, value)
VALUES (null, :record_id, :name, :value)'; VALUES (null, :record_id, :name, :value)';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
@@ -1555,9 +1574,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
continue; continue;
$stmt->execute(array( $stmt->execute(array(
':record_id' => $record_id ':record_id' => $record_id
, ':name' => $name , ':name' => $name
, ':value' => $value , ':value' => $value
)); ));
} }
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1591,14 +1610,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$records = array(); $records = array();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$k = count($records); $k = count($records);
$records[$k] = new record_adapter($sbas_id, $row['record_id']); $records[$k] = new record_adapter($sbas_id, $row['record_id']);
} }
@@ -1623,11 +1642,11 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
public function delete() public function delete()
{ {
$connbas = $this->get_databox()->get_connection(); $connbas = $this->get_databox()->get_connection();
$sbas_id = $this->get_databox()->get_sbas_id(); $sbas_id = $this->get_databox()->get_sbas_id();
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$ftodel = array(); $ftodel = array();
foreach ($this->get_subdefs() as $subdef) foreach ($this->get_subdefs() as $subdef)
@@ -1635,30 +1654,30 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (!$subdef->is_physically_present()) if (!$subdef->is_physically_present())
continue; continue;
$ftodel[] = $subdef->get_pathfile(); $ftodel[] = $subdef->get_pathfile();
$watermark = $subdef->get_path() . 'watermark_' . $subdef->get_file(); $watermark = $subdef->get_path() . 'watermark_' . $subdef->get_file();
if (file_exists($watermark)) if (file_exists($watermark))
$ftodel[] = $watermark; $ftodel[] = $watermark;
$stamp = $subdef->get_path() . 'stamp_' . $subdef->get_file(); $stamp = $subdef->get_path() . 'stamp_' . $subdef->get_file();
if (file_exists($stamp)) if (file_exists($stamp))
$ftodel[] = $stamp; $ftodel[] = $stamp;
} }
$origcoll = phrasea::collFromBas($this->get_base_id()); $origcoll = phrasea::collFromBas($this->get_base_id());
$appbox->get_session()->get_logger($this->get_databox()) $appbox->get_session()->get_logger($this->get_databox())
->log($this, Session_Logger::EVENT_DELETE, $origcoll, $this->get_xml()); ->log($this, Session_Logger::EVENT_DELETE, $origcoll, $this->get_xml());
$sql = "DELETE FROM record WHERE record_id = :record_id"; $sql = "DELETE FROM record WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = 'SELECT id FROM metadatas WHERE record_id = :record_id'; $sql = 'SELECT id FROM metadatas WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$rs = $stmt->fetchAll(); $rs = $stmt->fetchAll();
$stmt->closeCursor(); $stmt->closeCursor();
try try
@@ -1669,7 +1688,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
if (isset($sbas_params[$sbas_id])) if (isset($sbas_params[$sbas_id]))
{ {
$params = $sbas_params[$sbas_id]; $params = $sbas_params[$sbas_id];
$sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname']))); $sbas_crc = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
foreach ($rs as $row) foreach ($rs as $row)
{ {
@@ -1683,49 +1702,49 @@ class record_adapter implements record_Interface, cache_cacheableInterface
unset($e); unset($e);
} }
$sql = "DELETE FROM metadatas WHERE record_id = :record_id"; $sql = "DELETE FROM metadatas WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM prop WHERE record_id = :record_id"; $sql = "DELETE FROM prop WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM idx WHERE record_id = :record_id"; $sql = "DELETE FROM idx WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM permalinks $sql = "DELETE FROM permalinks
WHERE subdef_id WHERE subdef_id
IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)"; IN (SELECT subdef_id FROM subdef WHERE record_id=:record_id)";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM subdef WHERE record_id = :record_id"; $sql = "DELETE FROM subdef WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM technical_datas WHERE record_id = :record_id"; $sql = "DELETE FROM technical_datas WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM thit WHERE record_id = :record_id"; $sql = "DELETE FROM thit WHERE record_id = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM regroup WHERE rid_parent = :record_id"; $sql = "DELETE FROM regroup WHERE rid_parent = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
$sql = "DELETE FROM regroup WHERE rid_child = :record_id"; $sql = "DELETE FROM regroup WHERE rid_child = :record_id";
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1785,7 +1804,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
echo 'Aucune sous definition a faire pour ' . $this->get_type() . "\n"; echo 'Aucune sous definition a faire pour ' . $this->get_type() . "\n";
} }
$subdef_class = 'databox_subdef' . ucfirst($this->get_type()); $subdef_class = 'databox_subdef' . ucfirst($this->get_type());
$record_subdefs = $this->get_subdefs(); $record_subdefs = $this->get_subdefs();
foreach ($subdefs as $subdef) foreach ($subdefs as $subdef)
@@ -1847,7 +1866,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
protected function generate_subdef(databox_subdefInterface $subdef_class, $pathdest) protected function generate_subdef(databox_subdefInterface $subdef_class, $pathdest)
{ {
$registry = registry::get_instance(); $registry = registry::get_instance();
$generated = $subdef_class->generate($this, $pathdest, $registry); $generated = $subdef_class->generate($this, $pathdest, $registry);
return $this; return $this;
@@ -1899,12 +1918,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
(null, :log_id, now(), :rec, :referrer, :site)'; (null, :log_id, now(), :rec, :referrer, :site)';
$params = array( $params = array(
':log_id' => $log_id ':log_id' => $log_id
, ':rec' => $this->get_record_id() , ':rec' => $this->get_record_id()
, ':referrer' => $referrer , ':referrer' => $referrer
, ':site' => $gv_sit , ':site' => $gv_sit
); );
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -1945,7 +1964,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_container_baskets() public function get_container_baskets()
{ {
$Core = bootstrap::getCore(); $Core = bootstrap::getCore();
$em = $Core->getEntityManager(); $em = $Core->getEntityManager();
$repo = $em->getRepository('\Entities\Basket'); $repo = $em->getRepository('\Entities\Basket');
@@ -1963,15 +1982,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public static function get_records_by_originalname(databox $databox, $original_name, $offset_start = 0, $how_many = 10) public static function get_records_by_originalname(databox $databox, $original_name, $offset_start = 0, $how_many = 10)
{ {
$offset_start = (int) ($offset_start < 0 ? 0 : $offset_start); $offset_start = (int) ($offset_start < 0 ? 0 : $offset_start);
$how_many = (int) (($how_many > 20 || $how_many < 1) ? 10 : $how_many); $how_many = (int) (($how_many > 20 || $how_many < 1) ? 10 : $how_many);
$sql = sprintf('SELECT record_id FROM record $sql = sprintf('SELECT record_id FROM record
WHERE original_name = :original_name LIMIT %d, %d' WHERE original_name = :original_name LIMIT %d, %d'
, $offset_start, $how_many); , $offset_start, $how_many);
$stmt = $databox->get_connection()->prepare($sql); $stmt = $databox->get_connection()->prepare($sql);
$stmt->execute(array(':original_name' => $original_name)); $stmt->execute(array(':original_name' => $original_name));
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$records = array(); $records = array();
@@ -2008,18 +2027,18 @@ class record_adapter implements record_Interface, cache_cacheableInterface
ORDER BY g.ord ASC, dateadd ASC, record_id ASC'; ORDER BY g.ord ASC, dateadd ASC, record_id ASC';
$params = array( $params = array(
':GV_site' => $appbox->get_registry()->get('GV_sit') ':GV_site' => $appbox->get_registry()->get('GV_sit')
, ':usr_id' => $appbox->get_session()->get_usr_id() , ':usr_id' => $appbox->get_session()->get_usr_id()
, ':record_id' => $this->get_record_id() , ':record_id' => $this->get_record_id()
); );
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$set = new set_selection(); $set = new set_selection();
$i = 1; $i = 1;
foreach ($rs as $row) foreach ($rs as $row)
{ {
$set->add_element(new record_adapter($this->get_sbas_id(), $row['record_id'], $i)); $set->add_element(new record_adapter($this->get_sbas_id(), $row['record_id'], $i));
@@ -2052,14 +2071,14 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$params = array( $params = array(
':GV_site' => $appbox->get_registry()->get('GV_sit') ':GV_site' => $appbox->get_registry()->get('GV_sit')
, ':usr_id' => $appbox->get_session()->get_usr_id() , ':usr_id' => $appbox->get_session()->get_usr_id()
, ':record_id' => $this->get_record_id() , ':record_id' => $this->get_record_id()
); );
$stmt = $this->get_databox()->get_connection()->prepare($sql); $stmt = $this->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$set = new set_selection(); $set = new set_selection();
@@ -2105,9 +2124,9 @@ class record_adapter implements record_Interface, cache_cacheableInterface
VALUES (null, :parent_record_id, :record_id, NOW(), :ord)'; VALUES (null, :parent_record_id, :record_id, NOW(), :ord)';
$params = array( $params = array(
':parent_record_id' => $this->get_record_id() ':parent_record_id' => $this->get_record_id()
, ':record_id' => $record->get_record_id() , ':record_id' => $record->get_record_id()
, ':ord' => $ord , ':ord' => $ord
); );
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
@@ -2115,7 +2134,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$stmt->closeCursor(); $stmt->closeCursor();
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id'; $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();
@@ -2136,15 +2155,15 @@ class record_adapter implements record_Interface, cache_cacheableInterface
AND rid_child = :record_id"; AND rid_child = :record_id";
$params = array( $params = array(
':parent_record_id' => $this->get_record_id() ':parent_record_id' => $this->get_record_id()
, ':record_id' => $record->get_record_id() , ':record_id' => $record->get_record_id()
); );
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
$sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id'; $sql = 'UPDATE record SET moddate = NOW() WHERE record_id = :record_id';
$stmt = $connbas->prepare($sql); $stmt = $connbas->prepare($sql);
$stmt->execute(array(':record_id' => $this->get_record_id())); $stmt->execute(array(':record_id' => $this->get_record_id()));
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -1135,10 +1135,10 @@ class system_file extends SplFileObject
foreach ($tmpval as $val) foreach ($tmpval as $val)
{ {
$ret[$meta->get_id()] = array( $ret[] = array(
'meta_struct_id' => $meta->get_id(), 'meta_struct_id' => $meta->get_id(),
'meta_id' => null, 'meta_id' => null,
'value' => array($val) 'value' => $val
); );
} }
} }
@@ -1211,16 +1211,19 @@ class system_file extends SplFileObject
$fv = array($fv); $fv = array($fv);
} }
if (isset($metadatas[$meta->get_id()]) && $meta->is_multi() === true) // if (isset($metadatas[$meta->get_id()]) && $meta->is_multi() === true)
{ // {
$fv = array_unique(array_merge($metadatas[$meta->get_id()], $fv)); // $fv = array_unique(array_merge($metadatas[$meta->get_id()], $fv));
} // }
$metadatas[$meta->get_id()] = array( foreach($fv as $value)
'meta_struct_id' => $meta->get_id(), {
'meta_id' => null, $metadatas[] = array(
'value' => $fv 'meta_struct_id' => $meta->get_id(),
); 'meta_id' => null,
'value' => $value
);
}
unset($meta); unset($meta);
} }

View File

@@ -5335,8 +5335,8 @@
</fields> </fields>
</index> </index>
<index> <index>
<name>unique</name> <name>index_meta</name>
<type>UNIQUE</type> <type>INDEX</type>
<fields> <fields>
<field>record_id</field> <field>record_id</field>
<field>meta_struct_id</field> <field>meta_struct_id</field>

View File

@@ -609,14 +609,17 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
*/ */
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
$old_datas[$field->get_meta_id()] = $field->get_value(); foreach($field->get_values() as $value)
if ($field->is_readonly() === false && $field->is_multi() === false)
{ {
$toupdate[$field->get_meta_id()] = array( $old_datas[$value->getId()] = $value->getValue();
'meta_struct_id' => $field->get_meta_struct_id(), if ($field->is_readonly() === false && $field->is_multi() === false)
'meta_id' => $field->get_meta_id(), {
'value' => array($field->get_value() . ' test') $toupdate[$value->getId()] = array(
); 'meta_struct_id' => $field->get_meta_struct_id(),
'meta_id' => $value->getId(),
'value' => array($value->getValue() . ' test')
);
}
} }
} }
$this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE'));
@@ -634,11 +637,13 @@ class ApiJsonApplication extends PhraseanetWebTestCaseAbstract
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
foreach($field->get_values() as $value)
if ($field->is_readonly() === false && $field->is_multi() === false)
{ {
$saved_value = $toupdate[$field->get_meta_id()]['value'][0]; if ($field->is_readonly() === false && $field->is_multi() === false)
$this->assertEquals($field->get_value(), $saved_value); {
$saved_value = $toupdate[$value->getId()]['value'][0];
$this->assertEquals($value->getValue(), $saved_value);
}
} }
} }
$this->evaluateRecordsMetadataResponse($content); $this->evaluateRecordsMetadataResponse($content);

View File

@@ -616,14 +616,17 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
*/ */
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
$old_datas[$field->get_meta_id()] = $field->get_value(); foreach($field->get_values() as $value)
if ($field->is_readonly() === false && $field->is_multi() === false)
{ {
$toupdate[$field->get_meta_id()] = array( $old_datas[$value->getId()] = $value->getValue();
'meta_struct_id' => $field->get_meta_struct_id(), if ($field->is_readonly() === false && $field->is_multi() === false)
'meta_id' => $field->get_meta_id(), {
'value' => array($field->get_value() . ' test') $toupdate[$value->getId()] = array(
); 'meta_struct_id' => $field->get_meta_struct_id(),
'meta_id' => $value->getId(),
'value' => array($value->getValue() . ' test')
);
}
} }
} }
$this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE')); $this->evaluateMethodNotAllowedRoute($route, array('GET', 'PUT', 'DELETE'));
@@ -641,11 +644,13 @@ class ApiYamlApplication extends PhraseanetWebTestCaseAbstract
foreach ($caption->get_fields() as $field) foreach ($caption->get_fields() as $field)
{ {
foreach($field->get_values() as $value)
if ($field->is_readonly() === false && $field->is_multi() === false)
{ {
$saved_value = $toupdate[$field->get_meta_id()]['value'][0]; if ($field->is_readonly() === false && $field->is_multi() === false)
$this->assertEquals($field->get_value(), $saved_value); {
$saved_value = $toupdate[$value->getId()]['value'][0];
$this->assertEquals($value->getValue(), $saved_value);
}
} }
} }
$this->evaluateRecordsMetadataResponse($content); $this->evaluateRecordsMetadataResponse($content);

View File

@@ -32,7 +32,8 @@ class ApplicationLightboxTest extends PhraseanetWebTestCaseAuthenticatedAbstract
public function tearDown() public function tearDown()
{ {
$this->feed->delete(); if($this->feed instanceof Feed_Adapter)
$this->feed->delete();
parent::tearDown(); parent::tearDown();
} }

View File

@@ -58,11 +58,6 @@ class oauthv2_application_test extends \PhraseanetWebTestCaseAuthenticatedAbstra
self::deleteInsertedRow(appbox::get_instance(), self::$appli); self::deleteInsertedRow(appbox::get_instance(), self::$appli);
} }
public function tearDown()
{
parent::tearDown();
}
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();

View File

@@ -24,11 +24,6 @@ class ApplicationRootTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
public function testRouteSlash() public function testRouteSlash()
{ {
$this->markTestIncomplete( $this->markTestIncomplete(

View File

@@ -24,11 +24,6 @@ class ApplicationSetupTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
public function testRouteSlash() public function testRouteSlash()
{ {
$this->markTestIncomplete( $this->markTestIncomplete(

View File

@@ -38,11 +38,6 @@ class ControllerFieldsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -28,11 +28,6 @@ class Module_Admin_Route_PublicationTest extends PhraseanetWebTestCaseAuthentica
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
public function createApplication() public function createApplication()
{ {
return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Admin.php'; return require __DIR__ . '/../../../../../Alchemy/Phrasea/Application/Admin.php';

View File

@@ -39,11 +39,6 @@ class ControllerSubdefsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -38,11 +38,6 @@ class ControllerUsersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -50,7 +50,8 @@ class BridgeApplication extends PhraseanetWebTestCaseAuthenticatedAbstract
public function tearDown() public function tearDown()
{ {
parent::tearDown(); parent::tearDown();
self::$api->delete(); if(self::$api instanceof Bridge_Api)
self::$api->delete();
if (self::$account instanceof Bridge_Account) if (self::$account instanceof Bridge_Account)
self::$account->delete(); self::$account->delete();
} }

View File

@@ -41,11 +41,6 @@ class ControllerEditTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -84,8 +84,9 @@ class ControllerFeedApp extends \PhraseanetWebTestCaseAuthenticatedAbstract
public function tearDown() public function tearDown()
{ {
if($this->feed instanceof Feed_Adapter)
$this->feed->delete();
parent::tearDown(); parent::tearDown();
$this->feed->delete();
} }
public function createApplication() public function createApplication()

View File

@@ -39,11 +39,6 @@ class ControllerMoveCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAb
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -39,11 +39,6 @@ class ControllerPrinterTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -39,11 +39,6 @@ class ControllerPushTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -38,11 +38,6 @@ class ControllerRootTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -40,9 +40,12 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
public function tearDown() public function tearDown()
{ {
self::$publisher->delete(); if(self::$publisher instanceof Feed_Publisher_Adapter)
self::$entry->delete(); self::$publisher->delete();
self::$feed->delete(); if(self::$entry instanceof Feed_Entry_Adapter)
self::$entry->delete();
if(self::$feed instanceof Feed_Adapter)
self::$feed->delete();
parent::tearDown(); parent::tearDown();
} }
@@ -473,7 +476,7 @@ class ControllerRssFeedTest extends \PhraseanetWebTestCaseAbstract
{ {
if ($p4field = $entry_item->get_record()->get_caption()->get_dc_field($field["dc_field"])) if ($p4field = $entry_item->get_record()->get_caption()->get_dc_field($field["dc_field"]))
{ {
$this->assertEquals($p4field->get_value(true, $field["separator"]), $node->nodeValue $this->assertEquals($p4field->get_serialized_values($field["separator"]), $node->nodeValue
, sprintf('Asserting good value for DC %s', $field["dc_field"])); , sprintf('Asserting good value for DC %s', $field["dc_field"]));
if (sizeof($field["media_field"]["attributes"]) > 0) if (sizeof($field["media_field"]["attributes"]) > 0)
{ {

View File

@@ -38,11 +38,6 @@ class ControllerInstallerTest extends \PhraseanetWebTestCaseAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -38,11 +38,6 @@ class ControllerUpgraderTest extends \PhraseanetWebTestCaseAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -39,11 +39,6 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -38,11 +38,6 @@ class ControllerPathFileTestTest extends \PhraseanetWebTestCaseAbstract
$this->client = $this->createClient(); $this->client = $this->createClient();
} }
public function tearDown()
{
parent::tearDown();
}
/** /**
* Default route test * Default route test
*/ */

View File

@@ -32,11 +32,6 @@ class ApplicationTest extends \PhraseanetPHPUnitAbstract
parent::setUp(); parent::setUp();
} }
public function tearDown()
{
parent::tearDown();
}
public function testGetConfigurationFilePath() public function testGetConfigurationFilePath()
{ {
$app = new Application(); $app = new Application();

View File

@@ -28,11 +28,6 @@ class ConfigurationTest extends \PhraseanetPHPUnitAbstract
parent::setUp(); parent::setUp();
} }
public function tearDown()
{
parent::tearDown();
}
public function testInitialization() public function testInitialization()
{ {
$spec = $this->getMock( $spec = $this->getMock(

View File

@@ -23,16 +23,6 @@ use Alchemy\Phrasea\Core\Configuration\Application;
class handlerTest extends \PhraseanetPHPUnitAbstract class handlerTest extends \PhraseanetPHPUnitAbstract
{ {
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testGetSpec() public function testGetSpec()
{ {
$spec = $this->getMock( $spec = $this->getMock(

View File

@@ -22,16 +22,6 @@ use Alchemy\Phrasea\Core\Configuration\Parser\Yaml;
*/ */
class parserTest extends \PhraseanetPHPUnitAbstract class parserTest extends \PhraseanetPHPUnitAbstract
{ {
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testParser() public function testParser()
{ {

View File

@@ -22,20 +22,6 @@ use Alchemy\Phrasea\Core\Version;
class VersionTest extends \PhraseanetPHPUnitAbstract class VersionTest extends \PhraseanetPHPUnitAbstract
{ {
/**
*
* @var \Alchemy\Phrasea\Core\Configuration\Application
*/
public function setUp()
{
parent::setUp();
}
public function tearDown()
{
parent::tearDown();
}
public function testGetNumber() public function testGetNumber()
{ {
$this->assertTrue(is_string(Version::getNumber())); $this->assertTrue(is_string(Version::getNumber()));

View File

@@ -24,7 +24,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testPropose_editing(). * @todo Implement testPropose_editing().
*/ */
public function testPropose_editing() public function testPropose_editing()
@@ -36,7 +36,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testHas_thesaurus(). * @todo Implement testHas_thesaurus().
*/ */
public function testHas_thesaurus() public function testHas_thesaurus()
@@ -48,7 +48,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_javascript_elements_ids(). * @todo Implement testGet_javascript_elements_ids().
*/ */
public function testGet_javascript_elements_ids() public function testGet_javascript_elements_ids()
@@ -60,7 +60,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_javascript_elements(). * @todo Implement testGet_javascript_elements().
*/ */
public function testGet_javascript_elements() public function testGet_javascript_elements()
@@ -72,7 +72,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_javascript_sugg_values(). * @todo Implement testGet_javascript_sugg_values().
*/ */
public function testGet_javascript_sugg_values() public function testGet_javascript_sugg_values()
@@ -84,7 +84,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_javascript_status(). * @todo Implement testGet_javascript_status().
*/ */
public function testGet_javascript_status() public function testGet_javascript_status()
@@ -96,7 +96,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_javascript_fields(). * @todo Implement testGet_javascript_fields().
*/ */
public function testGet_javascript_fields() public function testGet_javascript_fields()
@@ -108,7 +108,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_status(). * @todo Implement testGet_status().
*/ */
public function testGet_status() public function testGet_status()
@@ -120,7 +120,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_fields(). * @todo Implement testGet_fields().
*/ */
public function testGet_fields() public function testGet_fields()
@@ -132,7 +132,7 @@ class HelperEditTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testExecute(). * @todo Implement testExecute().
*/ */
public function testExecute() public function testExecute()

View File

@@ -24,7 +24,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testIs_basket(). * @todo Implement testIs_basket().
*/ */
public function testIs_basket() public function testIs_basket()
@@ -36,7 +36,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_original_basket(). * @todo Implement testGet_original_basket().
*/ */
public function testGet_original_basket() public function testGet_original_basket()
@@ -48,7 +48,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testIs_single_grouping(). * @todo Implement testIs_single_grouping().
*/ */
public function testIs_single_grouping() public function testIs_single_grouping()
@@ -60,7 +60,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_grouping_head(). * @todo Implement testGet_grouping_head().
*/ */
public function testGet_grouping_head() public function testGet_grouping_head()
@@ -72,7 +72,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_elements(). * @todo Implement testGet_elements().
*/ */
public function testGet_elements() public function testGet_elements()
@@ -84,7 +84,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testHas_many_sbas(). * @todo Implement testHas_many_sbas().
*/ */
public function testHas_many_sbas() public function testHas_many_sbas()
@@ -96,7 +96,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testIs_possible(). * @todo Implement testIs_possible().
*/ */
public function testIs_possible() public function testIs_possible()
@@ -108,7 +108,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_not_actionable(). * @todo Implement testGet_count_not_actionable().
*/ */
public function testGet_count_not_actionable() public function testGet_count_not_actionable()
@@ -120,7 +120,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_actionable(). * @todo Implement testGet_count_actionable().
*/ */
public function testGet_count_actionable() public function testGet_count_actionable()
@@ -132,7 +132,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_actionable_groupings(). * @todo Implement testGet_count_actionable_groupings().
*/ */
public function testGet_count_actionable_groupings() public function testGet_count_actionable_groupings()
@@ -144,7 +144,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_element_received(). * @todo Implement testGet_count_element_received().
*/ */
public function testGet_count_element_received() public function testGet_count_element_received()
@@ -156,7 +156,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_sbas_id(). * @todo Implement testGet_sbas_id().
*/ */
public function testGet_sbas_id() public function testGet_sbas_id()
@@ -168,7 +168,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_serialize_list(). * @todo Implement testGet_serialize_list().
*/ */
public function testGet_serialize_list() public function testGet_serialize_list()
@@ -180,7 +180,7 @@ class HelperHelperTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGrep_records(). * @todo Implement testGrep_records().
*/ */
public function testGrep_records() public function testGrep_records()

View File

@@ -24,7 +24,7 @@ class HelperMoveCollectionTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testAvailable_destination(). * @todo Implement testAvailable_destination().
*/ */
public function testAvailable_destination() public function testAvailable_destination()
@@ -36,7 +36,7 @@ class HelperMoveCollectionTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testPropose(). * @todo Implement testPropose().
*/ */
public function testPropose() public function testPropose()
@@ -48,7 +48,7 @@ class HelperMoveCollectionTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testExecute(). * @todo Implement testExecute().
*/ */
public function testExecute() public function testExecute()

View File

@@ -24,7 +24,7 @@ class HelperPrinterTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_preview(). * @todo Implement testGet_count_preview().
*/ */
public function testGet_count_preview() public function testGet_count_preview()
@@ -36,7 +36,7 @@ class HelperPrinterTest extends \PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_count_thumbnail(). * @todo Implement testGet_count_thumbnail().
*/ */
public function testGet_count_thumbnail() public function testGet_count_thumbnail()

View File

@@ -21,12 +21,11 @@ class HelperPushTest extends \PhraseanetPHPUnitAuthenticatedAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->object = new Push(self::$core, \Symfony\Component\HttpFoundation\Request::createFromGlobals());
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSearch(). * @todo Implement testSearch().
*/ */
public function testSearch() public function testSearch()

View File

@@ -3,9 +3,12 @@
require_once __DIR__ . '/../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../Bridge_datas.inc'; require_once __DIR__ . '/../../Bridge_datas.inc';
$new_include_path = realpath(__DIR__ . '/../../../../vendor/gdata/') . PATH_SEPARATOR . get_include_path(); $include_path = realpath(__DIR__ . '/../../../../vendor/gdata/');
set_include_path($new_include_path); if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
require_once('Zend/Loader.php'); require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_YouTube');

View File

@@ -3,9 +3,12 @@
require_once __DIR__ . '/../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc'; require_once __DIR__ . '/../../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
require_once __DIR__ . '/../../Bridge_datas.inc'; require_once __DIR__ . '/../../Bridge_datas.inc';
$new_include_path = realpath(__DIR__ . '/../../../../vendor/gdata/') . PATH_SEPARATOR . get_include_path(); $include_path = realpath(__DIR__ . '/../../../../vendor/gdata/');
set_include_path($new_include_path); if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
require_once('Zend/Loader.php'); require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata_YouTube'); Zend_Loader::loadClass('Zend_Gdata_YouTube');

View File

@@ -2,8 +2,12 @@
require_once __DIR__ . '/../../bootstrap.php'; require_once __DIR__ . '/../../bootstrap.php';
$new_include_path = realpath(__DIR__ . "/../../vendor/") . PATH_SEPARATOR . get_include_path(); $include_path = realpath(__DIR__ . '/../../vendor/');
set_include_path($new_include_path); if(strpos(get_include_path(), $include_path) === false)
{
$new_include_path = $include_path . PATH_SEPARATOR . get_include_path();
set_include_path($new_include_path);
}
require_once __DIR__ . "/../../vendor/Phlickr/Api.php"; require_once __DIR__ . "/../../vendor/Phlickr/Api.php";

View File

@@ -842,10 +842,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
unlink(Setup_Upgrade::get_lock_file()); unlink(Setup_Upgrade::get_lock_file());
} }
$upgrader = new Setup_Upgrade($appbox);
$appbox->forceUpgrade($upgrader);
unset($upgrader);
if (null !== self::$core) if (null !== self::$core)
{ {
/* @var $em \Doctrine\ORM\EntityManager */ /* @var $em \Doctrine\ORM\EntityManager */
@@ -866,6 +862,10 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$tool->createSchema($metas); $tool->createSchema($metas);
} }
$upgrader = new Setup_Upgrade($appbox);
$appbox->forceUpgrade($upgrader);
unset($upgrader);
self::$updated = true; self::$updated = true;
} }
@@ -898,12 +898,12 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
if (!$usr_alt1_id) if (!$usr_alt1_id)
{ {
$user = User_Adapter::create($appbox, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false); $user = User_Adapter::create($appbox, 'test_phpunit_alt1', random::generatePassword(), 'noonealt1@example.com', false);
$usr_id = $user->get_id(); $usr_alt1_id = $user->get_id();
} }
if (!$usr_alt2_id) if (!$usr_alt2_id)
{ {
$user = User_Adapter::create($appbox, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false); $user = User_Adapter::create($appbox, 'test_phpunit_alt2', random::generatePassword(), 'noonealt2@example.com', false);
$usr_id = $user->get_id(); $usr_alt2_id = $user->get_id();
} }
self::$user = User_Adapter::getInstance($usr_id, $appbox); self::$user = User_Adapter::getInstance($usr_id, $appbox);
@@ -1001,7 +1001,8 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
} }
if (!$collection_no_acces instanceof collection) if (!$collection_no_acces instanceof collection)
{ {
self::fail('Unable to find a second collection'); $collection_no_acces = collection::create($databox, $appbox, 'BIBOO', self::$user);
// self::fail('Unable to find a second collection');
} }
self::$collection = $coll; self::$collection = $coll;

View File

@@ -249,11 +249,15 @@ class API_V1_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$metadatas = array(); $metadatas = array();
foreach (self::$record_1->get_caption()->get_fields() as $field) foreach (self::$record_1->get_caption()->get_fields() as $field)
{ {
$metadatas[] = array( $values = $field->get_values();
'meta_id' => $field->get_meta_id() foreach($values as $value)
, 'meta_struct_id' => $field->get_meta_struct_id() {
, 'value' => $field->get_value() $metadatas[] = array(
); 'meta_id' => $value->getId()
, 'meta_struct_id' => $field->get_meta_struct_id()
, 'value' => $value->getValue()
);
}
} }
$metadatas = array_shift($metadatas); $metadatas = array_shift($metadatas);

View File

@@ -14,20 +14,20 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
*/ */
protected static $grouping; protected static $grouping;
protected static $need_records = true; protected static $need_records = true;
protected static $need_story = true; protected static $need_story = true;
protected static $need_subdefs = true; protected static $need_subdefs = true;
public static function setUpBeforeClass() public static function setUpBeforeClass()
{ {
parent::setUpBeforeClass(); parent::setUpBeforeClass();
$system_file = self::$record_1->get_hd_file(); $system_file = self::$record_1->get_hd_file();
$databox = self::$record_1->get_databox(); $databox = self::$record_1->get_databox();
$metadatas = $system_file->extract_metadatas($databox->get_meta_structure()); $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
static::$record_1->set_metadatas($metadatas['metadatas']); static::$record_1->set_metadatas($metadatas['metadatas']);
$databox = self::$record_23->get_databox(); $databox = self::$record_23->get_databox();
$system_file = self::$record_23->get_hd_file(); $system_file = self::$record_23->get_hd_file();
$metadatas = $system_file->extract_metadatas($databox->get_meta_structure()); $metadatas = $system_file->extract_metadatas($databox->get_meta_structure());
static::$record_23->set_metadatas($metadatas['metadatas']); static::$record_23->set_metadatas($metadatas['metadatas']);
$system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg'); $system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg');
@@ -38,7 +38,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
parent::tearDownAfterClass(); parent::tearDownAfterClass();
} }
public function testGet_creation_date() public function testGet_creation_date()
{ {
$date_obj = new DateTime(); $date_obj = new DateTime();
@@ -89,7 +88,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
catch (Exception $e) catch (Exception $e)
{ {
} }
$old_type = self::$record_1->get_type(); $old_type = self::$record_1->get_type();
self::$record_1->set_type('video'); self::$record_1->set_type('video');
@@ -137,7 +136,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -166,10 +165,9 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGenerate_subdefs() public function testGenerate_subdefs()
{ {
} }
public function testGet_sha256() public function testGet_sha256()
{ {
$this->assertNotNull(static::$record_1->get_sha256()); $this->assertNotNull(static::$record_1->get_sha256());
@@ -180,13 +178,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testGet_mime() public function testGet_mime()
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$found = $coll = false; $found = $coll = false;
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
foreach ($databox->get_collections() as $collection) foreach ($databox->get_collections() as $collection)
{ {
$found = true; $found = true;
$coll = $collection; $coll = $collection;
break; break;
} }
if ($found) if ($found)
@@ -234,7 +232,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -257,7 +255,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
foreach (self::$record_1->get_caption()->get_fields() as $field) foreach (self::$record_1->get_caption()->get_fields() as $field)
{ {
$tagname = $field->get_name(); $tagname = $field->get_name();
$this->assertEquals($field->get_value(true), (string) $sxe->description->$tagname); $this->assertEquals($field->get_serialized_values(), (string) $sxe->description->$tagname);
} }
} }
@@ -297,7 +295,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -307,19 +305,70 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$meta_structure_el = self::$collection->get_databox()->get_meta_structure()->get_elements(); $meta_structure_el = self::$collection->get_databox()->get_meta_structure()->get_elements();
$current_caption = self::$record_1->get_caption(); $current_caption = self::$record_1->get_caption();
$metadatas = array();
foreach ($meta_structure_el as $meta_el) foreach ($meta_structure_el as $meta_el)
{ {
$current_fields = $current_caption->get_fields(array($meta_el->get_name())); $current_fields = $current_caption->get_fields(array($meta_el->get_name()));
$meta_id = null;
$field = null;
if (count($current_fields) > 0) if (count($current_fields) > 0)
{ {
$meta_id = $current_fields[0]->get_meta_id(); $field = array_pop($current_fields);
}
if($meta_el->is_multi())
{
if($field)
{
foreach($field->get_values() as $value)
{
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $value->getId()
, 'value' => ''
);
}
}
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => null
, 'value' => 'un'
);
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => null
, 'value' => 'jeu'
);
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => null
, 'value' => 'de'
);
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => null
, 'value' => 'test'
);
}
else
{
$meta_id = null;
if($field)
{
$meta_id = array_pop($field->get_values())->getId();
}
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $meta_id
, 'value' => 'un jeu de test'
);
} }
$value = $meta_el->is_multi() ? array('un', 'jeu', 'de', 'test') : array('un jeu de test');
$metadatas[] = array('meta_struct_id' => $meta_el->get_id(), 'meta_id' => $meta_id, 'value' => $value);
} }
self::$record_1->set_metadatas($metadatas); self::$record_1->set_metadatas($metadatas);
@@ -339,23 +388,29 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
if ($meta_el->is_multi()) if ($meta_el->is_multi())
{ {
$this->assertEquals($multi_imploded, implode(' ' . $meta_el->get_separator() . ' ', $field->get_value(false))); $initial_values = array();
$this->assertEquals($multi_imploded, $field->get_value(true)); foreach($field->get_values() as $value)
{
$initial_values[] = $value->getValue();
}
$this->assertEquals($multi_imploded, implode(' ' . $meta_el->get_separator() . ' ', $initial_values));
$this->assertEquals($multi_imploded, $field->get_serialized_values());
} }
else else
$this->assertEquals('un jeu de test', $field->get_value()); $this->assertEquals('un jeu de test', $field->get_serialized_values());
} }
} }
public function testReindex() public function testReindex()
{ {
self::$record_1->reindex(); self::$record_1->reindex();
$sql = 'SELECT record_id FROM record $sql = 'SELECT record_id FROM record
WHERE (status & 7) IN (4,5,6) AND record_id = :record_id'; WHERE (status & 7) IN (4,5,6) AND record_id = :record_id';
$stmt = self::$record_1->get_databox()->get_connection()->prepare($sql); $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id())); $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
@@ -368,14 +423,14 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
self::$record_1->rebuild_subdefs(); self::$record_1->rebuild_subdefs();
$sql = 'SELECT record_id $sql = 'SELECT record_id
FROM record FROM record
WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0 WHERE jeton & ' . JETON_MAKE_SUBDEF . ' > 0
AND record_id = :record_id'; AND record_id = :record_id';
$stmt = self::$record_1->get_databox()->get_connection()->prepare($sql); $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id())); $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
@@ -387,13 +442,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
public function testWrite_metas() public function testWrite_metas()
{ {
self::$record_1->write_metas(); self::$record_1->write_metas();
$sql = 'SELECT record_id, coll_id, jeton $sql = 'SELECT record_id, coll_id, jeton
FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0) FROM record WHERE (jeton & ' . JETON_WRITE_META . ' > 0)
AND record_id = :record_id'; AND record_id = :record_id';
$stmt = self::$record_1->get_databox()->get_connection()->prepare($sql); $stmt = self::$record_1->get_databox()->get_connection()->prepare($sql);
$stmt->execute(array(':record_id' => self::$record_1->get_record_id())); $stmt->execute(array(':record_id' => self::$record_1->get_record_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$row) if (!$row)
@@ -409,7 +464,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -453,7 +508,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -461,7 +516,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
// Remove the following lines when you implement this test. // Remove the following lines when you implement this test.
$this->markTestIncomplete( $this->markTestIncomplete(
'This test has not been implemented yet.' 'This test has not been implemented yet.'
); );
} }
@@ -472,28 +527,28 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
{ {
$appbox = appbox::get_instance(); $appbox = appbox::get_instance();
$usr_id = $appbox->get_session()->get_usr_id(); $usr_id = $appbox->get_session()->get_usr_id();
$em = self::$core->getEntityManager(); $em = self::$core->getEntityManager();
$basket = $this->insertOneBasket(); $basket = $this->insertOneBasket();
$this->assertInstanceOf('\Entities\Basket', $basket); $this->assertInstanceOf('\Entities\Basket', $basket);
/* @var $basket \Entities\Basket */ /* @var $basket \Entities\Basket */
$basket_element = new \Entities\BasketElement(); $basket_element = new \Entities\BasketElement();
$basket_element->setRecord(self::$record_1); $basket_element->setRecord(self::$record_1);
$basket_element->setBasket($basket); $basket_element->setBasket($basket);
$em->persist($basket_element);
$basket->addBasketElement($basket_element);
$em->merge($basket);
$em->flush();
$found = $sselcont_id = false;
$sbas_id = self::$record_1->get_sbas_id(); $em->persist($basket_element);
$basket->addBasketElement($basket_element);
$em->merge($basket);
$em->flush();
$found = $sselcont_id = false;
$sbas_id = self::$record_1->get_sbas_id();
$record_id = self::$record_1->get_record_id(); $record_id = self::$record_1->get_record_id();
foreach (self::$record_1->get_container_baskets() as $c_basket) foreach (self::$record_1->get_container_baskets() as $c_basket)
@@ -512,7 +567,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
if (!$found) if (!$found)
$this->fail(); $this->fail();
} }
} }

View File

@@ -33,7 +33,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
*/ */
public function testSet_locale() public function testSet_locale()
{ {
@@ -43,7 +43,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_locale(). * @todo Implement testGet_locale().
*/ */
public function testGet_locale() public function testGet_locale()
@@ -54,7 +54,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_sort(). * @todo Implement testSet_sort().
*/ */
public function testSet_sort() public function testSet_sort()
@@ -70,7 +70,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_sortby(). * @todo Implement testGet_sortby().
*/ */
public function testGet_sortby() public function testGet_sortby()
@@ -83,7 +83,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_sortord(). * @todo Implement testGet_sortord().
*/ */
public function testGet_sortord() public function testGet_sortord()
@@ -96,7 +96,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_use_stemming(). * @todo Implement testSet_use_stemming().
*/ */
public function testSet_use_stemming() public function testSet_use_stemming()
@@ -110,7 +110,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_use_stemming(). * @todo Implement testGet_use_stemming().
*/ */
public function testGet_use_stemming() public function testGet_use_stemming()
@@ -124,7 +124,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_search_type(). * @todo Implement testSet_search_type().
*/ */
public function testSet_search_type() public function testSet_search_type()
@@ -141,7 +141,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_search_type(). * @todo Implement testGet_search_type().
*/ */
public function testGet_search_type() public function testGet_search_type()
@@ -158,7 +158,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_bases(). * @todo Implement testSet_bases().
*/ */
public function testSet_bases() public function testSet_bases()
@@ -169,7 +169,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_bases(). * @todo Implement testGet_bases().
*/ */
public function testGet_bases() public function testGet_bases()
@@ -180,7 +180,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_fields(). * @todo Implement testSet_fields().
*/ */
public function testSet_fields() public function testSet_fields()
@@ -192,7 +192,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_fields(). * @todo Implement testGet_fields().
*/ */
public function testGet_fields() public function testGet_fields()
@@ -204,7 +204,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_status(). * @todo Implement testSet_status().
*/ */
public function testSet_status() public function testSet_status()
@@ -216,7 +216,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_status(). * @todo Implement testGet_status().
*/ */
public function testGet_status() public function testGet_status()
@@ -228,7 +228,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_record_type(). * @todo Implement testSet_record_type().
*/ */
public function testSet_record_type() public function testSet_record_type()
@@ -240,7 +240,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_record_type(). * @todo Implement testGet_record_type().
*/ */
public function testGet_record_type() public function testGet_record_type()
@@ -252,7 +252,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_min_date(). * @todo Implement testSet_min_date().
*/ */
public function testSet_min_date() public function testSet_min_date()
@@ -264,7 +264,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_min_date(). * @todo Implement testGet_min_date().
*/ */
public function testGet_min_date() public function testGet_min_date()
@@ -276,7 +276,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_max_date(). * @todo Implement testSet_max_date().
*/ */
public function testSet_max_date() public function testSet_max_date()
@@ -288,7 +288,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_max_date(). * @todo Implement testGet_max_date().
*/ */
public function testGet_max_date() public function testGet_max_date()
@@ -300,7 +300,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSet_date_fields(). * @todo Implement testSet_date_fields().
*/ */
public function testSet_date_fields() public function testSet_date_fields()
@@ -312,7 +312,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testGet_date_fields(). * @todo Implement testGet_date_fields().
*/ */
public function testGet_date_fields() public function testGet_date_fields()
@@ -324,7 +324,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testSerialize(). * @todo Implement testSerialize().
*/ */
public function testSerialize() public function testSerialize()
@@ -344,7 +344,7 @@ class searchEngine_optionsTest extends PhraseanetPHPUnitAuthenticatedAbstract
} }
/** /**
* @covers {className}::{origMethodName} *
* @todo Implement testUnserialize(). * @todo Implement testUnserialize().
*/ */
public function testUnserialize() public function testUnserialize()

View File

@@ -190,14 +190,15 @@
<form id="export_form" method="post" target="exportwindow" action="/admin/users/search/export/"> <form id="export_form" method="post" target="exportwindow" action="/admin/users/search/export/">
<input name="srt" value="{{parm['srt']}}" type="hidden" /> <input name="srt" value="{{parm['srt']}}" type="hidden" />
<input name="ord" value="{{parm.ord}}" type="hidden" /> <input name="ord" value="{{parm.ord}}" type="hidden" />
<input name="act" value="{{parm.act}}" type="hidden" />
{% for sbas_id in parm.sbas_id %} {% for sbas_id in parm.sbas_id %}
<input name="sbas_id[]" value="{{sbas_id}}" type="hidden" /> <input name="sbas_id[]" value="{{sbas_id}}" type="hidden" />
{% endfor %} {% endfor %}
{% for base_id in parm.base_id %} {% for base_id in parm.base_id %}
<input name="base_id[]" value="{{base_id}}" type="hidden" /> <input name="base_id[]" value="{{base_id}}" type="hidden" />
{% endfor %} {% endfor %}
{% if parm['usr_ids'] is defined %}
<input name="usr_ids" value="{{parm.usr_ids}}" type="hidden" /> <input name="usr_ids" value="{{parm.usr_ids}}" type="hidden" />
{% endif %}
<input name="like_value" value="{{parm.like_value}}" type="hidden" /> <input name="like_value" value="{{parm.like_value}}" type="hidden" />
<input name="like_field" value="{{parm.like_field}}" type="hidden" /> <input name="like_field" value="{{parm.like_field}}" type="hidden" />
<input name="inactives" value="{{parm.inactives}}" type="hidden" /> <input name="inactives" value="{{parm.inactives}}" type="hidden" />

View File

@@ -66,7 +66,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class='required_field' type='text' name='{{name}}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : ''}}"/> <input class='required_field' type='text' name='{{name}}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_serialized_values(' ') : ''}}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>

View File

@@ -74,7 +74,7 @@
<label for='{{ name }}'>{% trans 'Tags' %}</label> <label for='{{ name }}'>{% trans 'Tags' %}</label>
</td> </td>
<td> <td>
<input class='required_field' type='text' style="width:150px;" name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : '' }}"/> <input class='required_field' type='text' style="width:150px;" name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_serialized_values(' ') : '' }}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>

View File

@@ -78,7 +78,7 @@
</div> </div>
</td> </td>
<td> <td>
<input class='required_field' type='text' name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_value(true, ' ') : ""}}"/> <input class='required_field' type='text' name='{{ name }}' value="{{ caption.get_dc_field('Subject') is not none ? caption.get_dc_field('Subject').get_serialized_values(' ') : ""}}"/>
<br /> <br />
{{ error_form.display_errors(name, constraint_errors) }} {{ error_form.display_errors(name, constraint_errors) }}
</td> </td>

View File

@@ -2,7 +2,7 @@
{# This file MUST NOT CONTAINS trans tag #} {# This file MUST NOT CONTAINS trans tag #}
{% extends '/setup/wrapper.twig' %} {% extends '/setup/wrapper.html.twig' %}
{% macro constraint_format(constraint) %} {% macro constraint_format(constraint) %}
{% if not constraint.is_ok() %} {% if not constraint.is_ok() %}

View File

@@ -1,4 +1,4 @@
{% extends '/setup/wrapper.twig' %} {% extends '/setup/wrapper.html.twig' %}
{% block extrahead %} {% block extrahead %}
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -1,4 +1,4 @@
{% extends '/setup/wrapper.twig' %} {% extends '/setup/wrapper.html.twig' %}
{% block extrahead %} {% block extrahead %}
<script type="text/javascript"> <script type="text/javascript">

View File

@@ -44,7 +44,7 @@ switch ($parm['action'])
$twig = $core->getTwig(); $twig = $core->getTwig();
$search_engine = null; $search_engine = null;
if (($options = unserialize($parm['options_serial'])) !== false) if ($parm['env'] == 'RESULT' && ($options = unserialize($parm['options_serial'])) !== false)
{ {
$search_engine = new searchEngine_adapter($registry); $search_engine = new searchEngine_adapter($registry);
$search_engine->set_options($options); $search_engine->set_options($options);