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


PHP Printer::delete方法代码示例

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


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

示例1: testPrinterTemplate

 /**
  * Check delete / purge on a template of printer
  */
 public function testPrinterTemplate()
 {
     $printer = new Printer();
     // Create
     $id[0] = $printer->add(array('name' => "Printer 1", 'entities_id' => 0, 'is_template' => 1));
     $this->assertGreaterThan(0, $id[0], "Fail to create Printer Template");
     $this->assertTrue($printer->getFromDB($id[0]), "Fail: can't read Template");
     $this->assertEquals(0, $printer->fields['is_deleted'], "Fail: is_deleted set");
     $this->assertEquals(1, $printer->fields['is_template'], "Fail: is_template not set");
     // Delete (= purge)
     $this->assertTrue($printer->delete(array('id' => $id[0]), 0), "Fail: can't delete Template");
     $this->assertFalse($printer->getFromDB($id[0]), "Fail: can read Template (deleted)");
 }
开发者ID:btry,项目名称:glpi,代码行数:16,代码来源:DeleteRestore.php

示例2: testDelete

 /**
  * @covers Printer::delete
  * @covers Printer::restore
  */
 public function testDelete()
 {
     $obj = new Printer();
     $this->assertTrue($obj->maybeDeleted());
     // Add
     $id = $obj->add(['name' => __METHOD__, 'entities_id' => getItemByTypeName('Entity', '_test_root_entity', true)]);
     $this->assertGreaterThan(0, $id);
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Delete
     $this->assertTrue($obj->delete(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     // Restore
     $this->assertTrue($obj->restore(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Purge
     $this->assertTrue($obj->delete(['id' => $id], 1));
     $this->assertFalse($obj->getFromDB($id));
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:28,代码来源:PrinterTest.php

示例3: testDelete

 /**
  * @covers Printer::delete
  * @covers Printer::restore
  */
 public function testDelete()
 {
     $obj = new Printer();
     $this->assertTrue($obj->maybeDeleted());
     // Add
     $id = $obj->add(['name' => __METHOD__]);
     $this->assertGreaterThan(0, $id);
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Delete
     $this->assertTrue($obj->delete(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     // Restore
     $this->assertTrue($obj->restore(['id' => $id], 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(0, $obj->getField('is_deleted'));
     $this->assertEquals(0, $obj->isDeleted());
     // Purge
     $this->assertTrue($obj->delete(['id' => $id], 1));
     $this->assertFalse($obj->getFromDB($id));
 }
开发者ID:btry,项目名称:glpi,代码行数:28,代码来源:PrinterTest.php

示例4: putOldPrintersInTrash

 /**
  * @param $IDS array
  */
 function putOldPrintersInTrash($IDS = array())
 {
     $printer = new Printer();
     foreach ($IDS as $id) {
         $printer->delete(array('id' => $id));
     }
 }
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:10,代码来源:ruledictionnaryprintercollection.class.php

示例5: Printer

    $_GET["order"] = "";
}
if (!isset($_GET["withtemplate"])) {
    $_GET["withtemplate"] = "";
}
$print = new Printer();
if (isset($_POST["add"])) {
    $print->check(-1, 'w', $_POST);
    if ($newID = $print->add($_POST)) {
        Event::log($newID, "printers", 4, "inventory", $_SESSION["glpiname"] . "  " . $LANG['log'][20] . "  " . $_POST["name"] . ".");
    }
    glpi_header($_SERVER['HTTP_REFERER']);
} else {
    if (isset($_POST["delete"])) {
        $print->check($_POST["id"], 'd');
        $print->delete($_POST);
        Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][22]);
        $print->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $print->check($_POST["id"], 'd');
            $print->restore($_POST);
            Event::log($_POST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][23]);
            $print->redirectToList();
        } else {
            if (isset($_REQUEST["purge"])) {
                $print->check($_REQUEST["id"], 'd');
                $print->delete($_REQUEST, 1);
                Event::log($_REQUEST["id"], "printers", 4, "inventory", $_SESSION["glpiname"] . " " . $LANG['log'][24]);
                $print->redirectToList();
            } else {
开发者ID:ryukansent,项目名称:Thesis-SideB,代码行数:31,代码来源:printer.form.php

示例6: testPrinterDicoIgnoreImport

 public function testPrinterDicoIgnoreImport()
 {
     global $DB;
     $DB->connect();
     self::restore_database();
     $_SESSION['glpiactive_entity'] = 0;
     $_SESSION["plugin_fusioninventory_entity"] = 0;
     $_SESSION["glpiname"] = 'Plugin_FusionInventory';
     $pfConfig = new PluginFusioninventoryConfig();
     $computer = new Computer();
     /*
      * TODO: maybe we could use some dataProvider here ?
      */
     // Add dictionnary rule for ignore import for printer p2
     $rulecollection = new RuleDictionnaryPrinterCollection();
     $rule = $rulecollection->getRuleClass();
     $input = array();
     $input['is_active'] = 1;
     $input['name'] = 'Ignore import';
     $input['match'] = 'AND';
     $input['sub_type'] = 'RuleDictionnaryPrinter';
     $input['ranking'] = 1;
     $rule_id = $rule->add($input);
     // Add criteria
     $rule = $rulecollection->getRuleClass();
     $rulecriteria = new RuleCriteria(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['criteria'] = "name";
     $input['pattern'] = 'p2';
     $input['condition'] = 0;
     $rulecriteria->add($input);
     // Add action
     $ruleaction = new RuleAction(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['action_type'] = 'assign';
     $input['field'] = '_ignore_import';
     $input['value'] = '1';
     $ruleaction->add($input);
     // Add dictionnary rule for ignore import for printer p3
     $rulecollection = new RuleDictionnaryPrinterCollection();
     $rule = $rulecollection->getRuleClass();
     $input = array();
     $input['is_active'] = 1;
     $input['name'] = 'rename';
     $input['match'] = 'AND';
     $input['sub_type'] = 'RuleDictionnaryPrinter';
     $input['ranking'] = 2;
     $rule_id = $rule->add($input);
     // Add criteria
     $rule = $rulecollection->getRuleClass();
     $rulecriteria = new RuleCriteria(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['criteria'] = "name";
     $input['pattern'] = 'p3';
     $input['condition'] = 0;
     $rulecriteria->add($input);
     // Add action
     $ruleaction = new RuleAction(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['action_type'] = 'assign';
     $input['field'] = 'name';
     $input['value'] = 'p3bis';
     $ruleaction->add($input);
     // Add action
     $ruleaction = new RuleAction(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['action_type'] = 'assign';
     $input['field'] = 'manufacturer';
     $input['value'] = '1';
     $ruleaction->add($input);
     // Add action
     $ruleaction = new RuleAction(get_class($rule));
     $input = array();
     $input['rules_id'] = $rule_id;
     $input['action_type'] = 'assign';
     $input['field'] = 'is_global';
     $input['value'] = '0';
     $ruleaction->add($input);
     $pfici = new PluginFusioninventoryInventoryComputerInventory();
     $_SESSION['plugin_fusioninventory_agents_id'] = 1;
     $pfici->sendCriteria("toto", $this->a_computer1_beforeformat);
     $computer->getFromDB(1);
     $this->assertEquals('ggheb7ne7', $computer->fields['serial'], 'Computer not updated correctly');
     $a_printers = getAllDatasFromTable("glpi_printers");
     $this->assertEquals(0, countElementsInTable('glpi_printers'), 'Printer p2 may be ignored (' . print_r($a_printers, TRUE) . ')');
     $printer = new Printer();
     $printer->delete(array('id' => 1), 1);
     $DB->query("TRUNCATE TABLE `glpi_printers`");
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:94,代码来源:ComputerPrinterTest.php

示例7: resetPrinters

 /**
  * Delete all old printers of a computer.
  *
  * @param $glpi_computers_id integer : glpi computer id.
  *
  * @return nothing.
  **/
 static function resetPrinters($glpi_computers_id)
 {
     global $DB;
     $query = "SELECT*\n                FROM `glpi_computers_items`\n                WHERE `computers_id` = '{$glpi_computers_id}'\n                      AND `itemtype` = 'Printer'";
     $result = $DB->query($query);
     if ($DB->numrows($result) > 0) {
         $conn = new Computer_Item();
         while ($data = $DB->fetch_assoc($result)) {
             $conn->delete(array('id' => $data['id']));
             $query2 = "SELECT COUNT(*)\n                       FROM `glpi_computers_items`\n                       WHERE `items_id` = '" . $data['items_id'] . "'\n                             AND `itemtype` = 'Printer'";
             $result2 = $DB->query($query2);
             $printer = new Printer();
             if ($DB->result($result2, 0, 0) == 1) {
                 $printer->delete(array('id' => $data['items_id']), 1);
             }
         }
     }
 }
开发者ID:geldarr,项目名称:hack-space,代码行数:25,代码来源:ocsserver.class.php

示例8: Printer

    $_GET["withtemplate"] = "";
}
$print = new Printer();
if (isset($_POST["add"])) {
    $print->check(-1, CREATE, $_POST);
    if ($newID = $print->add($_POST)) {
        Event::log($newID, "printers", 4, "inventory", sprintf(__('%1$s adds the item %2$s'), $_SESSION["glpiname"], $_POST["name"]));
        if ($_SESSION['glpibackcreated']) {
            Html::redirect($print->getFormURL() . "?id=" . $newID);
        }
    }
    Html::back();
} else {
    if (isset($_POST["delete"])) {
        $print->check($_POST["id"], DELETE);
        $print->delete($_POST);
        Event::log($_POST["id"], "printers", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
        $print->redirectToList();
    } else {
        if (isset($_POST["restore"])) {
            $print->check($_POST["id"], DELETE);
            $print->restore($_POST);
            Event::log($_POST["id"], "printers", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
            $print->redirectToList();
        } else {
            if (isset($_POST["purge"])) {
                $print->check($_POST["id"], PURGE);
                $print->delete($_POST, 1);
                Event::log($_POST["id"], "printers", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
                $print->redirectToList();
            } else {
开发者ID:btry,项目名称:glpi,代码行数:31,代码来源:printer.form.php

示例9: array

        fMessaging::create('error', fURL::get(), $e->getMessage());
    }
    // Get manufacturers also for drop-down box
    #$manufacturers = fRecordSet::build('Manufacturer', NULL, array('name' => 'asc'));
    // Get list of models
    $models = Model::getSimple($db);
    include 'views/printers/addedit.php';
}
/**
 * Delete a printer
 */
if ($action == 'delete') {
    // Get ID
    $id = fRequest::get('id', 'integer');
    try {
        $p = new Printer($id);
        if (fRequest::isPost()) {
            $p->delete();
            fMessaging::create('success', fURL::get(), 'The printer ' . $p->getName() . ' was successfully deleted.');
            fURL::redirect(fURL::get());
        }
    } catch (fNotFoundException $e) {
        fMessaging::create('error', fURL::get(), 'The printer requested, ID ' . $id . ', could not be found.');
        fURL::redirect($manage_url);
    } catch (fExpectedException $e) {
        fMessaging::create('error', fURL::get(), $e->getMessage());
    } catch (fSQLException $e) {
        fMessaging::create('error', fURL::get(), 'Database error: ' . $e->getMessage());
    }
    include 'views/printers/delete.php';
}
开发者ID:mrjwc,项目名称:printmaster,代码行数:31,代码来源:printers.php


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