dhcp.diff

First implementation of DHCP server for 0.84 - webmyster, 10/15/2013 02:20 PM

Download (6.64 KB)

View differences:

front/dhcpserver.php (working copy)
33 33

  
34 34
include ('../inc/includes.php');
35 35

  
36
$dropdown = new IPNetwork();
37
include (GLPI_ROOT . "/front/dropdown.common.php");
36
Session::checkRight("internet","r");
37

  
38
Html::header(_n('DHCP server', 'DHCP servers', 2), $_SERVER['PHP_SELF'], 'inventory', 'allassets');
39

  
40
$query = 'SELECT `dhcp_servertype`, GROUP_CONCAT(DISTINCT `dhcp_servers_id`) AS dhcp_servers_ids
41
            FROM `glpi_networkports`
42
           WHERE `dhcp_servertype` IS NOT NULL '.getEntitiesRestrictRequest().'
43
          GROUP BY dhcp_servertype';
44

  
45
$result = $DB->request($query);
46
if ($result->numrows() > 0) {
47
   echo "<table class='tab_cadre_fixe'>";
48
   foreach($DB->request($query) as $line) {
49
      if ($dhcpserver = getItemForItemtype($line['dhcp_servertype'])) {
50
         $dhcpservers_ids = explode(',', $line['dhcp_servers_ids']);
51
         echo '<tr><th>'.$dhcpserver->getTypeName(count($dhcpservers_ids)).'</th></tr>';
52
         foreach($dhcpservers_ids as $dhcpservers_id) {
53
            if ($dhcpserver->getFromDB($dhcpservers_id)) {
54
               echo '<tr><td class="center">'.$dhcpserver->getLink().'</td></tr>';
55
            }
56
         }
57
      }
58
   }
59
   echo "</table>";
60
} else {
61
   echo "<div class='box' style='margin-bottom:20px;'>";
62
   echo "<div class='box-tleft'><div class='box-tright'><div class='box-tcenter'>";
63
   echo "</div></div></div>";
64
   echo "<div class='box-mleft'><div class='box-mright'><div class='box-mcenter'>";
65
   echo __('No DHCP server found');
66
   echo "</div></div></div>";
67
   echo "<div class='box-bleft'><div class='box-bright'><div class='box-bcenter'>";
68
   echo "</div></div></div>";
69
   echo "</div>";
70
}
71

  
72
Html::footer();
38 73
?>
install/update_0841_0843.php (working copy)
142 142
         }
143 143
      }
144 144
   }
145
   
146 145

  
146
   // Add DHCP field to NetworkPort
147
   $migration->addField('glpi_networkports', 'dhcp_servertype', 'string');
148
   $migration->addField('glpi_networkports', 'dhcp_servers_id', 'integer');
149
   $migration->addKey('glpi_networkports', array('dhcp_servertype', 'dhcp_servers_id'));
150

  
147 151
   // ************ Keep it at the end **************
148 152
   //TRANS: %s is the table or item to migrate
149 153
   $migration->displayMessage(sprintf(__('Data migration - %s'), 'glpi_displaypreferences'));
inc/networkport.class.php (working copy)
610 610
         $c_name    = $t_group->addHeader("Name", __('Name'), $c_main);
611 611
         $c_name->setItemType('NetworkPort');
612 612
         $c_name->setHTMLClass('center');
613
         $c_dhcp    = $t_group->addHeader('DHCP', _n('DHCP server', 'DHCP servers', 1), $c_main);
614
         $c_dhcp->setHTMLClass('center');
613 615

  
614 616
         if ($table_options['display_isDynamic']) {
615 617
            $c_dynamic = $t_group->addHeader("Dynamic", __('Automatic inventory'), $c_main);
......
726 728
                  $value = $netport->fields["name"];
727 729
                  $t_row->addCell($c_name, $value, NULL, $netport);
728 730

  
731
                  if ($netport->fields['dhcp_servertype'] != '') {
732
                     if ($dhcp_server = getItemForItemtype($netport->fields['dhcp_servertype'])) {
733
                        if ($dhcp_server->getFromDB($netport->fields['dhcp_servers_id'])) {
734
                           $value = $dhcp_server->getLink();
735
                        } else {
736
                           $value = Dropdown::getYesNo(false);
737
                        }
738
                     } else {
739
                        $value = Dropdown::getYesNo(false);
740
                     }
741
                  } else {
742
                     $value = Dropdown::getYesNo(false);
743
                  }
744
                  $t_row->addCell($c_dhcp, $value);
745

  
729 746
                  if ($table_options['display_isDynamic']) {
730 747
                     $t_row->addCell($c_dynamic,
731 748
                                     Dropdown::getYesNo($netport->fields['is_dynamic']));
......
816 833

  
817 834
      $this->displayRecursiveItems($recursiveItems, "Link");
818 835
      echo "</td>\n";
819
      $colspan = 2;
836
      $colspan = 3;
820 837

  
821 838
      if (!$options['several']) {
822 839
         $colspan ++;
......
850 867
      Html::autocompletionTextField($this, "name");
851 868
      echo "</td></tr>\n";
852 869

  
870
      echo "<tr class='tab_bg_1'><td>" . _n('DHCP server', 'DHCP servers', 1) . "</td>\n";
871
      echo "<td>";
872
      Dropdown::showAllItems('dhcp_servers_id', $this->fields['dhcp_servertype'],
873
                             $this->fields['dhcp_servers_id'], $this->fields['entities_id'],
874
                             array('Computer', 'NetworkEquipment'), false, false, 'dhcp_servertype');
875
      echo "</td></tr>\n";
876

  
853 877
      $instantiation = $this->getInstantiation();
854 878
      if ($instantiation !== false) {
855 879
         echo "<tr class='tab_bg_1'><th colspan='4'>".$instantiation->getTypeName(1)."</th></tr>\n";
inc/html.class.php (working copy)
1332 1332
      $menu['utils']['content']['rssfeed']['links']['search'] = '/front/rssfeed.php';
1333 1333
      $menu['utils']['content']['rssfeed']['links']['add']    = '/front/rssfeed.form.php';
1334 1334

  
1335
      $menu['utils']['content']['rssfeed']['title']           = _n('RSS feed', 'RSS feeds', 2);
1336
      $menu['utils']['content']['rssfeed']['page']            = '/front/rssfeed.php';
1337
      $menu['utils']['content']['rssfeed']['links']['search'] = '/front/rssfeed.php';
1338
      $menu['utils']['content']['rssfeed']['links']['add']    = '/front/rssfeed.form.php';
1339

  
1335 1340
      if (Session::haveRight("knowbase","r") || Session::haveRight("faq","r")) {
1336 1341
         if (Session::haveRight("knowbase","r")) {
1337 1342
            $menu['utils']['content']['knowbase']['title']        = __('Knowledge base');
......
1368 1373
         $menu['utils']['content']['report']['page']     = '/front/report.php';
1369 1374
      }
1370 1375

  
1376
      if (Session::haveRight("internet","r")) {
1377
         $menu['utils']['content']['dhcp_servers']['title']    = _n('DHCP server', 'DHCP servers', 2);
1378
         $menu['utils']['content']['dhcp_servers']['shortcut'] = 'd';
1379
         $menu['utils']['content']['dhcp_servers']['page']     = '/front/dhcpserver.php';
1380
      }
1381

  
1371 1382
      if (!isset($_SESSION['glpishowmigrationcleaner'])) {
1372 1383

  
1373 1384
         if (TableExists('glpi_networkportmigrations')