当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonDBChild::doSpecificMassiveActions方法代码示例

本文整理汇总了PHP中CommonDBChild::doSpecificMassiveActions方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBChild::doSpecificMassiveActions方法的具体用法?PHP CommonDBChild::doSpecificMassiveActions怎么用?PHP CommonDBChild::doSpecificMassiveActions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonDBChild的用法示例。


在下文中一共展示了CommonDBChild::doSpecificMassiveActions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doSpecificMassiveActions

 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "assign_vlan":
             if (!empty($input["vlans_id"])) {
                 $networkportvlan = new NetworkPort_Vlan();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->can($key, 'w')) {
                             if ($networkportvlan->assignVlan($key, $input["vlans_id"], isset($input['tagged']) ? '1' : '0')) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         case "unassign_vlan":
             if (!empty($input["vlans_id"])) {
                 $networkportvlan = new NetworkPort_Vlan();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->can($key, 'w')) {
                             if ($networkportvlan->unassignVlan($key, $input["vlans_id"])) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $nbko++;
             }
             break;
             // Interest of this massive action ? Replace switch by another : don't re-create manually all ports
         // Interest of this massive action ? Replace switch by another : don't re-create manually all ports
         case "move_port":
             if (isset($input["items_id"]) && !empty($input["items_id"])) {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->getFromDB($key)) {
                             $input2 = array();
                             $input2['id'] = $key;
                             $input2['items_id'] = $input["items_id"];
                             $input2['itemtype'] = 'NetworkEquipment';
                             if ($this->can($input2['id'], 'w')) {
                                 if ($this->update($input2)) {
                                     $res['ok']++;
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['noright']++;
                             }
                         } else {
                             $res['ko']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:81,代码来源:networkport.class.php

示例2: doSpecificMassiveActions

 /**
  * @since version 0.84
  *
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     //             print_r($input);exit();
     switch ($input['action']) {
         case "give":
             if ($input["give_items_id"] > 0 && !empty($input['give_itemtype'])) {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->can($key, 'w')) {
                             if ($this->out($key, $input['give_itemtype'], $input["give_items_id"])) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
                 if ($item = getItemForItemtype($input['give_itemtype'])) {
                     Event::log($input["consumableitems_id"], "consumables", 5, "inventory", sprintf(__('%s gives a consumable'), $_SESSION["glpiname"]));
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:37,代码来源:consumable.class.php

示例3: doSpecificMassiveActions

 /**
  * @since version 0.84
  *
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "uninstall":
             foreach ($input["item"] as $key => $val) {
                 if ($val == 1) {
                     if ($this->can($key, 'w')) {
                         if ($this->uninstall($key)) {
                             $res['ok']++;
                         } else {
                             $res['ko']++;
                         }
                     } else {
                         $res['noright']++;
                     }
                 }
             }
             break;
         case "updatepages":
             if (isset($input['pages'])) {
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($this->can($key, 'w')) {
                             if ($this->update(array('id' => $key, 'pages' => $input['pages']))) {
                                 $res['ok']++;
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
开发者ID:gaforeror,项目名称:glpi,代码行数:48,代码来源:cartridge.class.php

示例4: doSpecificMassiveActions

 /**
  * @see CommonDBTM::doSpecificMassiveActions()
  **/
 function doSpecificMassiveActions($input = array())
 {
     $res = array('ok' => 0, 'ko' => 0, 'noright' => 0);
     switch ($input['action']) {
         case "transform_to":
             if (isset($input["transform_to"]) && !empty($input["transform_to"])) {
                 $networkport = new NetworkPort();
                 foreach ($input["item"] as $key => $val) {
                     if ($val == 1) {
                         if ($networkport->can($key, 'w') && $this->can($key, 'd')) {
                             // Don't try to migrate already affected ports
                             if (empty($networkport->fields['instantiation_type'])) {
                                 if ($networkport->switchInstantiationType($input['transform_to']) !== false) {
                                     $instantiation = $networkport->getInstantiation();
                                     $input2 = $this->fields;
                                     $input2['networkports_id'] = $input2['id'];
                                     unset($input2['id']);
                                     if ($instantiation->add($input2)) {
                                         $this->delete(array('id' => $key));
                                         $res['ok']++;
                                     } else {
                                         $res['ko']++;
                                     }
                                 } else {
                                     $res['ko']++;
                                 }
                             } else {
                                 $res['ko']++;
                             }
                         } else {
                             $res['noright']++;
                         }
                     }
                 }
             } else {
                 $res['ko']++;
             }
             break;
         default:
             return parent::doSpecificMassiveActions($input);
     }
     return $res;
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:46,代码来源:networkportmigration.class.php


注:本文中的CommonDBChild::doSpecificMassiveActions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。