Esempio n. 1
0
 /**
  * Qos method - save Qos settings
  *
  * @package     las
  * @version     1.0
  */
 public static function qos($settings)
 {
     $validation = new \Las\Extension\Validation();
     $validation->add('defaultClass', new Validator\InclusionIn(array('domain' => Services::priority())));
     $validation->add('enableQos', new Validator\InclusionIn(array('domain' => [0, 1])));
     $validation->add('highestRate', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('highestRate', null, $settings)))));
     $validation->add('highestRate', new Validator\Between(array('minimum' => 1, 'maximum' => Services::rate('highestRate'))));
     $validation->add('highestCeil', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('highestCeil', null, $settings)))));
     $validation->add('highRate', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('highRate', null, $settings)))));
     $validation->add('highRate', new Validator\Between(array('minimum' => 1, 'maximum' => Services::rate('highRate'))));
     $validation->add('highCeil', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('highCeil', null, $settings)))));
     $validation->add('mediumRate', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('mediumRate', null, $settings)))));
     $validation->add('mediumRate', new Validator\Between(array('minimum' => 1, 'maximum' => Services::rate('mediumRate'))));
     $validation->add('mediumCeil', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('mediumCeil', null, $settings)))));
     $validation->add('lowRate', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('lowRate', null, $settings)))));
     $validation->add('lowRate', new Validator\Between(array('minimum' => 1, 'maximum' => Services::rate('lowRate'))));
     $validation->add('lowCeil', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('lowCeil', null, $settings)))));
     $validation->add('lowestRate', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('lowestRate', null, $settings)))));
     $validation->add('lowestRate', new Validator\Between(array('minimum' => 1, 'maximum' => Services::rate('lowestRate'))));
     $validation->add('lowestCeil', new Validator\InclusionIn(array('domain' => array_keys(Settings::options('lowestCeil', null, $settings)))));
     $validation->setLabels(array('defaultClass' => __('Default class'), 'enableQos' => __('Enable qos'), 'highestRate' => __('Highest rate'), 'highestCeil' => __('Highest ceil'), 'highRate' => __('High rate'), 'highCeil' => __('High ceil'), 'mediumRate' => __('Medium rate'), 'mediumCeil' => __('Medium ceil'), 'lowRate' => __('Low rate'), 'lowCeil' => __('Low ceil'), 'lowestRate' => __('Lowest rate'), 'lowestCeil' => __('Lowest ceil')));
     return Settings::updateSettings($settings, $validation);
 }
Esempio n. 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();
     }
 }
Esempio n. 3
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();
     }
 }