Revize 1838
Přidáno uživatelem Ondřej Fibich před více než 11 roky(ů)
freenetis/branches/1.1/application/models/subnet.php | ||
---|---|---|
{
|
||
$this->db->query("
|
||
UPDATE subnets s
|
||
SET dhcp_expired = ?
|
||
WHERE s.dhcp > 0 AND s.id IN (?)
|
||
", $flag, implode(',', array_map('intval', $subnets)));
|
||
SET s.dhcp_expired = ?
|
||
WHERE s.dhcp > 0 AND
|
||
s.id IN (" . implode(',', array_map('intval', $subnets)) . ")
|
||
", $flag);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Check if any of device subnet on that the device is gateway is expired
|
||
*
|
||
* @param int $device_id
|
||
* @return boolean
|
||
*/
|
||
public function is_any_subnet_of_device_expired($device_id)
|
||
{
|
||
return $this->db->query("
|
||
SELECT COUNT(*) AS c
|
||
FROM ifaces i
|
||
JOIN ip_addresses ip ON i.id = ip.iface_id
|
||
JOIN subnets s ON s.id = ip.subnet_id
|
||
WHERE i.device_id = ? AND s.dhcp > 0 AND s.dhcp_expired > 0
|
||
AND ip.gateway > 0
|
||
", $device_id)->current()->c > 0;
|
||
}
|
||
|
||
/**
|
||
* Check if the MAC address is unique in the subnet.
|
||
*
|
||
* @param string $mac MAC address
|
freenetis/branches/1.1/application/controllers/ip_addresses.php | ||
---|---|---|
if (++$transaction_attempt_counter >= $max_attempts) // this was last attempt?
|
||
{
|
||
Log::add_exception($e);
|
||
status::error('Error - cant add ip address.' . $e->getMessage());
|
||
status::error('Error - cant add ip address.');
|
||
$this->redirect($linkback);
|
||
}
|
||
|
freenetis/branches/1.1/application/controllers/devices.php | ||
---|---|---|
$grid->order_field('type_name')
|
||
->label('Type');
|
||
|
||
$grid->order_link_field('subnet_id')
|
||
->link('subnets/show', 'subnet_name')
|
||
->label('Subnet');
|
||
|
||
$grid->order_link_field('ip_address_id')
|
||
->link('ip_addresses/show', 'ip_address')
|
||
->label('IP address');
|
||
|
||
$grid->order_callback_field('access_time')
|
||
->callback('callback::dhcp_servers_last_access_diff_field')
|
||
->label('Last access time');
|
||
... | ... | |
try // try to make DB transction
|
||
{
|
||
$device->transaction_start();
|
||
|
||
// expired subnets (#465)
|
||
$expired = array();
|
||
foreach ($device->ifaces as $i)
|
||
{
|
||
foreach ($i->ip_addresses as $ip)
|
||
{
|
||
$expired[] = $ip->subnet_id;
|
||
}
|
||
}
|
||
ORM::factory('subnet')->set_expired_subnets($expired);
|
||
|
||
$device->delete_throwable();
|
||
|
||
$device->transaction_commit();
|
||
|
||
try
|
||
... | ... | |
{
|
||
status::warning('Error - cannot update allowed subnets of member.');
|
||
}
|
||
|
||
// expired subnets (#465)
|
||
ORM::factory('subnet')->set_expired_subnets($subnets);
|
||
|
||
// redirect
|
||
status::success('Device has been successfully deleted.');
|
Také k dispozici: Unified diff
Upravy:
- pridana funkce pri zjisteni expirovanych subnetu
Opravy:
- #465: Optimalizace reloadu DHCP zaznamu (chybne chovani pri mazani zarizeni)