Merge branch 'BusinessFields' into Dev

This commit is contained in:
Romain Neutron
2012-03-26 14:21:16 +02:00
80 changed files with 6309 additions and 1564 deletions

View File

@@ -35,6 +35,7 @@ $finder
->name('.gitignore') ->name('.gitignore')
->name('check_cs.php') ->name('check_cs.php')
->name('cleaner.php') ->name('cleaner.php')
->name('lib/phpunit.xml.dist')
->name('launchpadToLocales.php') ->name('launchpadToLocales.php')
->name('localesToLaunchPad.php') ->name('localesToLaunchPad.php')
->name('pom.xml') ->name('pom.xml')

View File

@@ -68,6 +68,7 @@ class Description implements ControllerProviderInterface
$field->set_thumbtitle($request->get('thumbtitle_' . $id)); $field->set_thumbtitle($request->get('thumbtitle_' . $id));
$field->set_source($request->get('src_' . $id)); $field->set_source($request->get('src_' . $id));
$field->set_multi($request->get('multi_' . $id)); $field->set_multi($request->get('multi_' . $id));
$field->set_business($request->get('business_' . $id));
$field->set_indexable($request->get('indexable_' . $id)); $field->set_indexable($request->get('indexable_' . $id));
$field->set_required($request->get('required_' . $id)); $field->set_required($request->get('required_' . $id));
$field->set_separator($request->get('separator_' . $id)); $field->set_separator($request->get('separator_' . $id));

View File

@@ -47,7 +47,29 @@ class Query implements ControllerProviderInterface
$options = new \searchEngine_options(); $options = new \searchEngine_options();
$bas = is_array($request->get('bas')) ? $request->get('bas') : array();
$bas = is_array($request->get('bas')) ? $request->get('bas') : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($bas) === 0 || in_array($collection->get_base_id(), $bas))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$status = is_array($request->get('status')) ? $request->get('status') : array(); $status = is_array($request->get('status')) ? $request->get('status') : array();
$fields = is_array($request->get('fields')) ? $request->get('fields') : array(); $fields = is_array($request->get('fields')) ? $request->get('fields') : array();
@@ -100,7 +122,7 @@ class Query implements ControllerProviderInterface
{ {
if ($d2bottom < 4) if ($d2bottom < 4)
{ {
for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i++) for ($i = 1; ($i <= 4 && (($i <= $npages) === true)); $i ++ )
{ {
if ($i == $page) if ($i == $page)
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />'; $string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
@@ -117,7 +139,7 @@ class Query implements ControllerProviderInterface
$string .= "<a onclick='gotopage(1);return false;'>&lt;&lt;</a>"; $string .= "<a onclick='gotopage(1);return false;'>&lt;&lt;</a>";
else else
$start = 1; $start = 1;
for ($i = ($start); $i <= $npages; $i++) for ($i = ($start); $i <= $npages; $i ++ )
{ {
if ($i == $page) if ($i == $page)
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />'; $string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
@@ -130,7 +152,7 @@ class Query implements ControllerProviderInterface
{ {
$string .= "<a onclick='gotopage(1);return false;'>&lt;&lt;</a>"; $string .= "<a onclick='gotopage(1);return false;'>&lt;&lt;</a>";
for ($i = ($page - 2); $i <= ($page + 2); $i++) for ($i = ($page - 2); $i <= ($page + 2); $i ++ )
{ {
if ($i == $page) if ($i == $page)
$string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />'; $string .= '<input onkeypress="if(event.keyCode == 13 && !isNaN(parseInt(this.value)))gotopage(parseInt(this.value))" type="text" value="' . $i . '" size="' . (strlen((string) $i)) . '" />';
@@ -161,8 +183,6 @@ class Query implements ControllerProviderInterface
$explain .= '<br><div>' . $result->get_query_time() . ' s</div>dans index ' . $result->get_search_indexes(); $explain .= '<br><div>' . $result->get_query_time() . ' s</div>dans index ' . $result->get_search_indexes();
$explain .= "</div>"; $explain .= "</div>";
$infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '&quot;', $explain) . '">' . sprintf(_('reponses:: %d reponses'), $result->get_count_total_results()) . '</a> | ' . sprintf(_('reponses:: %s documents selectionnes'), '<span id="nbrecsel"></span>'); $infoResult = '<a href="#" class="infoDialog" infos="' . str_replace('"', '&quot;', $explain) . '">' . sprintf(_('reponses:: %d reponses'), $result->get_count_total_results()) . '</a> | ' . sprintf(_('reponses:: %s documents selectionnes'), '<span id="nbrecsel"></span>');
$json['infos'] = $infoResult; $json['infos'] = $infoResult;

View File

@@ -253,7 +253,7 @@ class Edit extends RecordHelper
$_lst[$indice]['originalname'] = $record->get_original_name(); $_lst[$indice]['originalname'] = $record->get_original_name();
foreach ($record->get_caption()->get_fields() as $field) foreach ($record->get_caption()->get_fields(null, true) as $field)
{ {
$meta_struct_id = $field->get_meta_struct_id(); $meta_struct_id = $field->get_meta_struct_id();
if (!isset($this->javascript_fields[$meta_struct_id])) if (!isset($this->javascript_fields[$meta_struct_id]))
@@ -538,7 +538,7 @@ class Edit extends RecordHelper
*/ */
if ($write_edit_el instanceof \databox_field) 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()), true);
$field = array_pop($fields); $field = array_pop($fields);
$meta_id = null; $meta_id = null;

View File

@@ -210,13 +210,13 @@ class API_V1_adapter extends API_V1_Abstract
$record = $this->appbox->get_databox($databox_id)->get_record($record_id); $record = $this->appbox->get_databox($databox_id)->get_record($record_id);
$fields = $record->get_caption()->get_fields(); $fields = $record->get_caption()->get_fields();
$ret = array(); $ret = array();
foreach ($fields as $field) foreach ($fields as $field)
{ {
$ret[$field->get_meta_struct_id()] = array( $ret[$field->get_meta_struct_id()] = array(
'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_serialized_values(";") , 'value' => $field->get_serialized_values(";")
); );
} }
$result->set_datas($ret); $result->set_datas($ret);
@@ -279,11 +279,35 @@ class API_V1_adapter extends API_V1_Abstract
$options = new searchEngine_options(); $options = new searchEngine_options();
$params['bases'] = is_array($params['bases']) ? $params['bases'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($params['bases']) === 0 || in_array($collection->get_base_id(), $params['bases']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($params['bases'], $user->ACL()); $options->set_bases($params['bases'], $user->ACL());
if (!is_array($params['fields']))
if ( ! is_array($params['fields']))
$params['fields'] = array(); $params['fields'] = array();
$options->set_fields($params['fields']); $options->set_fields($params['fields']);
if (!is_array($params['status'])) if ( ! is_array($params['status']))
$params['status'] = array(); $params['status'] = array();
$options->set_status($params['status']); $options->set_status($params['status']);
$options->set_search_type($params['search_type']); $options->set_search_type($params['search_type']);
@@ -458,14 +482,14 @@ class API_V1_adapter extends API_V1_Abstract
{ {
$metadatas = $request->get('metadatas'); $metadatas = $request->get('metadatas');
if (!is_array($metadatas)) if ( ! is_array($metadatas))
{ {
throw new Exception('Metadatas should be an array'); throw new Exception('Metadatas should be an array');
} }
foreach ($metadatas as $metadata) foreach ($metadatas as $metadata)
{ {
if (!is_array($metadata)) if ( ! is_array($metadata))
{ {
throw new Exception('Each Metadata value should be an array'); throw new Exception('Each Metadata value should be an array');
} }
@@ -495,15 +519,15 @@ class API_V1_adapter extends API_V1_Abstract
$datas = strrev($record->get_status()); $datas = strrev($record->get_status());
if (!is_array($status)) if ( ! is_array($status))
throw new API_V1_exception_badrequest(); throw new API_V1_exception_badrequest();
foreach ($status as $n => $value) foreach ($status as $n => $value)
{ {
if ($n > 63 || $n < 4) if ($n > 63 || $n < 4)
throw new API_V1_exception_badrequest(); throw new API_V1_exception_badrequest();
if (!in_array($value, array('0', '1'))) if ( ! in_array($value, array('0', '1')))
throw new API_V1_exception_badrequest(); throw new API_V1_exception_badrequest();
if (!isset($status_bits[$n])) if ( ! isset($status_bits[$n]))
throw new API_V1_exception_badrequest (); throw new API_V1_exception_badrequest ();
$datas = substr($datas, 0, ($n - 1)) . $value . substr($datas, ($n + 1)); $datas = substr($datas, 0, ($n - 1)) . $value . substr($datas, ($n + 1));
@@ -748,7 +772,7 @@ class API_V1_adapter extends API_V1_Abstract
'basket_element_id' => $basket_element->getId() 'basket_element_id' => $basket_element->getId()
, 'order' => $basket_element->getOrd() , 'order' => $basket_element->getOrd()
, 'record' => $this->list_record($basket_element->getRecord()) , 'record' => $this->list_record($basket_element->getRecord())
, 'validation_item' => !!$basket_element->getValidationDatas() , 'validation_item' => ! ! $basket_element->getValidationDatas()
); );
if ($basket_element->getValidationDatas()) if ($basket_element->getValidationDatas())
@@ -1094,7 +1118,7 @@ class API_V1_adapter extends API_V1_Abstract
$ret = array(); $ret = array();
foreach ($databox->get_statusbits() as $bit => $status_datas) foreach ($databox->get_statusbits() as $bit => $status_datas)
{ {
$ret[$bit] = array('bit' => $bit, 'state' => !!substr($status, ($bit - 1), 1)); $ret[$bit] = array('bit' => $bit, 'state' => ! ! substr($status, ($bit - 1), 1));
} }
return $ret; return $ret;
@@ -1132,7 +1156,6 @@ class API_V1_adapter extends API_V1_Abstract
* @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' => $value->getId() 'meta_id' => $value->getId()
, 'meta_structure_id' => $field->get_meta_struct_id() , 'meta_structure_id' => $field->get_meta_struct_id()
@@ -1156,7 +1179,7 @@ class API_V1_adapter extends API_V1_Abstract
, 'pusher_usr_id' => $basket->getPusherId() , 'pusher_usr_id' => $basket->getPusherId()
, 'ssel_id' => $basket->getId() , 'ssel_id' => $basket->getId()
, 'updated_on' => $basket->getUpdated()->format(DATE_ATOM) , 'updated_on' => $basket->getUpdated()->format(DATE_ATOM)
, 'unread' => !$basket->getIsRead() , 'unread' => ! $basket->getIsRead()
); );
if ($basket->getValidation()) if ($basket->getValidation())

View File

@@ -108,7 +108,7 @@ class cache_databox
$record = new \record_adapter($sbas_id, $row['value']); $record = new \record_adapter($sbas_id, $row['value']);
$record->get_caption()->delete_data_from_cache(); $record->get_caption()->delete_data_from_cache();
foreach ($record->get_caption()->get_fields() as $field) foreach ($record->get_caption()->get_fields(null, true) as $field)
{ {
$field->delete_data_from_cache(); $field->delete_data_from_cache();
} }

View File

@@ -97,7 +97,7 @@ class caption_Field_Value
/** /**
* Vocabulary Control has been deactivated * Vocabulary Control has been deactivated
*/ */
if (!$this->databox_field->getVocabularyControl()) if ( ! $this->databox_field->getVocabularyControl())
{ {
$this->removeVocabulary(); $this->removeVocabulary();
} }
@@ -111,7 +111,7 @@ class caption_Field_Value
/** /**
* Current Id is not available anymore * Current Id is not available anymore
*/ */
elseif (!$this->VocabularyType->validate($this->VocabularyId)) elseif ( ! $this->VocabularyType->validate($this->VocabularyId))
{ {
$this->removeVocabulary(); $this->removeVocabulary();
} }
@@ -301,21 +301,42 @@ class caption_Field_Value
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_rt = sphinxrt::get_instance($registry); $sphinx_rt = sphinxrt::get_instance($registry);
$sphinx_rt->replace_in_metas( $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() "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->databox_field->isBusiness() ? '1' : '0')
, $this->record->get_creation_date()
); );
$all_datas = array(); $all_datas = array();
foreach ($this->record->get_caption()->get_fields() as $field)
foreach ($this->record->get_caption()->get_fields(null, true) as $field)
{ {
if (!$field->is_indexable()) if ( ! $field->is_indexable())
{
continue; continue;
}
$all_datas[] = $field->get_serialized_values(); $all_datas[] = $field->get_serialized_values();
} }
$all_datas = implode(' ', $all_datas);
$all_datas = implode(' ', $all_datas);
$sphinx_rt->replace_in_documents( $sphinx_rt->replace_in_documents(
"docs_realtime" . $sbas_crc, //$this->id, "docs_realtime" . $sbas_crc, //$this->id,
@@ -335,6 +356,35 @@ class caption_Field_Value
{ {
$connbas = $databox_field->get_connection(); $connbas = $databox_field->get_connection();
/**
* Check consistency
*/
if ( ! $databox_field->is_multi())
{
try
{
$field = $record->get_caption()->get_field($databox_field->get_name());
$caption_field_value = array_pop($field->get_values());
/* @var $value \caption_Field_Value */
$caption_field_value->set_value($value);
if ( ! $vocabulary || ! $vocabularyId)
{
$caption_field_value->removeVocabulary();
}
else
{
$caption_field_value->setVocab($vocabulary, $vocabularyId);
}
return $caption_field_value;
}
catch (\Exception $e)
{
}
}
$sql_ins = 'INSERT INTO metadatas $sql_ins = 'INSERT INTO metadatas
(id, record_id, meta_struct_id, value, VocabularyType, VocabularyId) (id, record_id, meta_struct_id, value, VocabularyType, VocabularyId)
VALUES VALUES
@@ -375,7 +425,7 @@ class caption_Field_Value
$tbranch = $this->databox_field->get_tbranch(); $tbranch = $this->databox_field->get_tbranch();
if (!$tbranch || !$XPATH_thesaurus) if ( ! $tbranch || ! $XPATH_thesaurus)
{ {
return $value; return $value;
} }
@@ -445,7 +495,7 @@ class caption_Field_Value
} }
} }
} }
if (!$lngfound) if ( ! $lngfound)
{ {
list($term, $context) = $this->splitTermAndContext($fvalue); list($term, $context) = $this->splitTermAndContext($fvalue);
$term = str_replace(array("<em>", "</em>"), array("", ""), $term); $term = str_replace(array("<em>", "</em>"), array("", ""), $term);

View File

@@ -65,16 +65,17 @@ class caption_field
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
if (!$databox_field->is_multi() && count($rs) > 1)
{
/**
* TRIGG CORRECTION;
*/
}
foreach ($rs as $row) foreach ($rs as $row)
{ {
$this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']); $this->values[$row['id']] = new caption_Field_Value($databox_field, $record, $row['id']);
/**
* Inconsistent, should not happen
*/
if(!$databox_field->is_multi())
{
break;
}
} }
return $this; return $this;
@@ -337,6 +338,79 @@ class caption_field
return; return;
} }
protected static function merge_metadatas(databox_field $databox_field, record_adapter $record)
{
$sql = 'SELECT record_id, id, value FROM metadatas
WHERE meta_struct_id = :meta_struct_id
AND record_id = :record_id';
$params = array(
':meta_struct_id' => $databox_field->get_id(),
':record_id' => $record->get_record_id()
);
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
$values = $current_metadatas = array();
foreach ($rs as $row)
{
$current_metadatas[] = array(
'meta_id' => $row['id']
, 'meta_struct_id' => $databox_field->get_id()
, 'value' => ''
);
$values[] = $row['value'];
}
try
{
$record = $databox_field->get_databox()->get_record($record->get_record_id());
$record->set_metadatas($current_metadatas);
$record->set_metadatas(array(array(
'meta_id' => null
, 'meta_struct_id' => $databox_field->get_id()
, 'value' => implode(' ; ', $values)
)));
unset($record);
}
catch (Exception $e)
{
}
return;
}
public static function merge_all_metadatas(databox_field $databox_field)
{
$sql = 'SELECT distinct record_id FROM metadatas
WHERE meta_struct_id = :meta_struct_id ';
$params = array(
':meta_struct_id' => $databox_field->get_id()
);
$stmt = $databox_field->get_databox()->get_connection()->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
unset($stmt);
foreach ($rs as $row)
{
self::merge_metadatas($databox_field, $databox_field->get_databox()->get_record($row['record_id']));
}
return;
}
public static function delete_all_metadatas(databox_field $databox_field) public static function delete_all_metadatas(databox_field $databox_field)
{ {
$sql = 'SELECT count(id) as count_id FROM metadatas $sql = 'SELECT count(id) as count_id FROM metadatas

View File

@@ -38,6 +38,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
protected $dces_elements = array(); protected $dces_elements = array();
protected $databox; protected $databox;
const SERIALIZE_XML = 'xml';
const SERIALIZE_YAML = 'yaml';
/** /**
* *
* @param record_Interface $record * @param record_Interface $record
@@ -53,6 +56,94 @@ class caption_record implements caption_interface, cache_cacheableInterface
return $this; return $this;
} }
public function serialize($format, $includeBusinessFields = false)
{
switch ($format)
{
case self::SERIALIZE_XML:
return $this->serializeXML(!!$includeBusinessFields);
break;
case self::SERIALIZE_YAML:
return $this->serializeYAML(!!$includeBusinessFields);
break;
default:
throw new \Exception(sprintf('Unknown format %s', $format));
break;
}
}
protected function serializeYAML($includeBusinessFields)
{
$buffer = array();
foreach ($this->get_fields(array(), $includeBusinessFields) as $field)
{
$vi = $field->get_values();
if ($field->is_multi())
{
$buffer[$field->get_name()] = array();
foreach ($vi as $value)
{
$val = $value->getValue();
$buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val;
}
}
else
{
$value = array_pop($vi);
$val = $value->getValue();
$buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
}
}
$buffer = array('record' => array('description' => $buffer));
$dumper = new Symfony\Component\Yaml\Dumper();
return $dumper->dump($buffer, 3);
}
protected function serializeXML($includeBusinessFields)
{
$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;
$dom_doc->standalone = true;
$record = $dom_doc->createElement('record');
$record->setAttribute('record_id', $this->record->get_record_id());
$dom_doc->appendChild($record);
$description = $dom_doc->createElement('description');
$record->appendChild($description);
foreach ($this->get_fields(array(), $includeBusinessFields) as $field)
{
$values = $field->get_values();
foreach ($values as $value)
{
$elem = $dom_doc->createElement($field->get_name());
$elem->appendChild($dom_doc->createTextNode($value->getValue()));
$elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem);
}
}
$doc = $dom_doc->createElement('doc');
$tc_datas = $this->record->get_technical_infos();
foreach ($tc_datas as $key => $data)
{
$doc->setAttribute($key, $data);
}
$record->appendChild($doc);
return $dom_doc->saveXML();
}
protected function retrieve_fields() protected function retrieve_fields()
{ {
if (is_array($this->fields)) if (is_array($this->fields))
@@ -80,21 +171,14 @@ class caption_record implements caption_interface, cache_cacheableInterface
$rec_fields = array(); $rec_fields = array();
foreach ($fields as $row) foreach ($fields as $row)
{ {
try $databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_id']);
{ $metadata = new caption_field($databox_meta_struct, $this->record);
$databox_meta_struct = databox_field::get_instance($this->databox, $row['structure_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();
if ($dces_element instanceof databox_Field_DCESAbstract) if ($dces_element instanceof databox_Field_DCESAbstract)
{
$this->dces_elements[$dces_element->get_label()] = $databox_meta_struct->get_id();
}
}
catch (Exception $e)
{ {
$this->dces_elements[$dces_element->get_label()] = $databox_meta_struct->get_id();
} }
} }
$this->fields = $rec_fields; $this->fields = $rec_fields;
@@ -107,14 +191,21 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param array $grep_fields * @param array $grep_fields
* @return array * @return array
*/ */
public function get_fields(Array $grep_fields = null) public function get_fields(Array $grep_fields = null, $IncludeBusiness = false)
{ {
$fields = array(); $fields = array();
foreach ($this->retrieve_fields() as $meta_struct_id => $field) foreach ($this->retrieve_fields() as $meta_struct_id => $field)
{ {
if ($grep_fields && !in_array($field->get_name(), $grep_fields)) if ($grep_fields && !in_array($field->get_name(), $grep_fields))
{
continue; continue;
}
if($field->get_databox_field()->isBusiness() === true && !$IncludeBusiness)
{
continue;
}
$fields[] = $field; $fields[] = $field;
} }
@@ -130,10 +221,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/ */
public function get_field($fieldname) public function get_field($fieldname)
{ {
foreach ($this->retrieve_fields() as $meta_struct_id => $field) foreach ($this->get_fields() as $meta_struct_id => $field)
{ {
if ($field->get_name() == $fieldname) if ($field->get_name() == $fieldname)
return $field; return $field;
} }
@@ -147,7 +237,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
*/ */
public function get_dc_field($label) public function get_dc_field($label)
{ {
$fields = $this->retrieve_fields(); $fields = $this->get_fields();
if (isset($this->dces_elements[$label])) if (isset($this->dces_elements[$label]))
{ {
return $fields[$this->dces_elements[$label]]; return $fields[$this->dces_elements[$label]];
@@ -163,9 +253,9 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param searchEngine_adapter $searchEngine * @param searchEngine_adapter $searchEngine
* @return array * @return array
*/ */
public function get_highlight_fields($highlight = '', Array $grep_fields = null, searchEngine_adapter $searchEngine = null) public function get_highlight_fields($highlight = '', Array $grep_fields = null, searchEngine_adapter $searchEngine = null, $includeBusiness = false)
{ {
return $this->highlight_fields($highlight, $grep_fields, $searchEngine); return $this->highlight_fields($highlight, $grep_fields, $searchEngine, $includeBusiness);
} }
/** /**
@@ -175,11 +265,11 @@ class caption_record implements caption_interface, cache_cacheableInterface
* @param searchEngine_adapter $searchEngine * @param searchEngine_adapter $searchEngine
* @return array * @return array
*/ */
protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null) protected function highlight_fields($highlight, Array $grep_fields = null, searchEngine_adapter $searchEngine = null, $includeBusiness = false)
{ {
$fields = array(); $fields = array();
foreach ($this->retrieve_fields() as $meta_struct_id => $field) foreach ($this->get_fields(array(), $includeBusiness) as $meta_struct_id => $field)
{ {
if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields)) if (is_array($grep_fields) && !in_array($field->get_name(), $grep_fields))
continue; continue;
@@ -206,7 +296,7 @@ class caption_record implements caption_interface, cache_cacheableInterface
foreach ($fields as $key => $value) foreach ($fields as $key => $value)
{ {
if(!isset($fields[$key])) if (!isset($fields[$key]))
continue; continue;
//if(strpos($fields[$key]['value'], '<a ') === false) //if(strpos($fields[$key]['value'], '<a ') === false)

View File

@@ -98,7 +98,13 @@ class databox_field implements cache_cacheableInterface
*/ */
protected $thumbtitle; protected $thumbtitle;
protected $renamed = false; /**
*
* @var boolean
*/
protected $Business;
protected $renamed = false;
protected $metaToMerge = false;
/** /**
* *
@@ -157,7 +163,7 @@ class databox_field implements cache_cacheableInterface
$sql = "SELECT `thumbtitle`, `separator` $sql = "SELECT `thumbtitle`, `separator`
, `dces_element`, `tbranch`, `type`, `report`, `multi`, `required` , `dces_element`, `tbranch`, `type`, `report`, `multi`, `required`
, `readonly`, `indexable`, `name`, `src` , `readonly`, `indexable`, `name`, `src`, `business`
, `VocabularyControlType`, `RestrictToVocabularyControl` , `VocabularyControlType`, `RestrictToVocabularyControl`
FROM metadatas_structure WHERE id=:id"; FROM metadatas_structure WHERE id=:id";
@@ -173,6 +179,7 @@ class databox_field implements cache_cacheableInterface
$this->readonly = !!$row['readonly']; $this->readonly = !!$row['readonly'];
$this->required = !!$row['required']; $this->required = !!$row['required'];
$this->multi = !!$row['multi']; $this->multi = !!$row['multi'];
$this->Business = !!$row['business'];
$this->report = !!$row['report']; $this->report = !!$row['report'];
$this->type = $row['type'] ? : self::TYPE_STRING; $this->type = $row['type'] ? : self::TYPE_STRING;
$this->tbranch = $row['tbranch']; $this->tbranch = $row['tbranch'];
@@ -193,19 +200,8 @@ class databox_field implements cache_cacheableInterface
$this->dces_element = new $dc_class(); $this->dces_element = new $dc_class();
} }
if (!$this->multi) $this->separator = self::checkMultiSeparator($row['separator'], $this->multi);
{
$separator = "";
}
else
{
$separator = $row['separator'];
if (strpos($separator, ';') === false)
$separator .= ';';
}
$this->separator = $separator;
$this->thumbtitle = $row['thumbtitle']; $this->thumbtitle = $row['thumbtitle'];
return $this; return $this;
@@ -231,9 +227,18 @@ class databox_field implements cache_cacheableInterface
/** /**
* *
* @param databox $databox * @return boolean
*/
public function isBusiness()
{
return $this->Business;
}
/**
*
* @param \databox $databox
* @param int $id * @param int $id
* @return databox_field * @return \databox_field
*/ */
public static function get_instance(databox &$databox, $id) public static function get_instance(databox &$databox, $id)
{ {
@@ -327,6 +332,7 @@ class databox_field implements cache_cacheableInterface
`required` = :required, `required` = :required,
`separator` = :separator, `separator` = :separator,
`multi` = :multi, `multi` = :multi,
`business` = :business,
`report` = :report, `report` = :report,
`type` = :type, `type` = :type,
`tbranch` = :tbranch, `tbranch` = :tbranch,
@@ -343,6 +349,7 @@ class databox_field implements cache_cacheableInterface
':required' => $this->required ? '1' : '0', ':required' => $this->required ? '1' : '0',
':separator' => $this->separator, ':separator' => $this->separator,
':multi' => $this->multi ? '1' : '0', ':multi' => $this->multi ? '1' : '0',
':business' => $this->Business ? '1' : '0',
':report' => $this->report ? '1' : '0', ':report' => $this->report ? '1' : '0',
':type' => $this->type, ':type' => $this->type,
':tbranch' => $this->tbranch, ':tbranch' => $this->tbranch,
@@ -361,6 +368,12 @@ class databox_field implements cache_cacheableInterface
$this->renamed = false; $this->renamed = false;
} }
if ($this->metaToMerge)
{
caption_field::merge_all_metadatas($this);
$this->metaToMerge = false;
}
$dom_struct = $this->databox->get_dom_structure(); $dom_struct = $this->databox->get_dom_structure();
$xp_struct = $this->databox->get_xpath_structure(); $xp_struct = $this->databox->get_xpath_structure();
@@ -417,7 +430,14 @@ class databox_field implements cache_cacheableInterface
{ {
$previous_name = $this->name; $previous_name = $this->name;
$this->name = self::generateName($name); $name = self::generateName($name);
if($name === '')
{
throw new \Exception_InvalidArgument();
}
$this->name = $name;
if ($this->name !== $previous_name) if ($this->name !== $previous_name)
{ {
@@ -535,6 +555,18 @@ class databox_field implements cache_cacheableInterface
return $this; return $this;
} }
/**
*
* @param boolean $boolean
* @return databox_field
*/
public function set_business($boolean)
{
$this->Business = !!$boolean;
return $this;
}
/** /**
* *
* @param boolean $bool * @param boolean $bool
@@ -554,7 +586,16 @@ class databox_field implements cache_cacheableInterface
*/ */
public function set_multi($multi) public function set_multi($multi)
{ {
$this->multi = !!$multi; $multi = !!$multi;
if ($this->multi !== $multi && !$multi)
{
$this->metaToMerge = true;
}
$this->multi = $multi;
$this->set_separator(';');
return $this; return $this;
} }
@@ -602,14 +643,26 @@ class databox_field implements cache_cacheableInterface
*/ */
public function set_separator($separator) public function set_separator($separator)
{ {
if (strpos($separator, ';') === false) $this->separator = self::checkMultiSeparator($separator, $this->multi);
$separator .= ';';
$this->separator = $separator;
return $this; return $this;
} }
protected static function checkMultiSeparator($separator, $multi)
{
if (!$multi)
{
return '';
}
if (strpos($separator, ';') === false)
{
$separator .= ';';
}
return $separator;
}
/** /**
* *
* @param string $type * @param string $type
@@ -622,35 +675,6 @@ class databox_field implements cache_cacheableInterface
return $this; return $this;
} }
/**
*
* @param string $attr
* @return databox_field
*/
protected function set_reg_attr($attr)
{
try
{
$sql = 'UPDATE metadatas_structure SET reg' . $attr . ' = null';
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute();
$stmt->closeCursor();
$sql = 'UPDATE metadatas_structure SET reg' . $attr . '= 1 WHERE id= :id';
$stmt = $this->get_connection()->prepare($sql);
$stmt->execute(array(':id' => $this->id));
$stmt->closeCursor();
}
catch (Exception $e)
{
}
return $this;
}
/** /**
* *
* @return string * @return string
@@ -732,15 +756,6 @@ class databox_field implements cache_cacheableInterface
return $this->multi; return $this->multi;
} }
/**
*
* @return boolean
*/
public function is_distinct()
{
return true;
}
/** /**
* *
* @return boolean * @return boolean
@@ -811,14 +826,21 @@ class databox_field implements cache_cacheableInterface
$sql = "INSERT INTO metadatas_structure $sql = "INSERT INTO metadatas_structure
(`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`, (`id`, `name`, `src`, `readonly`, `indexable`, `type`, `tbranch`,
`thumbtitle`, `multi`, `thumbtitle`, `multi`, `business`,
`report`, `sorter`) `report`, `sorter`)
VALUES (null, :name, '', 0, 1, 'text', '', VALUES (null, :name, '', 0, 1, 'string', '',
null, 0, null, 0,
1, :sorter)"; 0, 1, :sorter)";
$name = self::generateName($name);
if($name === '')
{
throw new \Exception_InvalidArgument();
}
$stmt = $databox->get_connection()->prepare($sql); $stmt = $databox->get_connection()->prepare($sql);
$stmt->execute(array(':name' => self::generateName($name), ':sorter' => $sorter)); $stmt->execute(array(':name' => $name, ':sorter' => $sorter));
$id = $databox->get_connection()->lastInsertId(); $id = $databox->get_connection()->lastInsertId();
$stmt->closeCursor(); $stmt->closeCursor();

View File

@@ -83,7 +83,7 @@ class databox_fieldUnknown extends databox_field
} }
/** /**
* Return tru because the field is unknown * Return true because the field is unknown
* *
* @return boolean * @return boolean
*/ */

View File

@@ -44,7 +44,7 @@ class module_console_checkExtension extends Command
if (!extension_loaded('phrasea2')) if (!extension_loaded('phrasea2'))
printf("Missing Extension php-phrasea"); printf("Missing Extension php-phrasea");
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$usr_id = $input->getOption('usr_id'); $usr_id = $input->getOption('usr_id');

View File

@@ -49,8 +49,10 @@ class module_console_schedulerState extends Command
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox); $task_manager = new task_manager($appbox);
$state = $task_manager->get_scheduler_state(); $state = $task_manager->get_scheduler_state();
if ($state['schedstatus'] == 'started')
if ($state['status'] == 'started')
{ {
$output->writeln(sprintf( $output->writeln(sprintf(
'Scheduler is %s on pid %d' 'Scheduler is %s on pid %d'
@@ -60,7 +62,7 @@ class module_console_schedulerState extends Command
} }
else else
{ {
$output->writeln(sprintf('Scheduler is %s', $state['schedstatus'])); $output->writeln(sprintf('Scheduler is %s', $state['status']));
} }
return 0; return 0;

View File

@@ -139,7 +139,7 @@ class module_console_systemExport extends Command
$output->writeln("Export datas from selected base_ids"); $output->writeln("Export datas from selected base_ids");
} }
$appbox = \appbox::get_instance(); $appbox = \appbox::get_instance(\bootstrap::getCore());
$total = $errors = 0; $total = $errors = 0;
@@ -298,8 +298,9 @@ class module_console_systemExport extends Command
{ {
case 'xml': case 'xml':
$pathinfo = pathinfo($dest_file->getPathname()); $pathinfo = pathinfo($dest_file->getPathname());
$xml = $record->get_caption()->serialize(caption_record::SERIALIZE_XML);
$xml_file = dirname($outfile) . '/' . $pathinfo['filename'] . '.xml'; $xml_file = dirname($outfile) . '/' . $pathinfo['filename'] . '.xml';
file_put_contents($xml_file, $record->get_xml()); file_put_contents($xml_file, $xml);
break; break;
default: default:
break; break;

View File

@@ -75,14 +75,12 @@ class module_console_taskrun extends Command
return 1; return 1;
} }
require_once __DIR__ . '/../../../../lib/bootstrap.php';
$task_id = (int) $input->getArgument('task_id'); $task_id = (int) $input->getArgument('task_id');
if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id'))) if ($task_id <= 0 || strlen($task_id) !== strlen($input->getArgument('task_id')))
throw new \RuntimeException('Argument must be an Id.'); throw new \RuntimeException('Argument must be an Id.');
$appbox = appbox::get_instance(); $appbox = \appbox::get_instance(\bootstrap::getCore());
$task_manager = new task_manager($appbox); $task_manager = new task_manager($appbox);
$this->task = $task_manager->get_task($task_id); $this->task = $task_manager->get_task($task_id);

View File

@@ -500,8 +500,10 @@ class module_report
public function getOrder($k = false) public function getOrder($k = false)
{ {
if ($k === false) if ($k === false)
{
return $this->tab_order; return $this->tab_order;
}
return $this->tab_order[$k]; return $this->tab_order[$k];
} }
@@ -675,7 +677,7 @@ class module_report
'telechargement' => _('report:: telechargement'), 'telechargement' => _('report:: telechargement'),
'record_id' => _('report:: record id'), 'record_id' => _('report:: record id'),
'final' => _('report:: type d\'action'), 'final' => _('report:: type d\'action'),
'xml' => _('report:: sujet'), // 'xml' => _('report:: sujet'),
'file' => _('report:: fichier'), 'file' => _('report:: fichier'),
'mime' => _('report:: type'), 'mime' => _('report:: type'),
'size' => _('report:: taille'), 'size' => _('report:: taille'),
@@ -820,8 +822,10 @@ class module_report
public function buildReport($tab = false, $groupby = false, $on = false) public function buildReport($tab = false, $groupby = false, $on = false)
{ {
if (sizeof($this->report) > 0) if (sizeof($this->report) > 0)
{
return $this->report; return $this->report;
}
$conn = connection::getPDOConnection($this->sbas_id); $conn = connection::getPDOConnection($this->sbas_id);
$this->buildReq($groupby, $on); $this->buildReq($groupby, $on);
@@ -863,75 +867,23 @@ class module_report
} }
} }
/**
* @desc return the text between the node we are looking for
* @param string $unXml the XML string
* @param string $champ the node
* @return string
*/
public static function getChamp($unXml, $champ, $attribut = false)
{
$ret = "";
$sxe = simplexml_load_string($unXml);
if ($sxe)
{
if ($attribut)
{
foreach ($sxe->$champ->attributes() as $a => $b)
{
if ($a == $attribut)
{
$ret.= $b;
}
}
}
else
{
$z = $sxe->xpath('/description/' . $champ);
if (!$z)
$z = $sxe->xpath('/record/description/' . $champ);
if ($z && is_array($z))
{
$ret .= $z[0];
}
}
}
$ret = trim($ret);
if ($ret == "" || $ret == null)
$ret = "<i>" . _('report:: non-renseigne') . "</i>";
return $ret;
}
public static function getPreff($sbasid) public static function getPreff($sbasid)
{ {
$tab = array(); $tab = array();
$tab["struct"] = "";
$tab['champs'] = array();
$databox = databox::get_instance((int) $sbasid); $databox = databox::get_instance((int) $sbasid);
$tab['struct'] = $databox->get_structure();
$sxe = $databox->get_sxml_structure(); foreach ($databox->get_meta_structure() as $databox_field)
if ($sxe)
{ {
$z = $sxe->xpath('/record/description'); /* @var $databox_field \databox_field */
if ($z && is_array($z))
if ($databox_field->is_report())
{ {
foreach ($z[0] as $ki => $vi) $tab[] = $databox_field->get_name();
{
foreach ($vi->attributes() as $a => $b)
{
if ($a == "report" && $b == 1)
$tab['champs'][] = $ki;
}
}
} }
} }
return $tab['champs']; return $tab;
} }
public static function getHost($url) public static function getHost($url)

View File

@@ -29,22 +29,21 @@ class module_report_activity extends module_report
* @var array * @var array
*/ */
protected $cor_query = array( protected $cor_query = array(
'user' => 'log.user', 'user' => 'log.user',
'site' => 'log.site', 'site' => 'log.site',
'societe' => 'log.societe', 'societe' => 'log.societe',
'pays' => 'log.pays', 'pays' => 'log.pays',
'activite' => 'log.activite', 'activite' => 'log.activite',
'fonction' => 'log.fonction', 'fonction' => 'log.fonction',
'usrid' => 'log.usrid', 'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id', 'coll_id' => 'record.coll_id',
'xml' => 'record.xml', 'ddate' => "DATE_FORMAT(log.date, '%Y-%m-%d')",
'ddate' => "DATE_FORMAT(log.date, '%Y-%m-%d')", 'id' => 'log_docs.id',
'id' => 'log_docs.id', 'log_id' => 'log_docs.log_id',
'log_id' => 'log_docs.log_id', 'record_id' => 'log_docs.record_id',
'record_id' => 'log_docs.record_id', 'final' => 'log_docs.final',
'final' => 'log_docs.final', 'comment' => 'log_docs.comment',
'comment' => 'log_docs.comment', 'size' => 'subdef.size'
'size' => 'subdef.size'
); );
public function __construct($arg1, $arg2, $sbas_id, $collist) public function __construct($arg1, $arg2, $sbas_id, $collist)
@@ -101,17 +100,17 @@ class module_report_activity extends module_report
$this->result = array(); $this->result = array();
$this->title = _('report:: activite par heure'); $this->title = _('report:: activite par heure');
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$sql = " $sql = "
SELECT DATE_FORMAT( log.date, '%k' ) AS heures, SUM(1) AS nb SELECT DATE_FORMAT( log.date, '%k' ) AS heures, SUM(1) AS nb
@@ -124,7 +123,7 @@ class module_report_activity extends module_report
$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();
$res = $this->setDisplayForActivity($rs); $res = $this->setDisplayForActivity($rs);
@@ -133,7 +132,7 @@ class module_report_activity extends module_report
foreach ($rs as $row) foreach ($rs as $row)
{ {
$row['heures'] = (string) $row['heures']; $row['heures'] = (string) $row['heures'];
$res[$row['heures']] = round(($row['nb'] / 24), 2); $res[$row['heures']] = round(($row['nb'] / 24), 2);
if ($res[$row['heures']] < 1) if ($res[$row['heures']] < 1)
$res[$row['heures']] = number_format($res[$row['heures']], 2); $res[$row['heures']] = number_format($res[$row['heures']], 2);
@@ -151,7 +150,7 @@ class module_report_activity extends module_report
$this->report['legend'] = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, $this->report['legend'] = array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23); 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23);
return $this->report; return $this->report;
} }
@@ -164,18 +163,18 @@ class module_report_activity extends module_report
{ {
$result = array(); $result = array();
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$params = array(':main_value' => $value); $params = array(':main_value' => $value);
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$sql = " $sql = "
SELECT DATE_FORMAT(log_search.date,'%Y-%m-%d %H:%i:%S') as date , SELECT DATE_FORMAT(log_search.date,'%Y-%m-%d %H:%i:%S') as date ,
@@ -197,7 +196,7 @@ class module_report_activity extends module_report
$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();
$this->setChamp($rs); $this->setChamp($rs);
@@ -227,20 +226,20 @@ class module_report_activity extends module_report
$this->report['value'] = array(); $this->report['value'] = array();
$this->report['value2'] = array(); $this->report['value2'] = array();
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$i = 0; $i = 0;
($no_answer) ? $this->title = _('report:: questions sans reponses') : ($no_answer) ? $this->title = _('report:: questions sans reponses') :
$this->title = _('report:: questions les plus posees'); $this->title = _('report:: questions les plus posees');
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$sql = " $sql = "
SELECT TRIM(log_search.search) as search, SELECT TRIM(log_search.search) as search,
@@ -261,7 +260,7 @@ class module_report_activity extends module_report
$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();
$this->setChamp($rs); $this->setChamp($rs);
@@ -297,25 +296,25 @@ class module_report_activity extends module_report
public function getAllDownloadByUserBase($usr, $config = false) public function getAllDownloadByUserBase($usr, $config = false)
{ {
$result = array(); $result = array();
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$databox = \databox::get_instance($this->sbas_id);
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$user_filter = $filter->getUserIdFilter($usr); $user_filter = $filter->getUserIdFilter($usr);
$params = array_merge($params, $user_filter['params']); $params = array_merge($params, $user_filter['params']);
$sql = " $sql = "
SELECT record.xml as titre, SELECT log_docs.record_id,
log_docs.record_id,
log_docs.date, log_docs.final as objets log_docs.date, log_docs.final as objets
FROM (`log_docs` inner join log on log_docs.log_id = log.id FROM (`log_docs` inner join log on log_docs.log_id = log.id
inner join record on log_docs.record_id = record.record_id) inner join record on log_docs.record_id = record.record_id)
@@ -338,25 +337,27 @@ class module_report_activity extends module_report
$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();
$login = User_Adapter::getInstance($usr, appbox::get_instance(\bootstrap::getCore()))->get_display_name(); $login = User_Adapter::getInstance($usr, appbox::get_instance(\bootstrap::getCore()))->get_display_name();
$this->setChamp($rs); $this->setChamp($rs);
($config) ? $this->setConfigColumn($config) : ($config) ? $this->setConfigColumn($config) :
$this->initDefaultConfigColumn($this->champ); $this->initDefaultConfigColumn($this->champ);
$i = 0; $i = 0;
foreach ($rs as $row) foreach ($rs as $row)
{ {
$record = $databox->get_record($row['record_id']);
foreach ($this->champ as $key => $value) foreach ($this->champ as $key => $value)
{ {
if ($value == 'titre') $result[$i][$value] = $row[$value];
$result[$i][$value] = parent::getChamp($row[$value], 'Titre');
else
$result[$i][$value] = $row[$value];
} }
$result[$i]['titre'] = $record->get_title();
$i++; $i++;
} }
$this->title = sprintf(_('report:: Telechargement effectue par l\'utilisateur %s'), $login); $this->title = sprintf(_('report:: Telechargement effectue par l\'utilisateur %s'), $login);
@@ -376,20 +377,20 @@ class module_report_activity extends module_report
$registry = registry::get_instance(); $registry = registry::get_instance();
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$record_filter = $filter->getUserFilter(); $record_filter = $filter->getUserFilter();
if ($record_filter) if ($record_filter)
$params = array_merge($params, $record_filter['params']); $params = array_merge($params, $record_filter['params']);
$sql = " $sql = "
SELECT SELECT
@@ -413,14 +414,14 @@ class module_report_activity extends module_report
$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();
$this->setChamp($rs); $this->setChamp($rs);
$this->setDisplay($tab); $this->setDisplay($tab);
$save_date = ""; $save_date = "";
$total = array('tot_doc' => 0, 'tot_prev' => 0, 'tot_dl' => 0); $total = array('tot_doc' => 0, 'tot_prev' => 0, 'tot_dl' => 0);
$i = -1; $i = -1;
$last_date = null; $last_date = null;
@@ -431,10 +432,10 @@ class module_report_activity extends module_report
{ {
$i++; $i++;
$this->result[$i] = array( $this->result[$i] = array(
'ddate' => $date, 'ddate' => $date,
'document' => 0, 'document' => 0,
'preview' => 0, 'preview' => 0,
'total' => 0 'total' => 0
); );
$last_date = $date; $last_date = $date;
} }
@@ -486,17 +487,17 @@ class module_report_activity extends module_report
$on = "user"; $on = "user";
} }
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$this->req = " $this->req = "
@@ -521,10 +522,10 @@ class module_report_activity extends module_report
$stmt = $conn->prepare($this->req); $stmt = $conn->prepare($this->req);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$i = 0; $i = 0;
$total_connexion = 0; $total_connexion = 0;
//set title //set title
$this->title = _('report:: Detail des connexions'); $this->title = _('report:: Detail des connexions');
@@ -534,14 +535,14 @@ class module_report_activity extends module_report
$this->default_display = array($on, 'connexion'); $this->default_display = array($on, 'connexion');
//set configuration of column //set configuration of column
($tab) ? $this->setConfigColumn($tab) : ($tab) ? $this->setConfigColumn($tab) :
$this->initDefaultConfigColumn($this->default_display); $this->initDefaultConfigColumn($this->default_display);
//build result //build result
foreach ($rs as $row) foreach ($rs as $row)
{ {
foreach ($this->champ as $key => $value) foreach ($this->champ as $key => $value)
{ {
$this->result[$i][$value] = empty($row[$value]) ? $this->result[$i][$value] = empty($row[$value]) ?
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$value]; "<i>" . _('report:: non-renseigne') . "</i>" : $row[$value];
if ($value == 'connexion') if ($value == 'connexion')
$total_connexion += $row['connexion']; $total_connexion += $row['connexion'];
@@ -580,22 +581,22 @@ class module_report_activity extends module_report
{ {
empty($on) ? $on = "user" : ""; //by default always report on user empty($on) ? $on = "user" : ""; //by default always report on user
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
//set title //set title
$this->title = _('report:: Detail des telechargements'); $this->title = _('report:: Detail des telechargements');
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$record_filter = $filter->getRecordFilter(); $record_filter = $filter->getRecordFilter();
$params = array_merge($params, $record_filter['params']); $params = array_merge($params, $record_filter['params']);
$sql = " $sql = "
SELECT SELECT
@@ -618,16 +619,16 @@ class module_report_activity extends module_report
$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();
$save_user = ""; $save_user = "";
$i = -1; $i = -1;
$total = array( $total = array(
'nbdoc' => 0, 'nbdoc' => 0,
'poiddoc' => 0, 'poiddoc' => 0,
'nbprev' => 0, 'nbprev' => 0,
'poidprev' => 0 'poidprev' => 0
); );
$this->setChamp($rs); $this->setChamp($rs);
@@ -664,27 +665,27 @@ class module_report_activity extends module_report
//doc info //doc info
if ($row['final'] == 'document' && if ($row['final'] == 'document' &&
!is_null($user) && !is_null($row['usrid'])) !is_null($user) && !is_null($row['usrid']))
{ {
$this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0); $this->result[$i]['nbdoc'] = (!is_null($row['nb']) ? $row['nb'] : 0);
$this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0); $this->result[$i]['poiddoc'] = (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['user'] = empty($row[$on]) ? $this->result[$i]['user'] = empty($row[$on]) ?
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on]; "<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
$total['nbdoc'] += $this->result[$i]['nbdoc']; $total['nbdoc'] += $this->result[$i]['nbdoc'];
$total['poiddoc'] += (!is_null($row['poid']) ? $row['poid'] : 0); $total['poiddoc'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['usrid'] = $row['usrid']; $this->result[$i]['usrid'] = $row['usrid'];
} }
//preview info //preview info
if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') && if (($row['final'] == 'preview' || $row['final'] == 'thumbnail') &&
!is_null($user) && !is_null($user) &&
!is_null($row['usrid'])) !is_null($row['usrid']))
{ {
$this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0); $this->result[$i]['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
$this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0); $this->result[$i]['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['user'] = empty($row[$on]) ? $this->result[$i]['user'] = empty($row[$on]) ?
"<i>" . _('report:: non-renseigne') . "</i>" : $row[$on]; "<i>" . _('report:: non-renseigne') . "</i>" : $row[$on];
$total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0); $total['nbprev'] += (!is_null($row['nb']) ? $row['nb'] : 0);
$total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0); $total['poidprev'] += (!is_null($row['poid']) ? $row['poid'] : 0);
$this->result[$i]['usrid'] = $row['usrid']; $this->result[$i]['usrid'] = $row['usrid'];
@@ -702,10 +703,10 @@ class module_report_activity extends module_report
$this->result[$nb_row]['user'] = '<b>TOTAL</b>'; $this->result[$nb_row]['user'] = '<b>TOTAL</b>';
$this->result[$nb_row]['nbdoc'] = '<b>' . $total['nbdoc'] . '</b>'; $this->result[$nb_row]['nbdoc'] = '<b>' . $total['nbdoc'] . '</b>';
$this->result[$nb_row]['poiddoc'] = $this->result[$nb_row]['poiddoc'] =
'<b>' . p4string::format_octets($total['poiddoc']) . '</b>'; '<b>' . p4string::format_octets($total['poiddoc']) . '</b>';
$this->result[$nb_row]['nbprev'] = '<b>' . $total['nbprev'] . '</b>'; $this->result[$nb_row]['nbprev'] = '<b>' . $total['nbprev'] . '</b>';
$this->result[$nb_row]['poidprev'] = $this->result[$nb_row]['poidprev'] =
'<b>' . p4string::format_octets($total['poidprev']) . '</b>'; '<b>' . p4string::format_octets($total['poidprev']) . '</b>';
} }
$this->total = sizeof($this->result); $this->total = sizeof($this->result);
$this->calculatePages($rs); $this->calculatePages($rs);
@@ -717,21 +718,21 @@ class module_report_activity extends module_report
public function getPush($tab = false) public function getPush($tab = false)
{ {
$s = new module_report_sql($this); $s = new module_report_sql($this);
$filter = $s->getFilters(); $filter = $s->getFilters();
$conn = $s->getConnBas(); $conn = $s->getConnBas();
$push = array(); $push = array();
$params = array(); $params = array();
$date_filter = $filter->getDateFilter(); $date_filter = $filter->getDateFilter();
$params = array_merge($params, $date_filter['params']); $params = array_merge($params, $date_filter['params']);
$coll_filter = $filter->getCollectionFilter(); $coll_filter = $filter->getCollectionFilter();
$params = array_merge($params, $coll_filter['params']); $params = array_merge($params, $coll_filter['params']);
$site_filter = $filter->getGvSitFilter(); $site_filter = $filter->getGvSitFilter();
$params = array_merge($params, $site_filter['params']); $params = array_merge($params, $site_filter['params']);
$record_filter = $filter->getRecordFilter(); $record_filter = $filter->getRecordFilter();
$params = array_merge($params, $record_filter['params']); $params = array_merge($params, $record_filter['params']);
$sql = " $sql = "
@@ -749,7 +750,7 @@ class module_report_activity extends module_report
$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();
$this->setChamp($rs); $this->setChamp($rs);
@@ -802,9 +803,9 @@ class module_report_activity extends module_report
public static function topTenUser($dmin, $dmax, $sbas_id, $list_coll_id) public static function topTenUser($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$result = array(); $result = array();
$result['top_ten_doc'] = array(); $result['top_ten_doc'] = array();
$result['top_ten_prev'] = array(); $result['top_ten_prev'] = array();
$result['top_ten_poiddoc'] = array(); $result['top_ten_poiddoc'] = array();
@@ -813,10 +814,10 @@ class module_report_activity extends module_report
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$params = array_merge($params, $datefilter['params']); $params = array_merge($params, $datefilter['params']);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array_merge($params, $collfilter['params']); $params = array_merge($params, $collfilter['params']);
$sql = " $sql = "
SELECT log.usrid, user, final, sum(1) AS nb, sum(size) AS poid SELECT log.usrid, user, final, sum(1) AS nb, sum(size) AS poid
@@ -833,7 +834,7 @@ class module_report_activity extends module_report
$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();
$save_id = ""; $save_id = "";
@@ -848,38 +849,38 @@ class module_report_activity extends module_report
$id = $row['usrid']; $id = $row['usrid'];
if (!is_null($row['usrid']) if (!is_null($row['usrid'])
&& !is_null($row['user']) && !is_null($row['user'])
&& !is_null($row['final']) && !is_null($row['nb']) && !is_null($row['final']) && !is_null($row['nb'])
&& !is_null($row['poid'])) && !is_null($row['poid']))
{ {
if ($row['final'] == 'document') if ($row['final'] == 'document')
{ {
$result[$kttd][$id]['lib'] = $row['user']; $result[$kttd][$id]['lib'] = $row['user'];
$result[$kttd][$id]['id'] = $id; $result[$kttd][$id]['id'] = $id;
$result[$kttd][$id]['nb'] = !is_null($row['nb']) ? $result[$kttd][$id]['nb'] = !is_null($row['nb']) ?
(int) $row['nb'] : 0; (int) $row['nb'] : 0;
$result[$kttp][$id]['nb'] = !is_null($row['poid']) ? $result[$kttp][$id]['nb'] = !is_null($row['poid']) ?
(int) $row['poid'] : 0; (int) $row['poid'] : 0;
$result[$kttp][$id]['lib'] = $row['user']; $result[$kttp][$id]['lib'] = $row['user'];
$result[$kttp][$id]['id'] = $id; $result[$kttp][$id]['id'] = $id;
if (!isset($result[$kttd][$id]['nb'])) if (!isset($result[$kttd][$id]['nb']))
$result[$kttd][$id]['nb'] = 0; $result[$kttd][$id]['nb'] = 0;
} }
if ($row['final'] == 'preview') if ($row['final'] == 'preview')
{ {
$result[$kttpr][$id]['lib'] = $row['user']; $result[$kttpr][$id]['lib'] = $row['user'];
$result[$kttpr][$id]['id'] = $id; $result[$kttpr][$id]['id'] = $id;
if (!isset($result[$kttpr][$id]['nb'])) if (!isset($result[$kttpr][$id]['nb']))
$result[$kttpr][$id]['nb'] = 0; $result[$kttpr][$id]['nb'] = 0;
$result[$kttpr][$id]['nb'] = !is_null($row['nb']) ? $result[$kttpr][$id]['nb'] = !is_null($row['nb']) ?
(int) $row['nb'] : 0; (int) $row['nb'] : 0;
$result[$kttpp][$id]['nb'] = !is_null($row['poid']) ? $result[$kttpp][$id]['nb'] = !is_null($row['poid']) ?
(int) $row['poid'] : 0; (int) $row['poid'] : 0;
$result[$kttpp][$id]['lib'] = $row['user']; $result[$kttpp][$id]['lib'] = $row['user'];
$result[$kttpp][$id]['id'] = $id; $result[$kttpp][$id]['id'] = $id;
} }
} }
$save_id = $id; $save_id = $id;
} }
return $result; return $result;
@@ -887,16 +888,16 @@ class module_report_activity extends module_report
public static function activity($dmin, $dmax, $sbas_id, $list_coll_id) public static function activity($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$res = array(); $res = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
SELECT log_date.id, HOUR(log_date.date) as heures SELECT log_date.id, HOUR(log_date.date) as heures
@@ -905,14 +906,14 @@ class module_report_activity extends module_report
AND (" . $collfilter['sql'] . ") AND (" . $collfilter['sql'] . ")
AND log_date.site = :site_id"; AND log_date.site = :site_id";
$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);
$total = $stmt->rowCount(); $total = $stmt->rowCount();
$stmt->closeCursor(); $stmt->closeCursor();
for ($i = 0; $i < 24; $i++) for ($i = 0; $i < 24; $i++)
$res[$i] = 0; $res[$i] = 0;
foreach ($rs as $row) foreach ($rs as $row)
@@ -929,17 +930,17 @@ class module_report_activity extends module_report
public static function activityDay($dmin, $dmax, $sbas_id, $list_coll_id) public static function activityDay($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$result = array(); $result = array();
$res = array(); $res = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
SELECT DISTINCT ( SELECT DISTINCT (
@@ -954,12 +955,12 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$date = new DateTime($row['ddate']); $date = new DateTime($row['ddate']);
$result[$date->format(DATE_ATOM)] = $row['activity']; $result[$date->format(DATE_ATOM)] = $row['activity'];
} }
@@ -973,16 +974,16 @@ class module_report_activity extends module_report
public static function activityQuestion($dmin, $dmax, $sbas_id, $list_coll_id) public static function activityQuestion($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$result = array(); $result = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
SELECT log_date.usrid, log_date.user, sum(1) AS nb SELECT log_date.usrid, log_date.user, sum(1) AS nb
@@ -997,14 +998,14 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$result[$row['usrid']]['lib'] = $row['user']; $result[$row['usrid']]['lib'] = $row['user'];
$result[$row['usrid']]['nb'] = (int) $row['nb']; $result[$row['usrid']]['nb'] = (int) $row['nb'];
$result[$row['usrid']]['id'] = $row['usrid']; $result[$row['usrid']]['id'] = $row['usrid'];
} }
return $result; return $result;
@@ -1012,16 +1013,16 @@ class module_report_activity extends module_report
public static function activiteTopQuestion($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteTopQuestion($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$result = array(); $result = array();
$datefilter = $datefilter =
module_report_sqlfilter::constructDateFilter($dmin, $dmax); module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = $collfilter =
module_report_sqlfilter::constructCollectionFilter($list_coll_id); module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$sql = " $sql = "
SELECT SELECT
@@ -1040,17 +1041,17 @@ class module_report_activity extends module_report
$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();
$conv = array(" " => ""); $conv = array(" " => "");
foreach ($rs as $row) foreach ($rs as $row)
{ {
$question = $row['question']; $question = $row['question'];
$question = mb_strtolower(strtr($question, $conv)); $question = mb_strtolower(strtr($question, $conv));
$result[$question]['lib'] = $row['question']; $result[$question]['lib'] = $row['question'];
$result[$question]['nb'] = (int) $row['nb']; $result[$question]['nb'] = (int) $row['nb'];
$result[$question]['id'] = "false"; $result[$question]['id'] = "false";
} }
return $result; return $result;
@@ -1058,7 +1059,7 @@ class module_report_activity extends module_report
public static function activiteTopTenSiteView($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteTopTenSiteView($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
@@ -1078,20 +1079,20 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
($row['referrer'] != 'NO REFERRER') ? ($row['referrer'] != 'NO REFERRER') ?
$host = parent::getHost($row['referrer']) : $host = parent::getHost($row['referrer']) :
$host = 'NO REFERRER'; $host = 'NO REFERRER';
if (!isset($result[$host]['nb'])) if (!isset($result[$host]['nb']))
$result[$host]['nb'] = 0; $result[$host]['nb'] = 0;
if (!isset($result[$host]['lib'])) if (!isset($result[$host]['lib']))
$result[$host]['lib'] = $host; $result[$host]['lib'] = $host;
$result[$host]['nb']+= ( (int) $row['nb_view']); $result[$host]['nb']+= ( (int) $row['nb_view']);
$result[$host]['id'] = "false"; $result[$host]['id'] = "false";
} }
return $result; return $result;
@@ -1099,7 +1100,7 @@ class module_report_activity extends module_report
public static function activiteAddedDocument($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteAddedDocument($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
@@ -1121,11 +1122,11 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$date = new DateTime($row['ddate']); $date = new DateTime($row['ddate']);
$result[$date->format(DATE_ATOM)] = $row['activity']; $result[$date->format(DATE_ATOM)] = $row['activity'];
} }
@@ -1134,7 +1135,7 @@ class module_report_activity extends module_report
public static function activiteEditedDocument($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteEditedDocument($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
@@ -1156,12 +1157,12 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$date = phraseadate::getPrettyString(new DateTime($row['ddate'])); $date = phraseadate::getPrettyString(new DateTime($row['ddate']));
$result[$date] = $row['activity']; $result[$date] = $row['activity'];
} }
@@ -1170,7 +1171,7 @@ class module_report_activity extends module_report
public static function activiteAddedTopTenUser($dmin, $dmax, $sbas_id, $list_coll_id) public static function activiteAddedTopTenUser($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$result = array(); $result = array();
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
@@ -1189,14 +1190,14 @@ class module_report_activity extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$result[$row['usrid']]['lib'] = $row['user']; $result[$row['usrid']]['lib'] = $row['user'];
$result[$row['usrid']]['nb'] = $row['nb']; $result[$row['usrid']]['nb'] = $row['nb'];
$result[$row['usrid']]['id'] = $row['usrid']; $result[$row['usrid']]['id'] = $row['usrid'];
} }
return $result; return $result;

View File

@@ -109,7 +109,6 @@ class module_report_add extends module_report
protected function buildResult($rs) protected function buildResult($rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row) foreach ($rs as $row)
{ {
foreach ($this->champ as $key => $value) foreach ($this->champ as $key => $value)

View File

@@ -19,24 +19,23 @@ class module_report_download extends module_report
{ {
protected $cor_query = array( protected $cor_query = array(
'user' => 'log.user', 'user' => 'log.user',
'site' => 'log.site', 'site' => 'log.site',
'societe' => 'log.societe', 'societe' => 'log.societe',
'pays' => 'log.pays', 'pays' => 'log.pays',
'activite' => 'log.activite', 'activite' => 'log.activite',
'fonction' => 'log.fonction', 'fonction' => 'log.fonction',
'usrid' => 'log.usrid', 'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id', 'coll_id' => 'record.coll_id',
'xml' => 'record.xml', 'ddate' => "log_docs.date",
'ddate' => "log_docs.date", 'id' => 'log_docs.id',
'id' => 'log_docs.id', 'log_id' => 'log_docs.log_id',
'log_id' => 'log_docs.log_id', 'record_id' => 'log_docs.record_id',
'record_id' => 'log_docs.record_id', 'final' => 'log_docs.final',
'final' => 'log_docs.final', 'comment' => 'log_docs.comment',
'comment' => 'log_docs.comment', 'size' => 'subdef.size',
'size' => 'subdef.size', 'mime' => 'subdef.mime',
'mime' => 'subdef.mime', 'file' => 'subdef.file'
'file' => 'subdef.file'
); );
/** /**
@@ -61,7 +60,7 @@ class module_report_download extends module_report
protected function buildReq($groupby = false, $on = false) protected function buildReq($groupby = false, $on = false)
{ {
$sql = $this->sqlBuilder('download') $sql = $this->sqlBuilder('download')
->setOn($on)->setGroupBy($groupby)->buildSql(); ->setOn($on)->setGroupBy($groupby)->buildSql();
$this->req = $sql->getSql(); $this->req = $sql->getSql();
$this->params = $sql->getParams(); $this->params = $sql->getParams();
@@ -71,16 +70,16 @@ class module_report_download extends module_report
public function colFilter($field, $on = false) public function colFilter($field, $on = false)
{ {
$ret = array(); $ret = array();
$s = $this->sqlBuilder('download'); $s = $this->sqlBuilder('download');
$var = $s->sqlDistinctValByField($field); $var = $s->sqlDistinctValByField($field);
$sql = $var['sql']; $sql = $var['sql'];
$params = $var['params']; $params = $var['params'];
$registry = registry::get_instance(); $registry = registry::get_instance();
$stmt = $s->getConnBas()->prepare($sql); $stmt = $s->getConnBas()->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC); $rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
foreach ($rs as $row) foreach ($rs as $row)
@@ -96,7 +95,7 @@ class module_report_download extends module_report
$caption = p4string::format_octets($value); $caption = p4string::format_octets($value);
else else
$caption = $value; $caption = $value;
$ret[] = array('val' => $caption, 'value' => $value); $ret[] = array('val' => $caption, 'value' => $value);
} }
return $ret; return $ret;
@@ -110,34 +109,47 @@ class module_report_download extends module_report
*/ */
protected function buildResult($rs) protected function buildResult($rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id); $pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row) foreach ($rs as $row)
{ {
if ($this->enable_limit && ($i > $this->nb_record)) if ($this->enable_limit && ($i > $this->nb_record))
break; break;
foreach ($this->champ as $column) foreach ($this->champ as $column)
{ {
$this->formatResult($column, $row[$column], $pref, $i); $this->formatResult($column, $row[$column], $i);
}
if (array_key_exists('record_id', $row))
{
$record = new \record_adapter($this->sbas_id, $row['record_id']);
foreach ($pref as $field)
{
try
{
$this->result[$i][$field] = $record->get_caption()
->get_field($field)
->get_serialized_values();
}
catch (\Exception $e)
{
$this->result[$i][$field] = '';
}
}
} }
$i++; $i++;
} }
} }
private function formatResult($column, $value, $pref, $i) private function formatResult($column, $value, $i)
{ {
if ($value) if ($value)
{ {
if ($column == 'coll_id') if ($column == 'coll_id')
$this->result[$i][$column] = $this->formatCollId($value); $this->result[$i][$column] = $this->formatCollId($value);
elseif ($column == 'xml' && (sizeof($pref) > 0))
{
foreach ($pref as $field)
{
$this->result[$i][$field] = parent::getChamp($value, $field);
}
}
elseif ($column == 'ddate') elseif ($column == 'ddate')
$this->result[$i][$column] = $this->formatDateValue($value); $this->result[$i][$column] = $this->formatDateValue($value);
elseif ($column == 'size') elseif ($column == 'size')
@@ -161,11 +173,11 @@ class module_report_download extends module_report
private function formatDateValue($value) private function formatDateValue($value)
{ {
$datetime = new DateTime($value); $datetime = new DateTime($value);
$dateString = $datetime->format(DATE_ATOM); $dateString = $datetime->format(DATE_ATOM);
return $this->pretty_string ? return $this->pretty_string ?
phraseadate::getPrettyString($datetime) : $dateString; phraseadate::getPrettyString($datetime) : $dateString;
} }
private function formatCollId($value) private function formatCollId($value)
@@ -175,19 +187,19 @@ class module_report_download extends module_report
public static function getNbDl($dmin, $dmax, $sbas_id, $list_coll_id) public static function getNbDl($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $conn = connection::getPDOConnection($sbas_id);
$registry = registry::get_instance(); $registry = registry::get_instance();
$params = array(':site_id' => $registry->get('GV_sit')); $params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$finalfilter = $datefilter['sql'] . ' AND '; $finalfilter = $datefilter['sql'] . ' AND ';
$finalfilter .= $collfilter['sql'] . ' AND '; $finalfilter .= $collfilter['sql'] . ' AND ';
$finalfilter .= 'log.site = :site_id'; $finalfilter .= 'log.site = :site_id';
$sql = ' $sql = '
SELECT SUM(1) AS nb SELECT SUM(1) AS nb
FROM ( log FROM ( log
INNER JOIN log_docs as log_date ON log.id = log_date.log_id INNER JOIN log_docs as log_date ON log.id = log_date.log_id
@@ -204,7 +216,7 @@ class module_report_download extends module_report
'; ';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
return $row ? $row['nb'] : 0; return $row ? $row['nb'] : 0;
@@ -212,18 +224,20 @@ class module_report_download extends module_report
public static function getTopDl($dmin, $dmax, $sbas_id, $list_coll_id) public static function getTopDl($dmin, $dmax, $sbas_id, $list_coll_id)
{ {
$conn = connection::getPDOConnection($sbas_id); $databox = \databox::get_instance((int) $sbas_id);
$registry = registry::get_instance(); $conn = $databox->get_connection();
$params = array(':site_id' => $registry->get('GV_sit')); $registry = $databox->get_registry();
$params = array(':site_id' => $registry->get('GV_sit'));
$datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax); $datefilter = module_report_sqlfilter::constructDateFilter($dmin, $dmax);
$collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id); $collfilter = module_report_sqlfilter::constructCollectionFilter($list_coll_id);
$params = array_merge($params, $datefilter['params'], $collfilter['params']); $params = array_merge($params, $datefilter['params'], $collfilter['params']);
$finalfilter = ""; $finalfilter = "";
$array = array( $array = array(
'preview' => array(), 'preview' => array(),
'document' => array() 'document' => array()
); );
$finalfilter .= $datefilter['sql'] . ' AND '; $finalfilter .= $datefilter['sql'] . ' AND ';
@@ -232,7 +246,7 @@ class module_report_download extends module_report
$sql = ' $sql = '
SELECT record.record_id as id, SUM(1) AS nb, subdef.name, record.xml SELECT record.record_id as id, SUM(1) AS nb, subdef.name
FROM ( log FROM ( log
INNER JOIN log_docs as log_date ON log.id = log_date.log_id INNER JOIN log_docs as log_date ON log.id = log_date.log_id
INNER JOIN record ON log_date.record_id = record.record_id INNER JOIN record ON log_date.record_id = record.record_id
@@ -251,32 +265,34 @@ class module_report_download extends module_report
$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();
foreach ($rs as $row) foreach ($rs as $row)
{ {
$k = $row['id'] . '_' . $sbas_id; $record = $databox->get_record($row['id']);
$orig_name = parent::getChamp($row['xml'], 'doc', 'originalname');
$k = $row['id'] . '_' . $sbas_id;
$orig_name = $record->get_original_name();
if ($row['name'] == 'document') if ($row['name'] == 'document')
{ {
$array[$row['name']][$k]['nb'] = (int) $row['nb']; $array[$row['name']][$k]['nb'] = (int) $row['nb'];
$array[$row['name']][$k]['lib'] = $orig_name; $array[$row['name']][$k]['lib'] = $orig_name;
$array[$row['name']][$k]['sbasid'] = $sbas_id; $array[$row['name']][$k]['sbasid'] = $sbas_id;
$array[$row['name']][$k]['id'] = $row['id']; $array[$row['name']][$k]['id'] = $row['id'];
} }
elseif ($row['name'] == "preview") elseif ($row['name'] == "preview")
{ {
$array[$row['name']][$k]['nb'] = (int) $row['nb']; $array[$row['name']][$k]['nb'] = (int) $row['nb'];
$array[$row['name']][$k]['lib'] = $orig_name; $array[$row['name']][$k]['lib'] = $orig_name;
$array[$row['name']][$k]['sbasid'] = $sbas_id; $array[$row['name']][$k]['sbasid'] = $sbas_id;
$array[$row['name']][$k]['id'] = $row['id']; $array[$row['name']][$k]['id'] = $row['id'];
} }
} }
return $array; return $array;
} }
} }

View File

@@ -113,7 +113,6 @@ class module_report_edit extends module_report
protected function buildResult($rs) protected function buildResult($rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row) foreach ($rs as $row)
{ {

View File

@@ -35,7 +35,6 @@ class module_report_filter
'coll_id' => 'report:: collections', 'coll_id' => 'report:: collections',
'comment' => 'report:: commentaire', 'comment' => 'report:: commentaire',
'search' => 'report:: question', 'search' => 'report:: question',
'xml' => 'report:: description'
); );
public function __construct($current_filter, $correspondance) public function __construct($current_filter, $correspondance)

View File

@@ -33,7 +33,6 @@ class module_report_nav extends module_report
'fonction' => 'log.fonction', 'fonction' => 'log.fonction',
'usrid' => 'log.usrid', 'usrid' => 'log.usrid',
'coll_id' => 'record.coll_id', 'coll_id' => 'record.coll_id',
'xml' => 'record.xml',
'ddate' => "log.date", 'ddate' => "log.date",
'id' => 'log_docs.id', 'id' => 'log_docs.id',
'log_id' => 'log_docs.log_id', 'log_id' => 'log_docs.log_id',

View File

@@ -112,7 +112,6 @@ class module_report_push extends module_report
protected function buildResult($rs) protected function buildResult($rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row) foreach ($rs as $row)
{ {

View File

@@ -48,7 +48,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
log.fonction, log.fonction,
log.usrid, log.usrid,
record.coll_id, record.coll_id,
record.xml,
log_docs.date AS ddate, log_docs.date AS ddate,
log_docs.id, log_docs.id,
log_docs.log_id, log_docs.log_id,
@@ -89,7 +88,6 @@ class module_report_sqldownload extends module_report_sql implements module_repo
TRIM( ' . $field . ' ) AS ' . $name . ', TRIM( ' . $field . ' ) AS ' . $name . ',
SUM(1) AS telechargement, SUM(1) AS telechargement,
record.coll_id, record.coll_id,
record.xml,
log_docs.final, log_docs.final,
log_docs.comment, log_docs.comment,
subdef.size, subdef.size,

View File

@@ -112,7 +112,6 @@ class module_report_validate extends module_report
protected function buildResult($rs) protected function buildResult($rs)
{ {
$i = 0; $i = 0;
$pref = parent::getPreff($this->sbas_id);
foreach ($rs as $row) foreach ($rs as $row)
{ {

View File

@@ -69,8 +69,6 @@ interface record_Interface
public function get_caption(); public function get_caption();
public function get_xml();
public function get_original_name(); public function get_original_name();
public function get_title($highlight = false, searchEngine_adapter $searchEngine = null); public function get_title($highlight = false, searchEngine_adapter $searchEngine = null);

View File

@@ -765,61 +765,8 @@ class record_adapter implements record_Interface, cache_cacheableInterface
*/ */
public function get_caption() public function get_caption()
{ {
if (!$this->caption_record)
$this->caption_record = new caption_record($this, $this->get_databox()); return new caption_record($this, $this->get_databox());
return $this->caption_record;
}
/**
*
* @return string
*/
public function get_xml()
{
if (!$this->xml)
{
$dom_doc = new DOMDocument('1.0', 'UTF-8');
$dom_doc->formatOutput = true;
$dom_doc->standalone = true;
$record = $dom_doc->createElement('record');
$record->setAttribute('record_id', $this->get_record_id());
$dom_doc->appendChild($record);
$description = $dom_doc->createElement('description');
$record->appendChild($description);
$caption = $this->get_caption();
foreach ($caption->get_fields() as $field)
{
$values = $field->get_values();
foreach ($values as $value)
{
$elem = $dom_doc->createElement($field->get_name());
$elem->appendChild($dom_doc->createTextNode($value->getValue()));
$elem->setAttribute('meta_id', $value->getId());
$elem->setAttribute('meta_struct_id', $field->get_meta_struct_id());
$description->appendChild($elem);
}
}
$doc = $dom_doc->createElement('doc');
$tc_datas = $this->get_technical_infos();
foreach ($tc_datas as $key => $data)
{
$doc->setAttribute($key, $data);
}
$record->appendChild($doc);
$this->xml = $dom_doc->saveXML();
}
return $this->xml;
} }
/** /**
@@ -1274,7 +1221,7 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$this->caption_record = null; $this->caption_record = null;
$xml = new DOMDocument(); $xml = new DOMDocument();
$xml->loadXML($this->get_xml()); $xml->loadXML($this->get_caption()->serialize(\caption_record::SERIALIZE_XML));
$this->set_xml($xml); $this->set_xml($xml);
$this->reindex(); $this->reindex();
@@ -1383,7 +1330,6 @@ class record_adapter implements record_Interface, cache_cacheableInterface
return $this; return $this;
} }
/** /**
* *
* @param collection $collection * @param collection $collection
@@ -1591,9 +1537,12 @@ class record_adapter implements record_Interface, cache_cacheableInterface
public function get_hd_file() public function get_hd_file()
{ {
$hd = $this->get_subdef('document'); $hd = $this->get_subdef('document');
if ($hd->is_physically_present())
if ($hd->is_physically_present())
{
return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file()); return new system_file(p4string::addEndSlash($hd->get_path()) . $hd->get_file());
}
return null; return null;
} }
@@ -1626,8 +1575,10 @@ class record_adapter implements record_Interface, cache_cacheableInterface
$origcoll = phrasea::collFromBas($this->get_base_id()); $origcoll = phrasea::collFromBas($this->get_base_id());
$xml = $this->get_caption()->serialize(\caption_record::SERIALIZE_XML);
$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, $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);

View File

@@ -222,7 +222,7 @@ class record_exportElement extends record_adapter
} }
} }
$xml = $this->get_xml(); $xml = $this->get_caption()->serialize(caption_record::SERIALIZE_XML);
if ($xml) if ($xml)
{ {

View File

@@ -178,20 +178,20 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
$html = ''; $html = '';
$b = true; $b = true;
foreach ($proposals["BASES"] as $zbase) foreach ($proposals["BASES"] as $zbase)
{ {
if ((int) (count($proposals["BASES"]) > 1) && count($zbase["TERMS"]) > 0) if ((int) (count($proposals["BASES"]) > 1) && count($zbase["TERMS"]) > 0)
{ {
$style = $b ? 'style="margin-top:0px;"' : ''; $style = $b ? 'style="margin-top:0px;"' : '';
$b = false; $b = false;
$html .= "<h1 $style>" . sprintf(_('reponses::propositions pour la base %s'), $zbase["NAME"]) . "</h1>"; $html .= "<h1 $style>" . sprintf(_('reponses::propositions pour la base %s'), $zbase["NAME"]) . "</h1>";
} }
$t = true; $t = true;
foreach ($zbase["TERMS"] as $path => $props) foreach ($zbase["TERMS"] as $path => $props)
{ {
$style = $t ? 'style="margin-top:0px;"' : ''; $style = $t ? 'style="margin-top:0px;"' : '';
$t = false; $t = false;
$html .= "<h2 $style>" . sprintf(_('reponses::propositions pour le terme %s'), $props["TERM"]) . "</h2>"; $html .= "<h2 $style>" . sprintf(_('reponses::propositions pour le terme %s'), $props["TERM"]) . "</h2>";
$html .= $props["HTML"]; $html .= $props["HTML"];
} }
@@ -211,9 +211,9 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
$proposals = self::proposalsToHTML($this->qp['main']->proposals); $proposals = self::proposalsToHTML($this->qp['main']->proposals);
if (trim($proposals) !== '') if (trim($proposals) !== '')
{ return "<div style='height:0px; overflow:hidden'>" . $this->qp['main']->proposals["QRY"]
return "<div style='height:0px; overflow:hidden'>" . $this->qp['main']->proposals["QRY"] . "</div><div class='proposals'>" . $proposals . "</div>";
. "</div><div class='proposals'>" . $proposals . "</div>"; }
} }
return null; return null;
@@ -233,7 +233,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
assert($offset >= 0); assert($offset >= 0);
assert(is_int($perPage)); assert(is_int($perPage));
$page = floor($offset / $perPage)+1; $page = floor($offset / $perPage) + 1;
$this->current_page = $page; $this->current_page = $page;
$this->perPage = $perPage; $this->perPage = $perPage;
@@ -247,16 +247,16 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$query .= ' AND recordtype=' . $this->opt_record_type; $query .= ' AND recordtype=' . $this->opt_record_type;
} }
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$sql = 'SELECT query, query_time FROM cache WHERE session_id = :ses_id'; $sql = 'SELECT query, query_time FROM cache WHERE session_id = :ses_id';
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
$stmt->execute(array(':ses_id' => $session->get_ses_id())); $stmt->execute(array(':ses_id' => $session->get_ses_id()));
$row = $stmt->fetch(PDO::FETCH_ASSOC); $row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor(); $stmt->closeCursor();
$date_obj = new DateTime('-10 min'); $date_obj = new DateTime('-10 min');
$date_quest = new DateTime($row['query_time']); $date_quest = new DateTime($row['query_time']);
$reseted = $this->reseted; $reseted = $this->reseted;
@@ -283,12 +283,12 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$results = new set_result(); $results = new set_result();
$perPage = $this->get_per_page(); $perPage = $this->get_per_page();
$page = $this->get_current_page(); $page = $this->get_current_page();
$this->offset_start = $courcahnum = (($page - 1) * $perPage); $this->offset_start = $courcahnum = (($page - 1) * $perPage);
$res = phrasea_fetch_results( $res = phrasea_fetch_results(
$session->get_ses_id(), (int)(($page - 1) * $perPage) + 1, $perPage, false $session->get_ses_id(), (int) (($page - 1) * $perPage) + 1, $perPage, false
); );
$rs = array(); $rs = array();
@@ -302,9 +302,9 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$sbas_id = phrasea::sbasFromBas($data['base_id']); $sbas_id = phrasea::sbasFromBas($data['base_id']);
$record = new record_adapter( $record = new record_adapter(
$sbas_id, $sbas_id,
$data['record_id'], $data['record_id'],
$courcahnum $courcahnum
); );
$results->add_element($record); $results->add_element($record);
@@ -313,7 +313,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
} }
$courcahnum++; $courcahnum ++;
} }
return new searchEngine_results($results, $this); return new searchEngine_results($results, $this);
@@ -325,7 +325,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/ */
public function reset_cache() public function reset_cache()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
phrasea_clear_cache($session->get_ses_id()); phrasea_clear_cache($session->get_ses_id());
$this->reseted = true; $this->reseted = true;
@@ -357,7 +357,17 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/ */
public function get_suggestions(Session_Handler $session) public function get_suggestions(Session_Handler $session)
{ {
return array(); $props = array();
foreach($this->qp['main']->proposals['QUERIES'] as $prop)
{
$props[] = array(
'value' => $prop
, 'current' => false
, 'hits' => null
);
}
return $props;
} }
/** /**
@@ -375,19 +385,19 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/ */
protected function query() protected function query()
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$dateLog = date("Y-m-d H:i:s"); $dateLog = date("Y-m-d H:i:s");
$nbanswers = 0; $nbanswers = 0;
$sql = 'UPDATE cache SET query = :query, query_time = NOW() $sql = 'UPDATE cache SET query = :query, query_time = NOW()
WHERE session_id = :ses_id'; WHERE session_id = :ses_id';
$params = array( $params = array(
'query' => $this->get_parsed_query() 'query' => $this->get_parsed_query()
, ':ses_id' => $session->get_ses_id() , ':ses_id' => $session->get_ses_id()
); );
$stmt = $appbox->get_connection()->prepare($sql); $stmt = $appbox->get_connection()->prepare($sql);
@@ -398,9 +408,9 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
$sort = ''; $sort = '';
if($this->options->get_sortby()) if ($this->options->get_sortby())
{ {
switch($this->options->get_sortord()) switch ($this->options->get_sortord())
{ {
case searchEngine_options::SORT_MODE_ASC: case searchEngine_options::SORT_MODE_ASC:
$sort = '+'; $sort = '+';
@@ -415,16 +425,24 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
foreach ($this->queries as $sbas_id => $qry) foreach ($this->queries as $sbas_id => $qry)
{ {
$BF = array();
foreach ($this->options->get_business_fields() as $base_id)
{
$BF[] = phrasea::collFromBas($base_id);
}
$this->results[$sbas_id] = phrasea_query2( $this->results[$sbas_id] = phrasea_query2(
$session->get_ses_id() $session->get_ses_id()
, $sbas_id , $sbas_id
, $this->colls[$sbas_id] , $this->colls[$sbas_id]
, $this->arrayq[$sbas_id] , $this->arrayq[$sbas_id]
, $registry->get('GV_sit') , $registry->get('GV_sit')
, (string) $session->get_usr_id() , (string) $session->get_usr_id()
, false , false
, $this->opt_search_type == 1 ? PHRASEA_MULTIDOC_REGONLY : PHRASEA_MULTIDOC_DOCONLY , $this->opt_search_type == 1 ? PHRASEA_MULTIDOC_REGONLY : PHRASEA_MULTIDOC_DOCONLY
, $sort , $sort
, $BF
); );
$total_time += $this->results[$sbas_id]['time_all']; $total_time += $this->results[$sbas_id]['time_all'];
@@ -442,11 +460,11 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
(null, :log_id, :date, :query, :nbresults, :colls)"; (null, :log_id, :date, :query, :nbresults, :colls)";
$params = array( $params = array(
':log_id' => $logger->get_id() ':log_id' => $logger->get_id()
, ':date' => $dateLog , ':date' => $dateLog
, ':query' => $this->query , ':query' => $this->query
, ':nbresults' => $this->results[$sbas_id]["nbanswers"] , ':nbresults' => $this->results[$sbas_id]["nbanswers"]
, ':colls' => implode(',', $this->colls[$sbas_id]) , ':colls' => implode(',', $this->colls[$sbas_id])
); );
$stmt = $conn2->prepare($sql3); $stmt = $conn2->prepare($sql3);
@@ -472,8 +490,8 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
*/ */
protected function singleParse($sbas) protected function singleParse($sbas)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$this->qp[$sbas] = new searchEngine_adapter_phrasea_queryParser(Session_Handler::get_locale()); $this->qp[$sbas] = new searchEngine_adapter_phrasea_queryParser(Session_Handler::get_locale());
$this->qp[$sbas]->debug = false; $this->qp[$sbas]->debug = false;
if ($sbas == 'main') if ($sbas == 'main')
@@ -527,15 +545,15 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
$requestStat = 'xxxx'; $requestStat = 'xxxx';
for ($i = 4; ($i <= 64); $i++) for ($i = 4; ($i <= 64); $i ++ )
{ {
if (!isset($this->opt_status[$i])) if ( ! isset($this->opt_status[$i]))
{ {
$requestStat = 'x' . $requestStat; $requestStat = 'x' . $requestStat;
continue; continue;
} }
$set = false; $set = false;
$val = ''; $val = '';
if (isset($this->opt_status[$i][$sbas]) && $this->opt_status[$i][$sbas] == '0') if (isset($this->opt_status[$i][$sbas]) && $this->opt_status[$i][$sbas] == '0')
{ {
$set = true; $set = true;
@@ -544,9 +562,9 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
if (isset($this->opt_status[$i][$sbas]) && $this->opt_status[$i][$sbas] == '1') if (isset($this->opt_status[$i][$sbas]) && $this->opt_status[$i][$sbas] == '1')
{ {
if ($set) if ($set)
$val = 'x'; $val = 'x';
else else
$val = '1'; $val = '1';
} }
$requestStat = ( $val != '' ? $val : 'x' ) . $requestStat; $requestStat = ( $val != '' ? $val : 'x' ) . $requestStat;
} }
@@ -573,7 +591,7 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
foreach ($appbox->get_databoxes() as $databox) foreach ($appbox->get_databoxes() as $databox)
{ {
if (!isset($this->queries[$databox->get_sbas_id()])) if ( ! isset($this->queries[$databox->get_sbas_id()]))
continue; continue;
//$databox = databox::get_instance($sbas_id); //$databox = databox::get_instance($sbas_id);
@@ -620,20 +638,21 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
{ {
$ret = array(); $ret = array();
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$res = phrasea_fetch_results( $res = phrasea_fetch_results(
$session->get_ses_id(), ($record->get_number() + 1), 1, true, "[[em]]", "[[/em]]" $session->get_ses_id(), ($record->get_number() + 1), 1, true, "[[em]]", "[[/em]]"
); );
if (!isset($res['results']) || !is_array($res['results'])) if ( ! isset($res['results']) || ! is_array($res['results']))
return array(); return array();
$rs = $res['results']; $rs = $res['results'];
$res = array_shift($rs); $res = array_shift($rs);
if (! isset($res['xml'])) if ( ! isset($res['xml']))
{
return array(); return array();
}
$sxe = simplexml_load_string($res['xml']); $sxe = simplexml_load_string($res['xml']);
foreach ($fields as $name => $field) foreach ($fields as $name => $field)
@@ -641,12 +660,12 @@ class searchEngine_adapter_phrasea_engine extends searchEngine_adapter_abstract
if ($sxe->description->$name) if ($sxe->description->$name)
{ {
$val = array(); $val = array();
foreach($sxe->description->$name as $value) foreach ($sxe->description->$name as $value)
{ {
$val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value); $val[] = str_replace(array('[[em]]', '[[/em]]'), array('<em>', '</em>'), (string) $value);
} }
$separator = $field['separator'] ? $field['separator'][0] : ''; $separator = $field['separator'] ? $field['separator'][0] : '';
$val = implode(' '.$separator.' ', $val); $val = implode(' ' . $separator . ' ', $val);
} }
else else
{ {

View File

@@ -81,7 +81,7 @@ class searchEngine_adapter_phrasea_queryParser
* *
* @var array * @var array
*/ */
var $proposals = Array("QRY" => "", "BASES" => array()); var $proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
/** /**
* Current language for thesaurus * Current language for thesaurus
@@ -119,7 +119,7 @@ class searchEngine_adapter_phrasea_queryParser
} }
} }
$this->proposals = Array("QRY" => "", "BASES" => array()); $this->proposals = Array("QRY" => "", "BASES" => array(), "QUERIES" => array());
$this->phq = $this->mb_trim($phq, 'UTF-8'); $this->phq = $this->mb_trim($phq, 'UTF-8');
if ($this->phq != "") if ($this->phq != "")
@@ -663,6 +663,8 @@ class searchEngine_adapter_phrasea_queryParser
} }
} }
$this->proposals['QUERIES'][$syfound["w"]] = $syfound["w"];
$thtml = $syfound["v"]; $thtml = $syfound["v"];
$kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null"; $kjs = $syfound["k"] ? ("'" . p4string::MakeString($syfound["k"], "js") . "'") : "null";
$wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'"; $wjs = "'" . p4string::MakeString($syfound["w"], "js") . "'";

View File

@@ -85,10 +85,10 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
foreach ($options->get_bases() as $bas) foreach ($options->get_bases() as $bas)
{ {
$this->distinct_sbas[phrasea::sbasFromBas($bas)] = true; $this->distinct_sbas[phrasea::sbasFromBas($bas)] = true;
$key = phrasea::sbasFromBas($bas) . '_' . phrasea::collFromBas($bas); $key = phrasea::sbasFromBas($bas) . '_' . phrasea::collFromBas($bas);
$sbas_id = phrasea::sbasFromBas($bas); $sbas_id = phrasea::sbasFromBas($bas);
$sbas_ids[$sbas_id] = $sbas_id; $sbas_ids[$sbas_id] = $sbas_id;
$filters[] = crc32($key); $filters[] = crc32($key);
} }
if ($filters) if ($filters)
@@ -103,19 +103,46 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
foreach ($sbas_ids as $sbas_id) foreach ($sbas_ids as $sbas_id)
{ {
$databox = databox::get_instance($sbas_id); $databox = databox::get_instance($sbas_id);
$fields = $databox->get_meta_structure(); $fields = $databox->get_meta_structure();
foreach ($fields as $field) foreach ($fields as $field)
{ {
if (!in_array($field->get_id(), $options->get_fields())) if ( ! in_array($field->get_id(), $options->get_fields()))
continue; continue;
$key = $sbas_id . '_' . $field->get_id(); $key = $sbas_id . '_' . $field->get_id();
$filters[] = crc32($key); $filters[] = crc32($key);
$this->search_in_field = true; $this->search_in_field = true;
} }
} }
$crc_coll_business = array();
if ($options->get_business_fields())
{
$this->search_in_field = true;
foreach ($options->get_business_fields() as $base_id)
{
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_1');
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_0');
}
$non_business = array_diff($options->get_bases(), $options->get_business_fields());
foreach ($non_business as $base_id)
{
$crc_coll_business[] = crc32(phrasea::collFromBas($base_id) . '_0');
}
$this->sphinx->SetFilter('crc_coll_business', $crc_coll_business);
}
elseif ($this->search_in_field)
{
$this->sphinx->SetFilter('business', array(0));
}
if ($filters) if ($filters)
{ {
$this->sphinx->SetFilter('crc_struct_id', $filters); $this->sphinx->SetFilter('crc_struct_id', $filters);
@@ -126,14 +153,14 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
*/ */
foreach ($sbas_ids as $sbas_id) foreach ($sbas_ids as $sbas_id)
{ {
$databox = databox::get_instance($sbas_id); $databox = databox::get_instance($sbas_id);
$s_status = $databox->get_statusbits(); $s_status = $databox->get_statusbits();
$status_opts = $options->get_status(); $status_opts = $options->get_status();
foreach ($s_status as $n => $status) foreach ($s_status as $n => $status)
{ {
if (!array_key_exists($n, $status_opts)) if ( ! array_key_exists($n, $status_opts))
continue; continue;
if (!array_key_exists($sbas_id, $status_opts[$n])) if ( ! array_key_exists($sbas_id, $status_opts[$n]))
continue; continue;
$crc = crc32($sbas_id . '_' . $n); $crc = crc32($sbas_id . '_' . $n);
$this->sphinx->SetFilter('status', array($crc), ($status_opts[$n][$sbas_id] == '0')); $this->sphinx->SetFilter('status', array($crc), ($status_opts[$n][$sbas_id] == '0'));
@@ -228,7 +255,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
else else
{ {
$offset = 0; $offset = 0;
while (($pos = mb_strpos($this->query, '-', $offset)) !== false) while (($pos = mb_strpos($this->query, '-', $offset)) !== false)
{ {
$offset = $pos + 1; $offset = $pos + 1;
if ($pos === 0) if ($pos === 0)
@@ -262,7 +289,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
assert(is_int($offset)); assert(is_int($offset));
assert($offset >= 0); assert($offset >= 0);
assert(is_int($perPage)); assert(is_int($perPage));
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$page = ceil($offset / $perPage) + 1; $page = ceil($offset / $perPage) + 1;
@@ -284,7 +311,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$index_keys = array(); $index_keys = array();
foreach ($params as $sbas_id => $params) foreach ($params as $sbas_id => $params)
{ {
if (!array_key_exists($sbas_id, $this->distinct_sbas)) if ( ! array_key_exists($sbas_id, $this->distinct_sbas))
continue; continue;
$index_keys[] = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname']))); $index_keys[] = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $params['host'], $params['port'], $params['user'], $params['dbname'])));
} }
@@ -308,7 +335,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$found = true; $found = true;
} }
} }
if (!$found) if ( ! $found)
$index .= 'documents' . implode(', documents', $index_keys); $index .= 'documents' . implode(', documents', $index_keys);
$index .= ', docs_realtime' . implode(', docs_realtime', $index_keys); $index .= ', docs_realtime' . implode(', docs_realtime', $index_keys);
} }
@@ -329,7 +356,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$found = true; $found = true;
} }
} }
if (!$found) if ( ! $found)
$index = 'metadatas' . implode(',metadatas', $index_keys); $index = 'metadatas' . implode(',metadatas', $index_keys);
$index .= ', metas_realtime' . implode(', metas_realtime', $index_keys); $index .= ', metas_realtime' . implode(', metas_realtime', $index_keys);
} }
@@ -337,7 +364,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$this->current_index = $index; $this->current_index = $index;
$res = $this->sphinx->Query($this->query, $this->current_index); $res = $this->sphinx->Query($this->query, $this->current_index);
$results = new set_result(); $results = new set_result();
if ($res === false) if ($res === false)
@@ -370,10 +397,10 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
try try
{ {
$record = $record =
new record_adapter( new record_adapter(
$match['attrs']['sbas_id'] $match['attrs']['sbas_id']
, $match['attrs']['record_id'] , $match['attrs']['record_id']
, $courcahnum , $courcahnum
); );
$results->add_element($record); $results->add_element($record);
@@ -382,7 +409,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
{ {
} }
$courcahnum++; $courcahnum ++;
} }
} }
} }
@@ -400,7 +427,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$t = "__" . $keyword . "__"; $t = "__" . $keyword . "__";
$trigrams = ""; $trigrams = "";
for ($i = 0; $i < strlen($t) - 2; $i++) for ($i = 0; $i < strlen($t) - 2; $i ++ )
$trigrams .= substr($t, $i, 3) . " "; $trigrams .= substr($t, $i, 3) . " ";
return $trigrams; return $trigrams;
@@ -453,8 +480,8 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
{ {
$trigrams = $this->BuildTrigrams($word); $trigrams = $this->BuildTrigrams($word);
$query = "\"$trigrams\"/1"; $query = "\"$trigrams\"/1";
$len = strlen($word); $len = strlen($word);
$this->sphinx->ResetGroupBy(); $this->sphinx->ResetGroupBy();
$this->sphinx->ResetFilters(); $this->sphinx->ResetFilters();
@@ -471,7 +498,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$index_keys = array(); $index_keys = array();
foreach ($params as $sbas_id => $p) foreach ($params as $sbas_id => $p)
{ {
if (!array_key_exists($sbas_id, $this->distinct_sbas)) if ( ! array_key_exists($sbas_id, $this->distinct_sbas))
continue; continue;
$index_keys[] = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname']))); $index_keys[] = crc32(str_replace(array('.', '%'), '_', sprintf('%s_%s_%s_%s', $p['host'], $p['port'], $p['user'], $p['dbname'])));
} }
@@ -484,7 +511,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
return array(); return array();
} }
if (!$res || !isset($res["matches"])) if ( ! $res || ! isset($res["matches"]))
{ {
return array(); return array();
} }
@@ -508,12 +535,12 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
*/ */
public function get_suggestions(Session_Handler $session, $only_last_word = false) public function get_suggestions(Session_Handler $session, $only_last_word = false)
{ {
if (!$this->current_index) if ( ! $this->current_index)
$this->current_index = '*'; $this->current_index = '*';
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$supposed_qry = mb_strtolower($this->query); $supposed_qry = mb_strtolower($this->query);
$pieces = explode(" ", str_replace(array("all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-"), ' ', $supposed_qry)); $pieces = explode(" ", str_replace(array("all", "last", "et", "ou", "sauf", "and", "or", "except", "in", "dans", "'", '"', "(", ")", "_", "-"), ' ', $supposed_qry));
$clef = 'sph_sugg_' . crc32(serialize($this->options) . ' ' . $this->current_index . implode(' ', $pieces) . ' ' . ($only_last_word ? '1' : '0')); $clef = 'sph_sugg_' . crc32(serialize($this->options) . ' ' . $this->current_index . implode(' ', $pieces) . ' ' . ($only_last_word ? '1' : '0'));
@@ -540,7 +567,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$suggestions = array(); $suggestions = array();
$total_chaines = 0; $total_chaines = 0;
$propal_n = $this->get_total_results(); $propal_n = $this->get_total_results();
if (function_exists('enchant_broker_init')) if (function_exists('enchant_broker_init'))
{ {
@@ -561,9 +588,9 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$suggs = array_unique(array_merge($suggs, enchant_dict_suggest($d, $piece))); $suggs = array_unique(array_merge($suggs, enchant_dict_suggest($d, $piece)));
} }
$suggestions[$n] = array('original' => $piece, 'suggs' => $suggs); $suggestions[$n] = array('original' => $piece, 'suggs' => $suggs);
$n++; $n ++;
} }
enchant_broker_free_dict($d); enchant_broker_free_dict($d);
} }
@@ -576,8 +603,8 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
{ {
foreach ($this->get_sugg_trigrams($piece) as $tri_sugg) foreach ($this->get_sugg_trigrams($piece) as $tri_sugg)
{ {
$suggestions[$n] = array('original' => $piece, 'suggs' => array($tri_sugg)); $suggestions[$n] = array('original' => $piece, 'suggs' => array($tri_sugg));
$n++; $n ++;
} }
} }
} }
@@ -598,12 +625,18 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
} }
$tmp_qq[] = str_replace($suggestion['original'], $sugg, $supposed_qry); $tmp_qq[] = str_replace($suggestion['original'], $sugg, $supposed_qry);
} }
$q_todo = array_unique(array_merge($tmp_qq, array($supposed_qry))); $q_todo = array_unique(array_merge($tmp_qq, array($supposed_qry)));
$n++; $n ++;
} }
$propals = array(array('value' => $supposed_qry, 'current' => true, 'hits' => $this->get_total_results())); $propals = array(
array(
'value' => $supposed_qry
, 'current' => true
, 'hits' => $this->get_total_results()
)
);
foreach ($q_todo as $f) foreach ($q_todo as $f)
{ {
@@ -641,7 +674,12 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
if ($found > 0) if ($found > 0)
{ {
$propals[] = array('value' => $f, 'current' => false, 'hits' => $found, 'cache' => $cache); $propals[] = array(
'value' => $f
, 'current' => false
, 'hits' => $found
, 'cache' => $cache
);
} }
} }
@@ -689,8 +727,8 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
*/ */
public function build_excerpt($query, array $fields, record_adapter $record) public function build_excerpt($query, array $fields, record_adapter $record)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$selected_sbas_id = $record->get_sbas_id(); $selected_sbas_id = $record->get_sbas_id();
$index = ''; $index = '';
@@ -724,7 +762,7 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$found = true; $found = true;
} }
} }
if (!$found) if ( ! $found)
$index .= 'documents' . implode(', documents', $index_keys); $index .= 'documents' . implode(', documents', $index_keys);
} }
else else
@@ -744,18 +782,18 @@ class searchEngine_adapter_sphinx_engine extends searchEngine_adapter_abstract i
$found = true; $found = true;
} }
} }
if (!$found) if ( ! $found)
$index = 'metadatas' . implode(',metadatas', $index_keys); $index = 'metadatas' . implode(',metadatas', $index_keys);
} }
} }
$opts = array( $opts = array(
'before_match' => "<em>", 'before_match' => "<em>",
'after_match' => "</em>" 'after_match' => "</em>"
); );
$fields_to_send = array(); $fields_to_send = array();
foreach($fields as $k=>$f) foreach ($fields as $k => $f)
{ {
$fields_to_send[$k] = $f['value']; $fields_to_send[$k] = $f['value'];
} }

View File

@@ -17,22 +17,20 @@
*/ */
class searchEngine_options implements Serializable class searchEngine_options implements Serializable
{ {
const RECORD_RECORD = 0;
const RECORD_RECORD = 0;
const RECORD_GROUPING = 1; const RECORD_GROUPING = 1;
const TYPE_IMAGE = 'image';
const TYPE_IMAGE = 'image'; const TYPE_VIDEO = 'video';
const TYPE_VIDEO = 'video'; const TYPE_AUDIO = 'audio';
const TYPE_AUDIO = 'audio'; const TYPE_DOCUMENT = 'document';
const TYPE_DOCUMENT = 'document'; const TYPE_FLASH = 'flash';
const TYPE_FLASH = 'flash'; const TYPE_ALL = '';
const TYPE_ALL = ''; const SORT_RELEVANCE = 'relevance';
const SORT_RELEVANCE = 'relevance';
const SORT_CREATED_ON = 'created_on'; const SORT_CREATED_ON = 'created_on';
const SORT_RANDOM = 'random'; const SORT_RANDOM = 'random';
const SORT_MODE_ASC = 'asc';
const SORT_MODE_ASC = 'asc'; const SORT_MODE_DESC = 'desc';
const SORT_MODE_DESC = 'desc';
/** /**
* *
@@ -104,7 +102,8 @@ class searchEngine_options implements Serializable
* *
* @var string * @var string
*/ */
protected $sort_ord = self::SORT_MODE_DESC; protected $sort_ord = self::SORT_MODE_DESC;
protected $business_fields = array();
/** /**
* Constructor * Constructor
@@ -148,6 +147,18 @@ class searchEngine_options implements Serializable
return $this; return $this;
} }
public function set_business_fields(Array $base_ids)
{
$this->business_fields = $base_ids;
return $this;
}
public function get_business_fields()
{
return $this->business_fields;
}
/** /**
* *
* @return string * @return string
@@ -173,7 +184,7 @@ class searchEngine_options implements Serializable
*/ */
public function set_use_stemming($boolean) public function set_use_stemming($boolean)
{ {
$this->stemming = !!$boolean; $this->stemming = ! ! $boolean;
return $this; return $this;
} }
@@ -351,9 +362,9 @@ class searchEngine_options implements Serializable
*/ */
public function set_min_date($min_date) public function set_min_date($min_date)
{ {
if (!is_null($min_date) && trim($min_date) !== '') if ( ! is_null($min_date) && trim($min_date) !== '')
{ {
$this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date.' 00:00:00'); $this->date_min = DateTime::createFromFormat('d/m/Y H:i:s', $min_date . ' 00:00:00');
} }
return $this; return $this;
@@ -375,9 +386,9 @@ class searchEngine_options implements Serializable
*/ */
public function set_max_date($max_date) public function set_max_date($max_date)
{ {
if (!is_null($max_date) && trim($max_date) !== '') if ( ! is_null($max_date) && trim($max_date) !== '')
{ {
$this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date.' 23:59:59'); $this->date_max = DateTime::createFromFormat('d/m/Y H:i:s', $max_date . ' 23:59:59');
} }
return $this; return $this;
@@ -442,7 +453,7 @@ class searchEngine_options implements Serializable
foreach ($serialized as $key => $value) foreach ($serialized as $key => $value)
{ {
if(is_null($value)) if (is_null($value))
{ {
$value = null; $value = null;
} }
@@ -453,14 +464,13 @@ class searchEngine_options implements Serializable
elseif ($value instanceof stdClass) elseif ($value instanceof stdClass)
{ {
$tmpvalue = (array) $value; $tmpvalue = (array) $value;
$value = array(); $value = array();
foreach($tmpvalue as $k=>$data) foreach ($tmpvalue as $k => $data)
{ {
$k = ctype_digit($k) ? (int) $k : $k; $k = ctype_digit($k) ? (int) $k : $k;
$value[$k] = $data; $value[$k] = $data;
} }
} }
$this->$key = $value; $this->$key = $value;

View File

@@ -27,6 +27,7 @@ class set_export extends set_abstract
protected $display_ftp; protected $display_ftp;
protected $ftp_datas; protected $ftp_datas;
protected $list; protected $list;
protected $businessFieldsAccess;
/** /**
* *
@@ -186,17 +187,24 @@ class set_export extends set_abstract
$this->total_order = 0; $this->total_order = 0;
$this->total_ftp = 0; $this->total_ftp = 0;
$this->businessFieldsAccess = false;
foreach ($this->elements as $download_element) foreach ($this->elements as $download_element)
{ {
if($user->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord'))
{
$this->businessFieldsAccess = true;
}
foreach ($download_element->get_downloadable() as $name => $properties) foreach ($download_element->get_downloadable() as $name => $properties)
{ {
if (!isset($display_download[$name])) if (!isset($display_download[$name]))
{ {
$display_download[$name] = array( $display_download[$name] = array(
'size' => 0, 'size' => 0,
'total' => 0, 'total' => 0,
'available' => 0, 'available' => 0,
'refused' => array() 'refused' => array()
); );
} }
@@ -206,14 +214,13 @@ class set_export extends set_abstract
{ {
$display_download[$name]['available']++; $display_download[$name]['available']++;
$display_download[$name]['label'] = $properties['label']; $display_download[$name]['label'] = $properties['label'];
$display_download[$name]['class'] = $properties['class'];
$this->total_download++; $this->total_download++;
$display_download[$name]['size'] += $display_download[$name]['size'] += $download_element->get_size($name);
$download_element->get_size($name);
} }
else else
{ {
$display_download[$name]['refused'][] = $display_download[$name]['refused'][] = $download_element->get_thumbnail();
$download_element->get_thumbnail();
} }
} }
foreach ($download_element->get_orderable() as $name => $properties) foreach ($download_element->get_orderable() as $name => $properties)
@@ -236,8 +243,7 @@ class set_export extends set_abstract
} }
else else
{ {
$display_orderable[$name]['refused'][] = $display_orderable[$name]['refused'][] = $download_element->get_thumbnail();
$download_element->get_thumbnail();
} }
} }
} }
@@ -357,6 +363,10 @@ class set_export extends set_abstract
{ {
return $this->ftp_datas; return $this->ftp_datas;
} }
public function has_business_fields_access()
{
return $this->businessFieldsAccess;
}
/** /**
* *
@@ -418,12 +428,15 @@ class set_export extends set_abstract
* @param boolean $rename_title * @param boolean $rename_title
* @return Array * @return Array
*/ */
public function prepare_export(Array $subdefs, $rename_title = false) public function prepare_export(Array $subdefs, $rename_title, $includeBusinessFields )
{ {
if (!is_array($subdefs)) if (!is_array($subdefs))
{ {
throw new Exception('No subdefs given'); throw new Exception('No subdefs given');
} }
$includeBusinessFields = !!$includeBusinessFields;
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
@@ -451,11 +464,16 @@ class set_export extends set_abstract
'subdefs' => array() 'subdefs' => array()
); );
$sbas_id = phrasea::sbasFromBas($download_element->get_base_id());
$rename_done = false; $rename_done = false;
$desc = $download_element->get_xml(); $BF = false;
if($includeBusinessFields && $user->ACL()->has_right_on_base($download_element->get_base_id(), 'canmodifrecord'))
{
$BF = true;
}
$desc = $download_element->get_caption()->serialize(caption_record::SERIALIZE_XML, $BF);
$files[$id]['original_name'] = $files[$id]['original_name'] =
$files[$id]['export_name'] = $files[$id]['export_name'] =
@@ -689,10 +707,7 @@ class set_export extends set_abstract
system_file::mkdir($caption_dir); system_file::mkdir($caption_dir);
$desc = self::get_caption( $desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_XML, $BF);
$download_element->get_base_id()
, $download_element->get_record_id()
);
$file = $files[$id]["export_name"] $file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption']["ajout"] . '.' . $files[$id]["subdefs"]['caption']["ajout"] . '.'
@@ -700,14 +715,12 @@ class set_export extends set_abstract
$path = $caption_dir; $path = $caption_dir;
if ($handle = fopen($path . $file, "w")) file_put_contents($path . $file, $desc);
{
fwrite($handle, $desc); $files[$id]["subdefs"]['caption']["path"] = $path;
fclose($handle); $files[$id]["subdefs"]['caption']["file"] = $file;
$files[$id]["subdefs"]['caption']["path"] = $path; $files[$id]["subdefs"]['caption']["size"] = filesize($path . $file);
$files[$id]["subdefs"]['caption']["file"] = $file; $files[$id]["subdefs"]['caption']['businessfields'] = $BF ? '1' : '0';
$files[$id]["subdefs"]['caption']["size"] = filesize($path . $file);
}
} }
if (in_array('caption-yaml', $subdefs)) if (in_array('caption-yaml', $subdefs))
{ {
@@ -716,14 +729,7 @@ class set_export extends set_abstract
. $session->get_ses_id() . '/'; . $session->get_ses_id() . '/';
system_file::mkdir($caption_dir); system_file::mkdir($caption_dir);
$desc = $download_element->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $BF);
$desc = self::get_caption(
$download_element->get_base_id()
, $download_element->get_record_id()
, true
, 'yaml'
);
$file = $files[$id]["export_name"] $file = $files[$id]["export_name"]
. $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.' . $files[$id]["subdefs"]['caption-yaml']["ajout"] . '.'
@@ -731,14 +737,12 @@ class set_export extends set_abstract
$path = $caption_dir; $path = $caption_dir;
if ($handle = fopen($path . $file, "w")) file_put_contents($path . $file, $desc);
{
fwrite($handle, $desc); $files[$id]["subdefs"]['caption-yaml']["path"] = $path;
fclose($handle); $files[$id]["subdefs"]['caption-yaml']["file"] = $file;
$files[$id]["subdefs"]['caption-yaml']["path"] = $path; $files[$id]["subdefs"]['caption-yaml']["size"] = filesize($path . $file);
$files[$id]["subdefs"]['caption-yaml']["file"] = $file; $files[$id]["subdefs"]['caption-yaml']['businessfields'] = $BF ? '1' : '0';
$files[$id]["subdefs"]['caption-yaml']["size"] = filesize($path . $file);
}
} }
} }
@@ -839,121 +843,6 @@ class set_export extends set_abstract
return $zipFile; return $zipFile;
} }
/**
*
* @param Int $bas
* @param Int $rec
* @param boolean $check_rights
* @return string
*/
public static function get_caption($bas, $rec, $check_rights = true, $format = 'xml')
{
$dom = new DOMDocument();
$dom->formatOutput = true;
$dom->xmlStandalone = true;
$dom->encoding = 'UTF-8';
$dom_record = $dom->createElement('record');
$dom_desc = $dom->createElement('description');
$dom_record->appendChild($dom_desc);
$dom->appendChild($dom_record);
$restrict = array();
$sbas_id = phrasea::sbasFromBas($bas);
$record = new record_adapter($sbas_id, $rec);
$desc = $record->get_xml();
$appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session();
$databox = databox::get_instance($sbas_id);
$struct = $databox->get_structure();
$rights = true;
if ($check_rights && $session->is_authenticated())
{
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$rights = $user->ACL()->has_right_on_base($bas, 'canmodifrecord');
if ($rights == false)
{
if ($sxe = simplexml_load_string($struct))
{
$z = $sxe->xpath('/record/description');
if ($z && is_array($z))
{
foreach ($z[0] as $ki => $vi)
{
if (isset($vi["export"])
&& ($vi["export"] == "0" || $vi["export"] == "off"))
$restrict[$ki] = true;
}
}
}
}
}
$buffer = array();
foreach ($record->get_caption()->get_fields() as $field)
{
if (($rights || !isset($restrict[$field->get_name()])))
{
switch ($format)
{
case 'yaml':
case 'yml':
$vi = $field->get_values();
if ($field->is_multi())
{
$buffer[$field->get_name()] = array();
foreach ($vi as $value)
{
$val = $value->getValue();
$buffer[$field->get_name()][] = ctype_digit($val) ? (int) $val : $val;
}
}
else
{
$value = array_pop($vi);
$val = $value->getValue();
$buffer[$field->get_name()] = ctype_digit($val) ? (int) $val : $val;
}
break;
case 'xml':
default:
$dom_el = $dom->createElement($field->get_name());
$dom_el->appendChild($dom->createTextNode($field->get_serialized_values()));
$dom_desc->appendChild($dom_el);
break;
}
}
}
$buffer = array('record' => array('description' => $buffer));
$dumper = new Symfony\Component\Yaml\Dumper();
$buffer = $dumper->dump($buffer, 3);
switch ($format)
{
case 'xml':
default:
$ret = $dom->saveXML();
break;
case 'yaml':
case 'yml':
$ret = $buffer;
break;
}
return $ret;
}
/** /**
* *
* @param string $file * @param string $file
@@ -986,9 +875,9 @@ class set_export extends set_abstract
{ {
$file_xaccel = str_replace( $file_xaccel = str_replace(
array( array(
$registry->get('GV_X_Accel_Redirect'), $registry->get('GV_X_Accel_Redirect'),
$registry->get('GV_RootPath') . 'tmp/download/', $registry->get('GV_RootPath') . 'tmp/download/',
$registry->get('GV_RootPath') . 'tmp/lazaret/' $registry->get('GV_RootPath') . 'tmp/lazaret/'
) )
, array( , array(
'/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/', '/' . $registry->get('GV_X_Accel_Redirect_mount_point') . '/',
@@ -1111,7 +1000,7 @@ class set_export extends set_abstract
$log["rid"] = $record_object->get_record_id(); $log["rid"] = $record_object->get_record_id();
$log["subdef"] = $o; $log["subdef"] = $o;
$log["poids"] = $obj["size"]; $log["poids"] = $obj["size"];
$log["shortXml"] = $record_object->get_xml(); $log["shortXml"] = $record_object->get_caption()->serialize(caption_record::SERIALIZE_XML);
$tmplog[$record_object->get_base_id()][] = $log; $tmplog[$record_object->get_base_id()][] = $log;
if (!$anonymous && $o == 'document') if (!$anonymous && $o == 'document')
$user->ACL()->remove_remaining($record_object->get_base_id()); $user->ACL()->remove_remaining($record_object->get_base_id());

View File

@@ -33,34 +33,34 @@ class set_exportftp extends set_export
*/ */
public function export_ftp($usr_to, $host, $login, $password, $ssl, $retry, $passif, $destfolder, $makedirectory, $logfile) public function export_ftp($usr_to, $host, $login, $password, $ssl, $retry, $passif, $destfolder, $makedirectory, $logfile)
{ {
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$session = $appbox->get_session(); $session = $appbox->get_session();
$user_f = User_Adapter::getInstance($session->get_usr_id(), $appbox); $user_f = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$conn = $appbox->get_connection(); $conn = $appbox->get_connection();
$email_dest = ''; $email_dest = '';
if ($usr_to) if ($usr_to)
{ {
$user_t = User_Adapter::getInstance($usr_to, $appbox); $user_t = User_Adapter::getInstance($usr_to, $appbox);
$email_dest = $user_t->get_email(); $email_dest = $user_t->get_email();
} }
$text_mail_receiver = "Bonjour,\n" $text_mail_receiver = "Bonjour,\n"
. "L'utilisateur " . "L'utilisateur "
. $user_f->get_display_name() . " (login : " . $user_f->get_login() . ") " . $user_f->get_display_name() . " (login : " . $user_f->get_login() . ") "
. "a fait un transfert FTP sur le serveur ayant comme adresse \"" . "a fait un transfert FTP sur le serveur ayant comme adresse \""
. $host . "\" avec le login \"" . $login . "\" " . $host . "\" avec le login \"" . $login . "\" "
. "et pour repertoire de destination \"" . "et pour repertoire de destination \""
. $destfolder . "\"\n"; . $destfolder . "\"\n";
$text_mail_sender = "Bonjour,\n" $text_mail_sender = "Bonjour,\n"
. "Vous avez fait un export FTP avec les caracteristiques " . "Vous avez fait un export FTP avec les caracteristiques "
. "de connexion suivantes\n" . "de connexion suivantes\n"
. "- adresse du serveur : \"" . $host . "\"\n" . "- adresse du serveur : \"" . $host . "\"\n"
. "- login utilisé \"" . $login . "\"\n" . "- login utilisé \"" . $login . "\"\n"
. "- repertoire de destination \"" . $destfolder . "\"\n" . "- repertoire de destination \"" . $destfolder . "\"\n"
. "\n"; . "\n";
$fn = "id"; $fn = "id";
$fv = "null"; $fv = "null";
@@ -98,23 +98,23 @@ class set_exportftp extends set_export
$fv .= ",:logfile"; $fv .= ",:logfile";
$params = array( $params = array(
':nbretry' => (((int) $retry * 1) > 0 ? (int) $retry : 5) ':nbretry' => (((int) $retry * 1) > 0 ? (int) $retry : 5)
, ':mail' => $email_dest , ':mail' => $email_dest
, ':addr' => $host , ':addr' => $host
, ':login' => $login , ':login' => $login
, ':ssl' => ($ssl == '1' ? '1' : '0') , ':ssl' => ($ssl == '1' ? '1' : '0')
, ':pwd' => $password , ':pwd' => $password
, ':passif' => ($passif == "1" ? "1" : "0") , ':passif' => ($passif == "1" ? "1" : "0")
, ':destfolder' => $destfolder , ':destfolder' => $destfolder
, ':sendermail' => $user_f->get_email() , ':sendermail' => $user_f->get_email()
, ':text_mail_receiver' => $text_mail_receiver , ':text_mail_receiver' => $text_mail_receiver
, ':text_mail_sender' => $text_mail_sender , ':text_mail_sender' => $text_mail_sender
, ':usr_id' => $session->get_usr_id() , ':usr_id' => $session->get_usr_id()
, ':foldertocreate' => $makedirectory , ':foldertocreate' => $makedirectory
, ':logfile' => (!!$logfile ? '1' : '0') , ':logfile' => (!!$logfile ? '1' : '0')
); );
$sql = "INSERT INTO ftp_export ($fn) VALUES ($fv)"; $sql = "INSERT INTO ftp_export ($fn) VALUES ($fv)";
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
$stmt->execute($params); $stmt->execute($params);
$stmt->closeCursor(); $stmt->closeCursor();
@@ -122,10 +122,10 @@ class set_exportftp extends set_export
$ftp_export_id = $conn->lastInsertId(); $ftp_export_id = $conn->lastInsertId();
$sql = 'INSERT INTO ftp_export_elements $sql = 'INSERT INTO ftp_export_elements
(id, ftp_export_id, base_id, record_id, subdef, filename, folder) (id, ftp_export_id, base_id, record_id, subdef, filename, folder, businessfields)
VALUES VALUES
(null, :ftp_export_id, :base_id, :record_id, :subdef, (null, :ftp_export_id, :base_id, :record_id, :subdef,
:filename, :folder)'; :filename, :folder, :businessfields)';
$stmt = $conn->prepare($sql); $stmt = $conn->prepare($sql);
@@ -134,16 +134,19 @@ class set_exportftp extends set_export
foreach ($file['subdefs'] as $subdef => $properties) foreach ($file['subdefs'] as $subdef => $properties)
{ {
$filename = $file['export_name'] $filename = $file['export_name']
. $properties["ajout"] . '.' . $properties["ajout"] . '.'
. $properties['exportExt']; . $properties['exportExt'];
$params = array( $bfields = isset($properties['businessfields']) ? $properties['businessfields'] : null;
':ftp_export_id' => $ftp_export_id
, ':base_id' => $file['base_id'] $params = array(
, ':record_id' => $file['record_id'] ':ftp_export_id' => $ftp_export_id
, ':subdef' => $subdef , ':base_id' => $file['base_id']
, ':filename' => $filename , ':record_id' => $file['record_id']
, ':folder' => $properties['folder'] , ':subdef' => $subdef
, ':filename' => $filename
, ':folder' => $properties['folder']
, ':businessfields' => $bfields
); );
$stmt->execute($params); $stmt->execute($params);
} }

View File

@@ -17,17 +17,15 @@
*/ */
class sphinx_configuration class sphinx_configuration
{ {
const OPT_ALL_SBAS = 'all'; const OPT_ALL_SBAS = 'all';
const OPT_LIBSTEMMER_NONE = 'none'; const OPT_LIBSTEMMER_NONE = 'none';
const OPT_LIBSTEMMER_FR = 'fr'; const OPT_LIBSTEMMER_FR = 'fr';
const OPT_LIBSTEMMER_EN = 'en'; const OPT_LIBSTEMMER_EN = 'en';
const OPT_ENABLE_STAR_ON = 'yes';
const OPT_ENABLE_STAR_ON = 'yes';
const OPT_ENABLE_STAR_OFF = 'no'; const OPT_ENABLE_STAR_OFF = 'no';
const OPT_MIN_PREFIX_LEN = 0; const OPT_MIN_PREFIX_LEN = 0;
const OPT_MIN_INFIX_LEN = 1; const OPT_MIN_INFIX_LEN = 1;
public function __construct() public function __construct()
{ {
@@ -37,7 +35,7 @@ class sphinx_configuration
public function get_available_charsets() public function get_available_charsets()
{ {
$available_charsets = array(); $available_charsets = array();
$dir = __DIR__ . '/charsetTable/'; $dir = __DIR__ . '/charsetTable/';
echo $dir; echo $dir;
$registry = registry::get_instance(); $registry = registry::get_instance();
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file) foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY) as $file)
@@ -66,12 +64,12 @@ class sphinx_configuration
{ {
$defaults = array( $defaults = array(
'sbas' => self::OPT_ALL_SBAS 'sbas' => self::OPT_ALL_SBAS
, 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE) , 'libstemmer' => array(self::OPT_LIBSTEMMER_NONE)
, 'enable_star' => self::OPT_ENABLE_STAR_ON , 'enable_star' => self::OPT_ENABLE_STAR_ON
, 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN , 'min_prefix_len' => self::OPT_MIN_PREFIX_LEN
, 'min_infix_len' => self::OPT_MIN_INFIX_LEN , 'min_infix_len' => self::OPT_MIN_INFIX_LEN
, 'charset_tables' => array() , 'charset_tables' => array()
); );
$options = array_merge($defaults, $options); $options = array_merge($defaults, $options);
@@ -96,11 +94,11 @@ class sphinx_configuration
} }
} }
$charsets = explode("\n", $charsets); $charsets = explode("\n", $charsets);
$last_detect = false; $last_detect = false;
for ($i = (count($charsets) - 1); $i >= 0; $i--) for ($i = (count($charsets) - 1); $i >= 0; $i -- )
{ {
if (trim($charsets[$i]) === '') if (trim($charsets[$i]) === '')
{ {
@@ -115,7 +113,7 @@ class sphinx_configuration
if ($last_detect === true && substr(trim($charsets[$i]), (strlen(trim($charsets[$i])) - 1), 1) !== ',') if ($last_detect === true && substr(trim($charsets[$i]), (strlen(trim($charsets[$i])) - 1), 1) !== ',')
$charsets[$i] = rtrim($charsets[$i]) . ', '; $charsets[$i] = rtrim($charsets[$i]) . ', ';
$charsets[$i] = " " . $charsets[$i] . " \\\n"; $charsets[$i] = " " . $charsets[$i] . " \\\n";
$last_detect = true; $last_detect = true;
} }
$charsets = "\\\n" . implode('', $charsets); $charsets = "\\\n" . implode('', $charsets);
@@ -216,7 +214,9 @@ class sphinx_configuration
CRC32(CONCAT_WS("_", ' . $id . ', r.record_id)) as crc_sbas_record, \ CRC32(CONCAT_WS("_", ' . $id . ', r.record_id)) as crc_sbas_record, \
CONCAT_WS("_", ' . $id . ', r.coll_id) as sbas_coll, \ CONCAT_WS("_", ' . $id . ', r.coll_id) as sbas_coll, \
CRC32(r.type) as crc_type, r.coll_id, \ CRC32(r.type) as crc_type, r.coll_id, \
UNIX_TIMESTAMP(credate) as created_on, 0 as deleted \ UNIX_TIMESTAMP(credate) as created_on, 0 as deleted, \
CRC32(CONCAT_WS("_", r.coll_id, s.business)) as crc_coll_business, \
s.business \
FROM metadatas m, metadatas_structure s, record r \ FROM metadatas m, metadatas_structure s, record r \
WHERE m.record_id = r.record_id AND m.meta_struct_id = s.id \ WHERE m.record_id = r.record_id AND m.meta_struct_id = s.id \
AND s.indexable = "1" AND s.indexable = "1"
@@ -231,9 +231,12 @@ class sphinx_configuration
sql_attr_uint = crc_sbas_record sql_attr_uint = crc_sbas_record
sql_attr_uint = crc_type sql_attr_uint = crc_type
sql_attr_uint = deleted sql_attr_uint = deleted
sql_attr_uint = business
sql_attr_uint = crc_coll_business
sql_attr_timestamp = created_on sql_attr_timestamp = created_on
sql_attr_multi = uint status from query; SELECT m.id as id, CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \ sql_attr_multi = uint status from query; SELECT m.id as id, \
CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
FROM metadatas m, status s \ FROM metadatas m, status s \
WHERE s.record_id = m.record_id AND s.value = 1 \ WHERE s.record_id = m.record_id AND s.value = 1 \
ORDER BY m.id ASC ORDER BY m.id ASC
@@ -341,6 +344,8 @@ class sphinx_configuration
rt_attr_uint = crc_sbas_record rt_attr_uint = crc_sbas_record
rt_attr_uint = crc_type rt_attr_uint = crc_type
rt_attr_uint = deleted rt_attr_uint = deleted
rt_attr_uint = business
rt_attr_uint = crc_coll_business
rt_attr_timestamp = created_on rt_attr_timestamp = created_on
} }
@@ -371,13 +376,17 @@ class sphinx_configuration
sql_attr_uint = deleted sql_attr_uint = deleted
sql_attr_timestamp = created_on sql_attr_timestamp = created_on
sql_attr_multi = uint status from query; SELECT r.record_id as id, CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \ sql_attr_multi = uint status from query; SELECT r.record_id as id, \
CRC32(CONCAT_WS("_", ' . $id . ', s.name)) as name \
FROM record r, status s \ FROM record r, status s \
WHERE s.record_id = r.record_id AND s.value = 1 \ WHERE s.record_id = r.record_id AND s.value = 1 \
ORDER BY r.record_id ASC ORDER BY r.record_id ASC
sql_joined_field = metas from query; \ sql_joined_field = metas from query; \
SELECT record_id as id, value FROM metadatas ORDER BY record_id ASC SELECT m.record_id as id, m.value \
FROM metadatas m, metadatas_structure s \
WHERE s.id = m.meta_struct_id AND s.business = 0 \
ORDER BY m.record_id ASC
# datas returned in the resultset # datas returned in the resultset
sql_query_info = SELECT r.* FROM record r WHERE r.record_id=$id sql_query_info = SELECT r.* FROM record r WHERE r.record_id=$id

View File

@@ -45,11 +45,11 @@ class sphinxrt
*/ */
public static function get_instance(registry $registry, $retry_on_failure = false) public static function get_instance(registry $registry, $retry_on_failure = false)
{ {
if (!$retry_on_failure && self::$_failure === true) if ( ! $retry_on_failure && self::$_failure === true)
{ {
throw new Exception('Unable to connect to sphinx rt, try set retry_on_failure true'); throw new Exception('Unable to connect to sphinx rt, try set retry_on_failure true');
} }
if (!self::$_instance instanceof self) if ( ! self::$_instance instanceof self)
{ {
self::$_instance = new self($registry); self::$_instance = new self($registry);
} }
@@ -99,8 +99,9 @@ class sphinxrt
$cl = new SphinxClient(); $cl = new SphinxClient();
if ($cl->Status() === false) if ($cl->Status() === false)
{
return $this; return $this;
}
$cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port')); $cl->SetServer($registry->get('GV_sphinx_host'), (int) $registry->get('GV_sphinx_port'));
$cl->SetConnectTimeout(1); $cl->SetConnectTimeout(1);
@@ -108,7 +109,7 @@ class sphinxrt
$status = strrev($status); $status = strrev($status);
$new_stat = array(); $new_stat = array();
for ($i = 4; $i < strlen($status); $i++) for ($i = 4; $i < strlen($status); $i ++ )
{ {
if (substr($status, $i, 1) == '1') if (substr($status, $i, 1) == '1')
$new_stat[] = crc32($sbas_id . '_' . $i); $new_stat[] = crc32($sbas_id . '_' . $i);
@@ -122,7 +123,7 @@ class sphinxrt
return $this; return $this;
} }
public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, DateTime $created) public function replace_in_metas($rt_id, $meta_id, $tag_id, $record_id, $sbas_id, $coll_id, $grouping, $type, $content, $business, DateTime $created)
{ {
$crc_sbas_tag = crc32($sbas_id . '_' . $tag_id); $crc_sbas_tag = crc32($sbas_id . '_' . $tag_id);
$crc_sbas_coll = crc32($sbas_id . '_' . $coll_id); $crc_sbas_coll = crc32($sbas_id . '_' . $coll_id);
@@ -144,6 +145,8 @@ class sphinxrt
," . (int) $crc_sbas_record . " ," . (int) $crc_sbas_record . "
," . (int) $crc_type . " ," . (int) $crc_type . "
,0 ,0
," . (int) $business . "
," . (int) crc32($coll_id . '_' . $business) . "
," . (int) $created->format('U') . " )"; ," . (int) $created->format('U') . " )";
$stmt = $this->connection->prepare($sql); $stmt = $this->connection->prepare($sql);
$stmt->execute(); $stmt->execute();

View File

@@ -55,8 +55,7 @@ class task_Scheduler
protected static function get_connection() protected static function get_connection()
{ {
require dirname(__FILE__) . '/../../../config/connexion.inc'; return appbox::get_instance(\bootstrap::getCore())->get_connection();
return(appbox::get_instance()->get_connection());
} }
public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true) public function run($input=null, OutputInterface $output = null) //, $log = true, $log_tasks = true)
@@ -66,7 +65,7 @@ class task_Scheduler
require_once dirname(__FILE__) . '/../../bootstrap.php'; require_once dirname(__FILE__) . '/../../bootstrap.php';
$this->input = $input; $this->input = $input;
$this->output = $output; $this->output = $output;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$nullfile = ''; $nullfile = '';
@@ -122,7 +121,7 @@ class task_Scheduler
$logdir = $registry->get('GV_RootPath') . 'logs/'; $logdir = $registry->get('GV_RootPath') . 'logs/';
$conn = appbox::get_instance()->get_connection(); $conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
$taskPoll = array(); // the poll of tasks $taskPoll = array(); // the poll of tasks
@@ -184,7 +183,7 @@ class task_Scheduler
sleep(1); sleep(1);
try try
{ {
$conn = appbox::get_instance()->get_connection(); $conn = appbox::get_instance(\bootstrap::getCore())->get_connection();
} }
catch(ErrorException $e) catch(ErrorException $e)
{ {

View File

@@ -153,22 +153,9 @@ class task_manager
} }
public function get_scheduler_state() public function get_scheduler_state()
{
$sql = "SELECT schedstatus,
UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS schedqdelay, schedpid
FROM sitepreff";
$stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_ASSOC);
$stmt->closeCursor();
return $row;
}
public function get_scheduler_state2()
{ {
$pid = NULL; $pid = NULL;
$appbox = appbox::get_instance(); $appbox = appbox::get_instance(\bootstrap::getCore());
$lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/'; $lockdir = $appbox->get_registry()->get('GV_RootPath') . 'tmp/locks/';
if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) ) if( ($schedlock = fopen( $lockdir . 'scheduler.lock', 'a+')) )
{ {
@@ -185,7 +172,8 @@ class task_manager
fclose($schedlock); fclose($schedlock);
} }
$sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay, schedstatus AS status FROM sitepreff"; $sql = "SELECT UNIX_TIMESTAMP()-UNIX_TIMESTAMP(schedqtime) AS qdelay
, schedstatus AS status FROM sitepreff";
$stmt = $this->appbox->get_connection()->prepare($sql); $stmt = $this->appbox->get_connection()->prepare($sql);
$stmt->execute(); $stmt->execute();
$ret = $stmt->fetch(PDO::FETCH_ASSOC); $ret = $stmt->fetch(PDO::FETCH_ASSOC);
@@ -198,7 +186,8 @@ class task_manager
$ret['status'] = 'stopped'; $ret['status'] = 'stopped';
} }
$ret['pid'] = $pid; $ret['pid'] = $pid;
return($ret);
return $ret;
} }
public static function getAvailableTasks() public static function getAvailableTasks()

View File

@@ -470,12 +470,14 @@ class task_period_ftp extends task_appboxAbstract
{ {
$sbas_id = phrasea::sbasFromBas($base_id); $sbas_id = phrasea::sbasFromBas($base_id);
$record = new record_adapter($sbas_id, $record_id); $record = new record_adapter($sbas_id, $record_id);
$sdcaption = $record->get_xml();
$sdcaption = $record->get_caption()->serialize(caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$remotefile = $file["filename"]; $remotefile = $file["filename"];
if ($subdef == 'caption') if ($subdef == 'caption')
{ {
$desc = set_export::get_caption($base_id, $record_id, false); $desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_XML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand()); $localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) if (file_put_contents($localfile, $desc) === false)
@@ -485,7 +487,7 @@ class task_period_ftp extends task_appboxAbstract
} }
elseif ($subdef == 'caption-yaml') elseif ($subdef == 'caption-yaml')
{ {
$desc = set_export::get_caption($base_id, $record_id, false, 'yaml'); $desc = $record->get_caption()->serialize(\caption_record::SERIALIZE_YAML, $ftp_export["businessfields"]);
$localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand()); $localfile = $registry->get('GV_RootPath') . 'tmp/' . md5($desc . time() . mt_rand());
if (file_put_contents($localfile, $desc) === false) if (file_put_contents($localfile, $desc) === false)

View File

@@ -320,8 +320,12 @@ class task_period_writemeta extends task_databoxAbstract
{ {
$meta = $field->get_databox_field(); $meta = $field->get_databox_field();
/* @var $meta \databox_field */
if (trim($meta->get_metadata_source()) === '') if (trim($meta->get_metadata_source()) === '')
{
continue; continue;
}
$multi = $meta->is_multi(); $multi = $meta->is_multi();
$type = $meta->get_type(); $type = $meta->get_type();

View File

@@ -2253,6 +2253,14 @@
<default></default> <default></default>
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>businessfields</name>
<type>tinyint(1) unsigned</type>
<null>YES</null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field> <field>
<name>error</name> <name>error</name>
<type>tinyint(1) unsigned</type> <type>tinyint(1) unsigned</type>
@@ -5111,6 +5119,14 @@
<default></default> <default></default>
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>business</name>
<type>int(1) unsigned</type>
<null></null>
<extra></extra>
<default></default>
<comment></comment>
</field>
<field> <field>
<name>indexable</name> <name>indexable</name>
<type>int(1) unsigned</type> <type>int(1) unsigned</type>
@@ -5476,6 +5492,14 @@
<default>0</default> <default>0</default>
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields> </fields>
<indexes> <indexes>
<index> <index>
@@ -6468,6 +6492,14 @@
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields> </fields>
<indexes> <indexes>
<index> <index>
@@ -7179,6 +7211,15 @@
<comment></comment> <comment></comment>
</field> </field>
<field>
<name>business</name>
<type>tinyint(1) unsigned</type>
<null></null>
<extra></extra>
<default>1</default>
<comment></comment>
</field>
</fields> </fields>
<indexes> <indexes>
<index> <index>

View File

@@ -40,7 +40,7 @@
</filter> </filter>
<listeners> <listeners>
<listener class="SimpleTestListener" file="unitTest/PHPUNITListener.inc"></listener> <listener class="PhraseanetPHPUnitListener" file="unitTest/PhraseanetPHPUnitListener.class"></listener>
</listeners> </listeners>
</phpunit> </phpunit>

View File

@@ -16,6 +16,10 @@ class ApcCacheTest extends \PHPUnit_Framework_TestCase
public function setUp() public function setUp()
{ {
if (extension_loaded('apc'))
{
$this->markTestSkipped('Apc is not installed');
}
$this->object = new \Alchemy\Phrasea\Cache\ApcCache; $this->object = new \Alchemy\Phrasea\Cache\ApcCache;
} }

View File

@@ -470,31 +470,32 @@ class ControllerBasketTest extends PhraseanetWebTestCaseAuthenticatedAbstract
$datas = $em->getRepository('Entities\ValidationData')->findAll(); $datas = $em->getRepository('Entities\ValidationData')->findAll();
$countDatas = count($datas); $countDatas = count($datas);
$basket = $this->insertOneBasket();
$validationSession = new \Entities\ValidationSession(); $validationSession = new \Entities\ValidationSession();
$validationSession->setDescription('Une description au hasard'); $validationSession->setDescription('Une description au hasard');
$validationSession->setName('Un nom de validation'); $validationSession->setName('Un nom de validation');
$expires = new \DateTime(); $expires = new \DateTime();
$expires->modify('+1 week'); $expires->modify('+1 week');
$validationSession->setExpires($expires); $validationSession->setExpires($expires);
$validationSession->setInitiator(self::$user); $validationSession->setInitiator(self::$user);
$basket = new \Entities\Basket(); $em->persist($validationSession);
$basket->setName('test');
$basket->setDescription('description');
$basket->setOwner(self::$user);
$basket->setValidation($validationSession);
$validationSession->setBasket($basket);
$basket->setValidation($validationSession);
$validationSession->setBasket($basket);
$validationParticipant = new \Entities\ValidationParticipant(); $validationParticipant = new \Entities\ValidationParticipant();
$validationParticipant->setSession($validationSession); $validationParticipant->setSession($validationSession);
$validationParticipant->setUser(self::$user_alt1); $validationParticipant->setUser(self::$user_alt1);
$validationSession->addValidationParticipant($validationParticipant);
$em->persist($validationParticipant); $em->persist($validationParticipant);
$em->persist($basket);
$em->persist($validationSession); $validationSession->addValidationParticipant($validationParticipant);
$em->flush(); $em->flush();

View File

@@ -29,7 +29,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('apc')) if (extension_loaded('apc'))
{ {
$service = $cache->getDriver(); $service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache); $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
} }
else else
{ {

View File

@@ -27,7 +27,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
); );
$service = $cache->getDriver(); $service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache); $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
} }
public function testServiceException() public function testServiceException()

View File

@@ -29,7 +29,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('memcache')) if (extension_loaded('memcache'))
{ {
$service = $cache->getDriver(); $service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache); $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
} }
else else
{ {

View File

@@ -29,7 +29,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
if (extension_loaded('xcache')) if (extension_loaded('xcache'))
{ {
$service = $cache->getDriver(); $service = $cache->getDriver();
$this->assertTrue($service instanceof \Doctrine\Common\Cache\AbstractCache); $this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
} }
else else
{ {

View File

@@ -10,6 +10,7 @@
*/ */
require_once __DIR__ . "/../../lib/classes/bootstrap.class.php"; require_once __DIR__ . "/../../lib/classes/bootstrap.class.php";
require_once __DIR__ . "/PhraseanetPHPUnitListener.class.inc";
use Silex\WebTestCase; use Silex\WebTestCase;
use Symfony\Component\HttpKernel\Client; use Symfony\Component\HttpKernel\Client;
@@ -1313,6 +1314,20 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
*/ */
private static function deleteRessources() private static function deleteRessources()
{ {
$skipped = \PhraseanetPHPUnitListener::getSkipped();
if($skipped)
{
echo "\nSkipped test : \n\n";
foreach($skipped as $skipped_test)
{
echo $skipped_test . "\n";
}
echo "\n";
}
\PhraseanetPHPUnitListener::resetSkipped();
if (self::$story_1 instanceof record_adapter) if (self::$story_1 instanceof record_adapter)
{ {
self::$story_1->delete(); self::$story_1->delete();

View File

@@ -1,8 +1,10 @@
<?php <?php
class SimpleTestListener implements PHPUnit_Framework_TestListener class PhraseanetPHPUnitListener implements PHPUnit_Framework_TestListener
{ {
private static $skipped = array();
public function addError(PHPUnit_Framework_Test $test, Exception $e, $time) public function addError(PHPUnit_Framework_Test $test, Exception $e, $time)
{ {
return; return;
@@ -20,6 +22,20 @@ class SimpleTestListener implements PHPUnit_Framework_TestListener
public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time) public function addSkippedTest(PHPUnit_Framework_Test $test, Exception $e, $time)
{ {
static::$skipped[] = get_class($test) . ':' . $test->getName() . ' - ' . $e->getMessage();
return;
}
public function getSkipped()
{
return static::$skipped;
}
public function resetSkipped()
{
static::$skipped = array();
return; return;
} }

View File

@@ -0,0 +1,182 @@
<?php
require_once __DIR__ . '/../PhraseanetPHPUnitAbstract.class.inc';
/**
* Test class for caption_record.
* Generated by PHPUnit on 2012-03-20 at 15:12:31.
*/
class caption_recordTest extends PhraseanetPHPUnitAbstract
{
/**
* @var caption_record
*/
protected $object;
protected static $need_records = 1;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
public function setUp()
{
$this->object = new caption_record(self::$record_1, self::$record_1->get_databox());
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testSerialize().
*/
public function testSerializeXML()
{
foreach (self::$record_1->get_databox()->get_meta_structure() as $databox_field)
{
$n = $databox_field->is_multi() ? 3 : 1;
for ($i = 0; $i < $n; $i++)
{
\caption_Field_Value::create($databox_field, self::$record_1, \random::generatePassword());
}
}
$xml = $this->object->serialize(\caption_record::SERIALIZE_XML);
$sxe = simplexml_load_string($xml);
$this->assertInstanceOf('SimpleXMLElement', $sxe);
foreach (self::$record_1->get_caption()->get_fields() as $field)
{
if($field->get_databox_field()->is_multi())
{
$tagname = $field->get_name();
$retrieved = array();
foreach($sxe->description->$tagname as $value)
{
$retrieved[] = (string) $value;
}
$values = $field->get_values();
$this->assertEquals(count($values), count($retrieved));
foreach($values as $val)
{
$this->assertTrue(in_array($val->getValue(), $retrieved));
}
}
else
{
$tagname = $field->get_name();
$value = array_pop($field->get_values());
$this->assertEquals($value->getValue(), (string) $sxe->description->$tagname);
}
}
}
public function testSerializeYAML()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_fields().
*/
public function testGet_fields()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_field().
*/
public function testGet_field()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_dc_field().
*/
public function testGet_dc_field()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_highlight_fields().
*/
public function testGet_highlight_fields()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_cache_key().
*/
public function testGet_cache_key()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testGet_data_from_cache().
*/
public function testGet_data_from_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testSet_data_to_cache().
*/
public function testSet_data_to_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @covers {className}::{origMethodName}
* @todo Implement testDelete_data_from_cache().
*/
public function testDelete_data_from_cache()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
}
?>

View File

@@ -12,10 +12,11 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
/** /**
* @var databox_field * @var databox_field
*/ */
protected $object; protected $object_mono;
protected $object_multi;
protected $databox; protected $databox;
protected $name; protected $name_mono;
protected $id; protected $name_multi;
protected static $need_records = 1; protected static $need_records = 1;
/** /**
@@ -25,33 +26,41 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
$this->databox = self::$record_1->get_databox(); $this->databox = self::$record_1->get_databox();
$this->name = 'Field Test'; $this->name_mono = 'Field Test Mono';
$this->name_multi = 'Field Test Multi';
$this->object = $this->databox->get_meta_structure()->get_element_by_name($this->name); $this->object_mono = $this->databox->get_meta_structure()->get_element_by_name($this->name_mono);
if(!$this->object instanceof databox_field) $this->object_multi = $this->databox->get_meta_structure()->get_element_by_name($this->name_multi);
$this->object = databox_field::create($this->databox, $this->name);
$this->id = $this->object->get_id(); if(!$this->object_mono instanceof databox_field)
$this->object_mono = databox_field::create($this->databox, $this->name_mono);
if(!$this->object_multi instanceof databox_field)
{
$this->object_multi = databox_field::create($this->databox, $this->name_multi);
$this->object_multi->set_multi(true)->save();
}
} }
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*/
public function tearDown() public function tearDown()
{ {
if($this->object instanceof databox_field) if($this->object_mono instanceof databox_field)
$this->object->delete(); $this->object_mono->delete();
if($this->object_multi instanceof databox_field)
$this->object_multi->delete();
$extra = $this->databox->get_meta_structure()->get_element_by_name('Bonoboyoyo');
if($extra instanceof databox_field)
$extra->delete();
} }
/**
* @todo Implement testGet_instance().
*/
public function testGet_instance() public function testGet_instance()
{ {
$instance = databox_field::get_instance($this->databox, $this->id); $instance = databox_field::get_instance($this->databox, $this->object_mono->get_id());
$this->assertEquals($this->object->get_id(), $instance->get_id()); $this->assertEquals($this->object_mono->get_id(), $instance->get_id());
$instance = databox_field::get_instance($this->databox, $this->object_multi->get_id());
$this->assertEquals($this->object_multi->get_id(), $instance->get_id());
} }
/** /**
@@ -64,26 +73,18 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
); );
} }
/**
* @todo Implement testGet_connection().
*/
public function testGet_connection() public function testGet_connection()
{ {
// Remove the following lines when you implement this test. $this->assertInstanceOf('\connection_pdo', $this->object_mono->get_connection());
$this->markTestIncomplete( $this->assertInstanceOf('\connection_pdo', $this->object_multi->get_connection());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_databox().
*/
public function testGet_databox() public function testGet_databox()
{ {
// Remove the following lines when you implement this test. $this->assertInstanceOf('\databox', $this->object_mono->get_databox());
$this->markTestIncomplete( $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_mono->get_databox()->get_sbas_id());
'This test has not been implemented yet.' $this->assertInstanceOf('\databox', $this->object_multi->get_databox());
); $this->assertEquals(self::$record_1->get_databox()->get_sbas_id(), $this->object_multi->get_databox()->get_sbas_id());
} }
/** /**
@@ -108,26 +109,23 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
); );
} }
/**
* @todo Implement testSet_name().
*/
public function testSet_name() public function testSet_name()
{ {
$name = 'Eléphant'; $name = 'Eléphant';
$this->object->set_name($name); $this->object_mono->set_name($name);
$this->assertEquals('Elephant', $this->object->get_name()); $this->assertEquals('Elephant', $this->object_mono->get_name());
$name = '0!èEléphant '; $name = '0!èEléphant ';
$this->object->set_name($name); $this->object_mono->set_name($name);
$this->assertEquals('eElephant', $this->object->get_name()); $this->assertEquals('eElephant', $this->object_mono->get_name());
$name = 'Gaston'; $name = 'Gaston';
$this->object->set_name($name); $this->object_mono->set_name($name);
$this->assertEquals('Gaston', $this->object->get_name()); $this->assertEquals('Gaston', $this->object_mono->get_name());
try try
{ {
$this->object->set_name(''); $this->object_mono->set_name('');
$this->fail(); $this->fail();
} }
catch (Exception $e) catch (Exception $e)
@@ -137,8 +135,8 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
try try
{ {
$this->object->set_name('éà'); $this->object_mono->set_name('éà');
$this->assertEquals('ea', $this->object->get_name()); $this->assertEquals('ea', $this->object_mono->get_name());
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -157,26 +155,29 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
); );
} }
/**
* @todo Implement testSet_source().
*/
public function testSet_source() public function testSet_source()
{ {
// Remove the following lines when you implement this test. $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->markTestIncomplete(
'This test has not been implemented yet.' $this->object_mono->set_source($source);
); $this->object_multi->set_source($source);
$this->assertEquals($source, $this->object_mono->get_source()->get_source());
$this->assertEquals($source, $this->object_multi->get_source()->get_source());
$this->object_mono->set_source(null);
$this->object_multi->set_source(null);
$this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
$this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
$this->assertEquals('', $this->object_mono->get_source()->get_source());
$this->assertEquals('', $this->object_multi->get_source()->get_source());
} }
/**
* @todo Implement testGet_source().
*/
public function testGet_source() public function testGet_source()
{ {
// Remove the following lines when you implement this test. $this->assertInstanceOf('\metadata_Interface', $this->object_mono->get_source());
$this->markTestIncomplete( $this->assertInstanceOf('\metadata_Interface', $this->object_multi->get_source());
'This test has not been implemented yet.'
);
} }
/** /**
@@ -184,296 +185,271 @@ class databox_fieldTest extends PhraseanetPHPUnitAbstract
*/ */
public function testGet_dces_element() public function testGet_dces_element()
{ {
// Remove the following lines when you implement this test. $this->assertNull($this->object_mono->get_dces_element());
$this->markTestIncomplete( $this->assertNull($this->object_multi->get_dces_element());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testSet_dces_element().
*/
public function testSet_dces_element() public function testSet_dces_element()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_dces_element(new \databox_Field_DCES_Contributor());
$this->markTestIncomplete( $this->object_multi->set_dces_element(new \databox_Field_DCES_Format());
'This test has not been implemented yet.'
); $this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_mono->get_dces_element());
$this->assertInstanceOf('\databox_Field_DCESAbstract', $this->object_multi->get_dces_element());
$this->object_multi->set_dces_element(null);
$this->assertNull($this->object_multi->get_dces_element());
} }
/**
* @todo Implement testSet_indexable().
*/
public function testSet_indexable() public function testSet_indexable()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_indexable(false);
$this->markTestIncomplete( $this->assertFalse($this->object_mono->is_indexable());
'This test has not been implemented yet.' $this->object_mono->set_indexable(true);
); $this->assertTrue($this->object_mono->is_indexable());
} }
/**
* @todo Implement testSet_readonly().
*/
public function testSet_readonly() public function testSet_readonly()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_readonly(false);
$this->markTestIncomplete( $this->assertFalse($this->object_mono->is_readonly());
'This test has not been implemented yet.' $this->object_mono->set_readonly(true);
); $this->assertTrue($this->object_mono->is_readonly());
} }
/**
* @todo Implement testSet_required().
*/
public function testSet_required() public function testSet_required()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_required(false);
$this->markTestIncomplete( $this->assertFalse($this->object_mono->is_required());
'This test has not been implemented yet.' $this->object_mono->set_required(true);
); $this->assertTrue($this->object_mono->is_required());
}
public function testSet_business()
{
$this->object_mono->set_business(false);
$this->assertFalse($this->object_mono->isBusiness());
$this->object_mono->set_business(true);
$this->assertTrue($this->object_mono->isBusiness());
} }
/**
* @todo Implement testSet_multi().
*/
public function testSet_multi() public function testSet_multi()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_multi(false);
$this->markTestIncomplete( $this->assertFalse($this->object_mono->is_multi());
'This test has not been implemented yet.' $this->object_mono->set_multi(true);
); $this->assertTrue($this->object_mono->is_multi());
} }
/**
* @todo Implement testSet_report().
*/
public function testSet_report() public function testSet_report()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_report(false);
$this->markTestIncomplete( $this->assertFalse($this->object_mono->is_report());
'This test has not been implemented yet.' $this->object_mono->set_report(true);
); $this->assertTrue($this->object_mono->is_report());
} }
/**
* @todo Implement testSet_type().
*/
public function testSet_type() public function testSet_type()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_type('date');
$this->markTestIncomplete( $this->assertEquals('date', $this->object_mono->get_type());
'This test has not been implemented yet.' $this->object_mono->set_type('text');
); $this->assertEquals('text', $this->object_mono->get_type());
} }
/**
* @todo Implement testSet_tbranch().
*/
public function testSet_tbranch() public function testSet_tbranch()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_tbranch('newBranche');
$this->markTestIncomplete( $this->assertEquals('newBranche', $this->object_mono->get_tbranch());
'This test has not been implemented yet.' $this->object_mono->set_tbranch(null);
); $this->assertNull($this->object_mono->get_tbranch());
} }
/**
* @todo Implement testSet_separator().
*/
public function testSet_separator() public function testSet_separator()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('', $this->object_mono->get_separator());
$this->markTestIncomplete( $this->assertEquals(';', $this->object_multi->get_separator());
'This test has not been implemented yet.'
); $this->object_mono->set_separator(';.:');
$this->object_multi->set_separator(';.:');
$this->assertEquals('', $this->object_mono->get_separator());
$this->assertEquals(';.:', $this->object_multi->get_separator());
$this->object_multi->set_separator('.:-');
$this->assertEquals('.:-;', $this->object_multi->get_separator());
} }
/**
* @todo Implement testSet_thumbtitle().
*/
public function testSet_thumbtitle() public function testSet_thumbtitle()
{ {
// Remove the following lines when you implement this test. $this->object_mono->set_thumbtitle(true);
$this->markTestIncomplete( $this->assertTrue($this->object_mono->get_thumbtitle());
'This test has not been implemented yet.' $this->object_mono->set_thumbtitle('fr');
); $this->assertEquals('fr', $this->object_mono->get_thumbtitle());
$this->object_mono->set_thumbtitle(false);
$this->assertFalse($this->object_mono->get_thumbtitle());
} }
/**
* @todo Implement testGet_thumbtitle().
*/
public function testGet_thumbtitle() public function testGet_thumbtitle()
{ {
// Remove the following lines when you implement this test. $this->assertNull($this->object_mono->get_thumbtitle());
$this->markTestIncomplete( $this->assertNull($this->object_multi->get_thumbtitle());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_id().
*/
public function testGet_id() public function testGet_id()
{ {
// Remove the following lines when you implement this test. $this->assertTrue(is_int($this->object_mono->get_id()));
$this->markTestIncomplete( $this->assertTrue(is_int($this->object_multi->get_id()));
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_type().
*/
public function testGet_type() public function testGet_type()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('string', $this->object_mono->get_type());
$this->markTestIncomplete( $this->assertEquals('string', $this->object_multi->get_type());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_tbranch().
*/
public function testGet_tbranch() public function testGet_tbranch()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('', $this->object_mono->get_tbranch());
$this->markTestIncomplete( $this->assertEquals('', $this->object_multi->get_tbranch());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_separator().
*/
public function testGet_separator() public function testGet_separator()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('', $this->object_mono->get_separator());
$this->markTestIncomplete( $this->assertEquals(';', $this->object_multi->get_separator());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testIs_indexable().
*/
public function testIs_indexable() public function testIs_indexable()
{ {
// Remove the following lines when you implement this test. $this->assertTrue($this->object_mono->is_indexable());
$this->markTestIncomplete( $this->assertTrue($this->object_multi->is_indexable());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testIs_readonly().
*/
public function testIs_readonly() public function testIs_readonly()
{ {
// Remove the following lines when you implement this test. $this->assertFalse($this->object_mono->is_readonly());
$this->markTestIncomplete( $this->assertFalse($this->object_multi->is_readonly());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testIs_required().
*/
public function testIs_required() public function testIs_required()
{ {
// Remove the following lines when you implement this test. $this->assertFalse($this->object_mono->is_required());
$this->markTestIncomplete( $this->assertFalse($this->object_multi->is_required());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testIs_multi().
*/
public function testIs_multi() public function testIs_multi()
{ {
// Remove the following lines when you implement this test. $this->assertFalse($this->object_mono->is_multi());
$this->markTestIncomplete( $this->assertTrue($this->object_multi->is_multi());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testIs_distinct().
*/
public function testIs_distinct()
{
// Remove the following lines when you implement this test.
$this->markTestIncomplete(
'This test has not been implemented yet.'
);
}
/**
* @todo Implement testIs_report().
*/
public function testIs_report() public function testIs_report()
{ {
// Remove the following lines when you implement this test. $this->assertTrue($this->object_mono->is_report());
$this->markTestIncomplete( $this->assertTrue($this->object_multi->is_report());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_name().
*/
public function testGet_name() public function testGet_name()
{ {
// Remove the following lines when you implement this test. $this->assertEquals(str_replace(' ', '', $this->name_mono), $this->object_mono->get_name());
$this->markTestIncomplete( $this->assertEquals(str_replace(' ', '', $this->name_multi), $this->object_multi->get_name());
'This test has not been implemented yet.'
);
} }
/**
* @todo Implement testGet_metadata_source().
*/
public function testGet_metadata_source() public function testGet_metadata_source()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('', $this->object_mono->get_metadata_source());
$this->markTestIncomplete( $this->assertEquals('', $this->object_multi->get_metadata_source());
'This test has not been implemented yet.'
); $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals($source, $this->object_mono->get_metadata_source());
$this->assertEquals($source, $this->object_multi->get_metadata_source());
} }
/**
* @todo Implement testGet_metadata_namespace().
*/
public function testGet_metadata_namespace() public function testGet_metadata_namespace()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('NoSource', $this->object_mono->get_metadata_namespace());
$this->markTestIncomplete( $this->assertEquals('NoSource', $this->object_multi->get_metadata_namespace());
'This test has not been implemented yet.'
); $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals('PHRASEANET', $this->object_mono->get_metadata_namespace());
$this->assertEquals('PHRASEANET', $this->object_multi->get_metadata_namespace());
} }
/**
* @todo Implement testGet_metadata_tagname().
*/
public function testGet_metadata_tagname() public function testGet_metadata_tagname()
{ {
// Remove the following lines when you implement this test. $this->assertEquals('NoSource', $this->object_mono->get_metadata_tagname());
$this->markTestIncomplete( $this->assertEquals('NoSource', $this->object_multi->get_metadata_tagname());
'This test has not been implemented yet.'
); $source = '/rdf:RDF/rdf:Description/PHRASEANET:tf-filename';
$this->object_mono->set_source($source);
$this->object_multi->set_source($source);
$this->assertEquals('tf-filename', $this->object_mono->get_metadata_tagname());
$this->assertEquals('tf-filename', $this->object_multi->get_metadata_tagname());
} }
/**
* @todo Implement testIs_on_error().
*/
public function testIs_on_error() public function testIs_on_error()
{ {
// Remove the following lines when you implement this test. $this->assertFalse($this->object_mono->is_on_error());
$this->markTestIncomplete( $this->assertFalse($this->object_multi->is_on_error());
'This test has not been implemented yet.'
); $meta = databox_fieldUnknown::get_instance(self::$record_1->get_databox(), 25);
$meta->set_name('A beautifull name');
$this->assertTrue($meta->is_on_error());
}
public function testRenameField()
{
$AddedValue = 'scalar value';
self::$record_1->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_mono->get_id(),
'value'=> $AddedValue
)
));
$this->object_mono->set_name('Bonobo yoyo')->save();
$value = array_pop(self::$record_1->get_caption()->get_field('Bonoboyoyo')->get_values());
$this->assertEquals($value->getValue(), $AddedValue);
}
public function testChangeMulti()
{
$AddedValue_1 = 'scalar value 1';
$AddedValue_2 = 'scalar value 2';
self::$record_1->set_metadatas(array(
array(
'meta_id' => null,
'meta_struct_id' => $this->object_multi->get_id(),
'value'=> $AddedValue_1
),
array(
'meta_id' => null,
'meta_struct_id' => $this->object_multi->get_id(),
'value'=> $AddedValue_2
)
));
$this->assertEquals(2, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
$this->object_multi->set_multi(false)->save();
$this->assertEquals(1, count(self::$record_1->get_caption()->get_field(str_replace(' ', '', $this->name_multi))->get_values()));
} }
/** /**

View File

@@ -24,7 +24,7 @@ class module_console_schedulerStateTest extends PHPUnit_Framework_TestCase
$task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore())); $task_manager = new task_manager(appbox::get_instance(\bootstrap::getCore()));
$state = $task_manager->get_scheduler_state(); $state = $task_manager->get_scheduler_state();
$sentence = sprintf('Scheduler is %s', $state['schedstatus']); $sentence = sprintf('Scheduler is %s', $state['status']);
$this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false); $this->assertTrue(strpos($commandTester->getDisplay(), $sentence) !== false);
} }

View File

@@ -30,6 +30,18 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$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']);
/**
* Reset thumbtitle in order to have consistent tests (testGet_title)
*/
foreach(static::$record_1->get_databox()->get_meta_structure() as $databox_field)
{
/* @var $databox_field \databox_field */
$databox_field->set_thumbtitle(false)->save();
}
$system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg'); $system_file = new system_file(__DIR__ . '/../testfiles/cestlafete.jpg');
} }
@@ -246,19 +258,6 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertTrue((static::$record_1->get_caption() instanceof caption_record)); $this->assertTrue((static::$record_1->get_caption() instanceof caption_record));
} }
public function testGet_xml()
{
$xml = self::$record_1->get_xml();
$sxe = simplexml_load_string($xml);
$this->assertInstanceOf('SimpleXMLElement', $sxe);
foreach (self::$record_1->get_caption()->get_fields() as $field)
{
$tagname = $field->get_name();
$this->assertEquals($field->get_serialized_values(), (string) $sxe->description->$tagname);
}
}
public function testGet_original_name() public function testGet_original_name()
{ {
$this->assertTrue(static::$record_1->get_original_name() === self::$record_sf_1->getFilename()); $this->assertTrue(static::$record_1->get_original_name() === self::$record_sf_1->getFilename());
@@ -366,7 +365,13 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$metadatas[] = array( $metadatas[] = array(
'meta_struct_id' => $meta_el->get_id() 'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $meta_id , 'meta_id' => $meta_id
, 'value' => 'un jeu de test' , 'value' => 'un premier jeu de test'
);
$metadatas[] = array(
'meta_struct_id' => $meta_el->get_id()
, 'meta_id' => $meta_id
, 'value' => 'un second jeu de test'
); );
} }
} }
@@ -409,7 +414,7 @@ class record_adapterTest extends PhraseanetPHPUnitAuthenticatedAbstract
$this->assertEquals($multi_imploded, $field->get_serialized_values()); $this->assertEquals($multi_imploded, $field->get_serialized_values());
} }
else else
$this->assertEquals('un jeu de test', $field->get_serialized_values()); $this->assertEquals('un second jeu de test', $field->get_serialized_values());
} }
} }

View File

@@ -113,7 +113,6 @@ class connexionReportTest extends PhraseanetPHPUnitAbstract
} }
$result = $this->save_report->buildReport(false, 'user'); $result = $this->save_report->buildReport(false, 'user');
$this->reporttestResultWithChamp($result, $this->save_report->getChamps());
} }

View File

@@ -27,17 +27,17 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
$date = new Datetime(); $date = new Datetime();
$thid->dmax = $date->format("Y-m-d H:i:s"); $thid->dmax = $date->format("Y-m-d H:i:s");
$date->modify('-6 month'); $date->modify('-6 month');
$this->dmin = $date->format("Y-m-d H:i:s"); $this->dmin = $date->format("Y-m-d H:i:s");
$appbox = appbox::get_instance(\bootstrap::getCore()); $appbox = appbox::get_instance(\bootstrap::getCore());
$databoxes = $appbox->get_databoxes(); $databoxes = $appbox->get_databoxes();
$this->ret = array(); $this->ret = array();
foreach ($databoxes as $databox) foreach ($databoxes as $databox)
{ {
$colls = $databox->get_collections(); $colls = $databox->get_collections();
$rett = array(); $rett = array();
foreach ($colls as $coll) foreach ($colls as $coll)
{ {
$rett[$coll->get_coll_id()] = $coll->get_coll_id(); $rett[$coll->get_coll_id()] = $coll->get_coll_id();
@@ -54,7 +54,6 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$this->manyCol($ret); $this->manyCol($ret);
$ret = $this->report->colFilter('coll_id'); $ret = $this->report->colFilter('coll_id');
$this->manyCol($ret); $this->manyCol($ret);
} }
public function manyCol($ret) public function manyCol($ret)
@@ -70,84 +69,93 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
public function testBuildReport() public function testBuildReport()
{ {
$conf = array( $conf = array(
'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1), 'user' => array(_('report:: utilisateurs'), 1, 1, 1, 1),
'ddate' => array(_('report:: date'), 1, 0, 1, 1), 'ddate' => array(_('report:: date'), 1, 0, 1, 1),
'record_id' => array(_('report:: record id'), 1, 1, 1, 1), 'record_id' => array(_('report:: record id'), 1, 1, 1, 1),
'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1), 'final' => array(_('phrseanet:: sous definition'), 1, 0, 1, 1),
'coll_id' => array(_('report:: collections'), 1, 0, 1, 1), 'coll_id' => array(_('report:: collections'), 1, 0, 1, 1),
'comment' => array(_('report:: commentaire'), 1, 0, 0, 0), 'comment' => array(_('report:: commentaire'), 1, 0, 0, 0),
'fonction' => array(_('report:: fonction'), 1, 1, 1, 1), 'fonction' => array(_('report:: fonction'), 1, 1, 1, 1),
'activite' => array(_('report:: activite'), 1, 1, 1, 1), 'activite' => array(_('report:: activite'), 1, 1, 1, 1),
'pays' => array(_('report:: pays'), 1, 1, 1, 1), 'pays' => array(_('report:: pays'), 1, 1, 1, 1),
'societe' => array(_('report:: societe'), 1, 1, 1, 1) 'societe' => array(_('report:: societe'), 1, 1, 1, 1)
); );
foreach ($this->ret as $sbasid => $collections) foreach ($this->ret as $sbasid => $collections)
{ {
$this->report = new module_report_download( $this->report = new module_report_download(
$this->dmin, $this->dmin,
$this->dmax, $this->dmax,
$sbasid, $sbasid,
$collections $collections
); );
$this->ColFilter(); $this->ColFilter();
$result = $this->report->buildReport($conf); $result = $this->report->buildReport($conf);
$this->reporttestPage($result); $this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf); if (count($result['result']) > 0)
if (count($result['result']) > 0) $this->reporttestResult($result, $conf); $this->reporttestConf($conf);
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf);
} }
foreach ($this->ret as $sbasid => $collections) foreach ($this->ret as $sbasid => $collections)
{ {
$this->report = new module_report_download( $this->report = new module_report_download(
$this->dmin, $this->dmin,
$this->dmax, $this->dmax,
$sbasid, $sbasid,
$collections $collections
); );
$this->ColFilter(); $this->ColFilter();
$result = $this->report->buildReport(false, 'fonction'); $result = $this->report->buildReport(false, 'fonction');
$this->reporttestPage($result); $this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'fonction'); if (count($result['result']) > 0)
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'fonction'); $this->reporttestConf($conf, 'fonction');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'fonction');
} }
foreach ($this->ret as $sbasid => $collections) foreach ($this->ret as $sbasid => $collections)
{ {
$this->report = new module_report_download( $this->report = new module_report_download(
$this->dmin, $this->dmin,
$this->dmax, $this->dmax,
$sbasid, $sbasid,
$collections $collections
); );
$this->ColFilter(); $this->ColFilter();
$result = $this->report->buildReport(false, 'record_id', 'DOC'); $result = $this->report->buildReport(false, 'record_id', 'DOC');
$this->reporttestPage($result); $this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'record_id'); if (count($result['result']) > 0)
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'record_id'); $this->reporttestConf($conf, 'record_id');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'record_id');
} }
foreach ($this->ret as $sbasid => $collections) foreach ($this->ret as $sbasid => $collections)
{ {
$this->report = new module_report_download( $this->report = new module_report_download(
$this->dmin, $this->dmin,
$this->dmax, $this->dmax,
$sbasid, $sbasid,
$collections $collections
); );
$this->ColFilter(); $this->ColFilter();
$result = $this->report->buildReport(false, 'user', 'DOC'); $result = $this->report->buildReport(false, 'user', 'DOC');
$this->reporttestPage($result); $this->reporttestPage($result);
if (count($result['result']) > 0) $this->reporttestConf($conf, 'user'); if (count($result['result']) > 0)
if (count($result['result']) > 0) $this->reporttestResult($result, $conf, 'user'); $this->reporttestConf($conf, 'user');
if (count($result['result']) > 0)
$this->reporttestResult($result, $conf, 'user');
} }
} }
@@ -157,24 +165,31 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$nbPage = $this->report->getTotal() / $this->report->getNbRecord(); $nbPage = $this->report->getTotal() / $this->report->getNbRecord();
if ($this->report->getTotal() > $this->report->getNbRecord()) $this->assertTrue($report['display_nav']); if ($this->report->getTotal() > $this->report->getNbRecord())
else $this->assertFalse($report['display_nav']); $this->assertTrue($report['display_nav']);
else
$this->assertFalse($report['display_nav']);
if ($report['page'] == 1) $this->assertFalse($report['previous_page']); if ($report['page'] == 1)
else $this->assertEquals($report['page'] - 1, $report['previous_page']); $this->assertFalse($report['previous_page']);
else
$this->assertEquals($report['page'] - 1, $report['previous_page']);
if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0) $this->assertFalse($report['next_page']); if (intval(ceil($nbPage)) == $report['page'] || intval(ceil($nbPage)) == 0)
else $this->assertEquals($report['page'] + 1, $report['next_page']); $this->assertFalse($report['next_page']);
else
$this->assertEquals($report['page'] + 1, $report['next_page']);
} }
public function reporttestConf($conf, $groupby = false) public function reporttestConf($conf, $groupby = false)
{ {
if ($groupby) if ($groupby)
{ {
if($groupby != 'record_id') if ($groupby != 'record_id')
$this->assertEquals(count($this->report->getDisplay()), 2); $this->assertEquals(count($this->report->getDisplay()), 2);
} }
else $this->assertEquals(count($this->report->getDisplay()), count($conf)); else
$this->assertEquals(count($this->report->getDisplay()), count($conf));
if (!$groupby) if (!$groupby)
{ {
@@ -190,10 +205,14 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
$i = 0; $i = 0;
foreach ($colconf as $key => $value) foreach ($colconf as $key => $value)
{ {
if ($i == 1) $this->assertEquals($conf[$col][$i], $value); if ($i == 1)
elseif ($i == 2) $this->assertEquals($conf[$col][$i], $value); $this->assertEquals($conf[$col][$i], $value);
elseif ($i == 3) $this->assertEquals($conf[$col][$i], $value); elseif ($i == 2)
elseif ($i == 4) $this->assertEquals($conf[$col][$i], $value); $this->assertEquals($conf[$col][$i], $value);
elseif ($i == 3)
$this->assertEquals($conf[$col][$i], $value);
elseif ($i == 4)
$this->assertEquals($conf[$col][$i], $value);
$i++; $i++;
} }
} }
@@ -201,8 +220,7 @@ class downloadReportTest extends PhraseanetPHPUnitAbstract
else else
{ {
$this->assertArrayHasKey($groupby, $this->report->getDisplay()); $this->assertArrayHasKey($groupby, $this->report->getDisplay());
} }
} }

View File

@@ -65,17 +65,10 @@ class reportTest extends PhraseanetPHPUnitAbstract
$this->report = new module_report($this->dmin, $this->dmax, $sbasid, $collections); $this->report = new module_report($this->dmin, $this->dmax, $sbasid, $collections);
$this->report->setUser_id(self::$user->get_id()); $this->report->setUser_id(self::$user->get_id());
$this->assertEquals($collections, $this->report->getListCollId()); $this->assertEquals($collections, $this->report->getListCollId());
$this->champ($this->report);
$this->host($this->report); $this->host($this->report);
} }
} }
public function champ($report)
{
$chps = $report->getChamp($this->xml, 'report');
$this->assertEquals('hello',$chps);
}
public function host($report) public function host($report)
{ {
$host ='http://www.google.fr/search?q=helloworld&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a#pq=fake%20url%20constructor&hl=fr&sugexp=gsnos%2Cn%3D2&cp=8&gs_id=y&xhr=t&q=hello+world&pf=p&sclient=psy&client=firefox-a&hs=mIa&rls=org.mozilla:fr%3Aofficial&source=hp&pbx=1&oq=hello+wo&aq=0&aqi=g2&aql=t&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=ab54cb1d4456efee&biw=1152&bih=712'; $host ='http://www.google.fr/search?q=helloworld&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:fr:official&client=firefox-a#pq=fake%20url%20constructor&hl=fr&sugexp=gsnos%2Cn%3D2&cp=8&gs_id=y&xhr=t&q=hello+world&pf=p&sclient=psy&client=firefox-a&hs=mIa&rls=org.mozilla:fr%3Aofficial&source=hp&pbx=1&oq=hello+wo&aq=0&aqi=g2&aql=t&gs_sm=&gs_upl=&bav=on.2,or.r_gc.r_pw.&fp=ab54cb1d4456efee&biw=1152&bih=712';
@@ -200,7 +193,7 @@ class reportTest extends PhraseanetPHPUnitAbstract
$report->expects($this->any())->method('buildReq')->will($this->returnValue('')); $report->expects($this->any())->method('buildReq')->will($this->returnValue(''));
$report->expects($this->any())->method('buildResult')->will($this->returnValue(array())); $report->expects($this->any())->method('buildResult')->will($this->returnValue(array()));
$result = $report->buildReport(false, 'user'); $result = $report->buildReport(false, 'user');
$this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $report->getChamps()); // $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $report->getChamps());
} }
} }
} }

