- show aps-databases also customer-mysql overview, fixes #272
- aps-databases are now increasing the customers mysql-contingent, refs #278 - customers viewing the aps-list are now notified if a package requires a database but the contingent is used up - the update will add all web[X]aps[Y] databases to the according customer regardless of contingent - fix tiny issue in preconfig - setting version to 0.9.10-svn2 refs #272,278
This commit is contained in:
@@ -252,6 +252,12 @@ class ApsInstaller extends ApsParser
|
||||
|
||||
$this->db_root->query('DROP DATABASE IF EXISTS `' . $this->db->escape($Database) . '`');
|
||||
$this->db_root->query('FLUSH PRIVILEGES');
|
||||
|
||||
/*
|
||||
* remove database from customer-mysql overview, #272
|
||||
*/
|
||||
$this->db->query('DELETE FROM `' . TABLE_PANEL_DATABASES . '` WHERE `customerid`="' . (int)$Row['CustomerID'] . '" AND `databasename`="' . $this->db->escape($Database) . '" AND `apsdb`="1"');
|
||||
$result = $this->db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 WHERE `customerid`="' . (int)$Row['CustomerID'] . '"');
|
||||
}
|
||||
|
||||
//remove task & delete package instance + settings
|
||||
@@ -259,20 +265,6 @@ class ApsInstaller extends ApsParser
|
||||
$this->db->query('DELETE FROM `' . TABLE_APS_TASKS . '` WHERE `Task` = ' . TASK_REMOVE . ' AND `InstanceID` = ' . $this->db->escape($Row['InstanceID']));
|
||||
$this->db->query('DELETE FROM `' . TABLE_APS_INSTANCES . '` WHERE `ID` = ' . $this->db->escape($Row['InstanceID']));
|
||||
$this->db->query('DELETE FROM `' . TABLE_APS_SETTINGS . '` WHERE `InstanceID` = ' . $this->db->escape($Row['InstanceID']));
|
||||
|
||||
|
||||
// decrease customer-counter
|
||||
/*
|
||||
* @TODO this is for 0.9.11 or so
|
||||
*
|
||||
$aps_userinfo = $db->query_first("SELECT * FROM `" . TABLE_PANEL_CUSTOMERS . "` WHERE `customerid` = '" . (int)$Row['CustomerID'] . "'");
|
||||
if($aps_userinfo['mysqls_used'] == '1')
|
||||
{
|
||||
$resetaccnumber = " , `mysql_lastaccountnumber`='0' ";
|
||||
}
|
||||
|
||||
$result = $db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`-1 ' . $resetaccnumber . 'WHERE `customerid`="' . (int)$Row['CustomerID'] . '"');
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -487,8 +479,6 @@ class ApsInstaller extends ApsParser
|
||||
|
||||
private function PrepareDatabase($Xml, $Row, $Task)
|
||||
{
|
||||
global $db_root;
|
||||
|
||||
$XmlDb = $Xml->requirements->children('http://apstandard.com/ns/1/db');
|
||||
|
||||
if ($this->aps_version == '1.0')
|
||||
@@ -525,6 +515,13 @@ class ApsInstaller extends ApsParser
|
||||
}
|
||||
|
||||
$this->db_root->query('FLUSH PRIVILEGES');
|
||||
|
||||
/*
|
||||
* add database to customers databases, #272
|
||||
*/
|
||||
$databasedescription = $Xml->name.' '.$Xml->version.' (Release ' . $Xml->release . ')';
|
||||
$result = $this->db->query('INSERT INTO `' . TABLE_PANEL_DATABASES . '` (`customerid`, `databasename`, `description`, `dbserver`, `apsdb`) VALUES ("' . (int)$Row['CustomerID'] . '", "' . $this->db->escape($NewDatabase) . '", "' . $this->db->escape($databasedescription) . '", "0", "1")');
|
||||
$result = $this->db->query('UPDATE `' . TABLE_PANEL_CUSTOMERS . '` SET `mysqls_used`=`mysqls_used`+1 WHERE `customerid`="' . (int)$Row['CustomerID'] . '"');
|
||||
}
|
||||
|
||||
//get first mysql access host
|
||||
|
||||
@@ -1351,7 +1351,7 @@ class ApsParser
|
||||
|
||||
private function InstallNewPackage($Filename)
|
||||
{
|
||||
global $lng;
|
||||
global $lng, $userinfo;
|
||||
|
||||
if(file_exists($Filename)
|
||||
&& $Xml = self::GetXmlFromZip($Filename))
|
||||
@@ -1831,7 +1831,7 @@ class ApsParser
|
||||
|
||||
public function MainHandler($Action)
|
||||
{
|
||||
global $lng, $filename, $s, $page, $action, $Id;
|
||||
global $lng, $filename, $s, $page, $action, $Id, $userinfo;
|
||||
|
||||
//check for basic functions, classes and permissions
|
||||
|
||||
@@ -2183,8 +2183,9 @@ class ApsParser
|
||||
}
|
||||
|
||||
// no more contingent, #278
|
||||
if($userinfo['aps_packages'] == $userinfo['aps_packages_used'])
|
||||
{
|
||||
if($userinfo['aps_packages'] == $userinfo['aps_packages_used']
|
||||
&& $userinfo['aps_packages'] != '-1'
|
||||
){
|
||||
self::InfoBox($lng['aps']['nocontingent']);
|
||||
}
|
||||
|
||||
@@ -3494,6 +3495,41 @@ class ApsParser
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* check if packages needs a database
|
||||
* and if the customer has contingent for that, #272
|
||||
*/
|
||||
if ($this->aps_version == '1.0')
|
||||
{
|
||||
// the good ole way
|
||||
$XmlDb = $Xml->requirements->children('http://apstandard.com/ns/1/db');
|
||||
}
|
||||
else
|
||||
{
|
||||
// since 1.1
|
||||
$Xml->registerXPathNamespace('db', 'http://apstandard.com/ns/1/db');
|
||||
|
||||
$XmlDb = new DynamicProperties;
|
||||
$XmlDb->db->id = getXPathValue($Xml, '//db:id');
|
||||
}
|
||||
|
||||
if($XmlDb->db->id)
|
||||
{
|
||||
if($userinfo['mysqls_used'] < $userinfo['mysqls']
|
||||
|| $userinfo['mysqls'] == '-1'
|
||||
){
|
||||
$can_use_db = true;
|
||||
} else {
|
||||
$can_use_db = false;
|
||||
}
|
||||
} else { $can_use_db = true; }
|
||||
|
||||
$db_info = '';
|
||||
if(!$can_use_db)
|
||||
{
|
||||
$db_info = $lng['aps']['packageneedsdb'];
|
||||
}
|
||||
|
||||
eval("echo \"" . getTemplate("aps/package") . "\";");
|
||||
unset($Xml);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user