示例#1
0
 /** 
  * delete Vlan 
  */
 public function deleteVlans()
 {
     //init Vlan class
     $vlan = new Vlan();
     //provide id
     $vlan->id = $this->_params['id'];
     //fetch results
     $res = $vlan->deleteVlan();
     //return Vlan(s) in array format
     return $res;
 }
示例#2
0
    protected function renderVlan(Vlan $vlan, Port $port)
    {
        $display = '';
        if ('' != $vlan->getName()) {
            $display = $vlan->getName() . ' (' . $vlan->getId() . ')';
        }
        ?>
        <td rowspan="<?php 
        echo $port->nbVlanDistant[$vlan->getId()];
        ?>
"><?php 
        echo $display;
        ?>
</td>
        <?php 
    }
示例#3
0
 /**
  * Logs in the user using the given username and password in the model.
  * @return boolean whether login is successful
  */
 public function searchResult()
 {
     $result = array();
     $hosts = Host::model()->findAllByAttributes(array('id' => $this->hosts));
     switch ($this->type) {
         case "camtable_mac":
             $search_table = 'camtable';
             $search_field = 'mac';
             break;
         case "camtable_vlan":
             $search_table = 'camtable';
             $search_field = 'vlan_tag';
             break;
     }
     if (count($hosts) && $search_table == 'camtable') {
         foreach ($hosts as $host) {
             $host->loadCamTable();
             foreach ($host->cam_table as $row) {
                 if ($this->exact_match) {
                     $found = $row[$search_field] == $this->query;
                 } else {
                     $found = strpos($row[$search_field], $this->query) !== FALSE;
                 }
                 if ($found) {
                     $hostDst = $host->getHostOnPort($row['port']);
                     if ($this->exclude_link_ports && !empty($hostDst)) {
                         continue;
                     }
                     $row['host'] = $host;
                     $row['hostDst'] = $hostDst;
                     $row['vlan'] = Vlan::model()->findByAttributes(array('tag' => $row['vlan_tag']));
                     $result[] = $row;
                 }
             }
         }
     }
     return $result;
 }
示例#4
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "assign_vlan":
             Vlan::dropdown();
             echo "&nbsp;" . __('Tagged') . "&nbsp;<input type='checkbox' name='tagged' value='1'>";
             echo "&nbsp;<input type='submit' name='assign_vlan' class='submit' value='" . __s('Associate') . "'>";
             return true;
         case "unassign_vlan":
             Vlan::dropdown();
             echo "&nbsp;<input type='submit' name='unassign_vlan' class='submit' value='" . __s('Dissociate') . "'>";
             return true;
         case "move_port":
             Dropdown::show('NetworkEquipment', array('name' => 'items_id'));
             echo "&nbsp;<input type='submit' name='move' class='submit' value=\"" . __s('Move') . "\">";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         $nb = 0;
         switch ($item->getType()) {
             case 'NetworkPort':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     $nb = countElementsInTable($this->getTable(), "networkports_id = '" . $item->getID() . "'");
                 }
                 return self::createTabEntry(Vlan::getTypeName(), $nb);
         }
     }
     return '';
 }
