本文整理汇总了PHP中CommonDBTM::merge方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::merge方法的具体用法?PHP CommonDBTM::merge怎么用?PHP CommonDBTM::merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::merge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}