Force le recalcul des quotas juste avant l'affichage des menus

=> si on viens de faire un ajout, ça en tiens compte dans l'affichage \o/
This commit is contained in:
Alan Garcia 2012-08-27 10:37:31 +00:00
parent f0842b9b5a
commit cbbbc3d5f9
3 changed files with 21 additions and 29 deletions

View File

@ -36,6 +36,8 @@ require_once("../class/config.php");
<div class="menu-title"><img src="images/home.png" alt="<?php __("Home / Information"); ?>" />&nbsp;<a href="main.php"><?php __("Home / Information"); ?></a></div>
</div>
<?php
// Force rebuilding quota, in case of add or edit of the quota and cache not up-to-date
$quota->getquota("",true); // rebuild quota
$MENUPATH=ALTERNC_PANEL."/admin/";
$file=file("/etc/alternc/menulist.txt", FILE_SKIP_EMPTY_LINES);

View File

@ -34,37 +34,24 @@ $fields = array (
);
getFields($fields);
if (!$quota->cancreate("mysql")) {
$error=_("err_mysql_1");
include("sql_add.php");
$error=_("You ");
include("sql_add.php"); //FIXME svn del sql_add
exit;
}
$q=$quota->getquota("mysql");
if($q['u'] == 0){
$dbname=$mem->user["login"];
if(!$mysql->add_db($dbname)){
$error=$err->errstr();
include("sql_add.php");
exit;
}
}else{
if(!empty($dbn)){
if($q['u'] > 0){
$dbname=$mem->user["login"]."_".$dbn;
if(!$mysql->add_db($dbname)) {
$error=$err->errstr();
include("sql_add.php");
exit;
}
} else {
$dbname=$mem->user["login"];
}
if(!$mysql->add_db($dbname)) {
$error=$err->errstr();
include("sql_add.php");
include("sql_add.php"); //FIXME svn del sql_add
exit;
}
}
}
include("sql_list.php");

View File

@ -81,15 +81,18 @@ class m_quota {
return $qlist;
}
/* ----------------------------------------------------------------- */
/** Return a ressource usage (u) and total quota (t)
* @param string $ressource ressource to get quota of
* @Return array the quota used and total for this ressource (or for all ressource if unspecified)
*/
function getquota($ressource="") {
function getquota($ressource="",$recheck=false) {
global $db,$err,$cuid,$get_quota_cache,$hooks;
$err->log("quota","getquota",$ressource);
if ($recheck) { // rebuilding quota
$get_quota_cache=null;
$this->quota=array();
}
if (! empty($get_quota_cache[$cuid]) ) {
// This function is called many time each webpage, so I cache the result
$this->quotas = $get_quota_cache[$cuid];