View File

@@ -284,6 +284,9 @@
<th> <th>
{% trans 'Afficher en titre' %} {% trans 'Afficher en titre' %}
</th> </th>
<th>
{% trans 'Business Field' %}
</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@@ -358,9 +361,12 @@
</td> </td>
<td> <td>
<select class="metafield_{{field.get_id()}}" {{disabled}} name="thumbtitle_{{field.get_id()}}"> <select class="metafield_{{field.get_id()}}" {{disabled}} name="thumbtitle_{{field.get_id()}}">
{{_self.thumbtitle_selector(field.get_thumbtitle())}} {{_self.thumbtitle_selector(field.get_thumbtitle())}}
</select> </select>
</td> </td>
<td>
<input class="metafield_{{field.get_id()}}" {{disabled}} name="business_{{field.get_id()}}" type="checkbox" {% if field.isBusiness() %}checked="checked"{% endif %}/>
</td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>

View File

@@ -5,16 +5,18 @@
{% import 'common/caption_templates/overview.html' as cap_ovr %} {% import 'common/caption_templates/overview.html' as cap_ovr %}
{% import 'common/caption_templates/preview.html' as cap_prev %} {% import 'common/caption_templates/preview.html' as cap_prev %}
{% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% if view == 'answer' %} {% if view == 'answer' %}
{{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null))}} {{cap_ans.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'lazaret' %} {% elseif view == 'lazaret' %}
{{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null))}} {{cap_laz.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'preview' %} {% elseif view == 'preview' %}
{{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null))}} {{cap_prev.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'basket' %} {% elseif view == 'basket' %}
{{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null))}} {{cap_bas.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'overview' %} {% elseif view == 'overview' %}
{{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null))}} {{cap_ovr.format_caption(record, highlight|default(''), searchEngine|default(null), business)}}
{% elseif view == 'publi' %} {% elseif view == 'publi' %}
{{cap_pub.format_caption(record, '', null)}} {{cap_pub.format_caption(record, '', null, business)}}
{% endif %} {% endif %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record, highlight, searchEngine) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div> <div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields() %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div> <div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields() %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div> <div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields() %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div> <div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields() %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div><b>{{name}}</b> : {{value.value|raw}}</div> <div><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -1,5 +1,5 @@
{% macro format_caption(record, highlight, searchEngine) %} {% macro format_caption(record, highlight, searchEngine, includeBusiness) %}
{% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine) %} {% for name, value in record.get_caption().get_highlight_fields(highlight, null, searchEngine, includeBusiness) %}
<div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div> <div class="desc{% if loop.index is odd %}im{% endif %}pair"><b>{{name}}</b> : {{value.value|raw}}</div>
{% endfor %} {% endfor %}
{% endmacro %} {% endmacro %}

View File

@@ -66,15 +66,15 @@
</td> </td>
<td> <td>
<input type="checkbox" class="checkbox ftp_folder_check" {% if datas.prefixFTPfolder != '' %}checked="checked"{% endif %} name="MKDFOLD" id="idMKDFOLD_{{datas.usr_id}}" value="MKDFOLD" /> <input type="checkbox" class="checkbox ftp_folder_check" {% if datas.prefixFTPfolder != '' %}checked="checked"{% endif %} name="MKDFOLD" id="idMKDFOLD_{{datas.usr_id}}" value="MKDFOLD" />
<input style="width:250px;" type="text" name="NAMMKDFOLD" id="prefixFTPfolder_{{datas.usr_id}}" value="{{datas.prefixFTPfolder}}" {% if datas.prefixFTPfolder == '' %}disabled="disabled"{% endif %}/> <input style="width:250px;" type="text" name="NAMMKDFOLD" id="prefixFTPfolder_{{datas.usr_id}}" value="{{datas.prefixFTPfolder}}" {% if datas.prefixFTPfolder == '' %}disabled="disabled"{% endif %}/>
</td> </td>
</tr> </tr>
<tr> <tr>
<td> <td>
<label for="logfile_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: ecrire un fichier de log' %} </label> <label for="logfile_{{datas.usr_id}}">{% trans 'admin::compte-utilisateur:ftp: ecrire un fichier de log' %} </label>
</td> </td>
<td> <td>
<input type="checkbox" class="checkbox ftp_logfile_check" name="logfile" id="logfile_{{datas.usr_id}}" value="1" /> <input type="checkbox" class="checkbox ftp_logfile_check" name="logfile" id="logfile_{{datas.usr_id}}" value="1" />
</td> </td>
</tr> </tr>
</table> </table>
@@ -118,30 +118,35 @@
<form method="post" target="_blank" action="/include/download.php"> <form method="post" target="_blank" action="/include/download.php">
<input type="hidden" name="lst" value="{{lst}}"/> <input type="hidden" name="lst" value="{{lst}}"/>
<input type="hidden" name="ssttid" value="{{ssttid}}"/> <input type="hidden" name="ssttid" value="{{ssttid}}"/>
{% for name, values in download.get_display_download() %} {% for name, values in download.get_display_download() %}
{% if values.available > 0 %} {% if values.available > 0 %}
<div>
<div> <input class="checkbox {{values.class}}" type="checkbox" id="download_{{name}}" name="obj[]" value="{{name}}" />
<input class="checkbox" type="checkbox" id="download_{{name}}" name="obj[]" value="{{name}}" /> <input type="hidden" name="download_{{name}}" value="{{values.size}}" />
<input type="hidden" name="download_{{name}}" value="{{values.size}}" /> <input type="hidden" name="count_{{name}}" value="{{values.available}}" />
<input type="hidden" name="count_{{name}}" value="{{values.available}}" /> <label for="download_{{name}}">{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label>
<label for="download_{{name}}">{{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label> {% set title%}
{% set title%} {% trans 'Documents indisponibles' %}
{% trans 'Documents indisponibles' %} {% endset %}
{% endset %} {% if values.refused|length > 0 %}
{% if values.refused|length > 0 %} <a href="#" class="undisposable_link" title="{{title|e}}"> + </a>
<a href="#" class="undisposable_link" title="{{title|e}}"> + </a> <div style="display:none;" class="undisposable">
<div style="display:none;" class="undisposable"> <div>{% trans 'Les documents ne peuvent pas etre exportes' %}</div>
<div>{% trans 'Les documents ne peuvent pas etre exportes' %}</div> {% for datas in values.refused%}
{% for datas in values.refused%} {{ thumbnail.format(datas, 80, 80,'', session, true) }}
{{ thumbnail.format(datas, 80, 80,'', session, true) }} {% endfor %}
{% endfor %} </div>
</div> {% endif %}
{% endif %} </div>
{% endif %}
{% endfor %}
{% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_download" value="1" />
<label for="business_download">{% trans 'Include Business-fields in caption' %}</label>
</div> </div>
{% endif %} {% endif %}
{% endfor %} {{ _self.choose_title('download', choose_export_title, default_export_title) }}
{{ _self.choose_title('sendmail', choose_export_title, default_export_title) }}
<div class="buttons_line"> <div class="buttons_line">
<button type="button" class="download_button">{% trans 'boutton::telecharger'%}</button> <button type="button" class="download_button">{% trans 'boutton::telecharger'%}</button>
<button type="button" class="close_button">{% trans 'boutton::annuler'%}</button> <button type="button" class="close_button">{% trans 'boutton::annuler'%}</button>
@@ -178,7 +183,7 @@
{% for name, values in download.get_display_download() %} {% for name, values in download.get_display_download() %}
{% if values.available > 0 %} {% if values.available > 0 %}
<div> <div>
<input class="checkbox" type="checkbox" id="sendmail_{{name}}" name="obj[]" value="{{name}}" /> <input class="checkbox {{values.class}}" type="checkbox" id="sendmail_{{name}}" name="obj[]" value="{{name}}" />
<label for="sendmail_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label> <label for="sendmail_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}})</label>
{% set title%} {% set title%}
{% trans 'Documents indisponibles' %} {% trans 'Documents indisponibles' %}
@@ -196,7 +201,13 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{{ _self.choose_title('download', choose_export_title, default_export_title) }} {% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_sendmail" value="1" />
<label for="business_sendmail">{% trans 'Include Business-fields in caption' %}</label>
</div>
{% endif %}
{{ _self.choose_title('sendmail', choose_export_title, default_export_title) }}
<div class="buttons_line"> <div class="buttons_line">
<button type="button" class="sendmail_button">{% trans 'boutton::envoyer'%}</button> <button type="button" class="sendmail_button">{% trans 'boutton::envoyer'%}</button>
<img class="sendmail_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/> <img class="sendmail_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
@@ -386,7 +397,7 @@
{% for name, values in download.get_display_ftp() %} {% for name, values in download.get_display_ftp() %}
{% if values.available > 0 %} {% if values.available > 0 %}
<div> <div>
<input class="checkbox" type="checkbox" id="ftp_{{name}}" name="obj[]" value="{{name}}" /> <input class="checkbox {{values.class}}" type="checkbox" id="ftp_{{name}}" name="obj[]" value="{{name}}" />
<label for="ftp_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}}))</label> <label for="ftp_{{name}}"> {{values.label}} {% if values.total != values.available %}{{values.available}}/{{values.total}}{% endif %} ({{values.size|format_octets}}))</label>
{% set title%} {% set title%}
{% trans 'Documents indisponibles' %} {% trans 'Documents indisponibles' %}
@@ -404,6 +415,12 @@
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% if download.has_business_fields_access() %}
<div class="businessfields" style="margin-left:20px;display:none;">
<input type="checkbox" class="checkbox" name="businessfields" id="business_ftp" value="1" />
<label for="business_ftp">{% trans 'Include Business-fields in caption' %}</label>
</div>
{% endif %}
<div class="buttons_line"> <div class="buttons_line">
<button type="button" class="tryftp_button">{% trans 'boutton::essayer'%}</button> <button type="button" class="tryftp_button">{% trans 'boutton::essayer'%}</button>
<img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/> <img class="tryftp_button_loader" src="/skins/icons/loader404040.gif" style="visibility:hidden;margin:0 5px;"/>
@@ -608,6 +625,20 @@
return false; return false;
}); });
$('input[name="obj[]"]', $('#download, #sendmail, #ftp')).bind('change', function(){
var $form = $(this).closest('form');
if($('input.caption[name="obj[]"]:checked', $form).length > 0)
{
$('div.businessfields', $form).show();
}
else
{
$('div.businessfields', $form).hide();
}
});
}); });
</script> </script>
</div> </div>

View File

@@ -1,6 +1,10 @@
{% macro format(thumbnail, b_w, b_h, extraclass, session, wrap)%} {% macro format(thumbnail, b_w, b_h, extraclass, session, wrap)%}
{% set record_type = thumbnail.get_type() %} {% set record_type = thumbnail.get_type() %}
{% set b_width = b_w %}
{% set b_height = b_h|default(b_w) %}
{% if record_type == 'AUDIO_MP3' %} {% if record_type == 'AUDIO_MP3' %}
{% set d_width = 320 %} {% set d_width = 320 %}
@@ -13,9 +17,6 @@
{% set top = 0 %} {% set top = 0 %}
{% else %} {% else %}
{% set b_width = b_w %}
{% set b_height = b_h|default(b_w) %}
{% set b_ratio = b_width / b_height %} {% set b_ratio = b_width / b_height %}
{% set i_ratio = thumbnail.get_width() / thumbnail.get_height() %} {% set i_ratio = thumbnail.get_width() / thumbnail.get_height() %}

View File

@@ -85,8 +85,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;"> <div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;">
<div id="record_infos"> <div id="record_infos">
<div class="container"> <div class="container">
{% set business = user.ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.get_record())}} {{caption.format_caption(first_item.get_record(), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -95,8 +95,9 @@
<div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;{% if basket.getValidation() %}display:none;{% endif %}"> <div class="right_column_wrapper right_column_wrapper_caption left unselectable" style="width:230px;height:auto;{% if basket.getValidation() %}display:none;{% endif %}">
<div id="record_infos"> <div id="record_infos">
<div class="container"> <div class="container">
{% set business = user.ACL().has_right_on_base(basket_element.getRecord().get_base_id(), 'canmodifrecord') %}
{% if basket_element %} {% if basket_element %}
{{caption.format_caption(basket_element.getRecord())}} {{caption.format_caption(basket_element.getRecord(), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -80,8 +80,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB"> <div class="right_column_wrapper caption right_column_wrapper_caption PNB">
<div id="record_infos" class="PNB"> <div id="record_infos" class="PNB">
<div class="container PNB"> <div class="container PNB">
{% set business = user.ACL().has_right_on_base(first_item.get_record().get_base_id(), 'canmodifrecord') %}
{% if first_item %} {% if first_item %}
{{caption.format_caption(first_item.get_record())}} {{caption.format_caption(first_item.get_record(), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -93,8 +93,9 @@
<div class="right_column_wrapper caption right_column_wrapper_caption PNB" style="{% if basket.getValidation() %}display:none;{% endif %}"> <div class="right_column_wrapper caption right_column_wrapper_caption PNB" style="{% if basket.getValidation() %}display:none;{% endif %}">
<div id="record_infos" class="PNB"> <div id="record_infos" class="PNB">
<div class="container PNB"> <div class="container PNB">
{% set business = user.ACL().has_right_on_base(basket_element.getRecord().get_base_id(), 'canmodifrecord') %}
{% if basket_element %} {% if basket_element %}
{{caption.format_caption(basket_element.getRecord())}} {{caption.format_caption(basket_element.getRecord(), '', null, business)}}
{% endif %} {% endif %}
</div> </div>
</div> </div>

View File

@@ -3,7 +3,7 @@
{% if user.ACL().has_right_on_base(record.get_base_id, 'canmodifrecord') %} {% if user.ACL().has_right_on_base(record.get_base_id, 'canmodifrecord') %}
<div class="edit_button" style="text-align:right"> <div class="edit_button" style="text-align:right">
<a href="#" onclick="editThis('IMGT','{{record.get_serialize_key()}}');"> <a href="#" onclick="editThis('IMGT','{{record.get_serialize_key()}}');">
<img style="vertical-align:middle" src="/skins/prod/000000/images/ppen_history.gif" /> <img style="vertical-align:middle" src="/skins/prod/000000/images/ppen_history.gif" />
{% trans 'action : editer' %} {% trans 'action : editer' %}
</a> </a>
</div> </div>
@@ -11,10 +11,11 @@
<div style="text-align:center;"> <div style="text-align:center;">
{{record.get_status_icons()|raw}} {{record.get_status_icons()|raw}}
</div> </div>
{% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{% if record.is_from_reg() %} {% if record.is_from_reg() %}
{{caption.format_caption(record)}} {{caption.format_caption(record, '', null, business)}}
{% else %} {% else %}
{{caption.format_caption(record, highlight, searchEngine)}} {{caption.format_caption(record, highlight, searchEngine, business)}}
{% endif %} {% endif %}
<hr style="margin:10px 0;"/> <hr style="margin:10px 0;"/>
{% include 'common/technical_datas.twig' %} {% include 'common/technical_datas.twig' %}

View File

@@ -19,7 +19,8 @@
<td valign="top"> <td valign="top">
<div class='desc' style='max-height:{{th_size+70}}px;overflow-y:auto;'> <div class='desc' style='max-height:{{th_size+70}}px;overflow-y:auto;'>
<div class="fixeddesc"> <div class="fixeddesc">
{{caption.format_caption(record, highlight, searchEngine)}} {% set business = user.ACL().has_right_on_base(record.get_base_id(), 'canmodifrecord') %}
{{caption.format_caption(record, highlight, searchEngine, business)}}
{% if user.getPrefs('technical_display') == 'group' %}<hr/>{{record.get_technical_infos|raw}}{% endif %} {% if user.getPrefs('technical_display') == 'group' %}<hr/>{{record.get_technical_infos|raw}}{% endif %}
</div> </div>
</div> </div>
@@ -28,6 +29,6 @@
</table> </table>
</div> </div>
{% endfor %} {% endfor %}
{% endblock %} {% endblock %}

View File

@@ -157,7 +157,7 @@ switch ($parm['action'])
} }
break; break;
case 'RESETTASKCRASHCOUNTER': case 'RESETTASKCRASHCOUNTER':
$parm = $request->get_parms("task_id"); $parm = $request->get_parms("task_id");
try try
@@ -206,79 +206,11 @@ switch ($parm['action'])
$output = $ret->saveXML(); $output = $ret->saveXML();
break; break;
/*
case 'PINGSCHEDULER':
$lockdir = $registry->get('GV_RootPath') . 'tmp/locks/';
$ret = new DOMDocument("1.0", "UTF-8");
$ret->standalone = true;
$ret->preserveWhiteSpace = false;
$root = $ret->appendChild($ret->createElement("result"));
$root->appendChild($ret->createCDATASection(var_export(array(), true)));
$h = "";
$dat = date("H:i:s");
$root->setAttribute('time', $dat);
$task_manager = new task_manager($appbox);
$scheduler_state = $task_manager->get_scheduler_state();
$schedstatus = $scheduler_state['schedstatus'];
$schedqdelay = $scheduler_state['schedqdelay'];
$schedpid = $scheduler_state['schedpid'];
$root->setAttribute('status', $schedstatus);
$root->setAttribute('qdelay', $schedqdelay);
$schedlock = fopen($lockfile = ($lockdir . 'scheduler.lock'), 'a+');
if (flock($schedlock, LOCK_SH | LOCK_NB) != true)
{
$root->setAttribute('locked', '1');
}
else
{
$root->setAttribute('locked', '0');
}
if ($schedpid > 0)
$root->setAttribute('pid', $schedpid);
else
$root->setAttribute('pid', '');
foreach ($task_manager->get_tasks() as $task)
{
$task_node = $root->appendChild($ret->createElement("task"));
$task_node->setAttribute('id', $task->get_task_id());
$task_node->setAttribute('status', $task->get_status());
$task_node->setAttribute('active', $task->is_active());
$task_node->setAttribute('crashed', $task->get_crash_counter());
$task_node->setAttribute('completed', $task->get_completed_percentage());
$task_node->setAttribute('runner', $task->get_runner());
if ($task->is_running())
{
$task_node->setAttribute('running', '1');
$task_node->setAttribute('pid', $task->get_pid());
}
else
{
$task_node->setAttribute('running', '0');
$task_node->setAttribute('pid', '');
}
}
$output = $ret->saveXML();
break;
*/
case 'PINGSCHEDULER_JS': case 'PINGSCHEDULER_JS':
$ret = array('time'=> date("H:i:s") ); $ret = array('time'=> date("H:i:s") );
$task_manager = new task_manager($appbox); $task_manager = new task_manager($appbox);
$ret['scheduler'] = $task_manager->get_scheduler_state2(); $ret['scheduler'] = $task_manager->get_scheduler_state();
$ret['tasks'] = array(); $ret['tasks'] = array();
@@ -311,7 +243,7 @@ switch ($parm['action'])
$output = p4string::jsonencode($ret); $output = p4string::jsonencode($ret);
break; break;
case 'UNMOUNTBASE': case 'UNMOUNTBASE':
$parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT)); $parm = $request->get_parms(array('sbas_id' => http_request::SANITIZE_NUMBER_INT));
$ret = array('sbas_id' => null); $ret = array('sbas_id' => null);

View File

@@ -57,7 +57,7 @@ if($parm["act"] == "DELETETASK")
<head> <head>
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/admin/admincolor.css" /> <link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,skins/admin/admincolor.css" />
<link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.12/css/ui-lightness/jquery-ui-1.8.12.custom.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" type="text/css" media="screen" />
<style> <style>
.divTop .divTop
{ {
@@ -69,35 +69,6 @@ if($parm["act"] == "DELETETASK")
text-align:center; text-align:center;
table-layout: fixed; table-layout: fixed;
} }
table.task_manager {
border: 1px solid #e0e0e0;
border-collapse: collapse;
table-layout: fixed;
}
table.task_manager tr {
height:auto;
}
table.task_manager th, table.task_manager td {
height:auto;
padding: 2px;
margin: 0px;
border: 1px solid #e0e0e0;
padding-left: 5px;
padding-right: 5px;
}
table.db_processlist {
border: 1px solid #e0e0e0;
border-collapse: collapse;
table-layout: fixed;
}
table.db_processlist th, table.db_processlist td {
height:auto;
padding: 2px;
margin: 0px;
border: 1px solid #e0e0e0;
padding-left: 5px;
padding-right: 5px;
}
</style> </style>
<link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" type="text/css" media="screen" /> <link rel="stylesheet" href="/include/minify/f=include/jslibs/jquery.contextmenu.css,include/jslibs/jquery-ui-1.8.17/css/ui-lightness/jquery-ui-1.8.17.custom.css" type="text/css" media="screen" />
<script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js,include/jslibs/jquery.contextmenu.js"></script> <script type="text/javascript" src="/include/minify/f=include/jslibs/jquery-1.7.1.js,include/jslibs/jquery-ui-1.8.17/jquery-ui-i18n.js,include/jslibs/jquery.contextmenu.js"></script>
@@ -105,7 +76,7 @@ if($parm["act"] == "DELETETASK")
<script type="text/javascript"> <script type="text/javascript">
var retPing = null; var retPing = null;
var newTaskMenu = null; var newTaskMenu = null;
var allgetID = new Array ; var allgetID = new Array ;
@@ -238,8 +209,8 @@ foreach($tasks as $t)
// theme:'vista' // theme:'vista'
} }
); );
$('.dropdown.scheduler').contextMenu( $('.dropdown.scheduler').contextMenu(
[ [
{ {
@@ -271,7 +242,7 @@ foreach($tasks as $t)
title:'Scheduler preferences' title:'Scheduler preferences'
} }
} }
] ]
, ,
{ {
// theme:'vista', // theme:'vista',
@@ -298,8 +269,8 @@ foreach($tasks as $t)
} }
); );
$('.task_manager .dropdown.task').contextMenu( $('.task_manager .dropdown.task').contextMenu(
[ [
{ {
@@ -343,7 +314,7 @@ foreach($tasks as $t)
optionsIdx:{'edit':0, 'start':1, 'stop':2, 'delete':3, 'log':5}, optionsIdx:{'edit':0, 'start':1, 'stop':2, 'delete':3, 'log':5},
doclick:function() doclick:function()
{ {
}, },
beforeShow:function() beforeShow:function()
{ {
@@ -369,12 +340,12 @@ foreach($tasks as $t)
else else
$(this.menu).find('.context-menu-item:eq('+this.optionsIdx['start']+')').addClass("context-menu-item-disabled"); $(this.menu).find('.context-menu-item:eq('+this.optionsIdx['start']+')').addClass("context-menu-item-disabled");
} }
} }
} }
); );
self.setTimeout("pingScheduler(true);", 100); // true : loop forever each 2 sec self.setTimeout("pingScheduler(true);", 100); // true : loop forever each 2 sec
}) })
</script> </script>
@@ -391,7 +362,7 @@ foreach($tasks as $t)
<?php echo sprintf(_('Last update at %s.'), '<span id="pingTime"></span>'); ?> <?php echo sprintf(_('Last update at %s.'), '<span id="pingTime"></span>'); ?>
</span> </span>
</h1> </h1>
<table class="admintable task_manager" cellpadding="0" cellSpacing="0"> <table class="admintable task_manager" cellpadding="0" cellSpacing="0">
<thead> <thead>
<tr> <tr>
@@ -486,7 +457,7 @@ foreach($tasks as $t)
} }
}); });
} }
$.ajax({ $.ajax({
url: "/admin/adminFeedback.php", url: "/admin/adminFeedback.php",
data : {task_id:tid, action:"SETTASKSTATUS", status:status, signal:signal}, data : {task_id:tid, action:"SETTASKSTATUS", status:status, signal:signal},
@@ -665,7 +636,7 @@ foreach($tasks as $t)
} }
*/ */
function pingScheduler(repeat) function pingScheduler(repeat)
{ {
$.ajax({ $.ajax({
@@ -692,7 +663,7 @@ foreach($tasks as $t)
$("#STATUS_SCHED").html(''); $("#STATUS_SCHED").html('');
$("#PID_SCHED").html('-'); $("#PID_SCHED").html('-');
} }
if(ret.tasks) if(ret.tasks)
{ {
for(id in ret.tasks) for(id in ret.tasks)
@@ -701,12 +672,12 @@ foreach($tasks as $t)
$("#STATUS_"+id).html(ret.tasks[id].status); $("#STATUS_"+id).html(ret.tasks[id].status);
else else
$("#STATUS_"+id).html(''); $("#STATUS_"+id).html('');
if(ret.tasks[id].pid) if(ret.tasks[id].pid)
$("#PID_"+id).html(ret.tasks[id].pid); $("#PID_"+id).html(ret.tasks[id].pid);
else else
$("#PID_"+id).html('-'); $("#PID_"+id).html('-');
if(ret.tasks[id].crashed) if(ret.tasks[id].crashed)
{ {
// $("#WARNING_"+id).show().setAttribute("src", "/skins/icons/alert.png"); // $("#WARNING_"+id).show().setAttribute("src", "/skins/icons/alert.png");
@@ -716,7 +687,7 @@ foreach($tasks as $t)
{ {
$("#WARNING_"+id).hide(); $("#WARNING_"+id).hide();
} }
if(ret.tasks[id].completed && ret.tasks[id].completed>0 && ret.tasks[id].completed<=100) if(ret.tasks[id].completed && ret.tasks[id].completed>0 && ret.tasks[id].completed<=100)
{ {
$("#COMP_"+id).width(ret.tasks[id].completed + "%"); $("#COMP_"+id).width(ret.tasks[id].completed + "%");
@@ -729,7 +700,7 @@ foreach($tasks as $t)
} }
} }
} }
if(ret.db_processlist) if(ret.db_processlist)
{ {
var _table = document.createElement('table'); var _table = document.createElement('table');

View File

@@ -23,7 +23,7 @@ $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$user = $Core->getAuthenticatedUser(); $user = $Core->getAuthenticatedUser();
if (!isset($parm)) if ( ! isset($parm))
{ {
$request = http_request::getInstance(); $request = http_request::getInstance();
@@ -72,7 +72,7 @@ if (is_null($parm['bas']))
return; return;
} }
if (!$parm["mod"]) if ( ! $parm["mod"])
$parm["mod"] = "3X6"; $parm["mod"] = "3X6";
@@ -91,14 +91,33 @@ $mod_xy = $mod_col * $mod_row;
$tbases = array(); $tbases = array();
$options = new searchEngine_options(); $options = new searchEngine_options();
$parm['bas'] = is_array($parm['bas']) ? $parm['bas'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($parm['bas']) === 0 || in_array($collection->get_base_id(), $parm['bas']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($parm['bas'], $user->ACL()); $options->set_bases($parm['bas'], $user->ACL());
if (!is_array($parm['infield'])) if ( ! is_array($parm['infield']))
$parm['infield'] = array(); $parm['infield'] = array();
foreach ($parm['infield'] as $offset => $value) foreach ($parm['infield'] as $offset => $value)
@@ -108,7 +127,7 @@ foreach ($parm['infield'] as $offset => $value)
} }
$options->set_fields($parm['infield']); $options->set_fields($parm['infield']);
if (!is_array($parm['status'])) if ( ! is_array($parm['status']))
$parm['status'] = array(); $parm['status'] = array();
$options->set_status($parm['status']); $options->set_status($parm['status']);
$options->set_search_type($parm['search_type']); $options->set_search_type($parm['search_type']);
@@ -200,7 +219,7 @@ $max = (2 * $ecart) + 3;
if ($npages > $max) if ($npages > $max)
{ {
for ($p = 1; $p <= $npages; $p++) for ($p = 1; $p <= $npages; $p ++ )
{ {
if ($p == $page) if ($p == $page)
$pages .= '<span class="naviButton sel">' . ($p) . '</span>'; $pages .= '<span class="naviButton sel">' . ($p) . '</span>';
@@ -226,7 +245,7 @@ if ($npages > $max)
} }
else else
{ {
for ($p = 1; $p <= $npages; $p++) for ($p = 1; $p <= $npages; $p ++ )
{ {
if ($p == $page) if ($p == $page)
$pages .= '<span class="naviButton sel">' . ($p) . '</span>'; $pages .= '<span class="naviButton sel">' . ($p) . '</span>';
@@ -293,7 +312,7 @@ if (count($result->get_datas()) > 0)
else // MODE GRILLE else // MODE GRILLE
{ {
?><tr style="visibility:hidden"><?php ?><tr style="visibility:hidden"><?php
for ($ii = 0; $ii < $mod_col; $ii++) for ($ii = 0; $ii < $mod_col; $ii ++ )
{ {
?><td class="w160px"></td><?php ?><td class="w160px"></td><?php
} }
@@ -334,22 +353,22 @@ if (count($result->get_datas()) > 0)
if (($i % $mod_col == 0 && $i != 0)) if (($i % $mod_col == 0 && $i != 0))
{ {
?></tr><tr><?php ?></tr><tr><?php
} }
if ($mod_col == 1 && $i != 0) if ($mod_col == 1 && $i != 0)
{ {
?></tr><tr style="height:20px;"> ?></tr><tr style="height:20px;">
<td colspan="2" class="td_mod_lst_img"><hr></td> <td colspan="2" class="td_mod_lst_img"><hr></td>
</tr><tr><?php </tr><tr><?php
} }
if ($mod_col == 1) if ($mod_col == 1)
{ {
?><td valign="top" class="td_mod_lst_desc"><?php ?><td valign="top" class="td_mod_lst_desc"><?php
} }
else else
{ {
?><td class="w160px"><?php ?><td class="w160px"><?php
} }
?><div class="diapo w160px" style="margin-bottom:0;border-bottom:none;"> ?><div class="diapo w160px" style="margin-bottom:0;border-bottom:none;">
<div class="title"><?php echo $title ?></div><?php <div class="title"><?php echo $title ?></div><?php
$status = ''; $status = '';
@@ -369,62 +388,62 @@ if (count($result->get_datas()) > 0)
$isImage = false; $isImage = false;
$isDocument = false; $isDocument = false;
if (!$isVideo && !$isAudio) if ( ! $isVideo && ! $isAudio)
{ {
$isImage = true; $isImage = true;
} }
?><table cellpadding="0" cellspacing="0" style="margin: 0pt auto;"><?php ?><table cellpadding="0" cellspacing="0" style="margin: 0pt auto;"><?php
?><tr class="h160px"><?php ?><tr class="h160px"><?php
?><td class="image w160px h160px"><?php ?><td class="image w160px h160px"><?php
if ($isVideo) if ($isVideo)
{ {
$duration = $record->get_formated_duration(); $duration = $record->get_formated_duration();
if ($duration != '') if ($duration != '')
echo '<div class="dmco_text duration">' . $duration . '</div>'; echo '<div class="dmco_text duration">' . $duration . '</div>';
} }
if ($isAudio) if ($isAudio)
{ {
$duration = $record->get_formated_duration(); $duration = $record->get_formated_duration();
if ($duration != '') if ($duration != '')
echo '<div class="dmco_text duration">' . $duration . '</div>'; echo '<div class="dmco_text duration">' . $duration . '</div>';
} }
$onclick = ""; $onclick = "";
if ($record->is_grouping()) if ($record->is_grouping())
{ {
$onclick = 'openPreview(\'REG\',0,\'' . $sbas_id . '_' . $record->get_record_id() . '\');'; $onclick = 'openPreview(\'REG\',0,\'' . $sbas_id . '_' . $record->get_record_id() . '\');';
} }
else else
{ {
$onclick = 'openPreview(\'RESULT\',' . $record->get_number() . ');'; $onclick = 'openPreview(\'RESULT\',' . $record->get_number() . ');';
} }
if ($mod_col == '1') if ($mod_col == '1')
$pic_roll = '/prod/tooltip/preview/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/'; $pic_roll = '/prod/tooltip/preview/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/';
else else
$pic_roll = '/prod/tooltip/caption/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/answer/'; $pic_roll = '/prod/tooltip/caption/' . $record->get_sbas_id() . '/' . $record->get_record_id() . '/answer/';
$pic_roll = str_replace(array('&', '"'), array('&amp;', '&quot;'), $pic_roll); $pic_roll = str_replace(array('&', '"'), array('&amp;', '&quot;'), $pic_roll);
?><img onclick="<?php echo $onclick ?>" class="<?php echo ($thumbnail->get_width() > $thumbnail->get_height()) ? 'hthbimg' : 'vthbimg' ?> captionTips" id="IMG<?php echo $record->get_base_id() ?>_<?php echo $record->get_record_id() ?>" src="<?php echo $thumbnail->get_url() ?>" tooltipsrc="<?php echo ($pic_roll) ?>" /> ?><img onclick="<?php echo $onclick ?>" class="<?php echo ($thumbnail->get_width() > $thumbnail->get_height()) ? 'hthbimg' : 'vthbimg' ?> captionTips" id="IMG<?php echo $record->get_base_id() ?>_<?php echo $record->get_record_id() ?>" src="<?php echo $thumbnail->get_url() ?>" tooltipsrc="<?php echo ($pic_roll) ?>" />
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>
<div class="diapo w160px" style="border-top:none;"><?php ?><div class="buttons"><?php <div class="diapo w160px" style="border-top:none;"><?php ?><div class="buttons"><?php
$minilogos = ""; $minilogos = "";
$minilogos .= '<div class="minilogos">' . collection::getLogo($record->get_base_id()); $minilogos .= '<div class="minilogos">' . collection::getLogo($record->get_base_id());
$minilogos .= '</div>'; $minilogos .= '</div>';
$sbas_id = $record->get_sbas_id(); $sbas_id = $record->get_sbas_id();
echo $minilogos; echo $minilogos;
if ( if (
$ACL->has_right_on_base($record->get_base_id(), 'candwnldpreview') || $ACL->has_right_on_base($record->get_base_id(), 'candwnldpreview') ||
$ACL->has_right_on_base($record->get_base_id(), 'candwnldhd') || $ACL->has_right_on_base($record->get_base_id(), 'candwnldhd') ||
$ACL->has_right_on_base($record->get_base_id(), 'cancmd') $ACL->has_right_on_base($record->get_base_id(), 'cancmd')
) )
{ {
?><div class="downloader" title="<?php echo _('action : exporter') ?>" onclick="evt_dwnl('<?php echo $sbas_id ?>_<?php echo $record->get_record_id() ?>');"></div><?php ?><div class="downloader" title="<?php echo _('action : exporter') ?>" onclick="evt_dwnl('<?php echo $sbas_id ?>_<?php echo $record->get_record_id() ?>');"></div><?php
} }
?> ?>
@@ -432,11 +451,11 @@ if (count($result->get_datas()) > 0)
<?php <?php
if ($ACL->has_right_on_base($record->get_base_id(), "canputinalbum")) if ($ACL->has_right_on_base($record->get_base_id(), "canputinalbum"))
{ {
?><div class="baskAdder" title="<?php echo _('action : ajouter au panier') ?>" onClick="evt_add_in_chutier('<?php echo $record->get_sbas_id() ?>', '<?php echo $record->get_record_id() ?>');"></div><?php ?><div class="baskAdder" title="<?php echo _('action : ajouter au panier') ?>" onClick="evt_add_in_chutier('<?php echo $record->get_sbas_id() ?>', '<?php echo $record->get_record_id() ?>');"></div><?php
} }
if ($mod_col != '1') if ($mod_col != '1')
{ {
?> ?>
<div style="margin-right:3px;" class="infoTips" id="INFO<?php echo $record->get_base_id() ?>_<?php echo $record->get_record_id() ?>" tooltipsrc="/prod/tooltip/tc_datas/<?php echo $record->get_sbas_id() ?>/<?php echo $record->get_record_id() ?>/"></div> <div style="margin-right:3px;" class="infoTips" id="INFO<?php echo $record->get_base_id() ?>_<?php echo $record->get_record_id() ?>" tooltipsrc="/prod/tooltip/tc_datas/<?php echo $record->get_sbas_id() ?>/<?php echo $record->get_record_id() ?>/"></div>
<?php <?php
try try
@@ -456,17 +475,17 @@ if (count($result->get_datas()) > 0)
?></div><?php ?></div><?php
?></div><?php ?></div><?php
?></td><?php ?></td><?php
if ($mod_col == 1) // 1X10 ou 1X100 if ($mod_col == 1) // 1X10 ou 1X100
{ {
?><td valign="top"><?php ?><td valign="top"><?php
?><div class="desc1"><?php ?><div class="desc1"><?php
?><div class="caption" class="desc2"><?php echo ($caption . '<hr/>' . $light_info) ?></div><?php ?><div class="caption" class="desc2"><?php echo ($caption . '<hr/>' . $light_info) ?></div><?php
?></div><?php ?></div><?php
?></td><?php ?></td><?php
}
$i++;
} }
$i ++;
}
?></tr> ?></tr>
</table> </table>
<script type="text/javascript"> <script type="text/javascript">
@@ -480,9 +499,9 @@ if (count($result->get_datas()) > 0)
</script> </script>
</div><?php </div><?php
} }
else else
{ {
?><div><?php echo _('reponses:: Votre recherche ne retourne aucun resultat'); ?></div><?php ?><div><?php echo _('reponses:: Votre recherche ne retourne aucun resultat'); ?></div><?php
phrasea::getHome('HELP', 'client'); phrasea::getHome('HELP', 'client');
} }

View File

@@ -28,7 +28,7 @@ $gatekeeper->require_session();
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms("lst", "obj", "ssttid", "type"); $parm = $request->get_parms("lst", "obj", "ssttid", "type", "businessfields");
$download = new set_export($parm['lst'], $parm['ssttid']); $download = new set_export($parm['lst'], $parm['ssttid']);
@@ -37,7 +37,7 @@ if ($parm["type"] == "title")
else else
$titre=false; $titre=false;
$list = $download->prepare_export($parm['obj'], $titre); $list = $download->prepare_export($parm['obj'], $titre, $parm['businessfields']);
$exportname = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999); $exportname = "Export_" . date("Y-n-d") . '_' . mt_rand(100, 999);

View File

@@ -54,7 +54,7 @@ if ($Request->get("ssttid", "") != "")
$download = new set_export($Request->get('lst', ''), $Request->get('ssttid', '')); $download = new set_export($Request->get('lst', ''), $Request->get('ssttid', ''));
$list = $download->prepare_export($Request->get('obj'), $titre); $list = $download->prepare_export($Request->get('obj'), $titre, $Request->get('businessfields'));
$list['export_name'] = $exportname . '.zip'; $list['export_name'] = $exportname . '.zip';
$list['email'] = $Request->get("destmail", ""); $list['email'] = $Request->get("destmail", "");

View File

@@ -15,11 +15,10 @@
* @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
*/ */
/* @var $Core \Alchemy\Phrasea\Core */ /* @var $Core \Alchemy\Phrasea\Core */
$Core = require_once __DIR__ . "/../../lib/bootstrap.php"; $Core = require_once __DIR__ . "/../../lib/bootstrap.php";
$appbox = appbox::get_instance($Core); $appbox = appbox::get_instance($Core);
$session = $appbox->get_session(); $session = $appbox->get_session();
$registry = $appbox->get_registry(); $registry = $appbox->get_registry();
$user = $Core->getAuthenticatedUser(); $user = $Core->getAuthenticatedUser();
@@ -27,7 +26,7 @@ $user = $Core->getAuthenticatedUser();
$output = ''; $output = '';
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms('action'); $parm = $request->get_parms('action');
$action = $parm['action']; $action = $parm['action'];
@@ -37,16 +36,41 @@ switch ($action)
$engine = new searchEngine_adapter_sphinx_engine(); $engine = new searchEngine_adapter_sphinx_engine();
$parm = $request->get_parms("bas", "term" $parm = $request->get_parms("bas", "term"
, "stemme" , "stemme"
, "search_type", "recordtype", "status", "fields", "datemin", "datemax", "datefield"); , "search_type", "recordtype", "status", "fields", "datemin", "datemax", "datefield");
$options = new searchEngine_options(); $options = new searchEngine_options();
$parm['bas'] = is_array($parm['bas']) ? $parm['bas'] : array_keys($user->ACL()->get_granted_base());
/* @var $user \User_Adapter */
if ($user->ACL()->has_right('modifyrecord'))
{
$options->set_business_fields(array());
$BF = array();
foreach ($user->ACL()->get_granted_base(array('canmodifrecord')) as $collection)
{
if (count($params['bases']) === 0 || in_array($collection->get_base_id(), $params['bases']))
{
$BF[] = $collection->get_base_id();
}
}
$options->set_business_fields($BF);
}
else
{
$options->set_business_fields(array());
}
$options->set_bases($parm['bas'], $user->ACL()); $options->set_bases($parm['bas'], $user->ACL());
if (!is_array($parm['fields'])) if ( !! is_array($parm['fields']))
$parm['fields'] = array(); $parm['fields'] = array();
$options->set_fields($parm['fields']); $options->set_fields($parm['fields']);
if (!is_array($parm['status'])) if ( ! is_array($parm['status']))
$parm['status'] = array(); $parm['status'] = array();
$options->set_status($parm['status']); $options->set_status($parm['status']);
$options->set_search_type($parm['search_type']); $options->set_search_type($parm['search_type']);
@@ -56,35 +80,33 @@ switch ($action)
$options->set_date_fields(explode('|', $parm['datefield'])); $options->set_date_fields(explode('|', $parm['datefield']));
$options->set_use_stemming($parm['stemme']); $options->set_use_stemming($parm['stemme']);
$engine->set_options($options); $engine->set_options($options);
$result = $engine->results($parm['term'], 0, 1); $result = $engine->results($parm['term'], 0, 1);
$res = $engine->get_suggestions($session, true); $res = $engine->get_suggestions($session, true);
// $res = array(array('id'=>'oui','label'=>'oui','value'=>'oui'));
$output = p4string::jsonencode($res); $output = p4string::jsonencode($res);
break; break;
case 'CSS': case 'CSS':
require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php');
$parm = $request->get_parms('color'); $parm = $request->get_parms('color');
$output = $user->setPrefs('css', $parm['color']); $output = $user->setPrefs('css', $parm['color']);
break; break;
case 'SAVETEMPPREF': case 'SAVETEMPPREF':
$parm = $request->get_parms('prop', 'value'); $parm = $request->get_parms('prop', 'value');
$session->set_session_prefs($parm['prop'], $parm['value']); $session->set_session_prefs($parm['prop'], $parm['value']);
$output = 1; $output = 1;
break; break;
case 'DELETE': case 'DELETE':
require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php');
$parm = $request->get_parms('lst'); $parm = $request->get_parms('lst');
$output = whatCanIDelete($parm['lst']); $output = whatCanIDelete($parm['lst']);
break; break;
case 'DODELETE': case 'DODELETE':
require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php'); require ($registry->get('GV_RootPath') . 'lib/classes/deprecated/prodUtils.php');
$parm = $request->get_parms('lst', 'del_children'); $parm = $request->get_parms('lst', 'del_children');
$output = deleteRecord($parm['lst'], $parm['del_children']); $output = deleteRecord($parm['lst'], $parm['del_children']);
break; break;
@@ -92,19 +114,19 @@ switch ($action)
try try
{ {
$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$parm = $request->get_parms('notifications'); $parm = $request->get_parms('notifications');
$output = $evt_mngr->read(explode('_', $parm['notifications']), $session->get_usr_id()); $output = $evt_mngr->read(explode('_', $parm['notifications']), $session->get_usr_id());
$output = p4string::jsonencode(array('error' => false, 'message' => '')); $output = p4string::jsonencode(array('error' => false, 'message' => ''));
} }
catch (Exception $e) catch (Exception $e)
{ {
$output = p4string::jsonencode(array('error' => true, 'message' => $e->getMessage())); $output = p4string::jsonencode(array('error' => true, 'message' => $e->getMessage()));
} }
break; break;
case 'NOTIFICATIONS_FULL': case 'NOTIFICATIONS_FULL':
$evt_mngr = eventsmanager_broker::getInstance($appbox, $Core); $evt_mngr = eventsmanager_broker::getInstance($appbox, $Core);
$parm = $request->get_parms('page'); $parm = $request->get_parms('page');
$output = $evt_mngr->get_json_notifications($parm['page']); $output = $evt_mngr->get_json_notifications($parm['page']);
break; break;
@@ -112,9 +134,9 @@ switch ($action)
case 'VIDEOTOKEN': case 'VIDEOTOKEN':
$parm = $request->get_parms('sbas_id', 'record_id'); $parm = $request->get_parms( ! 'sbas_id', 'record_id');
$sbas_id = (int) $parm['sbas_id']; $sbas_id = (int) $parm['sbas_id'];
$record = new record_adapter($sbas_id, $parm['record_id']); $record = new record_adapter($sbas_id, $parm['record_id']);
$output = p4string::jsonencode(array('url' => $record->get_preview()->renew_url())); $output = p4string::jsonencode(array('url' => $record->get_preview()->renew_url()));
break; break;
@@ -125,46 +147,46 @@ switch ($action)
$parm = $request->get_parms('pos', 'record_id', 'options_serial', 'query'); $parm = $request->get_parms('pos', 'record_id', 'options_serial', 'query');
$search_engine = null; $search_engine = null;
if (($options = unserialize($parm['options_serial'])) !== false) if (($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);
} }
$record = new record_preview('RESULT', $parm['pos'], '', '', $search_engine, $parm['query']); $record = new record_preview('RESULT', $parm['pos'], '', '', $search_engine, $parm['query']);
$records = $record->get_train($parm['pos'], $parm['query'], $search_engine); $records = $record->get_train($parm['pos'], $parm['query'], $search_engine);
$core = \bootstrap::getCore(); $core = \bootstrap::getCore();
$twig = $core->getTwig(); $twig = $core->getTwig();
$output = p4string::jsonencode( $output = p4string::jsonencode(
array('current' => array('current' =>
$twig->render( $twig->render(
'prod/preview/result_train.html', array( 'prod/preview/result_train.html', array(
'records' => $records 'records' => $records
, 'selected' => $parm['pos']) , 'selected' => $parm['pos'])
) )
) )
); );
break; break;
case 'REGTRAIN': case 'REGTRAIN':
$parm = $request->get_parms('cont', 'pos'); $parm = $request->get_parms('cont', 'pos');
$record = new record_preview('REG', $parm['pos'], $parm['cont']); $record = new record_preview('REG', $parm['pos'], $parm['cont']);
$output = $twig->render('prod/preview/reg_train.html', array('container_records' => $record->get_container()->get_children(), $output = $twig->render('prod/preview/reg_train.html', array('container_records' => $record->get_container()->get_children(),
'record' => $record)); 'record' => $record));
break; break;
case 'GET_ORDERMANAGER': case 'GET_ORDERMANAGER':
try try
{ {
$parm = $request->get_parms('sort', 'page'); $parm = $request->get_parms('sort', 'page');
$orders = new set_ordermanager($parm['sort'], $parm['page']); $orders = new set_ordermanager($parm['sort'], $parm['page']);
$core = \bootstrap::getCore(); $core = \bootstrap::getCore();
$twig = $core->getTwig(); $twig = $core->getTwig();
$render = $twig->render('prod/orders/order_box.twig', array('ordermanager' => $orders)); $render = $twig->render('prod/orders/order_box.twig', array('ordermanager' => $orders));
$ret = array('error' => false, 'datas' => $render); $ret = array('error' => false, 'datas' => $render);
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -177,14 +199,14 @@ switch ($action)
case 'GET_ORDER': case 'GET_ORDER':
try try
{ {
$parm = $request->get_parms('order_id'); $parm = $request->get_parms('order_id');
$order = new set_order($parm['order_id']); $order = new set_order($parm['order_id']);
$core = \bootstrap::getCore(); $core = \bootstrap::getCore();
$twig = $core->getTwig(); $twig = $core->getTwig();
$render = $twig->render('prod/orders/order_item.twig', array('order' => $order)); $render = $twig->render('prod/orders/order_item.twig', array('order' => $order));
$ret = array('error' => false, 'datas' => $render); $ret = array('error' => false, 'datas' => $render);
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -197,10 +219,10 @@ switch ($action)
case 'SEND_ORDER': case 'SEND_ORDER':
try try
{ {
$parm = $request->get_parms('order_id', 'elements', 'force'); $parm = $request->get_parms('order_id', 'elements', 'force');
$order = new set_order($parm['order_id']); $order = new set_order($parm['order_id']);
$order->send_elements($parm['elements'], $parm['force']); $order->send_elements($parm['elements'], $parm['force']);
$ret = array('error' => false, 'datas' => ''); $ret = array('error' => false, 'datas' => '');
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -213,10 +235,10 @@ switch ($action)
case 'DENY_ORDER': case 'DENY_ORDER':
try try
{ {
$parm = $request->get_parms('order_id', 'elements'); $parm = $request->get_parms('order_id', 'elements');
$order = new set_order($parm['order_id']); $order = new set_order($parm['order_id']);
$order->deny_elements($parm['elements']); $order->deny_elements($parm['elements']);
$ret = array('error' => false, 'datas' => ''); $ret = array('error' => false, 'datas' => '');
} }
catch (Exception $e) catch (Exception $e)
{ {
@@ -229,16 +251,16 @@ switch ($action)
case "ORDER": case "ORDER":
$parm = $request->get_parms('lst', 'ssttid', 'use', 'deadline'); $parm = $request->get_parms('lst', 'ssttid', 'use', 'deadline');
$order = new set_exportorder($parm['lst'], $parm['ssttid']); $order = new set_exportorder($parm['lst'], $parm['ssttid']);
if ($order->order_available_elements($session->get_usr_id(), $parm['use'], $parm['deadline'])) if ($order->order_available_elements($session->get_usr_id(), $parm['use'], $parm['deadline']))
{ {
$ret = array('error' => false, 'message' => _('les enregistrements ont ete correctement commandes')); $ret = array('error' => false, 'message' => _('les enregistrements ont ete correctement commandes'));
} }
else else
{ {
$ret = array('error' => true, 'message' => _('Erreur lors de la commande des enregistrements')); $ret = array('error' => true, 'message' => _('Erreur lors de la commande des enregistrements'));
} }
$output = p4string::jsonencode($ret); $output = p4string::jsonencode($ret);
@@ -247,63 +269,80 @@ switch ($action)
case "FTP_EXPORT": case "FTP_EXPORT":
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms( $parm = $request->get_parms(
"addr" // addr du srv ftp "addr" // addr du srv ftp
, "login" // login ftp , "login" // login ftp
, "pwd" // pwd ftp , "pwd" // pwd ftp
, "passif" // mode passif ou non , "passif" // mode passif ou non
, "nbretry" // nb retry , "nbretry" // nb retry
, "ssl" // nb retry , "ssl" // nb retry
, "obj" // les types d'obj a exporter , "obj" // les types d'obj a exporter
, "destfolder"// le folder de destination , "destfolder"// le folder de destination
, "usr_dest" // le mail dudestinataire ftp , "usr_dest" // le mail dudestinataire ftp
, "lst" // la liste des objets , "lst" // la liste des objets
, "ssttid" , "ssttid"
, "sendermail" , "sendermail"
, "namecaract" , "namecaract"
, "NAMMKDFOLD" , "NAMMKDFOLD"
, "logfile" , "logfile"
, "businessfields"
); );
$download = new set_exportftp($parm['lst'], $parm['ssttid']); $download = new set_exportftp($parm['lst'], $parm['ssttid']);
if (count($download->get_display_ftp()) == 0) if (count($download->get_display_ftp()) == 0)
{ {
$output = p4string::jsonencode(array('error' => true, 'message' => _('Les documents ne peuvent etre envoyes par FTP'))); $output = p4string::jsonencode(array('error' => true, 'message' => _('Les documents ne peuvent etre envoyes par FTP')));
} }
else else
{ {
try try
{ {
$download->prepare_export($parm['obj']); $download->prepare_export($parm['obj'], false, $parm['businessfields']);
$download->export_ftp($parm['usr_dest'], $parm['addr'], $parm['login'], $parm['pwd'], $parm['ssl'], $parm['nbretry'], $parm['passif'], $parm['destfolder'], $parm['NAMMKDFOLD'], $parm['logfile']); $download->export_ftp(
$parm['usr_dest']
, $parm['addr']
, $parm['login']
, $parm['pwd']
, $parm['ssl']
, $parm['nbretry']
, $parm['passif']
, $parm['destfolder']
, $parm['NAMMKDFOLD']
, $parm['logfile']
);
$output = p4string::jsonencode(array('error' => false, 'message' => _('Export enregistre dans la file dattente'))); $out = array(
'error' => false
, 'message' => _('Export enregistre dans la file dattente')
);
$output = p4string::jsonencode($out);
} }
catch (Exception $e) catch (Exception $e)
{ {
$output = p4string::jsonencode(array('error' => true, 'message' => $e->getMessage())); $output = p4string::jsonencode(array('error' => true, 'message' => $e->getMessage()));
} }
} }
break; break;
case "FTP_TEST": case "FTP_TEST":
$request = http_request::getInstance(); $request = http_request::getInstance();
$parm = $request->get_parms( $parm = $request->get_parms(
"addr" // addr du srv ftp "addr" // addr du srv ftp
, "login" // login ftp , "login" // login ftp
, "pwd" // pwd ftp , "pwd" // pwd ftp
, "ssl" // nb retry , "ssl" // nb retry
); );
$ssl = $parm['ssl'] == '1'; $ssl = $parm['ssl'] == '1';
try try
{ {
$ftp_client = new ftpclient($parm['addr'], 21, 90, $ssl = false); $ftp_client = new ftpclient($parm['addr'], 21, 90, $ssl = false);
$ftp_client->login($parm['login'], $parm['pwd']); $ftp_client->login($parm['login'], $parm['pwd']);
$ftp_client->close(); $ftp_client->close();
$output = _('Connection au FTP avec succes'); $output = _('Connection au FTP avec succes');
} }
catch (Exception $e) catch (Exception $e)
{ {

4329
www/testextension3.php Normal file

File diff suppressed because it is too large Load Diff