Merge with master

This commit is contained in:
jygaulier
2012-03-07 11:22:08 +01:00
157 changed files with 2915 additions and 1509 deletions

View File

@@ -34,4 +34,4 @@ return call_user_func(
});
return $app;
});
});

View File

@@ -58,6 +58,7 @@ return call_user_func(
{
$browser = Browser::getInstance();
if (!$browser->isMobile())
return new Response('');
$twig = new supertwig();

View File

@@ -70,10 +70,11 @@ return call_user_func(function()
return new response($twig->render('/prod/actions/Bridge/deactivated.twig', $params), 200);
}
return new response($twig->render('/prod/actions/Bridge/error.twig', $params), 200);
}
});
return $app;
});
});

View File

@@ -34,10 +34,13 @@ return call_user_func(function()
{
$browser = Browser::getInstance();
if ($browser->isMobile())
return $app->redirect("/login/?redirect=/lightbox");
elseif ($browser->isNewGeneration())
return $app->redirect("/login/?redirect=/prod");
else
return $app->redirect("/login/?redirect=/client");
});
@@ -70,6 +73,7 @@ return call_user_func(function()
/**
* Mount all aps
*/
return $app;
}
);
);

View File

@@ -49,8 +49,10 @@ return call_user_func(function()
$app->get('/', function() use ($app)
{
if ($app['install'] === true)
return $app->redirect('/setup/installer/');
if ($app['upgrade'] === true)
return $app->redirect('/setup/upgrader/');
});
@@ -63,6 +65,7 @@ return call_user_func(function()
$app->error(function($e) use ($app)
{
if ($e instanceof Exception_Setup_PhraseaAlreadyInstalled)
return $app->redirect('/login');
return new Response(
@@ -77,4 +80,4 @@ return call_user_func(function()
});
return $app;
});
});

View File

@@ -77,6 +77,7 @@ class module_admin
);
$twig = new supertwig();
return $twig->render('admin/tree.html.twig', $params);
}

View File

@@ -43,6 +43,43 @@ class module_admin_route_users
return $this;
}
public function export(Symfony\Component\HttpFoundation\Request $request)
{
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$offset_start = (int) $request->get('offset_start');
$offset_start = $offset_start < 0 ? 0 : $offset_start;
$this->query_parms = array(
'inactives' => $request->get('inactives')
, 'like_field' => $request->get('like_field')
, 'like_value' => $request->get('like_value')
, 'sbas_id' => $request->get('sbas_id')
, 'base_id' => $request->get('base_id')
, 'srt' => $request->get("srt", User_Query::SORT_CREATIONDATE)
, 'ord' => $request->get("ord", User_Query::ORD_DESC)
, 'offset_start' => 0
);
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$query = new User_Query($appbox);
if (is_array($this->query_parms['base_id']))
$query->on_base_ids($this->query_parms['base_id']);
elseif (is_array($this->query_parms['sbas_id']))
$query->on_sbas_ids($this->query_parms['sbas_id']);
$this->results = $query->sort_by($this->query_parms["srt"], $this->query_parms["ord"])
->like($this->query_parms['like_field'], $this->query_parms['like_value'])
->get_inactives($this->query_parms['inactives'])
->include_templates(false)
->on_bases_where_i_am($user->ACL(), array('canadmin'))
->execute();
return $this->results->get_results();
}
public function search(Symfony\Component\HttpFoundation\Request $request)
{
$appbox = appbox::get_instance();
@@ -106,8 +143,8 @@ class module_admin_route_users
if (is_null($v))
$this->query_parms[$k] = false;
}
$query = new User_Query($appbox);
$templates = $query
->only_templates(true)

View File

