Revize 1370
Přidáno uživatelem Ondřej Fibich před více než 12 roky(ů)
freenetis/branches/testing/application/i18n/cs_CZ/texts.php | ||
---|---|---|
'numbers' => 'Čísla',
|
||
'o' => 'V',
|
||
'object' => 'Objekt',
|
||
'object id' => 'ID objektu',
|
||
'october' => 'Říjen',
|
||
'of' => 'ze',
|
||
'of all approved work reports' => 'všech schválených pracovních výkazů',
|
||
... | ... | |
'system variables have been successfully updated' => 'Systémové proměnné byly úspěšně aktualizovány',
|
||
'system variables havent been updated' => 'Systémové proměnné nebyly úspěšně aktualizovány',
|
||
'table' => 'Tabulka',
|
||
'table name' => 'Jméno tabulky',
|
||
'table prefix' => 'Prefix tabulek',
|
||
'tag_802_1q' => 'Tag 802.1Q',
|
||
'target website' => 'Cílový web pro přesměrování',
|
freenetis/branches/testing/application/models/log.php | ||
---|---|---|
*
|
||
* @param int $offset
|
||
* @param int $limit
|
||
* @param array $filter_values Filter for where contition
|
||
* @param array $filter_sql Filter for where contition
|
||
* @return Mysql_Result
|
||
*/
|
||
public function get_all_logs($offset, $limit, $filter_values = array())
|
||
public function get_all_logs($offset, $limit, $filter_sql = array())
|
||
{
|
||
// array of where conditions
|
||
$where = array();
|
||
// filter
|
||
if (is_array($filter_values))
|
||
{
|
||
// user id condition
|
||
if (isset($filter_values['user_id']))
|
||
{
|
||
$where[] = 'user_id='.intval($filter_values['user_id']);
|
||
}
|
||
// object id condition
|
||
if (isset($filter_values['object_id']))
|
||
{
|
||
$where[] = 'object_id='.intval($filter_values['object_id']);
|
||
}
|
||
// date condition
|
||
if (isset($filter_values['date_from']) || isset($filter_values['date_to']))
|
||
{
|
||
$from = @$filter_values['date_from'];
|
||
$to = @$filter_values['date_to'];
|
||
|
||
if (!preg_match('/^[0-9]{4,4}\-[0-9]{2,2}\-[0-9]{2,2}$/', $from))
|
||
{
|
||
// logs are persisted at max for 30 days
|
||
$from = date('Y-m-d', time() - 60*60*24*30);
|
||
}
|
||
|
||
if (!preg_match('/^[0-9]{4,4}\-[0-9]{2,2}\-[0-9]{2,2}$/', $to))
|
||
{
|
||
$to = date('Y-m-d', time());
|
||
}
|
||
|
||
$where[] = 'time BETWEEN \'' .$from. ' 00-00-00\' AND \'' .$to. ' 23:59:59\'';
|
||
}
|
||
}
|
||
// fill where contition
|
||
$where_str = count($where) ? 'WHERE ' . implode(' AND ', $where) : '';
|
||
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
|
||
|
||
// query
|
||
return $this->db->query("
|
||
SELECT l.*
|
||
FROM logs l
|
||
$where_str
|
||
SELECT * FROM (
|
||
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
|
||
u.login AS user_login, m.name AS member_name
|
||
FROM logs
|
||
LEFT JOIN users u ON u.id = logs.user_id
|
||
LEFT JOIN members m ON m.id = u.member_id
|
||
) l $where
|
||
ORDER BY id DESC
|
||
LIMIT " .intval($offset). ", " .intval($limit). "
|
||
");
|
||
... | ... | |
/**
|
||
* Gets number of logs
|
||
*
|
||
* @param array $filter_sql Filter for where contition
|
||
* @return int
|
||
*/
|
||
public function count_all_logs()
|
||
public function count_all_logs($filter_sql = array())
|
||
{
|
||
// fill where contition
|
||
$where = !empty($filter_sql) ? 'WHERE ' . $filter_sql : '';
|
||
|
||
return $this->db->query("
|
||
SELECT COUNT(*) AS count FROM logs
|
||
SELECT COUNT(*) AS count FROM (
|
||
SELECT logs.*, u.name AS user_name, u.surname AS user_surname,
|
||
u.login AS user_login, m.name AS member_name
|
||
FROM logs
|
||
LEFT JOIN users u ON u.id = logs.user_id
|
||
LEFT JOIN members m ON m.id = u.member_id
|
||
) l $where
|
||
")->current()->count;
|
||
}
|
||
|
freenetis/branches/testing/application/controllers/logs.php | ||
---|---|---|
if (is_numeric($this->input->get('record_per_page')))
|
||
$limit_results = (int) $this->input->get('record_per_page');
|
||
|
||
$filter_form = new Filter_form('l');
|
||
|
||
$filter_form->add('table_name');
|
||
|
||
$filter_form->add('time')
|
||
->type('date');
|
||
|
||
$filter_form->add('user_name')
|
||
->type('combo')
|
||
->label('Firstname of user')
|
||
->callback('json/user_name');
|
||
|
||
$filter_form->add('user_surname')
|
||
->type('combo')
|
||
->label('Surname of user')
|
||
->callback('json/user_surname');
|
||
|
||
$filter_form->add('member_name')
|
||
->callback('json/member_name');
|
||
|
||
$filter_form->add('action')
|
||
->type('select')
|
||
->values(array
|
||
(
|
||
Log_Model::ACTION_ADD => __('Add'),
|
||
Log_Model::ACTION_DELETE => __('Delete'),
|
||
Log_Model::ACTION_UPDATE => __('Update')
|
||
));
|
||
|
||
$filter_form->add('object_id')
|
||
->type('number');
|
||
|
||
$log_model = new Log_Model();
|
||
|
||
$total_logs = $log_model->count_all_logs();
|
||
$total_logs = $log_model->count_all_logs($filter_form->as_sql());
|
||
|
||
if (($sql_offset = ($page - 1) * $limit_results) > $total_logs)
|
||
$sql_offset = 0;
|
||
|
||
// users checkbox
|
||
$user_model = new User_Model();
|
||
// can be replaced by Log::select_list_users_which_has_logs()
|
||
$users = $user_model->get_all_user_names();
|
||
|
||
$users_array = array ('0' => '');
|
||
foreach ($users as $user)
|
||
{
|
||
$users_array[$user->id] = $user->username . ' (' . $user->id . ')';
|
||
}
|
||
|
||
// creates fields for filtering logs
|
||
$filter = new Table_Form(url_lang::base() . 'logs/show_all', 'get', array
|
||
(
|
||
new Table_Form_Item('text', 'object_id', 'Object'),
|
||
new Table_Form_Item(
|
||
'select', 'user_id', 'User', $users_array,
|
||
array('style' => 'width: 207px')
|
||
),
|
||
'tr',
|
||
new Table_Form_Item(
|
||
'text', 'date_from', 'Date from',
|
||
NULL, array('id' => 'date_from')
|
||
),
|
||
new Table_Form_Item(
|
||
'text', 'date_to', 'Date to',
|
||
NULL, array('id' => 'date_to')
|
||
),
|
||
'tr',
|
||
'td',
|
||
new Table_Form_Item('submit','submit','Filter')
|
||
));
|
||
|
||
// load logs
|
||
$logs = $log_model->get_all_logs(
|
||
$sql_offset, (int) $limit_results, $filter->values()
|
||
$sql_offset, (int) $limit_results, $filter_form->as_sql()
|
||
);
|
||
|
||
$arr_gets = array();
|
||
... | ... | |
'order_by_direction' => 'DESC',
|
||
'limit_results' => $limit_results,
|
||
'query_string' => $query_string,
|
||
'filter' => $filter->view
|
||
'filter' => $filter_form
|
||
));
|
||
|
||
$grid->field('id');
|
freenetis/branches/testing/application/controllers/scheduler.php | ||
---|---|---|
private function logs_partitions_daily()
|
||
{
|
||
$model_log = new Log_Model();
|
||
// add partition for today
|
||
$model_log->add_partition();
|
||
// remove log partition
|
||
try
|
||
{
|
||
... | ... | |
catch (Exception $ignore)
|
||
{ // ignore exception - first 30 days do not have older one..
|
||
}
|
||
// add partition for today
|
||
$model_log->add_partition();
|
||
}
|
||
|
||
/**
|
Také k dispozici: Unified diff
Oprava #148 (Spatne strankovani a stare filtry u vypisu logu akci)