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


PHP CommonDBTM::update方法代码示例

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


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

示例1: processMassiveActionsForOneItemtype

 /**
  * @since version 0.90
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'merge':
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     if ($item->getEntityID() == $_SESSION['glpiactive_entity']) {
                         if ($item->update(array('id' => $key, 'is_recursive' => 1))) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $input2 = $item->fields;
                         // Change entity
                         $input2['entities_id'] = $_SESSION['glpiactive_entity'];
                         $input2['is_recursive'] = 1;
                         $input2 = Toolbox::addslashes_deep($input2);
                         if (!$item->import($input2)) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         }
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:jose-martins,项目名称:glpi,代码行数:40,代码来源:tickettemplate.class.php

示例2: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case "transfert":
             $input = $ma->getInput();
             $entities_id = $input['entities_id'];
             foreach ($ids as $id) {
                 if ($item->getFromDB($id)) {
                     $item->update(array("id" => $id, "entities_id" => $entities_id, "update" => __('Update')));
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                 }
             }
             return;
             break;
     }
     return;
 }
开发者ID:pluginsGLPI,项目名称:order,代码行数:23,代码来源:order.class.php

示例3: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'uninstall':
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     if ($item->uninstall($key)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'backtostock':
             foreach ($ids as $id) {
                 if ($item->can($id, UPDATE)) {
                     if ($item->backToStock(array("id" => $id))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'updatepages':
             $input = $ma->getInput();
             if (isset($input['pages'])) {
                 foreach ($ids as $key) {
                     if ($item->can($key, UPDATE)) {
                         if ($item->update(array('id' => $key, 'pages' => $input['pages']))) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:61,代码来源:cartridge.class.php

示例4: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'move_license':
             $input = $ma->getInput();
             if (isset($input['softwarelicenses_id'])) {
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         //Process rules
                         if ($item->update(array('id' => $id, 'softwarelicenses_id' => $input['softwarelicenses_id']))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
         case 'install':
             $csl = new self();
             $csv = new Computer_SoftwareVersion();
             foreach ($ids as $id) {
                 if ($csl->getFromDB($id)) {
                     $sl = new SoftwareLicense();
                     if ($sl->getFromDB($csl->fields["softwarelicenses_id"])) {
                         $version = 0;
                         if ($sl->fields["softwareversions_id_use"] > 0) {
                             $version = $sl->fields["softwareversions_id_use"];
                         } else {
                             $version = $sl->fields["softwareversions_id_buy"];
                         }
                         if ($version > 0) {
                             $params = array('computers_id' => $csl->fields['computers_id'], 'softwareversions_id' => $version);
                             //Get software name and manufacturer
                             if ($csv->can(-1, CREATE, $params)) {
                                 //Process rules
                                 if ($csv->add($params)) {
                                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                                 } else {
                                     $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 }
                             } else {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                             }
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:pvasener,项目名称:glpi,代码行数:68,代码来源:computer_softwarelicense.class.php

示例5: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  * */
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginSimcardSimcard') {
                 foreach ($ids as $key) {
                     // Types
                     $item->getFromDB($key);
                     $type = PluginSimcardSimcardType::transfer($item->fields["plugin_simcard_simcardtypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardtypes_id"] = $type;
                         $item->update($values);
                     }
                     // Size
                     $size = PluginSimcardSimcardSize::transfer($item->fields["plugin_simcard_simcardsizes_id"], $input['entities_id']);
                     if ($size > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardsizes_id"] = $size;
                         $item->update($values);
                     }
                     // Voltage
                     $voltage = PluginSimcardSimcardVoltage::transfer($item->fields["plugin_simcard_simcardvoltages_id"], $input['entities_id']);
                     if ($voltage > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_simcardvoltages_id"] = $voltage;
                         $item->update($values);
                     }
                     // Phoneoperator
                     $phoneoperator = PluginSimcardPhoneOperator::transfer($item->fields["plugin_simcard_phoneoperators_id"], $input['entities_id']);
                     if ($phoneoperator > 0) {
                         $values["id"] = $key;
                         $values["plugin_simcard_phoneoperators_id"] = $phoneoperator;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:NandyJoshu,项目名称:simcard,代码行数:56,代码来源:simcard.class.php

示例6: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     $certif_item = new PluginCertificatesCertificate_Item();
     switch ($ma->getAction()) {
         case "plugin_certificates_add_item":
             $input = $ma->getInput();
             foreach ($ids as $id) {
                 $input = array('plugin_certificates_certificates_id' => $input['plugin_certificates_certificates_id'], 'items_id' => $id, 'itemtype' => $item->getType());
                 if ($certif_item->can(-1, UPDATE, $input)) {
                     if ($certif_item->add($input)) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 }
             }
             return;
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginCertificatesCertificate') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginCertificatesCertificateType::transfer($item->fields["plugin_certificates_certificatetypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_certificates_certificatetypes_id"] = $type;
                         $item->update($values);
                     }
                     $state = PluginCertificatesCertificateState::transfer($this->fields["plugin_certificates_certificatestates_id"], $input['entities_id']);
                     if ($state > 0) {
                         $values["id"] = $key;
                         $values["plugin_certificates_certificatestates_id"] = $state;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
         case 'install':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     $values = array('plugin_certificates_certificates_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($certif_item->add($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'uninstall':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($val == 1) {
                     if ($certif_item->deleteItemByCertificatesAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:84,代码来源:certificate.class.php

示例7: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case 'move_version':
             $input = $ma->getInput();
             if (isset($input['softwareversions_id'])) {
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         //Process rules
                         if ($item->update(array('id' => $id, 'softwareversions_id' => $input['softwareversions_id']))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
         case 'add':
             $itemtoadd = new Computer_SoftwareVersion();
             if (isset($_POST['peer_softwareversions_id'])) {
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         //Process rules
                         if ($itemtoadd->add(array('computers_id' => $id, 'softwareversions_id' => $_POST['peer_softwareversions_id']))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($itemtoadd->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($itemtoadd->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:54,代码来源:computer_softwareversion.class.php

示例8: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  * */
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     global $DB;
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginTasklistsTask') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginTasklistsTaskType::transfer($item->fields["plugin_tasklists_tasktypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_tasklists_tasktypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:InfotelGLPI,项目名称:tasklists,代码行数:34,代码来源:task.class.php

示例9: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'merge':
             $input = $ma->getInput();
             if (isset($input['item_items_id'])) {
                 $items = array();
                 foreach ($ids as $id) {
                     $items[$id] = 1;
                 }
                 if ($item->can($input['item_items_id'], UPDATE)) {
                     if ($item->merge($items)) {
                         $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
             }
             return;
         case 'compute_software_category':
             $softcatrule = new RuleSoftwareCategoryCollection();
             foreach ($ids as $id) {
                 $params = array();
                 //Get software name and manufacturer
                 if ($item->can($id, UPDATE)) {
                     $params["name"] = $item->fields["name"];
                     $params["manufacturers_id"] = $item->fields["manufacturers_id"];
                     $params["comment"] = $item->fields["comment"];
                     $output = array();
                     $output = $softcatrule->processAllRules(null, $output, $params);
                     //Process rules
                     if (isset($output['softwarecategories_id']) && $item->update(array('id' => $id, 'softwarecategories_id' => $output['softwarecategories_id']))) {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                         $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                     }
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
         case 'replay_dictionnary':
             $softdictionnayrule = new RuleDictionnarySoftwareCollection();
             $allowed_ids = array();
             foreach ($ids as $id) {
                 if ($item->can($id, UPDATE)) {
                     $allowed_ids[] = $id;
                 } else {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             if ($softdictionnayrule->replayRulesOnExistingDB(0, 0, $allowed_ids) > 0) {
                 $ma->itemDone($item->getType(), $allowed_ids, MassiveAction::ACTION_OK);
             } else {
                 $ma->itemDone($item->getType(), $allowed_ids, MassiveAction::ACTION_KO);
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:btry,项目名称:glpi,代码行数:74,代码来源:software.class.php

示例10: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $input = $ma->getInput();
     switch ($ma->getAction()) {
         case 'move_under':
             if (isset($input['parent'])) {
                 $fk = $item->getForeignKeyField();
                 $parent = clone $item;
                 if (!$parent->getFromDB($input['parent'])) {
                     $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                     $ma->addMessage($parent->getErrorMessage(ERROR_NOT_FOUND));
                     return;
                 }
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         // Check if parent is not a child of the original one
                         if (!in_array($parent->getID(), getSonsOf($item->getTable(), $item->getID()))) {
                             if ($item->update(array('id' => $id, $fk => $parent->getID()))) {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                             } else {
                                 $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                                 $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                             }
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_COMPAT));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 $ma->addMessage($parent->getErrorMessage(ERROR_COMPAT));
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:korial29,项目名称:glpi,代码行数:45,代码来源:commontreedropdown.class.php

示例11: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'merge':
             $fk = $item->getForeignKeyField();
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     if ($item->getEntityID() == $_SESSION['glpiactive_entity']) {
                         if ($item->update(array('id' => $key, 'is_recursive' => 1))) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $input2 = $item->fields;
                         // Remove keys (and name, tree dropdown will use completename)
                         if ($item instanceof CommonTreeDropdown) {
                             unset($input2['id'], $input2['name'], $input2[$fk]);
                         } else {
                             unset($input2['id']);
                         }
                         // Change entity
                         $input2['entities_id'] = $_SESSION['glpiactive_entity'];
                         $input2['is_recursive'] = 1;
                         $input2 = Toolbox::addslashes_deep($input2);
                         // Import new
                         if ($newid = $item->import($input2)) {
                             // Delete old
                             if ($newid > 0) {
                                 // delete with purge for dropdown with dustbin (Budget)
                                 $item->delete(array('id' => $key, '_replace_by' => $newid), 1);
                             }
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
 }
开发者ID:pvasener,项目名称:glpi,代码行数:53,代码来源:commondropdown.class.php

示例12: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginBadgesBadge') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginBadgesBadgeType::transfer($item->fields["plugin_badges_badgetypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_badges_badgetypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:32,代码来源:badge.class.php

示例13: unglobalizeItem

 /**
  * Unglobalize an item : duplicate item and connections
  *
  * @param $item   CommonDBTM object to unglobalize
  **/
 static function unglobalizeItem(CommonDBTM $item)
 {
     global $DB;
     // Update item to unit management :
     if ($item->getField('is_global')) {
         $input = array('id' => $item->fields['id'], 'is_global' => 0);
         $item->update($input);
         // Get connect_wire for this connection
         $query = "SELECT `glpi_computers_items`.`id`\n                   FROM `glpi_computers_items`\n                   WHERE `glpi_computers_items`.`items_id` = '" . $item->fields['id'] . "'\n                         AND `glpi_computers_items`.`itemtype` = '" . $item->getType() . "'";
         $result = $DB->query($query);
         if ($data = $DB->fetch_assoc($result)) {
             // First one, keep the existing one
             // The others = clone the existing object
             unset($input['id']);
             $conn = new self();
             while ($data = $DB->fetch_assoc($result)) {
                 $temp = clone $item;
                 unset($temp->fields['id']);
                 if ($newID = $temp->add($temp->fields)) {
                     $conn->update(array('id' => $data['id'], 'items_id' => $newID));
                 }
             }
         }
     }
 }
开发者ID:stweil,项目名称:glpi,代码行数:30,代码来源:computer_item.class.php

示例14: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     switch ($ma->getAction()) {
         case 'changegroup':
             $input = $ma->getInput();
             if (isset($input["field"]) && isset($input['groups_id'])) {
                 foreach ($ids as $id) {
                     if ($item->can($id, UPDATE)) {
                         if ($item->update(array('id' => $id, $input["field"] => $input["groups_id"]))) {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
                             $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
                         }
                     } else {
                         $ma->itemDone($item->getType(), $id, MassiveAction::ACTION_NORIGHT);
                         $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                     }
                 }
             } else {
                 $ma->itemDone($item->getType(), $ids, MassiveAction::ACTION_KO);
                 $ma->addMessage($item->getErrorMessage(ERROR_ON_ACTION));
             }
             return;
     }
     parent::processMassiveActionsForOneItemtype($ma, $baseitem, $ids);
 }
开发者ID:korial29,项目名称:glpi,代码行数:32,代码来源:group.class.php

示例15: processMassiveActionsForOneItemtype

 /**
  * @since version 0.85
  *
  * @see CommonDBTM::processMassiveActionsForOneItemtype()
  **/
 static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
 {
     $account_item = new PluginAccountsAccount_Item();
     switch ($ma->getAction()) {
         case "add_item":
             $input = $ma->getInput();
             foreach ($ma->items as $itemtype => $myitem) {
                 foreach ($myitem as $key => $value) {
                     if (!countElementsInTable('glpi_plugin_accounts_accounts_items', "itemtype='{$itemtype}' \n                                             AND items_id='{$key}' \n                                             AND plugin_accounts_accounts_id='" . $input['plugin_accounts_accounts_id'] . "'")) {
                         $myvalue['plugin_accounts_accounts_id'] = $input['plugin_accounts_accounts_id'];
                         $myvalue['itemtype'] = $itemtype;
                         $myvalue['items_id'] = $key;
                         if ($account_item->add($myvalue)) {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                         } else {
                             $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                         }
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
         case "transfer":
             $input = $ma->getInput();
             if ($item->getType() == 'PluginAccountsAccount') {
                 foreach ($ids as $key) {
                     $item->getFromDB($key);
                     $type = PluginAccountsAccountType::transfer($item->fields["plugin_accounts_accounttypes_id"], $input['entities_id']);
                     if ($type > 0) {
                         $values["id"] = $key;
                         $values["plugin_accounts_accounttypes_id"] = $type;
                         $item->update($values);
                     }
                     unset($values);
                     $values["id"] = $key;
                     $values["entities_id"] = $input['entities_id'];
                     if ($item->update($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
         case 'install':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($item->can($key, UPDATE)) {
                     $values = array('plugin_accounts_accounts_id' => $key, 'items_id' => $input["item_item"], 'itemtype' => $input['typeitem']);
                     if ($account_item->add($values)) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 } else {
                     $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_NORIGHT);
                     $ma->addMessage($item->getErrorMessage(ERROR_RIGHT));
                 }
             }
             break;
         case 'uninstall':
             $input = $ma->getInput();
             foreach ($ids as $key) {
                 if ($val == 1) {
                     if ($account_item->deleteItemByAccountsAndItem($key, $input['item_item'], $input['typeitem'])) {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_OK);
                     } else {
                         $ma->itemDone($item->getType(), $key, MassiveAction::ACTION_KO);
                     }
                 }
             }
             break;
     }
 }
开发者ID:puchadesc,项目名称:accounts,代码行数:80,代码来源:account.class.php


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