@@ -183,7 +183,7 @@ class module_admin_route_users_edit
$templates = $query
->only_templates(true)
->execute()->get_results();
$this->users_datas = $rs;
$out = array(
'datas' => $this->users_datas,
@@ -543,10 +543,10 @@ class module_admin_route_users_edit
}
$users = $this->users;
$user = User_adapter::getInstance(array_pop($users), appbox::get_instance());
if ($user->is_template())
if ($user->is_template() || $user->is_special())
{
return $this;
}
@@ -572,7 +572,7 @@ class module_admin_route_users_edit
$parm = $request->get_parms_from_serialized_datas($infos, 'user_infos');
if (!mail::validateEmail($parm['email']))
if ($parm['email'] && !mail::validateEmail($parm['email']))
throw new Exception_InvalidArgument(_('Email addess is not valid'));
$user->set_firstname($parm['first_name'])
@@ -594,29 +594,29 @@ class module_admin_route_users_edit
{
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$template = \User_adapter::getInstance($this->request->get('template'), $appbox);
if ($template->get_template_owner()->get_id() != $session->get_usr_id())
{
throw new \Exception_Forbidden('You are not the owner of the template');
}
$current_user = \User_adapter::getInstance($session->get_usr_id(), $appbox);
$base_ids = array_keys($current_user->ACL()->get_granted_base(array('canadmin')));
foreach ($this->users as $usr_id)
{
$user = \User_adapter::getInstance($usr_id, $appbox);
if($user->is_template())
{
continue;
}
$user->ACL()->apply_model($template, $base_ids);
}
return $this;
}

View File

@@ -338,7 +338,7 @@ return call_user_func(function()
}
catch (Exception $e)
{
}
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -367,7 +367,7 @@ return call_user_func(function()
}
catch (Exception $e)
{
}
return new response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -387,7 +387,7 @@ return call_user_func(function()
}
catch (Exception $e)
{
}
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -405,7 +405,7 @@ return call_user_func(function()
}
catch (Exception $e)
{
}
return new Response(json_encode($result), 200, array("content-type" => "application/json"));
@@ -430,4 +430,4 @@ return call_user_func(function()
return $app;
});
});

View File

