本文整理汇总了PHP中Printer::addOrRestoreFromTrash方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::addOrRestoreFromTrash方法的具体用法?PHP Printer::addOrRestoreFromTrash怎么用?PHP Printer::addOrRestoreFromTrash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::addOrRestoreFromTrash方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replayDictionnaryOnOnePrinter
/**
* Replay dictionnary on one printer
*
* @param &$new_printers array containing new printers already computed
* @param $res_rule array of rule results
* @param $params array
* @param &$printers_ids array containing replay printer need to be dustbined
**/
function replayDictionnaryOnOnePrinter(array &$new_printers, array $res_rule, $params = array(), array &$printers_ids)
{
global $DB;
$p['id'] = 0;
$p['name'] = '';
$p['manufacturer'] = '';
$p['is_global'] = '';
$p['entity'] = 0;
foreach ($params as $key => $value) {
$p[$key] = $value;
}
$input["name"] = $p['name'];
$input["manufacturer"] = $p['manufacturer'];
if (empty($res_rule)) {
$res_rule = $this->processAllRules($input, array(), array());
}
$printer = new Printer();
//Printer's name has changed
if (isset($res_rule["name"]) && $res_rule["name"] != $p['name']) {
$manufacturer = "";
if (isset($res_rule["manufacturer"])) {
$manufacturer = addslashes(Dropdown::getDropdownName("glpi_manufacturers", $res_rule["manufacturer"]));
} else {
$manufacturer = addslashes($p['manufacturer']);
}
//New printer not already present in this entity
if (!isset($new_printers[$p['entity']][$res_rule["name"]])) {
// create new printer or restore it from dustbin
$new_printer_id = $printer->addOrRestoreFromTrash($res_rule["name"], $manufacturer, $p['entity']);
$new_printers[$p['entity']][$res_rule["name"]] = $new_printer_id;
} else {
$new_printer_id = $new_printers[$p['entity']][$res_rule["name"]];
}
// Move direct connections
$this->moveDirectConnections($p['id'], $new_printer_id);
} else {
$new_printer_id = $p['id'];
$res_rule["id"] = $p['id'];
if (isset($res_rule["manufacturer"])) {
if ($res_rule["manufacturer"] != '') {
$res_rule["manufacturers_id"] = $res_rule["manufacturer"];
}
unset($res_rule["manufacturer"]);
}
$printer->update($res_rule);
}
// Add to printer to deleted list
if ($new_printer_id != $p['id']) {
$printers_ids[] = $p['id'];
}
}
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:59,代码来源:ruledictionnaryprintercollection.class.php