Beispiel #1
0
 /**
  * Edit action - edit the message
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($message = Messages::findFirst($params[0]))) {
         $clients = Clients::find(['status!=:status:', 'bind' => ['status' => Clients::UNACTIVE]]);
         if (!count($clients)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the client first") . ': ' . $this->tag->linkTo('admin/clients/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Messages') . ' / ' . __('Edit'));
         $this->view->pick('messages/write');
         $this->view->setVars(['clients' => $clients, 'status' => Messages::status(true)]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $message->__set('clients', $clients);
             $valid = $message->edit();
             // Check if data are valid
             if ($valid instanceof Messages) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             $diff = ['client' => $message->client_id];
             // Values to fill out the form
             $this->tag->setDefaults(array_merge(get_object_vars($message), $diff));
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #2
0
 /**
  * Edit action - edit the network
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($network = Networks::findFirst($params[0]))) {
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Networks') . ' / ' . __('Edit'));
         $this->view->pick('networks/write');
         $this->view->setVars(['type' => Networks::type(true), 'status' => Networks::status(true), 'bitRate' => Settings::options('bitRate', $this->las['general']['bitRate'])]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $valid = $network->write('update');
             // Check if data are valid
             if ($valid instanceof Networks) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             $diff = ['subnetwork' => long2ip($network->subnetwork), 'IP' => long2ip($network->IP), 'gateway' => long2ip($network->gateway)];
             // Values to fill out the form
             $this->tag->setDefaults(array_merge(get_object_vars($network), $diff));
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #3
0
 /**
  * Edit action - edit the device
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($device = Devices::findFirst($params[0]))) {
         $clients = Clients::find(['status!=:status:', 'bind' => ['status' => Clients::UNACTIVE]]);
         $networks = Networks::find(['status=:status:', 'bind' => ['status' => Networks::ACTIVE]]);
         if (!count($clients)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the client first") . ': ' . $this->tag->linkTo('admin/clients/add', __('Add')));
         }
         if (!count($networks)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the network first") . ': ' . $this->tag->linkTo('admin/networks/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Devices') . ' / ' . __('Edit'));
         $this->view->pick('devices/write');
         $this->view->setVars(['clients' => $clients, 'networks' => $networks, 'type' => Devices::type(true), 'status' => Devices::status(true)]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $device->__set('clients', $clients);
             $device->__set('networks', $networks);
             $valid = $device->write('update');
             // Check if data are valid
             if ($valid instanceof Devices) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             // Values to fill out the form
             $this->tag->setDefaults(['name' => $device->name, 'network' => $device->network_id, 'client' => $device->client_id, 'type' => $device->type, 'IP' => long2ip($device->IP), 'MAC' => $device->MAC, 'description' => $device->description, 'status' => $device->status]);
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #4
0
 /**
  * Edit action - edit the tariff
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($tariff = Tariffs::findFirst($params[0]))) {
         $networks = Networks::find(['type=:type:', 'bind' => ['type' => Networks::WAN]]);
         if (!count($networks)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the network first") . ': ' . $this->tag->linkTo('admin/networks/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Tariffs') . ' / ' . __('Edit'));
         $this->view->pick('tariffs/write');
         $this->view->setVars(['status' => Tariffs::status(true), 'bitRate' => \Las\Models\Settings::options('bitRate', $this->las['general']['bitRate'])]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $valid = $tariff->write('update');
             // Check if data are valid
             if ($valid instanceof Tariffs) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             // Values to fill out the form
             $this->tag->setDefaults(get_object_vars($tariff));
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #5
0
 /**
  * Edit action - edit the firewall
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($firewall = Firewalls::findFirst($params[0]))) {
         // Set title, pick view and send variables
         $this->tag->setTitle(__('firewalls') . ' / ' . __('Edit'));
         $this->view->pick('firewalls/write');
         $this->view->setVars(['status' => Firewalls::status(true)]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $valid = $firewall->write('update');
             // Check if data are valid
             if ($valid instanceof Firewalls) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             $diff = ['status' => $firewall->status == Firewalls::COMPILED ? Firewalls::ACTIVE : $firewall->status];
             // Values to fill out the form
             $this->tag->setDefaults(array_merge(get_object_vars($firewall), $diff));
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #6
0
 /**
  * Edit action - edit the client
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($client = Clients::findFirst($params[0]))) {
         $tariffs = Tariffs::find(['status=:status:', 'bind' => ['status' => Tariffs::ACTIVE]]);
         if (!count($tariffs)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the tariff first") . ': ' . $this->tag->linkTo('admin/tariffs/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Clients') . ' / ' . __('Edit'));
         $this->view->pick('clients/write');
         $this->view->setVars(['tariffs' => $tariffs, 'status' => Clients::status(true)]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $client->__set('tariffs', $tariffs);
             $valid = $client->write('update');
             // Check if data are valid
             if ($valid instanceof Clients) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             // Values to fill out the form
             $this->tag->setDefaults(['fullName' => $client->fullName, 'address' => $client->address, 'tariff' => $client->tariff_id, 'description' => $client->description, 'status' => $client->status]);
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #7
0
 /**
  * Edit action - edit the service
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($service = Services::findFirst($params[0]))) {
         $clients = Clients::find(['status=:status:', 'bind' => ['status' => Clients::ACTIVE]]);
         $devices = Devices::find(['status=:status:', 'bind' => ['status' => Devices::ACTIVE]]);
         if (!count($clients)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the client first") . ': ' . $this->tag->linkTo('admin/clients/add', __('Add')));
         }
         if (!count($devices)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the device first") . ': ' . $this->tag->linkTo('admin/devices/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Services') . ' / ' . __('Add'));
         $this->view->pick('services/write');
         $this->view->setVars(['clients' => $clients, 'devices' => $devices, 'chain' => Services::chain(true), 'direction' => Services::direction(true), 'status' => Services::status(true), 'priority' => Services::priority(true), 'protocol' => Services::protocol(true), 'portDirection' => Services::portDirection(true)]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $service->__set('clients', $clients);
             $service->__set('devices', $devices);
             $valid = $service->write('update');
             // Check if data are valid
             if ($valid instanceof Services) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             $diff = ['client' => $service->client_id, 'device' => $service->device_id, 'IP' => $service->IP ? long2ip($service->IP) : null];
             // Values to fill out the form
             $this->tag->setDefaults(array_merge(get_object_vars($service), $diff));
         }
     } else {
         parent::notFoundAction();
     }
 }
Beispiel #8
0
 /**
  * Edit action - edit the task
  *
  * @package     las
  * @version     1.0
  */
 public function editAction()
 {
     // Get id from url params and check if record exist
     $params = $this->router->getParams();
     if (isset($params[0]) && ($task = Tasks::findFirst($params[0]))) {
         $firewalls = Firewalls::find();
         if (!count($firewalls)) {
             $this->flashSession->notice($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Notice') . '!</strong> ' . __("Please add the firewall first") . ': ' . $this->tag->linkTo('admin/firewalls/add', __('Add')));
         }
         // Set title, pick view and send variables
         $this->tag->setTitle(__('Tasks') . ' / ' . __('Edit'));
         $this->view->pick('tasks/write');
         $this->view->setVars(['type' => Tasks::type(true), 'status' => Tasks::status(true), 'firewalls' => $firewalls]);
         // Check if the form has been sent
         if ($this->request->isPost() === true && $this->request->hasPost('submit')) {
             $task->__set('firewalls', $firewalls);
             $valid = $task->write('update');
             // Check if data are valid
             if ($valid instanceof Tasks) {
                 $this->flashSession->success($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Success') . '!</strong> ' . __("The data has been saved."));
             } else {
                 $this->view->setVar('errors', $valid);
                 $this->flashSession->warning($this->tag->linkTo(['#', 'class' => 'close', 'title' => __("Close"), '×']) . '<strong>' . __('Warning') . '!</strong> ' . __("Please correct the errors."));
             }
         } else {
             $diff = ['firewall' => $task->firewall_id, 'next' => $task->next ? date('Y-m-d H:i', $task->next) : null];
             // Values to fill out the form
             $this->tag->setDefaults(array_merge(get_object_vars($task), $diff));
         }
     } else {
         parent::notFoundAction();
     }
 }