@@ -1,4 +1,4 @@
<?php
<?php
/*
* This file is part of Phraseanet
@@ -29,7 +29,7 @@ use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception;
return call_user_func(function(){
$app = new Silex\Application();
@@ -42,7 +42,7 @@ $app["appbox"] = appbox::get_instance();
$app['p4user'] = null;
/**
* @var API_OAuth2_Token
* @var API_OAuth2_Token
*/
$app['token'] = null;
@@ -121,6 +121,7 @@ $parseRoute = function ($route, Response $response)
}
}
}
return array('ressource' => $ressource, 'general' => $general, 'aspect' => $aspect, 'action' => $action);
};
@@ -139,6 +140,7 @@ $app->before(function($request) use ($app)
$app['token'] = API_OAuth2_Token::load_by_oauth_token($app["appbox"], $oauth2_adapter->getToken());
if ($session->is_authenticated())
return;
if ($oauth2_adapter->has_ses_id())
{
@@ -150,7 +152,7 @@ $app->before(function($request) use ($app)
}
catch (\Exception $e)
{
}
}
$auth = new Session_Authentication_None($app['p4user']);
@@ -171,7 +173,7 @@ $app->after(function (Request $request, Response $response) use ($app, $parseRou
$route = $parseRoute($pathInfo, $response);
$log = API_V1_Log::create(
$app["appbox"],
$account,
$account,
$request->getMethod() . " " . $pathInfo,
$response->getStatusCode(),
$response->headers->get('content-type'),
@@ -659,7 +661,7 @@ $app->get('/feeds/{wrong_feed_id}/content/', $bad_request_exception);
*/
$app->error(function (\Exception $e) use ($app)
{
if ($e instanceof API_V1_exception_methodnotallowed)
$code = API_V1_result::ERROR_METHODNOTALLOWED;
elseif ($e instanceof Exception\MethodNotAllowedHttpException)
@@ -745,4 +747,4 @@ $app->error(function (\Exception $e) use ($app)
//// public function add_user(\Symfony\Component\HttpFoundation\Request $app['request']);
return $app;
});
});

View File

@@ -46,14 +46,14 @@ class module_console_systemUpgrade extends Command
$output->writeln('This version of Phraseanet requires a config/config.inc');
$output->writeln('Would you like it to be created based on your settings ?');
$dialog = $this->getHelperSet()->get('dialog');
do
{
$continue = mb_strtolower($dialog->ask($output, '<question>' . _('Create automatically') . ' (Y/n)</question>', 'y'));
}
while (!in_array($continue, array('y', 'n')));
if ($continue == 'y')
{
require __DIR__ . "/../../../../config/_GV.php";
@@ -64,16 +64,16 @@ class module_console_systemUpgrade extends Command
.'$debug=false;'."\n"
.'$debug=true;'."\n"
.'';
file_put_contents(__DIR__ . "/../../../../config/config.inc", $datas);
}
else
{
{
throw new RuntimeException('Phraseanet is not set up');
}
}
}
require_once dirname(__FILE__) . '/../../../../lib/bootstrap.php';

View File

@@ -70,12 +70,12 @@ class module_prod
$name = $meta->get_name();
if ($meta->get_type() == 'date')
{
if (isset($dates[$id]))
$dates[$id]['sbas'][] = $sbas_id;
if (isset($dates[$name]))
$dates[$name]['sbas'][] = $sbas_id;
else
$dates[$id] = array('sbas' => array($sbas_id), 'fieldname' => $name);
$dates[$name] = array('sbas' => array($sbas_id), 'fieldname' => $name);
}
if (isset($fields[$name]))
{
$fields[$name]['sbas'][] = $sbas_id;

View File

@@ -46,7 +46,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
*
* @var Array
*/
protected $javascript_elements;
protected $javascript_elements = array();
/**
*
@@ -59,9 +59,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
* @var boolean
*/
protected $works_on_unique_sbas = true;
protected $has_thesaurus = false;
protected $has_thesaurus = false;
public function __construct(Symfony\Component\HttpFoundation\Request $request)
{
@@ -72,7 +70,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
if ($this->is_single_grouping())
{
$record = array_pop($this->selection->get_elements());
$record = array_pop($this->selection->get_elements());
$children = $record->get_children();
foreach ($children as $child)
{
@@ -85,9 +83,9 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
if ($this->is_possible())
{
$this->generate_javascript_fields()
->generate_javascript_sugg_values()
->generate_javascript_status()
->generate_javascript_elements();
->generate_javascript_sugg_values()
->generate_javascript_status()
->generate_javascript_elements();
}
return $this;
@@ -181,19 +179,19 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
protected function generate_javascript_elements()
{
$_lst = array();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$twig = new supertwig();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$twig = new supertwig();
foreach ($this->selection as $record)
{
$indice = $record->get_number();
$indice = $record->get_number();
$_lst[$indice] = array(
'bid' => $record->get_base_id(),
'rid' => $record->get_record_id(),
'sselcont_id' => null,
'_selected' => false
'bid' => $record->get_base_id(),
'rid' => $record->get_record_id(),
'sselcont_id' => null,
'_selected' => false
);
$_lst[$indice]['statbits'] = array();
@@ -201,12 +199,12 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
{
foreach ($this->javascript_status as $n => $s)
{
$tmp_val = substr(strrev($record->get_status()), $n, 1);
$tmp_val = substr(strrev($record->get_status()), $n, 1);
$_lst[$indice]['statbits'][$n]['value'] = ($tmp_val == '1') ? '1' : '0';
$_lst[$indice]['statbits'][$n]['dirty'] = false;
}
}
$_lst[$indice]['fields'] = array();
$_lst[$indice]['fields'] = array();
$_lst[$indice]['originalname'] = '';
$_lst[$indice]['originalname'] = $record->get_original_name();
@@ -220,22 +218,22 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
}
$_lst[$indice]['fields'][$meta_struct_id] = array(
'dirty' => false,
'meta_id' => $field->get_meta_id(),
'meta_struct_id' => $meta_struct_id,
'value' => $field->get_value()
'dirty' => false,
'meta_id' => $field->get_meta_id(),
'meta_struct_id' => $meta_struct_id,
'value' => $field->get_value()
);
}
$_lst[$indice]['subdefs'] = array('thumbnail' => null, 'preview' => null);
$_lst[$indice]['subdefs'] = array('thumbnail' => null, 'preview' => null);
$thumbnail = $record->get_thumbnail();
$_lst[$indice]['subdefs']['thumbnail'] = array(
'url' => $thumbnail->get_url()
, 'w' => $thumbnail->get_width()
, 'h' => $thumbnail->get_height()
'url' => $thumbnail->get_url()
, 'w' => $thumbnail->get_width()
, 'h' => $thumbnail->get_height()
);
$_lst[$indice]['preview'] = $twig->render('common/preview.html', array('record' => $record));
@@ -268,16 +266,16 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
foreach ($this->selection as $record)
{
/* @var $record record_adapter */
$base_id = $record->get_base_id();
$base_id = $record->get_base_id();
$record_id = $record->get_record_id();
$databox = $record->get_databox();
$databox = $record->get_databox();
if (isset($done[$base_id]))
continue;
$T_sgval['b' . $base_id] = array();
$collection = collection::get_from_base_id($base_id);
if ($sxe = simplexml_load_string($collection->get_prefs()))
{
$z = $sxe->xpath('/baseprefs/sugestedValues');
@@ -287,7 +285,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
foreach ($z[0] as $ki => $vi) // les champs
{
$field = $databox->get_meta_structure()->get_element_by_name($ki);
if (!$field)
continue; // champ inconnu dans la structure ?
@@ -298,12 +296,12 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
foreach ($vi->value as $oneValue) // les valeurs sug
{
$T_sgval['b' . $base_id][$field->get_id()][] =
(string) $oneValue;
(string) $oneValue;
}
}
}
unset($collection);
$done[$base_id] = true;
$done[$base_id] = true;
}
$this->javascript_sugg_values = $T_sgval;
@@ -318,9 +316,9 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
protected function generate_javascript_status()
{
$_tstatbits = array();
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
$user = User_Adapter::getInstance($session->get_usr_id(), $appbox);
if ($user->ACL()->has_right('changestatus'))
{
@@ -330,11 +328,11 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
foreach ($status[$this->get_sbas_id()] as $n => $statbit)
{
$_tstatbits[$n] = array();
$_tstatbits[$n]['label0'] = $statbit['labeloff'];
$_tstatbits[$n]['label1'] = $statbit['labelon'];
$_tstatbits[$n]['label0'] = $statbit['labeloff'];
$_tstatbits[$n]['label1'] = $statbit['labelon'];
$_tstatbits[$n]['img_off'] = $statbit['img_off'];
$_tstatbits[$n]['img_on'] = $statbit['img_on'];
$_tstatbits[$n]['_value'] = 0;
$_tstatbits[$n]['img_on'] = $statbit['img_on'];
$_tstatbits[$n]['_value'] = 0;
}
}
}
@@ -351,11 +349,11 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
*/
protected function generate_javascript_fields()
{
$_tfields = $fields = array();
$_tfields = $fields = array();
$this->has_thesaurus = false;
$databox = databox::get_instance($this->get_sbas_id());
$databox = databox::get_instance($this->get_sbas_id());
$meta_struct = $databox->get_meta_structure();
foreach ($meta_struct as $meta)
@@ -376,19 +374,19 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
switch ($meta->get_type())
{
case 'datetime':
$format = _('phraseanet::technique::datetime-edit-format');
$format = _('phraseanet::technique::datetime-edit-format');
$explain = _('phraseanet::technique::datetime-edit-explain');
break;
case 'date':
$format = _('phraseanet::technique::date-edit-format');
$format = _('phraseanet::technique::date-edit-format');
$explain = _('phraseanet::technique::date-edit-explain');
break;
case 'time':
$format = _('phraseanet::technique::time-edit-format');
$format = _('phraseanet::technique::time-edit-format');
$explain = _('phraseanet::technique::time-edit-explain');
break;
default:
$format = $explain = "";
$format = $explain = "";
break;
}
@@ -398,22 +396,22 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
$separator = $meta->get_separator();
$datas = array(
'meta_struct_id' => $meta->get_id()
, 'name' => $meta->get_name()
, '_status' => 0
, '_value' => ''
, '_sgval' => array()
, 'required' => $meta->is_required()
, 'readonly' => $meta->is_readonly()
, 'type' => $meta->get_type()
, 'format' => $format
, 'explain' => $explain
, 'tbranch' => $meta->get_tbranch()
, 'maxLength' => $meta->get_source()->maxlength()
, 'minLength' => $meta->get_source()->minLength()
, 'regfield' => $regfield
, 'multi' => $meta->is_multi()
, 'separator' => $separator
'meta_struct_id' => $meta->get_id()
, 'name' => $meta->get_name()
, '_status' => 0
, '_value' => ''
, '_sgval' => array()
, 'required' => $meta->is_required()
, 'readonly' => $meta->is_readonly()
, 'type' => $meta->get_type()
, 'format' => $format
, 'explain' => $explain
, 'tbranch' => $meta->get_tbranch()
, 'maxLength' => $meta->get_source()->maxlength()
, 'minLength' => $meta->get_source()->minLength()
, 'regfield' => $regfield
, 'multi' => $meta->is_multi()
, 'separator' => $separator
);
if (trim($meta->get_tbranch()) !== '')
@@ -435,7 +433,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
{
try
{
$reg_record = $this->get_grouping_head();
$reg_record = $this->get_grouping_head();
$reg_sbas_id = $reg_record->get_sbas_id();
$newsubdef_reg = new record_adapter($reg_sbas_id, $request->get('newrepresent'));
@@ -445,14 +443,14 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
foreach ($newsubdef_reg->get_subdefs() as $name => $value)
{
$pathfile = $value->get_pathfile();
$pathfile = $value->get_pathfile();
$system_file = new system_file($pathfile);
$reg_record->substitute_subdef($name, $system_file);
}
}
catch (Exception $e)
{
}
}
@@ -460,11 +458,11 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
return $this;
$sbas_id = (int) $request->get('sbid');
$databox = databox::get_instance($sbas_id);
$meta_struct = $databox->get_meta_structure();
$sbas_id = (int) $request->get('sbid');
$databox = databox::get_instance($sbas_id);
$meta_struct = $databox->get_meta_structure();
$write_edit_el = false;
$date_obj = new DateTime();
$date_obj = new DateTime();
foreach ($meta_struct->get_elements() as $meta_struct_el)
{
if ($meta_struct_el->get_metadata_namespace() == "PHRASEANET" && $meta_struct_el->get_metadata_tagname() == 'tf-editdate')
@@ -490,7 +488,7 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
if (!array_key_exists($key, $elements))
continue;
$statbits = $rec['status'];
$statbits = $rec['status'];
$editDirty = $rec['edit'];
if ($editDirty == '0')
@@ -509,22 +507,22 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
$field = array_pop($fields);
$metas = array(
array(
'meta_struct_id' => $write_edit_el->get_id()
, 'meta_id' => ($field ? $field->get_meta_id() : null)
, 'value' => array($date_obj->format('Y-m-d h:i:s'))
)
array(
'meta_struct_id' => $write_edit_el->get_id()
, 'meta_id' => ($field ? $field->get_meta_id() : null)
, 'value' => array($date_obj->format('Y-m-d h:i:s'))
)
);
$record->set_metadatas($metas);
$record->set_metadatas($metas, true);
}
$newstat = $record->get_status();
$newstat = $record->get_status();
$statbits = ltrim($statbits, 'x');
if (!in_array($statbits, array('', 'null')))
{
$mask_and = ltrim(str_replace(
array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
array('x', '0', '1', 'z'), array('1', 'z', '0', '1'), $statbits), '0');
if ($mask_and != '')
$newstat = databox_status::operation_and_not($newstat, $mask_and);
@@ -541,14 +539,14 @@ class module_prod_route_records_edit extends module_prod_route_records_abstract
if ($statbits != '')
{
$appbox->get_session()
->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_STATUS, '', '');
->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_STATUS, '', '');
}
if ($editDirty)
{
$appbox->get_session()
->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_EDIT, '', '');
->get_logger($record->get_databox())
->log($record, Session_Logger::EVENT_EDIT, '', '');
}
}

View File

@@ -23,171 +23,205 @@ class module_report
* @var string - timestamp
*/
protected $dmin;
/**
* End date of the report
* @var string - timestamp
*/
protected $dmax;
/**
* Id of the base we want to connect
* @var int
*/
protected $sbas_id;
/**
* Id of the current app's box user
* @var int
*/
protected $user_id;
/**
* The result of the report
* @var array
*/
public $report = array();
/**
* The title of the report
* @var string
*/
protected $title = '';
/**
* default displayed value in the formated tab
* @var array
*/
protected $display = array();
/**
* ?
* @var <array>
*/
protected $default_display = array();
/**
* Contain all the field from the sql request
* @var array
*/
protected $champ = array();
/**
* result of the report
* @var array
*/
protected $result = array();
/**
* The id of all collections from a databox
* @var string
*/
protected $list_coll_id = '';
/**
* The number of record displayed by page if enable limit is false
* @var int
*/
protected $nb_record = 30;
/**
* The current number of the page where are displaying the results
* @var int
*/
protected $nb_page = 1;
/**
* check if there is a previous page
* @var <bool>
*/
protected $previous_page = false;
/**
* check if there is a next page
* @var <bool>
*/
protected $next_page = false;
/**
*
* @var int total of result
*/
protected $total = 0;
/**
* the request executed
*/
protected $req = '';
/**
* the request executed
*/
protected $params = array();
/**
* do we display next and previous button
* @var bool
*/
protected $display_nav = false;
/**
* do we display the configuration button
* @var <bool>
*/
protected $config = true;
/**
* gettext tags for days
* @var <array>
*/
protected $jour;
/**
* gettext tags for month
* @var <array>
*/
protected $month;
/**
* The name of the database
* @var string
*/
protected $dbname;
/**
* The periode displayed in a string of the report
* @var string
*/
protected $periode;
/**
* filter executed on report choose by the user
* @var array;
*/
protected $tab_filter = array();
/**
* column displayed in the report choose by the user
* @var <array>
*/
protected $active_column = array();
/**
* array that contains the string displayed
* foreach filters
* @var <array>
*/
protected $posting_filter = array();
/**
* The ORDER BY filters of the query
* by default is empty
* @var array
*/
protected $tab_order = array();
/**
* define columns that are boundable
* @var <array>
*/
protected $bound = array();
/**
* do we display print button
* @var <bool>
*/
protected $print = true;
/**
* do we display csv button
* @var <bool>
*/
protected $csv = true;
/**
* do we enable limit filter for the report
* @var bool
*/
protected $enable_limit = true;
/**
* gettext correspondance for all available columns in report
* @var array
*/
protected $cor = array();
/**
* group result of a report this is the name ogf the grouped column
* @var string
*/
protected $groupby;
/**
* disbale or enable pretty string useful for export in csv
* @var boolean
@@ -197,9 +231,8 @@ class module_report
/**
*
*/
protected $cor_query = array();/* ~*~*~*~*~*~*~*~*~*~*~*~ */
/* METHODS, VARIABLES */
/* ~*~*~*~*~*~*~*~*~*~*~*~ */
protected $cor_query = array();
protected $isInformative;
/**
* Constructor
@@ -212,7 +245,7 @@ class module_report
*/
public function __construct($d1, $d2, $sbas_id, $collist)
{
$appbox = appbox::get_instance();
$appbox = appbox::get_instance();
$session = $appbox->get_session();
$this->dmin = $d1;
$this->dmax = $d2;
@@ -220,13 +253,23 @@ class module_report
$this->list_coll_id = $collist;
$this->user_id = $session->get_usr_id();
$this->periode = phraseadate::getPrettyString(new DateTime($d1))
. ' - ' . phraseadate::getPrettyString(new DateTime($d2));
. ' - ' . phraseadate::getPrettyString(new DateTime($d2));
$this->dbname = phrasea::sbas_names($sbas_id);
$this->cor = $this->setCor();
$this->jour = $this->setDay();
$this->month = $this->setMonth();
}
public function IsInformative()
{
return $this->isInformative;
}
public function setIsInformative($isInformative)
{
$this->isInformative = $isInformative;
}
public function getUser_id()
{
return $this->user_id;
@@ -242,7 +285,6 @@ class module_report
$this->user_id = $user_id;
}
public function getSbas_id()
{
return $this->sbas_id;
@@ -253,7 +295,7 @@ class module_report
$this->sbas_id = $sbas_id;
}
public function setPrettyString($bool)
public function setPrettyString($bool)
{
$this->pretty_string = $bool;
}
@@ -301,8 +343,6 @@ class module_report
$this->req = $sql;
}
public function getPeriode()
{
return $this->periode;
@@ -342,9 +382,9 @@ class module_report
public function setActiveColumn(array $active_column)
{
$this->active_column = $active_column;
$this->active_column = $active_column;
return $this;
return $this;
}
public function getActiveColumn()
@@ -509,6 +549,7 @@ class module_report
{
$this->total = $total;
}
public function getDefault_display()
{
return $this->default_display;
@@ -524,7 +565,6 @@ class module_report
return $this->champ;
}
/**
* Retourne un objet qui genere la requete selon le type de report
* @param string $domain
@@ -619,28 +659,28 @@ class module_report
private function setCor()
{
return array(
'user' => _('report:: utilisateur'),
'coll_id' => _('report:: collections'),
'connexion' => _('report:: Connexion'),
'comment' => _('report:: commentaire'),
'search' => _('report:: question'),
'date' => _('report:: date'),
'ddate' => _('report:: date'),
'fonction' => _('report:: fonction'),
'activite' => _('report:: activite'),
'pays' => _('report:: pays'),
'societe' => _('report:: societe'),
'nb' => _('report:: nombre'),
'pourcent' => _('report:: pourcentage'),
'telechargement' => _('report:: telechargement'),
'record_id' => _('report:: record id'),
'final' => _('report:: type d\'action'),
'xml' => _('report:: sujet'),
'file' => _('report:: fichier'),
'mime' => _('report:: type'),
'size' => _('report:: taille'),
'copyright' => _('report:: copyright'),
'final' => _('phraseanet:: sous definition')
'user' => _('report:: utilisateur'),
'coll_id' => _('report:: collections'),
'connexion' => _('report:: Connexion'),
'comment' => _('report:: commentaire'),
'search' => _('report:: question'),
'date' => _('report:: date'),
'ddate' => _('report:: date'),
'fonction' => _('report:: fonction'),
'activite' => _('report:: activite'),
'pays' => _('report:: pays'),
'societe' => _('report:: societe'),
'nb' => _('report:: nombre'),
'pourcent' => _('report:: pourcentage'),
'telechargement' => _('report:: telechargement'),
'record_id' => _('report:: record id'),
'final' => _('report:: type d\'action'),
'xml' => _('report:: sujet'),
'file' => _('report:: fichier'),
'mime' => _('report:: type'),
'size' => _('report:: taille'),
'copyright' => _('report:: copyright'),
'final' => _('phraseanet:: sous definition')
);
return;
@@ -653,13 +693,13 @@ class module_report
private function setDay()
{
return Array(
1 => _('phraseanet::jours:: lundi'),
2 => _('phraseanet::jours:: mardi'),
3 => _('phraseanet::jours:: mercredi'),
4 => _('phraseanet::jours:: jeudi'),
5 => _('phraseanet::jours:: vendredi'),
6 => _('phraseanet::jours:: samedi'),
7 => _('phraseanet::jours:: dimanche'));
1 => _('phraseanet::jours:: lundi'),
2 => _('phraseanet::jours:: mardi'),
3 => _('phraseanet::jours:: mercredi'),
4 => _('phraseanet::jours:: jeudi'),
5 => _('phraseanet::jours:: vendredi'),
6 => _('phraseanet::jours:: samedi'),
7 => _('phraseanet::jours:: dimanche'));
}
/**
@@ -669,18 +709,18 @@ class module_report
private function setMonth()
{
return array(
_('janvier'),
_('fevrier'),
_('mars'),
_('avril'),
_('mai'),
_('juin'),
_('juillet'),
_('aout'),
_('septembre'),
_('octobre'),
_('novembre'),
_('decembre')
_('janvier'),
_('fevrier'),
_('mars'),
_('avril'),
_('mai'),
_('juin'),
_('juillet'),
_('aout'),
_('septembre'),
_('octobre'),
_('novembre'),
_('decembre')
);
}
@@ -748,21 +788,21 @@ class module_report
if (array_key_exists($column, $this->cor))
{
$title_text = $this->cor[$column];
$def = true;
$def = true;
}
empty($row[0]) ? $title = $column : $title = $row[0];
empty($row[0]) ? $title = $column : $title = $row[0];
$sort = $row[1];
$sort = $row[1];
array_key_exists($column, $this->bound) ?
$bound = $this->bound[$column] : $bound = $row[2];
$filter = (isset($row[3]) ? $row[3] : 0);
$bound = $this->bound[$column] : $bound = $row[2];
$filter = (isset($row[3]) ? $row[3] : 0);
$groupby = $row[4];
$config = array(
'title' => $title,
'sort' => $sort,
'bound' => $bound,
'filter' => $filter,
'groupby' => $groupby
$config = array(
'title' => $title,
'sort' => $sort,
'bound' => $bound,
'filter' => $filter,
'groupby' => $groupby
);
$def ? $config['title'] = $title_text : "";
@@ -792,10 +832,10 @@ class module_report
{
$stmt = $conn->prepare($this->req);
$stmt->execute($this->params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
$stmt->closeCursor();
}
catch(PDOException $e)
catch (PDOException $e)
{
echo $e->getMessage();
@@ -837,13 +877,13 @@ class module_report
{
if ($attribut)
{
foreach ($sxe->$champ->attributes() as $a => $b)
foreach ($sxe->$champ->attributes() as $a => $b)
{
if ($a == $attribut)
{
if ($a == $attribut)
{
$ret.= $b;
}
$ret.= $b;
}
}
}
else
{
@@ -871,7 +911,7 @@ class module_report
$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();
@@ -897,7 +937,7 @@ class module_report
public static function getHost($url)
{
$parse_url = parse_url(trim($url));
$result = isset($parse_url['host']) ? $parse_url['host'] : array_shift(explode('/', $parse_url['path'], 2));
$result = isset($parse_url['host']) ? $parse_url['host'] : array_shift(explode('/', $parse_url['path'], 2));
return trim($result);
}

View File

@@ -935,7 +935,7 @@ class module_report_activity extends module_report
AND (" . $collfilter['sql'] . ")
GROUP by ddate
ORDER BY ddate ASC";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -951,7 +951,7 @@ class module_report_activity extends module_report
{
$res[$key] = number_format($act, 2, '.', '');
}
return $res;
}
@@ -1102,7 +1102,7 @@ class module_report_activity extends module_report
AND (" . $collfilter['sql'] . ")
GROUP BY ddate
ORDER BY activity ASC ";
$stmt = $conn->prepare($sql);
$stmt->execute($params);
$rs = $stmt->fetchAll(PDO::FETCH_ASSOC);
@@ -1112,6 +1112,7 @@ class module_report_activity extends module_report
$date = new DateTime($row['ddate']);
$result[$date->format(DATE_ATOM)] = $row['activity'];
}
return $result;
}

View File

@@ -157,8 +157,10 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
public function isValid()
{
if (isset($this->dashboard) && sizeof($this->dashboard) > 0)
return true;
else
return false;
}
@@ -348,11 +350,11 @@ class module_report_dashboard implements module_report_dashboard_componentInterf
}
catch (Exception $e)
{
}
$i++;
}
return;
}

View File

@@ -75,9 +75,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
}
catch (Exception $e)
{
}
$tmp = new self($sbasid, $sbas_coll, $dmin, $dmax);
$appbox->set_data_to_cache($tmp, $cache_id);
@@ -131,7 +131,7 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
* @return <void>
*/
public function process()
{
{
try
{
//Get number of DLs
@@ -250,8 +250,9 @@ class module_report_dashboard_feed implements module_report_dashboard_componentI
}
catch(PDOException $e)
{
}
return;
}

View File

@@ -149,8 +149,10 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function isValid()
{
if (isset($this->arraySorted) && sizeof($this->arraySorted) > 0)
return true;
else
return false;
}
@@ -162,10 +164,11 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
public function getTop($nbtop)
{
if (!is_int($nbtop))
return array();
$tmp = array();
if ($this->isValid())
{
foreach ($this->arraySorted as $k => $v)
@@ -182,6 +185,7 @@ class module_report_dashboard_sort implements module_report_dashboard_componentI
}
}
}
return $tmp;
}

View File

@@ -39,7 +39,6 @@ class module_report_download extends module_report
'file' => 'subdef.file'
);
protected $isInformative;
/**
* constructor
*
@@ -278,16 +277,6 @@ class module_report_download extends module_report
return $array;
}
public function IsInformative()
{
return $this->isInformative;
}
public function setIsInformative($isInformative)
{
$this->isInformative = $isInformative;
}
}

View File

@@ -603,10 +603,10 @@ class module_report_nav extends module_report
, 'titre' => $record->get_title()
, 'taille' => $document->get_size()
);
$this->setDisplayNav();
$this->setReport();
return $this->report;
}