Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1826

Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)

Novinky:
- fixes #462: Fronta chyb a logu z akci na pozadi
- fixes #446: Index pro sloupec ip_address v tabulce ip_addresses

Upravy:
- pridani noveho logovani do scheduleru

Zobrazit rozdíly:

freenetis/branches/1.1/db_upgrades/upgrade_1.1.0~alpha7.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* This upgrade is not equal to any of previos upgrades
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_equal_to['1.1.0~alpha7'] = array();
/**
* Queue of logs and errors in database (#462) and IP address index (#446).
*
*
* @author Ondřej Fibich <ondrej.fibich@gmail.com>
*/
$upgrade_sql['1.1.0~alpha7'] = array
(
/* IP address index (#446) */
"ALTER TABLE `ip_addresses` ADD INDEX `ip_address` (`ip_address`);",
/* Queue of logs and errors in database (#462) */
"CREATE TABLE `log_queues` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
`type` SMALLINT NOT NULL ,
`state` SMALLINT NOT NULL ,
`created_at` DATETIME NOT NULL ,
`closed_by_user_id` INT( 11 ) NULL DEFAULT NULL ,
`closed_at` DATETIME NULL DEFAULT NULL ,
`description` TEXT NOT NULL ,
`exception_backtrace` TEXT NULL DEFAULT NULL ,
`comments_thread_id` INT NULL DEFAULT NULL ,
PRIMARY KEY ( `id` ),
FOREIGN KEY `closed_by_user_id_fk` (`closed_by_user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL,
FOREIGN KEY `comments_thread_id_fk` (`comments_thread_id`) REFERENCES `comments_threads` (`id`) ON DELETE SET NULL
) ENGINE = InnoDB;",
);
freenetis/branches/1.1/application/i18n/cs_CZ/texts.php
'add backup' => 'Přidat zálohu',
'add comment to financial state of member' => 'Přidat komentář k finančnímu stavu člena',
'add comment to connection request' => 'Přidat komentář k žádosti o připojení',
'add comment to log' => 'Přidat komentář k záznamu o činnosti',
'add comment to work' => 'Přidat komentář k práci',
'add contact' => 'Přidat kontakt',
'add device' => 'Přidat zařízení',
......
'calls' => 'Volání',
'notice of adding connection request' => 'Oznámení o přidání žádosti o připojení',
'canceling of message for redirection' => 'Rušení zprávy pro přesměrování',
'cannot close log queue' => 'Nelze uzavřít záznam činnosti.',
'cannot add connection request' => 'Nelze přidat požadavek o připojení.',
'cannot change mode of the interface to client a virtual ap is derived from this interface' => 'Nemohu změnit mód rozhraní na klientský. Alespoň jedno virtuální AP je vytvořeno nad tímto rozhraním.',
'cannot connect to database' => 'Nelze se připojit k databázi',
......
'channel width' => 'Šířka kanálu',
'chars' => 'Znaků',
'check again' => 'Znovu zkontrolovat',
'check it' => 'zkontrolujte je',
'children interfaces' => 'Položky bridge',
'choose' => 'Vybrat',
'choose date' => 'Vyberte datum',
......
'clouds' => 'Oblasti',
'close' => 'Zavřít',
'close (esc)' => 'Zavřít (esc)',
'closed' => 'Uzavřená',
'closed at' => 'Uzavřeno',
'closed by' => 'Uzavřel',
'code' => 'Kód',
'collateral' => 'Vedlejší',
'column headers' => 'Hlavičky sloupců',
......
'locked' => 'Uzamčen',
'locked by admin' => 'Uzamčeno administrátorem',
'lock invoice' => 'Zamčít fakturu',
'error and log' => 'Chyba nebo záznam o činnosti',
'errors and logs' => 'Chyby a záznamy činnosti',
'log in to freenetis system' => 'Přihlásit do systému Freenetis',
'log queue has been closed' => 'Záznam činnosti byl uzavřen.',
'logged user' => 'Přihlášený uživatel',
'logging' => 'Logování',
'logging state' => 'Stav logování',
......
'received payment notice' => 'Oznámení o přijaté platbě',
'receiver' => 'Příjemce',
'receiver type' => 'Typ příjemce',
'recorded' => 'Zaznamenáno',
'recount of device repayments' => 'Přepočítání splátek zařízení',
'recount of member fees' => 'Přepočítání členských příspěvků',
'recount of entrance fees' => 'Přepočítání vstupních příspěvků',
......
'set notification to member' => 'Nastavit notifikace členovi',
'set votes to' => 'Nastavit hlasy na',
'set whitelist to member' => 'Nastavit bílou listinu členovi',
'set state closed' => 'Nastavit stav na uzavřený',
'settings' => 'Nastavení',
'settings for configuration files has been successfully updated' => 'Nastavení pro kofigurační soubory bylo úspěšně upraveno',
'setup config' => 'Nastavení konfigurace',
freenetis/branches/1.1/application/i18n/cs_CZ/help.php
'ignore_whitelist' => 'Umožňuje této zprávě, je-li aktivována, ignorovat bílou listinu. Určeno pro velmi speciální případy, například pokud je připojen městský úřad, který je na trvalé bílé listině, aby nebyl obtěžován a i přesto chceme jeho počítače přesměrovat kvůli informaci o výpadku.',
'initial_immunity' => 'Počet dní, po které nemá být nový člen upozorňován na placení. Výchozí hodnota je 14 dní.',
'initial_debtor_immunity' => 'Počet dní, po které nemá být nový člen blokován a upozorňován jako dlužník. Výchozí hodnota je 35 dní.',
'log_queues_info' => 'Byly zaznamenány chyby (systému nebo některých síťových prvků), %s prosím a proveďte nezbytné akce pro jejich nápravu.',
'login_name' => 'Přihlašovací jméno do systému je nutné k přihlášení. Přihlašovací jmémo může obsahovat znaky anglické abecedy, čísla, těčku a podtržítko, minimální délka jména je 5 znaků.',
'mail_to_field' => 'Políčko bere jako vstup login uživatele, kterému chcete odeslat zprávu. Příjemců můžete uvést více, oddělte je čárkou.',
'member_name' => 'Vyplňujte v případě přidávání nějaké organizace. Pokud připojujete běžného člena, tak jako výsledné jméno člena se použije jeho jméno a příjmení.',
freenetis/branches/1.1/application/i18n/en_US/help.php
'gateway' => 'Determines whether an IP address in your subnet gateway. Typically this is set each IP address ending in the number one network prefix 24th',
'gps_coordinates' => 'GPS can be in shape of real number, or: hours°minutes\'seconds&quot.',
'ignore_whitelist' => 'Allows this report, when activated, to ignore the white list. Designed for very special cases, such as when connected to the municipality, which is on permanent white list not to be harassed and even though we want to redirect his computer for information about the outage.',
'log_queues_info' => 'Errors has been reported (in system or in some network elements), please %s and perform the necessary actions to correct them.',
'login_name' => 'Login name is necessary for login to system. Login name can contains letters from english alphabet, numbers and dot. It has to contains at least 5 letters.',
'mail_to_field' => 'The box takes as input the user login you want to send a message. You can specify multiple recipients, separate them with commas.',
'member_name' => 'Fill in the case of adding an organization. If you connect a regular member, as the final name of the member uses his name and surname.',
freenetis/branches/1.1/application/helpers/callback.php
}
/**
* Callback function to print state of login log
*
* @param object $item
* @param string $name
*/
public static function log_queues_type_field($item, $name)
{
echo '<b style="padding:2px; color:white; background-color:'
. Log_queue_Model::get_type_color($item->type) . '">'
. Log_queue_Model::get_type_name($item->type) . '<b>';
}
/**
* Callback function to print state of login log
*
* @param object $item
* @param string $name
*/
public static function log_queues_state_field($item, $name)
{
if ($item->state == Log_queue_Model::STATE_NEW)
{
echo '<b style="color:green">' . __('New') . '</b>';
}
else
{
echo __('Closed');
}
if (isset($item->a_comment) && !empty($item->a_comment))
{
echo ' <span class="help" title="'.$item->a_comment.'">';
echo html::image('media/images/icons/comment.png');
echo '</span>';
}
if (isset($item->id) && isset($item->a_comment_add) && $item->a_comment_add)
{
$url = (isset($item->a_comments_thread_id) && $item->a_comments_thread_id) ?
'comments/add/'.$item->a_comments_thread_id :
'comments_threads/add/log_queue/'.$item->id;
echo ' ' . html::anchor($url, html::image('media/images/icons/ico_add.gif'), array
(
'title' => __('Add comment'),
'class' => 'popup_link'
));
}
}
/**
* Callback function to print name of segment's item
*
* @author Michal Kliment
freenetis/branches/1.1/application/helpers/condition.php
}
/**
* Check if the log queue is uncloded.
*
* @param object $item Data row
* @return boolean
*/
public static function is_log_queue_unclosed($item)
{
return ($item->state != Log_queue_Model::STATE_CLOSED);
}
/**
* Check if current row is not locked.
* Data row has to have locked column.
*
freenetis/branches/1.1/application/models/comments_thread.php
class Comments_thread_Model extends ORM
{
protected $has_many = array('comments');
protected $has_one = array('account', 'job', 'connection_request');
protected $has_one = array('account', 'job', 'connection_request', 'log_queue');
/**
* Return parent object of comment thread
freenetis/branches/1.1/application/models/log_queue.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is release under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Log queue for storing of logs and error logs into the database.
*
* @author Ondřej Fibich
* @package Model
*
* @property integer $id
* @property integer $type
* @property integer $state
* @property datetime $created_at
* @property integer $closed_by_user_id
* @property User_Model $closed_by_user
* @property datetime $closed_at
* @property string $description
* @property string $exception_backtrace
* @property integer $comments_thread_id
* @property Comments_thread_Model $comments_thread
*/
class Log_queue_Model extends ORM
{
// states of log
/** New state (log is unclosed) */
const STATE_NEW = 0;
/** Closed state (log is closed by an user) */
const STATE_CLOSED = 1;
// type of log
/** Fatal error type */
const TYPE_FATAL_ERROR = 0;
/** Error type */
const TYPE_ERROR = 1;
/** Warning type */
const TYPE_WARNING = 2;
/** Information type */
const TYPE_INFO = 3;
/**
* Types
*
* @var array
*/
private static $types = array
(
self::TYPE_FATAL_ERROR => 'Fatal error',
self::TYPE_ERROR => 'Error',
self::TYPE_WARNING => 'Warning',
self::TYPE_INFO => 'Information',
);
/**
* Type collors
*
* @var array
*/
private static $type_colors = array
(
self::TYPE_FATAL_ERROR => '#792020',
self::TYPE_ERROR => '#cd0000',
self::TYPE_WARNING => '#ff7800',
self::TYPE_INFO => '#1e84db',
);
/**
* Types
*
* @var array
*/
private static $states = array
(
self::STATE_NEW => 'New',
self::STATE_CLOSED => 'Closed',
);
// database relations
protected $belongs_to = array
(
'comments_thread', 'closed_by_user' => 'user'
);
// functions
/**
* Gets types
*
* @param boolean $translate Translate messages?
* @return array
*/
public static function get_types($translate = TRUE)
{
if ($translate)
{
return array_map('__', self::$types);
}
return self::$types;
}
/**
* Get name of log type.
*
* @param integer $type Type of log
* @param boolean $translate Translate messages?
* @return string Name
*/
public static function get_type_name($type, $translated = TRUE)
{
if (array_key_exists($type, self::$types))
{
if ($translated)
{
return __(self::$types[$type]);
}
return self::$types[$type];
}
return NULL;
}
/**
* Gets type colors
*
* @return array
*/
public static function get_type_colors()
{
return self::$type_colors;
}
/**
* Gets color of a type
*
* @param int $type Log type
* @return string Color
*/
public static function get_type_color($type)
{
if (array_key_exists($type, self::$type_colors))
{
return self::$type_colors[$type];
}
return NULL;
}
/**
* Gets states
*
* @param boolean $translate Translate messages?
* @return array
*/
public static function get_states($translate = TRUE)
{
if ($translate)
{
return array_map('__', self::$states);
}
return self::$states;
}
/**
* Gets state
*
* @param int $state
* @param boolean $translate Translate messages?
* @return array
*/
public static function get_state($state, $translate = TRUE)
{
if (array_key_exists($state, self::$states))
{
if ($translate)
{
return __(self::$states[$state]);
}
else
{
return self::$states[$state];
}
}
return NULL;
}
/**
* Creates new log.
*
* @param type $type Type of error
* @param type $description Decription of error
* @param type $exception_backtrace [optional - empty by default]
* @param type $created_at [optional - default current datetime]
* @return Log_queue_Model Created model or null on error during saving
*/
protected static function log($type, $description,
$exception_backtrace = NULL, $created_at = NULL)
{
if (empty($created_at))
{
$created_at = date('Y-m-d H:i:s');
}
try
{
$log_queue = new Log_queue_Model();
$log_queue->type = $type;
$log_queue->state = self::STATE_NEW;
$log_queue->created_at = $created_at;
$log_queue->description = $description;
$log_queue->exception_backtrace = $exception_backtrace;
$log_queue->save_throwable();
return $log_queue;
}
catch (Exception $e)
{
Log::add_exception($e);
return NULL;
}
}
/**
* Creates new fatal error log.
*
* @param type $description Decription of error
* @param type $exception_backtrace [optional - empty by default]
* @param type $created_at [optional - default current datetime]
* @return Log_queue_Model Created model
*/
public static function ferror($description,
$exception_backtrace = NULL, $created_at = NULL)
{
self::log(self::TYPE_FATAL_ERROR, $description, $exception_backtrace, $created_at);
}
/**
* Creates new error log.
*
* @param type $description Decription of error
* @param type $exception_backtrace [optional - empty by default]
* @param type $created_at [optional - default current datetime]
* @return Log_queue_Model Created model
*/
public static function error($description,
$exception_backtrace = NULL, $created_at = NULL)
{
self::log(self::TYPE_ERROR, $description, $exception_backtrace, $created_at);
}
/**
* Creates new warning log.
*
* @param type $description Decription of error
* @param type $exception_backtrace [optional - empty by default]
* @param type $created_at [optional - default current datetime]
* @return Log_queue_Model Created model
*/
public static function warn($description,
$exception_backtrace = NULL, $created_at = NULL)
{
self::log(self::TYPE_WARNING, $description, $exception_backtrace, $created_at);
}
/**
* Creates new info log.
*
* @param type $description Decription of error
* @param type $exception_backtrace [optional - empty by default]
* @param type $created_at [optional - default current datetime]
* @return Log_queue_Model Created model
*/
public static function info($description,
$exception_backtrace = NULL, $created_at = NULL)
{
self::log(self::TYPE_INFO, $description, $exception_backtrace, $created_at);
}
/**
* Counts filtered logs
*
* @param string $filter_sql SQL filter
* @return integer Count
*/
public function count_all_logs($filter_sql = '')
{
$where = '';
if (!empty($filter_sql))
{
$where = 'WHERE ' . $filter_sql;
}
else
{
return $this->count_all();
}
return $this->db->query("
SELECT COUNT(*) AS total FROM (
SELECT l.*, u.id AS user_id,
CONCAT(u.name, ' ', u.surname) AS user_name
FROM log_queues l
LEFT JOIN users u ON u.id = l.closed_by_user_id
) c
$where
", Config::get('lang'))->current()->total;
}
/**
* Gets filtered connection requests
*
* @param integer $limit_from
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $filter_sql SQL filter
* @return Mysql_Result
*/
public function get_all_logs(
$limit_from = 0, $limit_results = 50, $order_by = 'id',
$order_by_direction = 'asc', $filter_sql = '')
{
$where = '';
if (!empty($filter_sql))
{
$where = 'WHERE ' . $filter_sql;
}
if (strtolower($order_by_direction) != 'asc')
{
$order_by_direction = 'desc';
}
return $this->db->query("
SELECT * FROM (
SELECT l.*, u.id AS user_id, CONCAT(u.name, ' ', u.surname) AS user_name,
co.a_comment, l.comments_thread_id AS a_comments_thread_id,
1 AS a_comment_add
FROM log_queues l
LEFT JOIN users u ON u.id = l.closed_by_user_id
LEFT JOIN
(
SELECT comments_thread_id,
GROUP_CONCAT(
CONCAT(
u.surname,' ',u.name,
' (',SUBSTRING(c.datetime,1,10),'):\n',c.text)
ORDER BY c.datetime DESC
SEPARATOR '\n\n'
) AS a_comment
FROM comments c
JOIN users u ON c.user_id = u.id
GROUP BY comments_thread_id
) co ON co.comments_thread_id = l.comments_thread_id
) c
$where
ORDER BY " . $this->db->escape_column($order_by) . " $order_by_direction
LIMIT " . intval($limit_from) . ", " . intval($limit_results) . "
", Config::get('lang'));
}
/**
* Gets count of unclosed logs with a minimal type.
*
* @param int $minimal_type Minimal counted type (e.g. ERROR -> ERROR & FERROR)
* @return int Count
*/
public function count_of_unclosed_logs($minimal_type = self::TYPE_ERROR)
{
return $this->db->query("
SELECT COUNT(*) AS c
FROM log_queues l
WHERE state <> ? AND type <= ?
", self::STATE_CLOSED, $minimal_type)->current()->c;
}
}
freenetis/branches/1.1/application/controllers/comments_threads.php
// creates model name
$model = ucfirst($type) . '_Model';
// this model doesn't exist
if (!class_exists($model))
Controller::error(RECORD);
freenetis/branches/1.1/application/controllers/log_queues.php
<?php defined('SYSPATH') or die('No direct script access.');
/*
* This file is part of open source system FreenetIS
* and it is released under GPLv3 licence.
*
* More info about licence can be found:
* http://www.gnu.org/licenses/gpl-3.0.html
*
* More info about project can be found:
* http://www.freenetis.org/
*
*/
/**
* Manages log queues.
*
* @author Ondřej Fibich
* @package Controller
*/
class Log_queues_Controller extends Controller
{
/**
* Index redirect to show all
*/
public function index()
{
url::redirect('log_queues/show_all');
}
/**
* Shows all logs.
*
* @param integer $limit_results
* @param string $order_by
* @param string $order_by_direction
* @param string $page_word
* @param integer $page
*/
public function show_all(
$limit_results = 50, $order_by = 'created_at',
$order_by_direction = 'desc', $page_word = null, $page = 1)
{
if (!$this->acl_check_edit('Settings_Controller', 'system'))
{
Controller::error(ACCESS);
}
if (is_numeric($this->input->get('record_per_page')))
{
$limit_results = (int) $this->input->get('record_per_page');
}
$allowed_order_type = array
(
'id', 'user_name', 'created_at', 'type', 'status', 'closed_at',
'description'
);
if (!in_array(strtolower($order_by), $allowed_order_type))
{
$order_by = 'id';
}
if (strtolower($order_by_direction) != 'desc')
{
$order_by_direction = 'asc';
}
// filter
$filter_form = new Filter_form();
$filter_form->add('type')
->type('select')
->values(Log_queue_Model::get_types());
$filter_form->add('state')
->type('select')
->values(Log_queue_Model::get_states());
$filter_form->add('created_at')
->label('Recorded')
->type('date');
$filter_form->add('closed_at')
->type('date');
$filter_form->add('user_name')
->label('Closed by')
->callback('json/user_name');
$filter_form->add('description');
// get data
$lq_model = new Log_queue_Model();
$total = $lq_model->count_all_logs($filter_form->as_sql());
if (($sql_offset = ($page - 1) * $limit_results) > $total)
$sql_offset = 0;
$logs = $lq_model->get_all_logs(
$sql_offset, $limit_results, $order_by, $order_by_direction,
$filter_form->as_sql()
);
$headline = __('Errors and logs');
$grid = new Grid('log_queue', null, array
(
'current' => $limit_results,
'selector_increace' => 50,
'selector_min' => 50,
'selector_max_multiplier' => 10,
'base_url' => Config::get('lang')
. '/log_queues/show_all/' . $limit_results
. '/' . $order_by . '/' . $order_by_direction,
'uri_segment' => 'page',
'total_items' => $total,
'items_per_page' => $limit_results,
'style' => 'classic',
'order_by' => $order_by,
'order_by_direction' => $order_by_direction,
'limit_results' => $limit_results,
'filter' => $filter_form->html()
));
$grid->order_field('id')
->label('ID');
$grid->order_callback_field('type')
->callback('callback::log_queues_type_field');
$grid->order_callback_field('state')
->callback('callback::log_queues_state_field');
$grid->order_field('created_at')
->label('Recorded');
$grid->order_callback_field('description')
->callback('callback::limited_text');
$grid->order_field('closed_at');
$grid->order_link_field('user_id')
->link('users/show', 'user_name')
->label('Closed by');
$actions = $grid->grouped_action_field();
$actions->add_conditional_action()
->condition('is_log_queue_unclosed')
->icon_action('activate')
->url('log_queues/close_log')
->label('Set state closed');
$actions->add_action()
->icon_action('show')
->url('log_queues/show');
$grid->datasource($logs);
$view = new View('main');
$view->title = $headline;
$view->breadcrumbs = $headline;
$view->content = new View('show_all');
$view->content->headline = $headline;
$view->content->table = $grid;
$view->render(TRUE);
}
/**
* Shows a log queue.
*
* @param integer $log_queue_id
*/
public function show($log_queue_id = NULL)
{
if (!is_numeric($log_queue_id))
{
Controller::warning(PARAMETER);
}
$lq_model = new Log_queue_Model($log_queue_id);
if (!$lq_model || !$lq_model->id)
{
Controller::error(RECORD);
}
if (!$this->acl_check_edit('Settings_Controller', 'system'))
{
Controller::error(ACCESS);
}
// comments grid
$comment_model = new Comment_Model();
$comments = $comment_model->get_all_comments_by_comments_thread(
$lq_model->comments_thread_id
);
$comments_grid = new Grid('comments', NULL, array
(
'separator' => '<br /><br />',
'use_paginator' => FALSE,
'use_selector' => FALSE,
));
$url = ($lq_model->comments_thread_id) ?
'comments/add/'.$lq_model->comments_thread_id :
'comments_threads/add/log_queue/'.$lq_model->id;
$comments_grid->add_new_button(
$url, 'Add comment to connection request',
array('class' => 'popup_link')
);
$comments_grid->field('text');
if ($this->acl_check_view('Users_Controller', 'users'))
{
$comments_grid->link_field('user_id')
->link('users/show', 'user_name')
->label('User');
}
else
{
$comments_grid->field('user_name')
->label('User');
}
$comments_grid->field('datetime')
->label('Time');
$actions = $comments_grid->grouped_action_field();
$actions->add_conditional_action()
->icon_action('edit')
->url('comments/edit')
->condition('is_own')
->class('popup_link');
$actions->add_conditional_action()
->icon_action('delete')
->url('comments/delete')
->condition('is_own')
->class('delete_link');
$comments_grid->datasource($comments);
$headline = __('Error and log');
// breadcrumbs navigation
$breadcrumbs = breadcrumbs::add()
->link('log_queues/show_all', 'Errors and logs')
->disable_translation()
->text(Log_queue_Model::get_type_name($lq_model->type) . ' (' . $lq_model->id . ')');
// view
$view = new View('main');
$view->title = $headline;
$view->breadcrumbs = $breadcrumbs->html();
$view->content = new View('log_queues/show');
$view->content->headline = $headline;
$view->content->log_queue = $lq_model;
$view->content->comments_grid = $comments_grid;
$view->render(TRUE);
}
/**
* Close a log queue.
*
* @param integer $log_queue_id
*/
public function close_log($log_queue_id = NULL)
{
if (!is_numeric($log_queue_id))
{
Controller::warning(PARAMETER);
}
$lq_model = new Log_queue_Model($log_queue_id);
if (!$lq_model || !$lq_model->id)
{
Controller::error(RECORD);
}
if (!$this->acl_check_edit('Settings_Controller', 'system'))
{
Controller::error(ACCESS);
}
if ($lq_model->state == Log_queue_Model::STATE_CLOSED)
{
Controller::error(RECORD);
}
try
{
$lq_model->transaction_start();
// set data
$lq_model->state = Log_queue_Model::STATE_CLOSED;
$lq_model->closed_at = date('Y-m-d H:i:s');
$lq_model->closed_by_user_id = $this->user_id;
$lq_model->save_throwable();
$lq_model->transaction_commit();
status::success('Log queue has been closed.');
}
catch (Exception $e)
{
$lq_model->transaction_rollback();
Log::add_exception($e);
status::error('Cannot close log queue.');
}
$this->redirect('log_queues/show/', $log_queue_id);
}
}
freenetis/branches/1.1/application/controllers/scheduler.php
{
// get humanize method
$method = str_replace('|', ' ' . __('or') . ' ', $method);
// logg
Log::add('error', Kohana::lang(
'core.scheduler_exception', get_class($e),
$e->getMessage(), $method,
$e->getLine()
));
$text = Kohana::lang(
'core.scheduler_exception', get_class($e),
$e->getMessage(), $method,
$e->getLine()
);
// log to database
Log_queue_Model::error($text, $e->getTraceAsString());
// log to file
Log::add('error', $text);
}
/**
......
catch (Exception $e)
{
$monitor_host_model->transaction_rollback();
Log::add_exception($e);
self::add_exception('monitoring_notification', $e);
}
}
freenetis/branches/1.1/application/controllers/comments.php
$title = __('Add comment to work');
break;
// thread belongs to log queues
case 'log_queue':
// access control
if (!$this->acl_check_edit('Settings_Controller', 'system'))
Controller::error(ACCESS);
$link_back_url = Path::instance()->previous();
$title = __('Add comment to log');
$tname = Log_queue_Model::get_type_name($parent->type);
$breadcrumbs->link('log_queues/show_all', 'Errors and logs')
->disable_translation()
->link('log_queues/show/' . $parent->id, $tname . ' (' . $parent->id . ')')
->text($title);
break;
default:
Controller::error(RECORD);
break;
......
$link_back_url = Path::instance()->previous();
$title = __('Add comment to connection request');
$title = __('Edit comment');
$breadcrumbs->link('connection_requests/show_all', 'Connection requests',
$this->acl_check_view('Connection_requests_Controller', 'request'))
......
->text($title);
break;
// thread belongs to log queues
case 'log_queue':
// access control
if (!$this->acl_check_view('Settings_Controller', 'system'))
Controller::error(ACCESS);
$link_back_url = Path::instance()->previous();
$title = __('Edit comment');
$tname = Log_queue_Model::get_type_name($parent->type);
$breadcrumbs->link('log_queues/show_all', 'Errors and logs')
->disable_translation()
->link('log_queues/show/' . $parent->id, $tname . ' (' . $parent->id . ')')
->text($title);
break;
case 'job':
// access control
if (!$this->acl_check_edit(get_class($this), 'works', $comment->user->member_id))
......
break;
// thread belongs to log queues
case 'log_queue':
// access control
if (!$this->acl_check_view('Settings_Controller', 'system'))
Controller::error(ACCESS);
$link_back_url = Path::instance()->previous();
break;
case 'job':
// access control
if (!$this->acl_check_delete(get_class($this), 'works', $comment->user->member_id))
freenetis/branches/1.1/application/libraries/MY_Controller.php
/** @var integer */
public $count_of_registered_members = 0;
/** @var integer */
public $count_of_unclosed_logged_errors = 0;
/** @var integer */
public $count_of_unvoted_works_of_voter = 0;
/** @var integer */
public $count_of_unvoted_works_reports_of_voter = 0;
......
status::minfo($m, FALSE);
}
}
// log queue (#462)
if ($this->acl_check_view('Settings_Controller', 'system'))
{
$this->count_of_unclosed_logged_errors =
ORM::factory('log_queue')->count_of_unclosed_logs();
// inform box
if ($this->count_of_unclosed_logged_errors &&
url_lang::current(1) != 'log_queues' &&
!$this->noredirect)
{
$link = html::anchor('/log_queues/show_all', __('check it'));
status::mwarning(url_lang::lang('help.log_queues_info', $link), FALSE);
}
}
}
freenetis/branches/1.1/application/views/log_queues/show.php
<h2><?php echo $headline ?></h2><br />
<?php
$links = array();
if ($this->acl_check_edit('Settings_Controller', 'system') && ($log_queue->state != Log_queue_Model::STATE_CLOSED))
{
$links[] = html::anchor('log_queues/close_log/'.$log_queue->id, __('Set state closed'));
}
echo implode(' | ', $links);
if (count($links))
{
echo '<br /><br />';
}
?>
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('ID') ?></th>
<td><?php echo $log_queue->id ?></td>
</tr>
<tr>
<th><?php echo __('Type') ?></th>
<td><b style="color:white; padding:2px; background-color:<?php echo Log_queue_Model::get_type_color($log_queue->type) ?>"><?php echo Log_queue_Model::get_type_name($log_queue->type) ?></b></td>
</tr>
<tr>
<th><?php echo __('Description') ?></th>
<td><?php echo $log_queue->description ?></td>
</tr>
<?php if ($log_queue->exception_backtrace): ?>
<tr>
<th><?php echo __('Exception') ?></th>
<td><?php echo $log_queue->exception_backtrace ?></td>
</tr>
<?php endif; ?>
<tr>
<th><?php echo __('State') ?></th>
<td><b><?php echo Log_queue_Model::get_state($log_queue->state) ?></b></td>
</tr>
<?php if ($log_queue->closed_by_user_id): ?>
<tr>
<th><?php echo __('Closed by') ?></th>
<?php if ($this->acl_check_view('Users_Controller', 'users', $log_queue->closed_by_user->member_id)): ?>
<td><?php echo html::anchor('users/show/' . $log_queue->closed_by_user_id, $log_queue->closed_by_user->get_full_name()) ?> (<?php echo $log_queue->closed_at ?>)</td>
<?php else: ?>
<td><?php echo $log_queue->closed_by_user->get_full_name() ?> (<?php echo $log_queue->closed_at ?>)</td>
<?php endif; ?>
</tr>
<?php endif; ?>
</table>
<br />
<h3><?php echo __('Comments') ?></h3>
<?php echo $comments_grid ?>
freenetis/branches/1.1/version.php
* The current version of FreenetIS.
* This value must be changed by developers in a new release of FreenetIS.
*/
define('FREENETIS_VERSION', '1.1.0~alpha6');
define('FREENETIS_VERSION', '1.1.0~alpha7');

Také k dispozici: Unified diff