本文整理匯總了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);
}