Files
thetool/application/Admin/AdminController.php
2022-11-15 16:20:33 +01:00

41 lines
1.0 KiB
PHP

<?php
class AdminController extends mfBaseController {
protected function init() {
$this->needlogin=true;
$me = new User();
$me->loadMe();
$this->me = $me;
$this->layout()->set("me",$me);
if(!$me->is(["Admin"])) {
$this->redirect("Dashboard");
}
}
protected function indexAction() {
$this->layout()->setTemplate("Admin/Index");
}
protected function createNetworkAddressForNetowner() {
$i = 0;
foreach(NetworkModel::getAll() as $network) {
$netaddress = NetworkAddressModel::getFirst(["network_id" => $network->id, "address_id" => $network->owner_id, "addresstype" => "netowner"]);
if(!$netaddress) {
$netaddress = NetworkAddressModel::create([
'network_id' => $network->id,
'address_id' => $network->owner_id,
'type' => "netowner"
]);
$netaddress->save();
$i++;
}
}
$this->layout()->setFlash("$i NetworkAddress Objekte angelegt.", "success");
$this->redirect("Admin");
}
}