本文整理汇总了PHP中Lock::unlockItems方法的典型用法代码示例。如果您正苦于以下问题:PHP Lock::unlockItems方法的具体用法?PHP Lock::unlockItems怎么用?PHP Lock::unlockItems使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lock
的用法示例。
在下文中一共展示了Lock::unlockItems方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doMassiveActions
//.........这里部分代码省略.........
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Add items to contracts
$input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
}
if (isset($input['contracts_id'])) {
// Add contract to item
$input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
} else {
return false;
}
if ($contractitem->can(-1, 'w', $input)) {
if ($contractitem->add($input)) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
break;
case "remove_contract_item":
foreach ($input["item"] as $key => $val) {
if (isset($input['items_id'])) {
// Remove item to contracts
$input = array('itemtype' => $input["item_itemtype"], 'items_id' => $input["items_id"], 'contracts_id' => $key);
} else {
// Remove contract to items
$input = array('itemtype' => $input["itemtype"], 'items_id' => $key, 'contracts_id' => $input['contracts_id']);
}
$contractitem = new Contract_Item();
if ($contractitem->can(-1, 'w', $input)) {
if ($item = getItemForItemtype($input["itemtype"])) {
if ($item->getFromDB($input['items_id'])) {
$contract = new Contract();
if ($contract->getFromDB($input['contracts_id'])) {
if ($contractitem->getFromDBForItems($contract, $item)) {
if ($contractitem->delete(array('id' => $contractitem->getID()))) {
$res['ok']++;
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['ko']++;
}
} else {
$res['noright']++;
}
}
break;
//Lock management
//Lock management
case 'unlock_Printer':
case 'unlock_Monitor':
case 'unlock_NetworkPort':
case 'unlock_NetworkName':
case 'unlock_IPAddress':
case 'unlock_ComputerDisk':
case 'unlock_ComputerVirtualMachine':
case 'unlock_Peripheral':
case 'unlock_SoftwareVersion':
$itemtype = Lock::getItemTypeForMassiveAction($input["action"]);
if ($itemtype) {
$res = Lock::unlockItems($itemtype, $this->getType(), $input["item"]);
}
break;
case 'unlock_Device':
foreach (Item_Devices::getDeviceTypes() as $itemtype) {
$res = Lock::unlockItems($itemtype, $this->getType(), $input["item"]);
}
break;
default:
// Plugin specific actions
$split = explode('_', $input["action"]);
$res = '';
if ($split[0] == 'plugin' && isset($split[1])) {
// Normalized name plugin_name_action
// Allow hook from any plugin on any (core or plugin) type
$res = Plugin::doOneHook($split[1], 'MassiveActionsProcess', $input);
// } else if ($plug=isPluginItemType($input["itemtype"])) {
// non-normalized name
// hook from the plugin defining the type
// $res = Plugin::doOneHook($plug['plugin'], 'MassiveActionsProcess', $input);
} else {
$res = $this->doSpecificMassiveActions($input);
}
break;
}
return $res;
}
示例2: resetOCSLocks
static function resetOCSLocks($objectId, $entities)
{
global $DB;
$res = array('ok' => 0, 'ko' => 0);
$object = new $objectId();
$objecttable = getTableForItemType($objectId);
$restrict = "";
if ($object->maybeTemplate()) {
$restrict = "`is_template` = '0'";
}
if ($object->isEntityAssign() && $entities != -1) {
$restrict .= getEntitiesRestrictRequest(" AND ", $objecttable, '', $entities, $object->maybeRecursive());
}
$count = countElementsInTable($objecttable, $restrict);
$items = getAllDatasFromTable($objecttable, $restrict);
$computers = array();
if (!empty($items)) {
echo "<div class='center'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><td>";
Html::createProgressBar(__('Work in progress...'));
echo "</td></tr></table></div></br>\n";
$i = 0;
foreach ($items as $item) {
//Fields
if (PluginOcsinventoryngOcsServer::deleteInOcsArray($item['id'], 'all', "computer_update", true)) {
$res['ok']++;
}
$i++;
$computers[$item['id']] = 1;
Html::changeProgressBarPosition($i, $count);
}
foreach (Item_Devices::getDeviceTypes() as $itemtype) {
$res[] = Lock::unlockItems($itemtype, 'Computer', $computers);
}
$res[] = Lock::unlockItems('Monitor', 'Monitor', $computers);
$res[] = Lock::unlockItems('Printer', 'Printer', $computers);
$res[] = Lock::unlockItems('Peripheral', 'Peripheral', $computers);
$res[] = Lock::unlockItems('SoftwareVersion', 'SoftwareVersion', $computers);
$res[] = Lock::unlockItems('NetworkPort', 'Computer', $computers);
$res[] = Lock::unlockItems('NetworkName', 'NetworkPort', $computers);
$res[] = Lock::unlockItems('IPAddress', 'NetworkName', $computers);
$res[] = Lock::unlockItems('ComputerDisk', 'ComputerDisk', $computers);
$res[] = Lock::unlockItems('ComputerVirtualMachine', 'ComputerVirtualMachine', $computers);
Html::changeProgressBarPosition($i, $count, __('Task completed.'));
}
return $res;
}