Skip to content

Commit

Permalink
Fix database info
Browse files Browse the repository at this point in the history
  • Loading branch information
jmontoyaa committed Jan 22, 2016
1 parent bfe898b commit c42c9be
Showing 1 changed file with 62 additions and 27 deletions.
89 changes: 62 additions & 27 deletions main/inc/lib/diagnoser.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@
*/
class Diagnoser
{
const STATUS_OK = 1;
const STATUS_WARNING = 2;
const STATUS_ERROR = 3;
const STATUS_INFORMATION = 4;

/**
* The status's
* Contructor
*/
const STATUS_OK = 1;
const STATUS_WARNING = 2;
const STATUS_ERROR = 3;
const STATUS_INFORMATION = 4;

function __construct() {
public function __construct()
{
}

function show_html() {

$sections = array('chamilo', 'php', 'mysql', 'webserver');
public function show_html()
{
$sections = array('chamilo', 'php', 'database', 'webserver');

if (!in_array(trim($_GET['section']), $sections)) {
$current_section = 'chamilo';
Expand All @@ -37,7 +38,6 @@ function show_html() {
$html = '<div class="tabbable"><ul class="nav nav-tabs">';

foreach ($sections as $section) {

if ($current_section == $section) {
$html .= '<li class="active">';
} else {
Expand Down Expand Up @@ -68,7 +68,7 @@ function show_html() {
* Functions to get the data for the chamilo diagnostics
* @return array of data
*/
function get_chamilo_data()
public function get_chamilo_data()
{
$array = array();
$writable_folders = array(
Expand Down Expand Up @@ -107,7 +107,8 @@ function get_chamilo_data()
* Functions to get the data for the php diagnostics
* @return array of data
*/
function get_php_data() {
public function get_php_data()
{
$array = array();

// General Functions
Expand Down Expand Up @@ -270,18 +271,48 @@ function get_php_data() {
* Functions to get the data for the mysql diagnostics
* @return array of data
*/
function get_mysql_data() {
public function get_database_data()
{
$array = array();
$em = Database::getManager();
$connection = $em->getConnection();
$host = $connection->getHost();
$db = $connection->getDatabase();
$port = $connection->getPort();
$driver = $connection->getDriver()->getName();

$array[] = $this->build_setting(
self :: STATUS_INFORMATION,
'[Database]',
'driver',
'',
$driver, null, null, get_lang('Driver')
);

// A note: Maybe it would be better if all "MySQL"-like variable names and words on the page to be replaced with "Database"-like ones.
$array[] = $this->build_setting(
self :: STATUS_INFORMATION,
'[Database]',
'host',
'',
$host, null, null, get_lang('MysqlHostInfo')
);

//$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'host', 'http://www.php.net/manual/en/function.mysql-get-host-info.php', Database::get_host_info(), null, null, get_lang('MysqlHostInfo'));
/*
$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_server_info()', 'http://www.php.net/manual/en/function.mysql-get-server-info.php', Database::get_server_info(), null, null, get_lang('MysqlServerInfo'));
$array[] = $this->build_setting(
self :: STATUS_INFORMATION,
'[Database]',
'port',
'',
$port, null, null, get_lang('Port')
);

$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_proto_info()', 'http://www.php.net/manual/en/function.mysql-get-proto-info.php', Database::get_proto_info(), null, null, get_lang('MysqlProtoInfo'));

$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_client_info()', 'http://www.php.net/manual/en/function.mysql-get-client-info.php', Database::get_client_info(), null, null, get_lang('MysqlClientInfo'));*/
$array[] = $this->build_setting(
self :: STATUS_INFORMATION,
'[Database]',
'Database name',
'',
$db, null, null, get_lang('Name')
);

return $array;
}
Expand All @@ -290,7 +321,8 @@ function get_mysql_data() {
* Functions to get the data for the webserver diagnostics
* @return array of data
*/
function get_webserver_data() {
public function get_webserver_data()
{
$array = array();

$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_NAME"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_NAME"], null, null, get_lang('ServerNameInfo'));
Expand Down Expand Up @@ -320,8 +352,7 @@ function get_webserver_data() {
/**
* Additional functions needed for fast integration
*/

function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null) {
public function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null) {
switch ($status) {
case self :: STATUS_OK :
$img = 'bullet_green.png';
Expand Down Expand Up @@ -363,11 +394,13 @@ function build_setting($status, $section, $title, $url, $current_value, $expecte
* @param $url
* @return string the url
*/
function get_link($title, $url) {
public function get_link($title, $url)
{
return '<a href="' . $url . '" target="about:bank">' . $title . '</a>';
}

function format_yes_no_optional($value) {
public function format_yes_no_optional($value)
{
$return = '';
switch($value) {
case 0:
Expand All @@ -384,11 +417,13 @@ function format_yes_no_optional($value) {

}

function format_yes_no($value) {
function format_yes_no($value)
{
return $value ? get_lang('Yes') : get_lang('No');
}

function format_on_off($value) {
function format_on_off($value)
{
$value = intval($value);
if ($value > 1) {
// Greater than 1 values are shown "as-is", they may be interpreted as "On" later.
Expand Down

0 comments on commit c42c9be

Please sign in to comment.