Commit b7d3b166 authored by Florian Schaal's avatar Florian Schaal
Browse files

database-quota: add stats to website-tab

parent 1715c153
<?php
require_once '../../lib/config.inc.php';
require_once '../../lib/app.inc.php';
/******************************************
* Begin Form configuration
******************************************/
$list_def_file = "list/database_quota_stats.list.php";
/******************************************
* End Form configuration
******************************************/
//* Check permissions for module
$app->auth->check_module_permissions('mail');
$app->load('listform_actions','functions');
$tmp_rec = $app->db->queryOneRecord("SELECT data from monitor_data WHERE type = 'database_size' ORDER BY created DESC");
$monitor_data = array();
$tmp_array = unserialize($tmp_rec['data']);
foreach($tmp_array as $database_name => $data) {
$db_name = $data['database_name'];
$temp = $app->db->queryOneRecord("SELECT client.username, web_database.database_quota FROM web_database, sys_group, client WHERE web_database.sys_groupid = sys_group.groupid AND sys_group.client_id = client.client_id AND web_database.database_name = ?'", $db_name);
$monitor_data[$db_name]['database_name'] = $data['database_name'];
$monitor_data[$db_name]['client']=$temp['username'];
$monitor_data[$db_name]['used'] = $data['size'];
$monitor_data[$db_name]['quota']=$temp['database_quota'];
unset($temp);
}
class list_action extends listform_actions {
function prepareDataRow($rec) {
global $app, $monitor_data;
$rec = $app->listform->decode($rec);
//* Alternating datarow colors
$this->DataRowColor = ($this->DataRowColor == '#FFFFFF') ? '#EEEEEE' : '#FFFFFF';
$rec['bgcolor'] = $this->DataRowColor;
$database_name = $rec['database_name'];
$rec['database'] = isset($monitor_data[$database_name]['database_name']) ? $monitor_data[$database_name]['database_name'] : array(1 => 0);
$rec['client'] = isset($monitor_data[$database_name]['client']) ? $monitor_data[$database_name]['client'] : array(1 => 0);
$rec['used'] = isset($monitor_data[$database_name]['used']) ? $monitor_data[$database_name]['used'] : array(1 => 0);
$rec['quota'] = isset($monitor_data[$database_name]['quota']) ? $monitor_data[$database_name]['quota'] : array(1 => 0);
if (!is_numeric($rec['used'])) $rec['used']=$rec['used'][1];
if($rec['quota'] == 0){
$rec['quota'] = $app->lng('unlimited');
$rec['percentage'] = '';
} else {
$rec['percentage'] = round(100 * $rec['used'] / ( $rec['quota']*1024*1024) ).'%';
$rec['quota'] .= ' MB';
}
if ($rec['used'] > 0) $rec['used'] = $app->functions->formatBytes($rec['used']);
$rec['id'] = $rec[$this->idx_key];
return $rec;
}
}
$list = new list_action;
$list->SQLExtWhere = "";
$list->onLoad();
?>
<?php
$wb["database_txt"] = 'Database';
$wb["client_txt"] = 'Client';
$wb["used_txt"] = 'Used space';
$wb["quota_txt"] = 'Quota';
$wb["percentage_txt"] = 'Used in %';
?>
......@@ -184,6 +184,11 @@ $items[] = array( 'title' => 'Website quota (Harddisk)',
'link' => 'sites/user_quota_stats.php',
'html_id' => 'user_quota_stats');
$items[] = array( 'title' => 'Database quota',
'target' => 'content',
'link' => 'sites/database_quota_stats.php',
'html_id' => 'databse_quota_stats');
$module['nav'][] = array( 'title' => 'Statistics',
'open' => 1,
'items' => $items);
......
<?php
// Name of the list
$liste["name"] = "database_quota_stats";
// Database table
$liste["table"] = "web_database";
// Index index field of the database table
$liste["table_idx"] = "database_id";
// Search Field Prefix
$liste["search_prefix"] = "search_";
// Records per page
$liste["records_per_page"] = "15";
// Script File of the list
$liste["file"] = "database_quota_stats.php";
// Script file of the edit form
$liste["edit_file"] = "database_edit.php";
// Paging Template
$liste["paging_tpl"] = "templates/paging.tpl.htm";
// Enable auth
$liste["auth"] = "yes";
// mark columns for php sorting (no real mySQL columns)
$liste["phpsort"] = array('used_sort', 'files');
/*****************************************************
* Suchfelder
*****************************************************/
//$liste["item"][] = array( 'field' => "domain",
$liste["item"][] = array( 'field' => "database_name",
'datatype' => "VARCHAR",
'filters' => array( 0 => array( 'event' => 'SHOW',
'type' => 'IDNTOUTF8')
),
'formtype' => "TEXT",
'op' => "like",
'prefix' => "%",
'suffix' => "%",
'width' => "",
'value' => ""
);
?>
<h2><tmpl_var name="list_head_txt"></h2>
<div class="panel panel_list_database_quota_stats">
<div class="pnl_listarea">
<fieldset><legend><tmpl_var name="list_head_txt"></legend>
<table class="list">
<thead>
<tr class="caption">
<th class="tbl_col_database tbl_col_nosort" scope="col"><tmpl_var name="database_txt"></th>
<th class="tbl_col_client tbl_col_nosort" scope="col"><tmpl_var name="client_txt"></th>
<th class="tbl_col_used_sort" scope="col"><tmpl_var name="used_txt"></th>
<th class="tbl_col_quota tbl_col_nosort" scope="col"><tmpl_var name="quota_txt"></th>
<th class="tbl_col_percentage tbl_col_nosort" scope="col"><tmpl_var name="percentage_txt">
<th class="tbl_col_limit" scope="col">{tmpl_var name='search_limit'}</th>
</tr>
<tr class="filter">
<td class="tbl_col_database"><input type="text" name="search_database_name" value="{tmpl_var name='search_database_name'}" /></td>
<td class="tbl_col_client">&nbsp;</td>
<td class="tbl_col_used">&nbsp;</td>
<td class="tbl_col_quota">&nbsp;</td>
<td class="tbl_col_percentage">&nbsp;</td>
<td class="tbl_col_buttons">
<button type="button" class="button icons16 icoFilter" name="Filter" id="Filter" value="{tmpl_var name="filter_txt"}" onclick="submitForm('pageForm','sites/database_quota_stats.php');"><span>{tmpl_var name="filter_txt"}</span></button>
</td>
</tr>
</thead>
<tbody>
<tmpl_loop name="records">
<tr class="tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td class="tbl_col_database"><a href="#" onclick="loadContent('sites/database_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="database"}</a></td>
<td class="tbl_col_client"><a href="#" onclick="loadContent('sites/database_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="client"}</a></td>
<td class="tbl_col_used"><a href="#" onclick="loadContent('sites/database_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="used"}</a></td>
<td class="tbl_col_quota"><a href="#" onclick="loadContent('sites/database_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="quota"}</a></td>
<td class="tbl_col_percentage"><a href="#" onclick="loadContent('sites/database_edit.php?id={tmpl_var name='id'}');">{tmpl_var name="percentage"}</a></td>
<td class="tbl_col_buttons"></td>
</tr>
</tmpl_loop>
<tmpl_unless name="records">
<tr class="tbl_row_noresults tbl_row_<tmpl_if name='__EVEN__'}even<tmpl_else>uneven</tmpl_if>">
<td colspan="7">{tmpl_var name='globalsearch_noresults_text_txt'}</td>
</tr>
</tmpl_unless>
</tbody>
<tfoot>
<tr>
<td class="tbl_footer tbl_paging" colspan="7"><tmpl_var name="paging"></td>
</tr>
</tfoot>
</table>
</fieldset>
</div>
</div>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment