svn.diff

webmyster, 09/26/2013 08:38 PM

Download (5.67 KB)

View differences:

install/mysql/1.0.0-empty.sql (working copy)
135 135
  `TYPE` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
136 136
  `TYPEMIB` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
137 137
  `items_devicenetworkcards_id` int(11) NOT NULL DEFAULT '0',
138
  `speed` varchar(255) COLLATE utf8_unicode_ci DEFAULT '10mb/s',
138 139
  `comment` text COLLATE utf8_unicode_ci,
139 140
  PRIMARY KEY (`id`),
140 141
  UNIQUE KEY `networkports_id` (`networkports_id`),
hook.php (working copy)
1002 1002

  
1003 1003
         }
1004 1004
         break;
1005

  
1006
      case 'NetworkPort':
1007
         if (plugin_ocsinventoryng_haveRight("ocsng","w")
1008
             && Session::haveRight('networking','w')) {
1009
            return array('plugin_ocsinventoryng_update_networkport_type'
1010
                         =>  __('Update Networkport types',
1011
                                'ocsinventoryng'));
1012
         }
1013
         
1005 1014
   }
1006 1015
   return array ();
1007 1016
}
......
1046 1055
               break;
1047 1056

  
1048 1057
         }
1058
      case 'NetworkPort':
1059
         switch ($options['action']) {
1060
            case "plugin_ocsinventoryng_update_networkport_type" :
1061
               echo "<input type='submit' name='massiveaction' class='submit' value='".
1062
                      _sx('button', 'Post')."'>\n";
1063
               break;
1064
         }
1065
         
1049 1066
   }
1050 1067
   return "";
1051 1068
}
......
1057 1074
function plugin_ocsinventoryng_MassiveActionsProcess($data) {
1058 1075
   global $CFG_GLPI, $DB, $REDIRECT;
1059 1076

  
1060
   $nbok      = 0;
1077
   $nbok     = 0;
1061 1078
   $nbko      = 0;
1062 1079
   $noright = 0;
1063 1080
   
......
1182 1199
            }
1183 1200
         }
1184 1201
         break;
1202

  
1203
      case 'plugin_ocsinventoryng_update_networkport_type':
1204
         $networkport = new PluginOcsinventoryngNetworkPort();
1205
         foreach ($data["item"] as $key => $val) {
1206
            if ($val == 1) {
1207
               if ($networkport->getFromDBByQuery("WHERE `networkports_id` = '$key'")) {
1208
                  if ($networkport->transformAccordingTypes()) {
1209
                     $nbok ++;
1210
                  } else {
1211
                     $nbko ++;
1212
                  }
1213
               } else {
1214
                  $nbko ++;
1215
               }
1216
            }
1217
         }
1218
         break;
1185 1219
   }
1186 1220

  
1187 1221
   return array('ok'      => $nbok,
inc/networkport.class.php (working copy)
434 434
   }
435 435

  
436 436

  
437
   function transformAccordingTypes() {
438
      global $DB;
439

  
440
      $networkport_type = new PluginOcsinventoryngNetworkPortType();
441
      $TYPEMIB          = $this->fields['TYPEMIB'];
442
      $TYPE             = $this->fields['TYPE'];
443

  
444
      $networkport_type->getFromDBByQuery("WHERE `OCS_TYPE`='$TYPE'
445
                                             AND `OCS_TYPEMIB`='$TYPEMIB'");
446
      if ($networkport_type->isNewItem()) {
447
         $networkport_type->getFromDBByQuery("WHERE `OCS_TYPE`='$TYPE' AND `OCS_TYPEMIB`='*'");
448
      }
449
      if ($networkport_type->isNewItem()) {
450
         $networkport_type->getFromDBByQuery("WHERE `OCS_TYPE`='*' AND `OCS_TYPEMIB`='*'");
451
      }
452

  
453
      if (!$networkport_type->isNewItem()) {
454
         if (isset($networkport_type->fields['instantiation_type'])
455
             && ($networkport_type->fields['instantiation_type'] != __CLASS__)) {
456
            $networkport = $this->getItem();
457
            if ($networkport->switchInstantiationType($networkport_type->fields
458
                                                      ['instantiation_type']) !== false) {
459
               $instantiation             = $networkport->getInstantiation();
460
               $input2                    = $networkport_type->fields;
461
               $input2['networkports_id'] = $this->fields['networkports_id'];
462
               unset($input2['id']);
463
               if (isset($this->fields['speed'])) {
464
                  $input2['speed'] = NetworkPortEthernet::transformPortSpeed($this->fields
465
                                                                             ['speed'], false);
466
               }
467
               if ($instantiation->add($input2)) {
468
                  $this->delete(array(static::getIndexName() => $this->getID()));
469
                  return true;
470
               }
471
            }
472
         }
473
      }
474
      return false;
475
   }
476

  
477

  
437 478
}
438 479

  
439 480
?>
inc/networkporttype.class.php (working copy)
102 102
      if ($this->isNewItem() && isset($_GET['plugin_ocsinventoryng_networkports_id'])) {
103 103
         $network_port = new PluginOcsinventoryngNetworkPort();
104 104
         if ($network_port->getFromDB($_GET['plugin_ocsinventoryng_networkports_id'])) {
105
            $this->fields['OCS_TYPE'] = $network_port->fields['TYPE'];
105
            $this->fields['OCS_TYPE']    = $network_port->fields['TYPE'];
106 106
            $this->fields['OCS_TYPEMIB'] = $network_port->fields['TYPEMIB'];
107
            $speed = NetworkPortEthernet::transformPortSpeed($network_port->fields['speed'],
108
                                                             false);
109
            if (!empty($speed)) {
110
               $this->fields['speed'] = $speed;
111
            }
107 112
         }
108 113
      }
109 114

  
......
126 131
                         'label' => __('Wifi card Version', 'ocsinventoryng'),
127 132
                         'type'  => 'version'));
128 133
   }
129

  
130

  
131 134
}
132 135
?>