/** Generate bigdump : generate global dropdowns
**/
function generateGlobalDropdowns() {
   global $MAX, $DB;

   $items = array("CD", "CD-RW", "DVD-R", "DVD+R", "DVD-RW", "DVD+RW", "ramette papier",
                  "disk'ette", "ZIP");

   $dp = new ConsumableItemType();
   for ($i=0 ; $i<$MAX['consumable_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' consommable $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("phone d'power");
   $dp    = new PhonePowerSupply();
   for ($i=0 ; $i<$MAX['phone_power'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power ' $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Grand", "Moyen", "Mic'ro", "1U", "5U");
   $dp    = new DeviceCaseType();
   for ($i=0 ; $i<$MAX['case_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power ' $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Laser", "Jet d'Encre", "Encre Solide");
   $dp    = new CartridgeItemType();
   for ($i=0 ; $i<$MAX['cartridge_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' cartouche $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Technicien", "Commercial", "Technico-Commercial", "President", "Secretaire",
                  "Directeur d'agence");
   $dp    = new ContactType();
   for ($i=0 ; $i<$MAX['contact_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' contact $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }

   $items = array("Maintenance", "Support", "Location", "Adhesion");
   $dp    = new ContractType();
   for ($i=0 ; $i<$MAX['contract_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' crontact $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Fournisseur", "Transporteur", "SSII", "Revendeur d'", "Assembleur", "SSLL",
                  "Financeur", "Assureur");
   $dp    = new SupplierType();
   for ($i=0 ; $i<$MAX['enttype'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d'entreprise $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("H.07.02", "I.07.56", "P51", "P52", "1.60", "4.06", "43-4071299", "1.0.14",
                  "3.0.1", "rev 1.0", "rev 1.1", "rev 1.2", "rev 1.2.1", "rev 2.0", "rev 3.0");
   $dp    = new NetworkEquipmentFirmware();
   for ($i=0 ; $i<$MAX['firmware'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "firmware  $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Fire'wire");
   $dp    = new InterfaceType();
   for ($i=0 ; $i<$MAX['interface'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' disque dur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("100 Base TX", "100 Base T4", "10 base T", "1000 Base SX", "1000 Base LX",
                  "1000 Base T", "ATM", "802.3 10 Base 2", "IEEE 803.3 10 Base 5");
   $dp    = new NetworkInterface();
   for ($i=0 ; $i<$MAX['iface'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type carte reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Non", "Oui - generique", "Oui - specifique d'entite");
   $dp    = new AutoUpdateSystem();
   for ($i=0 ; $i<$MAX['auto_update'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de mise a jour '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Assemble", "Latitude C600", "Latitude C700", "VAIO FX601", "VAIO FX905P",
                  "VAIO TR5MP", "L5000C", "A600K", "PowerBook G4");
   $dp    = new ComputerModel();
   for ($i=0 ; $i<$MAX['model'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "Modele $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }


   $items = array("4200 DTN", "4200 DN", "4200 N", "8400 ADP", "7300 ADP", "5550 DN",
                  "PIXMA iP8500", "Stylus Color 3000", "DeskJet 5950");
   $dp    = new PrinterModel();
   for ($i=0 ; $i<$MAX['model_printers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele imprimante $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("LS902UTG", "MA203DT", "P97F+SB", "G220F", "10-30-75", "PLE438S-B0S",
                  "PLE481S-W", "L1740BQ", "L1920P", "SDM-X73H");
   $dp    = new MonitorModel();
   for ($i=0 ; $i<$MAX['model_monitors'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele moniteur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("HP 4108GL", "HP 2524", "HP 5308", "7600", "Catalyst 4500", "Catalyst 2950",
                  "Catalyst 3750", "Catalyst 6500");
   $dp    = new NetworkEquipmentModel();
   for ($i=0 ; $i<$MAX['model_networking'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele materiel reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DCS-2100+", "DCS-2100G", "KD-P35B", "Optical 5000", "Cordless", "ASR 600",
                  "ASR 375", "CS21", "MX5020", "VS4121", "T3030", "T6060");
   $dp    = new PeripheralModel();
   for ($i=0 ; $i<$MAX['model_peripherals'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele peripherique $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Alcatel Temporis 22", "Aastra 5370ip", "Alcatel-Lucent 400 DECT Handset",
                  "BlackBerry Curve 9300");
   $dp    = new PhoneModel();
   for ($i=0 ; $i<$MAX['model_phones'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele phone $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }


   $items = array("SIC", "LMS", "LMP", "LEA", "SP2MI", "STIC", "MATH", "ENS-MECA", "POUBELLE",
                  "WIFI");
   $dp    = new Network();
   for ($i=0 ; $i<$MAX['network'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Windows XP Pro SP2", "Linux (Debian)", "Mac OS X", "Linux (Mandriva 2006)",
                  "Linux (Redhat)", "Windows 98", "Windows 2000", "Windows XP Pro SP1",
                  "LINUX (Suse)", "Linux (Mandriva 10.2)");
   $dp    = new OperatingSystem();
   for ($i=0 ; $i<$MAX['os'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "os $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("XP Pro", "XP Home", "10.0", "10.1", "10.2", "2006", "Sarge");
   $dp    = new operatingSystemVersion();
   for ($i=0 ; $i<$MAX['os_version'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "osversion $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Service Pack 1", "Service Pack 2", "Service Pack 3", "Service Pack 4");
   $dp    = new OperatingSystemServicePack();
   for ($i=0 ; $i<$MAX['os_sp'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "ossp $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DDR2");
   $dp    = new DeviceMemoryType();
   for ($i=0 ; $i<$MAX['ram_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de ram $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }

   $items = array('Bureautique', 'Calcul', "logiciel d'antivirus", 'Multimédia');
   $dp    = new SoftwareCategory();
   for ($i=0 ; $i<max(1,pow($MAX['softwarecategory'],1/2)) ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "category $i";
      }
      $newID = $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                                       'comment' => "comment $val")));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['softwarecategory'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(array('name'    => "s-category '$j",
                                                           'comment' => "comment d' $val s-category $j",
                                                           'softwarecategories_id'
                                                                     => $newID)));
      }
   }
   $MAX['rubdocs'] = getMaxItem('glpi_softwarecategories');

   $dp = new SoftwareLicenseType();
   for ($i=0 ; $i<$MAX['licensetype'] ; $i++) {
      $val = "type ' $i";
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("SIC", "LMS", "LMP", "LEA", "SP2MI", "STIC", "MATH", "ENS-MECA", "POUBELLE",
                  "WIFI");
   $dp    = new Vlan();
   for ($i=0 ; $i<$MAX['vlan'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "VLAN $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val",
                                              'tag'     => $i)));
   }


   $items = array("Portable", "Desktop", "Tour");
   $dp    = new ComputerType();
   for ($i=0 ; $i<$MAX['type_computers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type ordinateur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Laser A4", "Jet d'Encre", "Laser A3", "Encre Solide A4", "Encre Solide A3");
   $dp    = new PrinterType();
   for ($i=0 ; $i<$MAX['type_printers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d'imprimante $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("TFT 17", "TFT 19", "TFT 21", "CRT 17", "CRT 19", "CRT 21", "CRT 15");
   $dp    = new MonitorType();
   for ($i=0 ; $i<$MAX['type_monitors'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type ecran $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Switch", "Routeur", "Hub", "Borne Wifi", "borne d'accueil");
   $dp    = new NetworkEquipmentType();
   for ($i=0 ; $i<$MAX['type_networking'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de materiel reseau '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Clavier", "Souris", "Webcam", "Enceintes", "Scanner", "Clef USB", "d'autres");
   $dp    = new PeripheralType();
   for ($i=0 ; $i<$MAX['type_peripherals'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de peripheriques '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Analogique", "IP", );
   $dp    = new PhoneType();
   for ($i=0 ; $i<$MAX['type_phones'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de phone $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DELL", "HP", "IIYAMA", "CANON", "EPSON", "LEXMARK", "ASUS", "MSI");
   $dp    = new Manufacturer();
   for ($i=0 ; $i<$MAX['manufacturer'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "manufacturer $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Ingénieur", "Stagiaire", "Secrétaire", "ouvrier d'atelier");
   $dp    = new UserCategory();
   for ($i=0 ; $i<$MAX['user_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "user type d'$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Président", "Agent Comptable", "Directeur d'agence");
   $dp    = new UserTitle();
   for ($i=0 ; $i<$MAX['user_title'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "user type '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }

   $items = array("Documentation", "Facture", "Bon Livraison", "Bon commande", "Capture d'Ecran",
                  "Dossier Technique");
   $dp    = new DocumentCategory();
   for ($i=0 ; $i<max(1,pow($MAX['rubdocs'],1/2)) ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "category $i";
      }
      $newID = $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                                       'comment' => "comment $val")));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['rubdocs'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(
                            array('name'                        => "s-category '$j",
                                  'comment'                     => "comment d' $val s-category $j",
                                  'documentcategories_id'       => $newID)));
      }
   }
   $MAX['rubdocs'] = getMaxItem('glpi_documentcategories');

   $dp = new ItilCategory();
   // GLobal ticket categories : also specific ones by entity
   for ($i=0 ; $i<max(1,pow($MAX['tracking_category'],1/3)) ; $i++) {
      $newID = $dp->add(toolbox::addslashes_deep(
                        array('name'                        => "category '$i",
                              'comment'                     => "comment ' category $i",
                              'is_recursive'                => 1,
                              'tickettemplates_id_incident' => 1,
                              'tickettemplates_id_demand'   => 1)));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['tracking_category'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(
                            array('name'                        => "s-category '$j",
                                  'comment'                     => "comment 'category $i s-category $j",
                                  'is_recursive'                => 1,
                                  'tickettemplates_id_incident' => 1,
                                  'tickettemplates_id_demand'   => 1,
                                  'itilcategories_id'           => $newID)));

         for ($k=0 ; $k<mt_rand(0,pow($MAX['tracking_category'],1/2)) ; $k++) {
            $newID3 = $dp->add(toolbox::addslashes_deep(
                               array('name'                        => "ss-category' $k",
                                     'comment'      => "comment ' category $i s-category $j ss-category $k",
                                     'is_recursive'                => 1,
                                     'tickettemplates_id_incident' => 1,
                                     'tickettemplates_id_demand'   => 1,
                                     'itilcategories_id'           => $newID2)));
         }
      }
   }

   $query = "OPTIMIZE TABLE `glpi_itilcategories`";
   $DB->query($query) or die("PB REQUETE ".$query);

   regenerateTreeCompleteName("glpi_itilcategories");

   $MAX['tracking_category'] = getMaxItem('glpi_itilcategories');

   // DEVICE
   $items = array("Textorm 6A19", "ARIA", "SLK3000B-EU", "Sonata II", "TA-212", "TA-551", "TA-581",
                  "TAC-T01", "CS-512", "Li PC-60891", "STT-TJ02S");
   $dp    = new DeviceCase();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "case $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'devicecasetypes_id' => mt_rand(0,$MAX["case_type"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("Escalade 8006-2LP", "Escalade 8506-4LP", "2810SA", "1210SA", "DuoConnect",
                  "DU-420", "DUB-A2", "FastTrak SX4100B", "DC-395U", "TFU-H33PI");
   $dp    = new DeviceControl();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "control $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment ' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("DUW1616", "DRW-1608P", "DW1625", "GSA-4160B", "GSA-4165B", "GSA-4167RBB",
                  "SHW-16H5S", "SOHW-1673SX", "DVR-110D", "PX-716AL", "PX-755A");
   $dp    = new DeviceDrive();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "drive $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'is_writer'          => mt_rand(0,1),
                     'speed'              => mt_rand(0,60),
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("A9250/TD", "AX550/TD", "Extreme N5900", "V9520-X/TD", "All-In-Wonder X800 GT",
                  "GV-NX66256D", "GV-RX80256DE", "Excalibur 9600XT", "X1300 IceQ",
                  "WinFast PX6200 TD", "Millenium 750","NX6600GT");
   $dp    = new DeviceGraphicCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "gfxcard $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment ' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'memory_default'     => 256*mt_rand(0,8))));
   }


   $items = array("Deskstar 7K500", "Deskstar T7K250", "Atlas 15K II", "DiamondMax Plus",
                  "SpinPoint P - SP2514N", "Barracuda 7200.9", "WD2500JS", "WD1600JB", "WD1200JD");
   $dp    = new DeviceHardDrive();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "hdd  $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'capacity_default'   => mt_rand(0,300),
                     'rpm'                => mt_rand(0,15000),
                     'cache'              => 51200*mt_rand(0,10))));
   }


   $items = array("DFE-530TX", "DFE-538TX", "PWLA8492MF", "PWLA8492MT", "USBVPN1", "GA311", "FA511",
                  "TEG-PCBUSR", "3C996-SX", "3C996B-T", "3C905C-TX-M");
   $dp    = new DeviceNetworkCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "iface  $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'bandwidth'          => mt_rand(0,1000))));
   }


   $items = array("AW8-MAX", "NV8", "AK86-L", "P4V88", "A8N-SLI", "A8N-VM", "K8V-MX", "K8N4-E",
                  "P5LD2", "GA-K8NE", "GA-8I945P Pro", "D945PBLL", "SE7525GP2", "865PE Neo3-F",
                  "K8N Neo4-F", "Thunder i7520 (S5360G2NR)", "Thunder K8SR - S2881UG2NR",
                  "Tiger K8QS Pro - S4882UG2NR", "Tomcat i875PF (S5105G2NR)");
   $dp    = new DeviceMotherBoard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "moboard $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'chipset'            => 'chipset '.mt_rand(0,1000))));
   }


   $items = array("Instant TV Cardbus", "WinTV Express", "WinTV-NOVA-S-Plus", "WinTV-NOVA-T",
                  "WinTV-PVR-150");
   $dp    = new DevicePci();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "pci $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("DB-Killer PW335", "DB-Killer PW385", "NeoHE 380", "NeoHE 450", "Phantom 500-PEC",
                  "TruePower 2.0 550", "Master RS-380", "EG375AX-VE-G-SFMA", "EG495AX");
   $dp    = new DevicePowerSupply();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'power'              => mt_rand(0,500).'W',
                     'is_atx'             => mt_rand(0,1))));
   }


   $items = array("Athlon 64 FX-57", "Athlon 64 FX-55", "Sempron 2400+", "Sempron 2600+",
                  "Celeron D 325", "Celeron D 330J", "Pentium 4 530J", "Pentium 4 631",
                  "Pentium D 830", "Pentium D 920");
   $dp    = new DeviceProcessor();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "processor $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'frequence'          => mt_rand(1000,3000),
                     'frequency_default'  => 1000+200*mt_rand(0,10),
                     'nbcores_default'    => mt_rand(1,8),
                     'nbthreads_default'  => mt_rand(1,4),
                     )));
   }


   $items = array("CM2X256A-5400C4", "CMX1024-3200C2", "CMXP512-3200XL", "TWIN2X1024-4300C3PRO",
                  "KTD-DM8400/1G", "KTH8348/1G", "KTD4400/256", "D6464D30A", "KTA-G5400/512",
                  "KVR667D2N5/1G", "KVR133X64C3/256");
   $dp    = new DeviceMemory();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "ram $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'          => $val,
                     'is_recursive'         => 1,
                     'comment'              => "comment' $val",
                     'manufacturers_id'     => mt_rand(1,$MAX['manufacturer']),
                     'frequence'            => 100*mt_rand(0,10),
                     'size_default'         => 1024*mt_rand(0,6),
                     'devicememorytypes_id' => mt_rand(1,$MAX['ram_type']))));
   }


   $items = array("DDTS-100", "Audigy 2 ZS Platinum", "Audigy SE", "DJ Console Mk2",
                  "Gamesurround Muse Pocket USB", "Phase 22", "X-Fi Platinum", "Live! 24-bit",
                  "X-Fi Elite Pro");
   $dp    = new DeviceSoundCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "sndcard $i";
      }
       $dp->add(toolbox::addslashes_deep(
                array('designation'         => $val,
                     'is_recursive'         => 1,
                     'comment'              => "comment '$val",
                     'manufacturers_id'     => mt_rand(1,$MAX['manufacturer']),
                     'type'                 => 'type '.mt_rand(0,100))));
   }

} // Fin generation global dropdowns
 /**
  * Get netwok ports for an object
  * for an authenticated user
  *
  * @param $protocol the commonication protocol used
  * @param $item_type : type of the item
  * @param $item_id : ID of the item
  * @param $id2name : translate id of dropdown to name
  *
  **/
 static function getItemNetworkports($protocol, $item_type, $item_id, $id2name = false)
 {
     global $DB;
     $item = new $item_type();
     $resp = array();
     if ($item->getFromDB($item_id) && $item->canView()) {
         //Get all ports for the object
         $ports = getAllDatasFromTable('glpi_networkports', "`itemtype`='{$item_type}' AND `items_id`='{$item_id}'");
         foreach ($ports as $port) {
             if ($id2name) {
                 if ($port['networkinterfaces_id'] > 0) {
                     $port['networkinterfaces_name'] = Html::clean(Dropdown::getDropdownName('glpi_networkinterfaces', $port['networkinterfaces_id']));
                 }
             }
             if ($port['netpoints_id'] > 0) {
                 //Get netpoint informations
                 $netpoint = new Netpoint();
                 $netpoint->getFromDB($port['netpoints_id']);
                 if ($id2name) {
                     $netpoint->fields['location_name'] = Html::clean(Dropdown::getDropdownName('glpi_locations', $netpoint->fields['locations_id']));
                 }
                 $port['netpoints'][$netpoint->fields['id']] = $netpoint->fields;
             }
             //Get VLANS
             $vlan = new NetworkPort_Vlan();
             $tmp = new Vlan();
             foreach ($vlan->getVlansForNetworkPort($port['id']) as $vlans_id) {
                 $tmp->getFromDB($vlans_id);
                 $port['vlans'][$tmp->fields['id']] = $tmp->fields;
             }
             $resp[$port['id']] = $port;
         }
     }
     return $resp;
 }
示例#8
0
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer $tag the Tag of the VLAN to be loaded
  * @return Vlan the loaded model
  * @throws CHttpException
  */
 public function loadModelByTag($tag)
 {
     $model = Vlan::model()->findByAttributes(array('tag' => $tag));
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#9
0
 /**
  * Displays connections of Host.
  */
 public function actionCamTable()
 {
     try {
         if (isset($_GET['id'])) {
             $model = $this->loadModel((int) $_GET['id']);
         } else {
             if (isset($_GET['name'])) {
                 $model = $this->loadModelByName((string) $_GET['name']);
             }
         }
         $model->loadCamTable();
         // TODO: associar roteadores aos switches para pegar a
         // tabela ARP dos gateways da rede
         //
         $gateway = Host::model()->findByPk(Yii::app()->params['hostGatewayId']);
         $cam_table = array();
         foreach ($model->cam_table as $ctItem) {
             $mac = $ctItem['mac'];
             $ctItem['host'] = $ctItem['mac'] ? Host::model()->findByAttributes(array('mac' => $mac)) : null;
             if (!$ctItem['host'] instanceof Host) {
                 $ip = $gateway instanceof Host ? $gateway->getIpInArpTable($mac) : null;
                 if ($ip) {
                     $ctItem['host'] = new Host();
                     $ctItem['host']->mac = $mac;
                     $ctItem['host']->ip = $ip;
                     $ctItem['host']->name = $ip ? $ip : $mac;
                 }
             }
             $ctItem['host_dst'] = $ctItem['host'] instanceof Host ? $model->getHostOnPort($ctItem['port']) : null;
             $ctItem['vlan'] = Vlan::model()->findByAttributes(array('tag' => $ctItem['vlan_tag']));
             if (!$ctItem['vlan'] instanceof Vlan) {
                 $ctItem['vlan'] = new Vlan();
                 $ctItem['vlan']->tag = $ctItem['vlan_tag'];
             }
             $cam_table[] = $ctItem;
         }
         $this->render('camTable', array('model' => $model, 'cam_table' => $cam_table));
     } catch (CHttpException $e) {
         if (isset($_GET['name'])) {
             $name = (string) trim($_GET['name']);
             $this->render('addHostNotFound', array('name' => $name));
         } else {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
 }
示例#10
0
 public function actionListHosts()
 {
     $this->layout = '//layouts/json';
     try {
         if (isset($_GET['hostId'])) {
             $hostId = (int) $_GET['hostId'];
             // get root host
             //
             $rootHost = $hosts[] = Host::model()->findbyPk($hostId);
             // get connections
             $hostConnections = $rootHost->getConnections();
             // get host from connections
             foreach ($hostConnections as $hosts_conn) {
                 array_push($hosts, $hosts_conn->hostDst);
             }
             // in switches, get hosts by CAM table
             if ($rootHost->type == Host::TYPE_SWITCH) {
                 $rootHost->loadCamTable();
                 // TODO: associar roteadores aos switches para pegar a
                 // tabela ARP dos gateways da rede
                 //
                 $gateway = Host::model()->findByPk(Yii::app()->params['hostGatewayId']);
                 //                    $arpTable = array();
                 foreach ($rootHost->cam_table as $k => $camHost) {
                     // se existir conexao cadastrada para a porta, ignore o host
                     // TODO: usar tipo do link==backbone
                     $hostOnPort = $rootHost->getHostOnPort($camHost['port']);
                     if ($hostOnPort instanceof Host && $hostOnPort->type != Host::TYPE_UNKNOWN) {
                         continue;
                     }
                     // havendo 2 ou + hosts numa porta sem conexao cadastrada, criar 'hub virtual'
                     $port = $camHost['port'];
                     $portLabelPrefix = 'port_';
                     if ($port == $rootHost->cam_table[$k + 1]['port'] || $sourcePort == $portLabelPrefix . $port) {
                         $sourcePort = $portLabelPrefix . $port;
                         if (!isset($virtualHost[$sourcePort])) {
                             $virtualHost[$sourcePort] = new Host();
                             $virtualHost[$sourcePort]->name = $sourcePort;
                             $virtualHost[$sourcePort]->type = Host::TYPE_SUPPOSED_HUB;
                             array_push($hosts, $virtualHost[$sourcePort]);
                             $virtualConn[$sourcePort] = new Connection();
                             $virtualConn[$sourcePort]->hostSrc = $rootHost;
                             $virtualConn[$sourcePort]->hostDst = $virtualHost[$sourcePort];
                             $virtualConn[$sourcePort]->host_src_port = $camHost['port'];
                             $virtualConn[$sourcePort]->type = Connection::TYPE_SUPPOSED_LINK;
                             // TODO: especificar tipo do link
                             array_push($hostConnections, $virtualConn[$sourcePort]);
                         }
                     } else {
                         unset($sourcePort);
                     }
                     // host
                     $host = Host::model()->findByAttributes(array('mac' => $camHost['mac']));
                     if ($host instanceof Host) {
                         $h = $host;
                     } else {
                         $h = new Host();
                         $h->mac = $camHost['mac'];
                         $h->ip = $gateway instanceof Host ? $gateway->getIpInArpTable($camHost['mac']) : null;
                         $h->name = $h->ip ? $h->ip : $h->mac;
                         $h->setTypeByMAC();
                     }
                     array_push($hosts, $h);
                     // connection
                     $c = new Connection();
                     $c->hostSrc = $virtualHost[$sourcePort] ? $virtualHost[$sourcePort] : $rootHost;
                     $c->hostDst = $h;
                     $c->host_src_port = $camHost['port'];
                     $c->type = Connection::TYPE_UNKNOWN;
                     // vlan
                     $c->vlan = Vlan::model()->findByAttributes(array('tag' => $camHost['vlan_tag']));
                     if (!$c->vlan instanceof Vlan) {
                         $c->vlan = new Vlan();
                         $c->vlan->tag = $camHost['vlan_tag'];
                     }
                     array_push($hostConnections, $c);
                 }
             }
         } else {
             $hosts = Host::model()->findAll(array('order' => 'id'));
             $hostConnections = Connection::model()->findAll();
         }
         $this->render('listHosts', array('hosts' => $hosts, 'hostConnections' => $hostConnections));
     } catch (Exception $exc) {
         $this->render('error', array('error' => "listHosts error:" . $exc->getMessage()));
     }
 }
示例#11
0
 function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
 {
     if (!$withtemplate) {
         switch ($item->getType()) {
             case 'IPNetwork':
                 if ($_SESSION['glpishow_count_on_tabs']) {
                     return self::createTabEntry(Vlan::getTypeName(), countElementsInTable($this->getTable(), "ipnetworks_id\n                                                                        = '" . $item->getID() . "'"));
                 }
                 return Vlan::getTypeName();
         }
     }
     return '';
 }
 /**
  * Display detail networkport based on glpi core networkport and fusioninventory
  * networkport
  *
  * @param array $data with id ant fusionid
  * @param boolean $monitoring true if monitoring installed && actived
  * @param boolean $aggrega true if this port is aggregate port
  *
  * @return nothing
  */
 function showNetworkPortDetail($data, $monitoring, $aggrega = 0)
 {
     global $CFG_GLPI, $DB;
     $nw = new NetworkPort_NetworkPort();
     $networkName = new NetworkName();
     $networkPort = new NetworkPort();
     $pfNetworkPort = new PluginFusioninventoryNetworkPort();
     $iPAddress = new IPAddress();
     $networkPort->getFromDB($data['id']);
     $pfNetworkPort->getFromDB($data['fusionid']);
     $background_img = "";
     if ($pfNetworkPort->fields["trunk"] == "1" && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
         $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/port_trunk.png\"); '";
     } else {
         if (PluginFusioninventoryNetworkPort::isPortHasMultipleMac($data['id']) && (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1)) {
             $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/multiple_mac_addresses.png\"); '";
         } else {
             if (strstr($pfNetworkPort->fields["ifstatus"], "up") || $pfNetworkPort->fields["ifstatus"] == 1) {
                 $background_img = " style='background-image: url(\"" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/connected_trunk.png\"); '";
             }
         }
     }
     echo "<tr class='tab_bg_1 center' height='40'" . $background_img . ">";
     if ($aggrega) {
         echo "<td style='background-color: #f2f2f2;'></td><td>";
     }
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td>";
         } else {
             echo "<td colspan='2'>";
         }
     }
     echo "<a href='networkport.form.php?id=" . $networkPort->fields["id"] . "'>" . $networkPort->fields["name"] . "</a>";
     Html::showToolTip($pfNetworkPort->fields['ifdescr']);
     if (!$aggrega) {
         if ($networkPort->fields['instantiation_type'] == 'NetworkPortAggregate') {
             echo "<td><i><font style='color: grey'>" . __('Aggregation port') . "</font></i></td>";
         }
     }
     if ($monitoring == '1') {
         echo "<td>";
         $state = PluginMonitoringNetworkport::isMonitoredNetworkport($data['id']);
         if (Session::haveRight("plugin_monitoring_componentscatalog", UPDATE)) {
             $checked = '';
             if ($state) {
                 $checked = 'checked';
             }
             echo "<input type='checkbox' name='networkports_id[]' value='" . $data['id'] . "' " . $checked . "/>";
         } else {
             if (Session::haveRight("plugin_monitoring_componentscatalog", READ)) {
                 echo Dropdown::getYesNo($state);
             }
         }
         echo "</td>";
     }
     $a_pref = DisplayPreference::getForTypeUser('PluginFusioninventoryNetworkport', Session::getLoginUserID());
     foreach ($a_pref as $data_array) {
         switch ($data_array) {
             case 3:
                 echo "<td>" . $pfNetworkPort->fields["ifmtu"] . "</td>";
                 break;
             case 5:
                 echo "<td>" . $this->byteSize($pfNetworkPort->fields["ifspeed"], 1000) . "bps</td>";
                 break;
             case 6:
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifinternalstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/greenbutton.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifinternalstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifinternalstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 7:
                 echo "<td>" . $pfNetworkPort->fields["iflastchange"] . "</td>";
                 break;
             case 8:
                 echo "<td>";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifinoctets"], 1000) . "o";
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifinoctets"] == "0") {
                     echo "-";
                 } else {
                     echo $this->byteSize($pfNetworkPort->fields["ifoutoctets"], 1000) . "o";
                 }
                 echo "</td>";
                 break;
             case 9:
                 $color = '';
                 if ($pfNetworkPort->fields["ifinerrors"] != "0" || $pfNetworkPort->fields["ifouterrors"] != "0") {
                     $color = "background='#cf9b9b' class='tab_bg_1_2'";
                 }
                 if ($pfNetworkPort->fields["ifinerrors"] == "0") {
                     echo "<td " . $color . ">-";
                 } else {
                     echo "<td " . $color . ">";
                     echo $pfNetworkPort->fields["ifinerrors"];
                 }
                 echo " / ";
                 if ($pfNetworkPort->fields["ifouterrors"] == "0") {
                     echo "-";
                 } else {
                     echo $pfNetworkPort->fields["ifouterrors"];
                 }
                 echo "</td>";
                 break;
             case 10:
                 if ($pfNetworkPort->fields["portduplex"] == 2) {
                     echo "<td background='#cf9b9b' class='tab_bg_1_2'>";
                     echo __('Half', 'fusioninventory');
                     echo '</td>';
                 } else {
                     if ($pfNetworkPort->fields["portduplex"] == 3) {
                         echo '<td>';
                         echo __('Full', 'fusioninventory');
                         echo '</td>';
                     } else {
                         echo "<td></td>";
                     }
                 }
                 break;
             case 11:
                 // ** internal mac
                 echo "<td>" . $networkPort->fields["mac"] . "</td>";
                 break;
             case 13:
                 // ** Mac address and link to device which are connected to this port
                 $opposite_port = $nw->getOppositeContact($data["id"]);
                 if ($opposite_port != "" && $opposite_port != 0) {
                     $networkPortOpposite = new NetworkPort();
                     if ($networkPortOpposite->getFromDB($opposite_port)) {
                         $data_device = $networkPortOpposite->fields;
                         $item = new $data_device["itemtype"]();
                         $item->getFromDB($data_device["items_id"]);
                         $link1 = $item->getLink(1);
                         $link = str_replace($item->getName(0), $data_device["mac"], $item->getLink());
                         // * GetIP
                         $a_networknames = current($networkName->find("`itemtype`='NetworkPort'\n                                          AND `items_id`='" . $item->getID() . "'", "", 1));
                         $a_ipaddresses = current($iPAddress->find("`itemtype`='NetworkName'\n                                          AND `items_id`='" . $a_networknames['id'] . "'", "", 1));
                         $link2 = str_replace($item->getName(0), $a_ipaddresses['name'], $item->getLink());
                         if ($data_device["itemtype"] == 'PluginFusioninventoryUnmanaged') {
                             $icon = $this->getItemtypeIcon($item->fields["item_type"]);
                             if ($item->getField("accepted") == "1") {
                                 echo "<td style='background:#bfec75'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             } else {
                                 echo "<td background='#cf9b9b'\n                                     class='tab_bg_1_2'>" . $icon . $link1;
                             }
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($item->getField("hub") == "1") {
                                 $this->displayHubConnections($data_device["items_id"], $background_img);
                             }
                             echo "</td>";
                         } else {
                             $icon = $this->getItemtypeIcon($data_device["itemtype"]);
                             echo "<td>" . $icon . $link1;
                             if (!empty($link)) {
                                 echo "<br/>" . $link;
                             }
                             if (!empty($link2)) {
                                 echo "<br/>" . $link2;
                             }
                             if ($data_device["itemtype"] == 'Phone') {
                                 $query_devicephone = "SELECT *\n                                   FROM `glpi_networkports`\n                                   WHERE `itemtype`='Phone'\n                                       AND `items_id`='" . $data_device["items_id"] . "'\n                                       AND `id`!='" . $data_device["id"] . "'\n                                   LIMIT 1";
                                 $result_devicephone = $DB->query($query_devicephone);
                                 if ($DB->numrows($result_devicephone) > 0) {
                                     $data_devicephone = $DB->fetch_assoc($result_devicephone);
                                     $computer_ports_id = $nw->getOppositeContact($data_devicephone["id"]);
                                     if ($computer_ports_id) {
                                         $networkport = new NetworkPort();
                                         $networkport->getFromDB($computer_ports_id);
                                         if ($networkport->fields['itemtype'] == 'Computer') {
                                             echo "<hr/>";
                                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/computer_icon.png' " . "style='float:left'/> ";
                                             $computer = new Computer();
                                             $computer->getFromDB($networkport->fields["items_id"]);
                                             $link1 = $computer->getLink(1);
                                             $link = str_replace($computer->getName(0), $networkport->fields["mac"], $computer->getLink());
                                             $link2 = str_replace($computer->getName(0), $networkport->fields["ip"], $computer->getLink());
                                             echo $icon . $link1;
                                             if (!empty($link)) {
                                                 echo "<br/>" . $link;
                                             }
                                             if (!empty($link2)) {
                                                 echo "<br/>" . $link2;
                                             }
                                         }
                                     }
                                 }
                             }
                             echo "</td>";
                         }
                     } else {
                         echo "<td></td>";
                     }
                 } else {
                     echo "<td></td>";
                 }
                 break;
             case 14:
                 // ** Connection status
                 echo "<td>";
                 if (strstr($pfNetworkPort->fields["ifstatus"], "up") || strstr($pfNetworkPort->fields["ifstatus"], "1")) {
                     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_on.png'/>";
                 } else {
                     if (strstr($pfNetworkPort->fields["ifstatus"], "down") || strstr($pfNetworkPort->fields["ifstatus"], "2")) {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/wired_off.png'/>";
                     } else {
                         if (strstr($pfNetworkPort->fields["ifstatus"], "testing") || strstr($pfNetworkPort->fields["ifstatus"], "3")) {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/yellowbutton.png'/>";
                         } else {
                             if (strstr($pfNetworkPort->fields["ifstatus"], "dormant") || strstr($pfNetworkPort->fields["ifstatus"], "5")) {
                                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/pics/orangebutton.png'/>";
                             }
                         }
                     }
                 }
                 echo "</td>";
                 break;
             case 12:
                 echo "<td>";
                 $canedit = Session::haveRight('networking', UPDATE);
                 $used = array();
                 $query_vlan = "SELECT * FROM glpi_networkports_vlans\n                              WHERE networkports_id='" . $data["id"] . "'";
                 $result_vlan = $DB->query($query_vlan);
                 if ($DB->numrows($result_vlan) > 0) {
                     echo "<table cellpadding='0' cellspacing='0'>";
                     while ($line = $DB->fetch_array($result_vlan)) {
                         $used[] = $line["vlans_id"];
                         $vlan = new Vlan();
                         $vlan->getFromDB($line["vlans_id"]);
                         if ($line['tagged'] == '1') {
                             $state = 'T';
                         } else {
                             $state = 'U';
                         }
                         echo "<tr><td>" . $vlan->fields['name'] . " [" . $vlan->fields['tag'] . "] " . $state;
                         echo "</td><td>";
                         if ($canedit) {
                             echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?unassign_vlan=unassigned&amp;id=" . $line["id"] . "'>";
                             echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/delete.png\" alt='" . __('Delete', 'fusioninventory') . "' title='" . __('Delete', 'fusioninventory') . "'></a>";
                         } else {
                             echo "&nbsp;";
                         }
                         echo "</td>";
                         echo "</tr>";
                     }
                     echo "</table>";
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
                 break;
             case 15:
                 echo "<td align='center'>";
                 if ($pfNetworkPort->fields['ifstatus'] == 1) {
                     echo __('Connected');
                 } else {
                     if ($pfNetworkPort->fields['lastup'] == "0000-00-00 00:00:00") {
                         echo '-';
                     } else {
                         $time = strtotime(date('Y-m-d H:i:s')) - strtotime($pfNetworkPort->fields['lastup']);
                         echo Html::timestampToString($time, FALSE);
                     }
                 }
                 echo "</td>";
                 break;
             case 16:
                 echo "<td>" . $pfNetworkPort->fields["ifalias"] . "</td>";
                 break;
         }
     }
     echo "</tr>";
 }
示例#13
0
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('State') . "</td><td>";
     State::dropdown(array('name' => "states_id", 'value' => $this->fields["states_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     $this->dropdownLocation($this, $ID);
     echo "</td>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('name' => "groups_id", 'value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Childs', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("child", $this->fields["child"]);
     echo "</td>";
     echo "<td>" . __('VLAN') . "</td><td>";
     Vlan::dropdown(array('name' => "vlans_id", 'value' => $this->fields["vlans_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Network') . "</td><td>";
     Network::dropdown(array('name' => "networks_id", 'value' => $this->fields["networks_id"]));
     echo "</td>";
     echo "<td>" . PluginArchiresView::getTypeName(1) . "</td><td>";
     //View
     Dropdown::show('PluginArchiresView', array('name' => "plugin_archires_views_id", 'value' => $this->fields["plugin_archires_views_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 function addVlan($a_vlan, $networkports_id)
 {
     $networkPort_Vlan = new NetworkPort_Vlan();
     $vlan = new Vlan();
     $db_vlans = $vlan->find("`tag`='" . $a_vlan['tag'] . "' AND `name`='" . $a_vlan['name'] . "'", "", 1);
     $vlans_id = 0;
     if (count($db_vlans) > 0) {
         $db_vlan = current($db_vlans);
         $vlans_id = $db_vlan['id'];
     } else {
         $input = array();
         $input['tag'] = $a_vlan['tag'];
         $input['name'] = $a_vlan['name'];
         $vlans_id = $vlan->add($input);
     }
     $input = array();
     $input['networkports_id'] = $networkports_id;
     $input['vlans_id'] = $vlans_id;
     $networkPort_Vlan->add($input);
 }