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


PHP Printer::getFromDB方法代码示例

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


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

 /**
  * Function to update Printer
  *
  * @param array $a_inventory data fron agent inventory
  * @param id $items_id id of the printer
  *
  * @return nothing
  */
 function updatePrinter($a_inventory, $items_id)
 {
     global $DB;
     $printer = new Printer();
     $pfPrinter = new PluginFusioninventoryPrinter();
     $printer->getFromDB($items_id);
     if (!isset($_SESSION['glpiactiveentities_string'])) {
         $_SESSION['glpiactiveentities_string'] = $printer->fields['entities_id'];
     }
     if (!isset($_SESSION['glpiactiveentities'])) {
         $_SESSION['glpiactiveentities'] = array($printer->fields['entities_id']);
     }
     if (!isset($_SESSION['glpiactive_entity'])) {
         $_SESSION['glpiactive_entity'] = $printer->fields['entities_id'];
     }
     // * Printer
     $db_printer = $printer->fields;
     $a_lockable = PluginFusioninventoryLock::getLockFields('glpi_printers', $items_id);
     $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['Printer'], $db_printer, $a_lockable);
     $a_inventory['Printer'] = $a_ret[0];
     $input = $a_inventory['Printer'];
     $input['id'] = $items_id;
     $printer->update($input);
     // * Printer fusion (ext)
     $db_printer = array();
     $query = "SELECT *\n            FROM `" . getTableForItemType("PluginFusioninventoryPrinter") . "`\n            WHERE `printers_id` = '{$items_id}'";
     $result = $DB->query($query);
     while ($data = $DB->fetch_assoc($result)) {
         foreach ($data as $key => $value) {
             $db_printer[$key] = Toolbox::addslashes_deep($value);
         }
     }
     if (count($db_printer) == '0') {
         // Add
         $a_inventory['PluginFusioninventoryPrinter']['printers_id'] = $items_id;
         $pfPrinter->add($a_inventory['PluginFusioninventoryPrinter']);
     } else {
         // Update
         $idtmp = $db_printer['id'];
         unset($db_printer['id']);
         unset($db_printer['printers_id']);
         unset($db_printer['plugin_fusioninventory_configsecurities_id']);
         $a_ret = PluginFusioninventoryToolbox::checkLock($a_inventory['PluginFusioninventoryPrinter'], $db_printer);
         $a_inventory['PluginFusioninventoryPrinter'] = $a_ret[0];
         $input = $a_inventory['PluginFusioninventoryPrinter'];
         $input['id'] = $idtmp;
         $pfPrinter->update($input);
     }
     // * Ports
     $this->importPorts($a_inventory, $items_id);
     // Page counters
     $this->importPageCounters($a_inventory['pagecounters'], $items_id);
     // Cartridges
     $this->importCartridges($a_inventory['cartridge'], $items_id);
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:63,代码来源:inventoryprinterlib.class.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: showGraph

    /**
     * Show printer graph form
     **/
    function showGraph($id, $options = array())
    {
        global $DB, $CFG_GLPI;
        $printer = new Printer();
        $where = '';
        $begin = '';
        $end = '';
        $timeUnit = 'day';
        $graphField = 'pages_total';
        $pagecounters = array();
        $graphType = 'day';
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_begin'])) {
            $begin = $_SESSION['glpi_plugin_fusioninventory_graph_begin'];
        }
        if ($begin == 'NULL' or $begin == '') {
            $begin = date("Y-m-01");
            // first day of current month
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_end'])) {
            $end = $_SESSION['glpi_plugin_fusioninventory_graph_end'];
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_type'])) {
            $graphType = $_SESSION['glpi_plugin_fusioninventory_graph_type'];
        }
        if ($end == 'NULL' or $end == '') {
            $end = date("Y-m-d");
            // today
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'])) {
            $timeUnit = $_SESSION['glpi_plugin_fusioninventory_graph_timeUnit'];
        }
        if (!isset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
            $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'] = array();
        }
        if (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'])) {
            $printerCompAdd = $_SESSION['glpi_plugin_fusioninventory_graph_printerCompAdd'];
            if (!key_exists($printerCompAdd, $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'])) {
                $oPrinter = new Printer();
                if ($oPrinter->getFromDB($printerCompAdd)) {
                    $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$printerCompAdd] = $oPrinter->getField('name');
                }
            }
        } elseif (isset($_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove'])) {
            unset($_SESSION['glpi_plugin_fusioninventory_graph_printersComp'][$_SESSION['glpi_plugin_fusioninventory_graph_printerCompRemove']]);
        }
        $oPrinter = new Printer();
        $printers = $_SESSION['glpi_plugin_fusioninventory_graph_printersComp'];
        $printersView = $printers;
        // printers without the current printer
        if (isset($printersView[$id])) {
            unset($printersView[$id]);
        } else {
            if ($oPrinter->getFromDB($id)) {
                $printers[$id] = $oPrinter->getField('name');
            }
        }
        $printersList = '';
        foreach ($printers as $printers_id => $printername) {
            if ($printersList != '') {
                $printersList .= '<br/>';
            }
            if ($printers_id == $id) {
                $printersList .= $printername;
            } else {
                $oPrinter->getFromDB($printers_id);
                $printersList .= $oPrinter->getLink(1);
            }
        }
        $printersIds = "";
        foreach (array_keys($printers) as $printerId) {
            if ($printersIds != '') {
                $printersIds .= ', ';
            }
            $printersIds .= $printerId;
        }
        $where = " WHERE `printers_id` IN(" . $printersIds . ")";
        if ($begin != '' || $end != '') {
            $where .= " AND " . getDateRequest("`date`", $begin, $end);
        }
        $group = '';
        switch ($timeUnit) {
            case 'day':
                $group = "GROUP BY `printers_id`, `year`, `month`, `day`";
                break;
            case 'week':
                $group = "GROUP BY `printers_id`, `year`, `month`, `week`";
                break;
            case 'month':
                $group = "GROUP BY `printers_id`, `year`, `month`";
                break;
            case 'year':
                $group = "GROUP BY `printers_id`, `year`";
                break;
        }
        echo "<form method='post' name='snmp_form' id='snmp_form' action='" . $CFG_GLPI['root_doc'] . "/plugins/fusioninventory/front/printer_info.form.php'>";
        echo "<table class='tab_cadre' cellpadding='5' width='950'>";
        $mapping = new PluginFusioninventoryMapping();
//.........这里部分代码省略.........
开发者ID:paisdelconocimiento,项目名称:glpi-smartcities,代码行数:101,代码来源:printerlog.class.php

示例5: PrinterDicoGlobalManagement

 /**
  * @test
  */
 public function PrinterDicoGlobalManagement()
 {
     $this->mark_incomplete();
     global $DB;
     $DB->connect();
     $printer = new Printer();
     $printer->getFromDB(1);
     $this->assertEquals('1', $printer->fields['is_global'], 'Printer p3 may be managed global');
 }
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:12,代码来源:ComputerPrinterTest.php

示例6: ComputerPrinter

 /**
  * @test
  */
 public function ComputerPrinter()
 {
     global $DB;
     $DB->connect();
     $a_dataLink = getAllDatasFromTable("glpi_computers_items", "`itemtype`='Printer'\n                                            AND `computers_id`='1'");
     $this->assertEquals(1, count($a_dataLink), "Number of printers not right");
     $a_dataLink = current($a_dataLink);
     $printer = new Printer();
     $printer->getFromDB($a_dataLink['items_id']);
     unset($printer->fields['date_mod']);
     $a_reference = array('id' => '1', 'entities_id' => '0', 'is_recursive' => '0', 'name' => 'HP Deskjet 5700 Series', 'contact' => 'ddurieux', 'contact_num' => NULL, 'users_id_tech' => '0', 'groups_id_tech' => '0', 'serial' => 'MY47L1W1JHEB6', 'otherserial' => NULL, 'have_serial' => '0', 'have_parallel' => '0', 'have_usb' => '1', 'have_wifi' => '0', 'have_ethernet' => '0', 'comment' => NULL, 'memory_size' => NULL, 'locations_id' => '0', 'domains_id' => '0', 'networks_id' => '0', 'printertypes_id' => '0', 'printermodels_id' => '0', 'manufacturers_id' => '0', 'is_global' => '0', 'is_deleted' => '0', 'is_template' => '0', 'template_name' => NULL, 'init_pages_counter' => '0', 'last_pages_counter' => '0', 'users_id' => '0', 'groups_id' => '0', 'states_id' => '0', 'ticket_tco' => '0.0000', 'is_dynamic' => '0');
     $this->assertEquals($a_reference, $printer->fields);
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:16,代码来源:ComputerUpdateTest.php

示例7: uninstall

 /**
  * UnLink a cartridge linked to a printer
  *
  * UnLink the cartridge identified by $ID
  *
  * @param $ID : cartridge identifier
  *
  * @return boolean
  **/
 function uninstall($ID)
 {
     global $DB;
     if ($this->getFromDB($ID)) {
         $printer = new Printer();
         $toadd = '';
         if ($printer->getFromDB($this->getField("printers_id"))) {
             $toadd .= ", `pages` = '" . $printer->fields['last_pages_counter'] . "' ";
         }
         $query = "UPDATE`" . $this->getTable() . "`\n                   SET `date_out` = '" . date("Y-m-d") . "'\n                       {$toadd}\n                   WHERE `id`='{$ID}'";
         if ($result = $DB->query($query) && $DB->affected_rows() > 0) {
             $changes[0] = '0';
             $changes[1] = '';
             $changes[2] = __('Uninstalling a cartridge');
             Log::history($this->getField("printers_id"), 'Printer', $changes, 0, Log::HISTORY_LOG_SIMPLE_MESSAGE);
             return true;
         }
         return false;
     }
 }
开发者ID:JULIO8,项目名称:respaldo_glpi,代码行数:29,代码来源:cartridge.class.php

示例8: updatePrinterFromNetdiscovery

 /**
  * @test
  */
 public function updatePrinterFromNetdiscovery()
 {
     global $DB;
     $DB->connect();
     $pfCNetworkDiscovery = new PluginFusioninventoryCommunicationNetworkDiscovery();
     $GLPIlog = new GLPIlogs();
     $networkName = new NetworkName();
     $iPAddress = new IPAddress();
     $_SESSION['SOURCE_XMLDEVICE'] = array('AUTHSNMP' => '1', 'DESCRIPTION' => 'Photosmart D7200 series', 'ENTITY' => '0', 'FIRMWARE' => '', 'IP' => '192.168.20.102', 'MAC' => '00:21:5a:0b:bb:c4', 'MANUFACTURER' => 'Hewlett-Packard', 'MODEL' => '', 'MODELSNMP' => 'Printer0093', 'NETBIOSNAME' => 'HP00215A0BBBC4', 'SERIAL' => 'MY89AQG0V9050N', 'SNMPHOSTNAME' => 'HP0BBBC4new', 'TYPE' => 'PRINTER');
     $printer = new Printer();
     $a_printers = $printer->find("`serial`='MY89AQG0V9050N'");
     $a_printer = current($a_printers);
     $printers_id = $a_printer['id'];
     $printer->getFromDB($printers_id);
     $pfCNetworkDiscovery->importDevice($printer);
     $GLPIlog->testSQLlogs();
     $GLPIlog->testPHPlogs();
     $printer->getFromDB($printers_id);
     $this->assertEquals('HP0BBBC4new', $printer->fields['name'], 'Name must be updated');
     $a_printerextends = getAllDatasFromTable('glpi_plugin_fusioninventory_printers', "`printers_id`='" . $printers_id . "'");
     $this->assertEquals('1', count($a_printerextends), 'May have one printer extend line for this printer');
     $a_printerextend = current($a_printerextends);
     $this->assertEquals('1', $a_printerextend['plugin_fusioninventory_configsecurities_id'], 'SNMPauth may be with id 1');
     $this->assertEquals('Photosmart D7200 series', $a_printerextend['sysdescr'], 'Sysdescr not updated correctly');
     // Check mac
     $networkPort = new NetworkPort();
     $a_ports = $networkPort->find("`itemtype`='Printer' AND `items_id`='" . $printers_id . "'");
     $this->assertEquals('1', count($a_ports), 'May have one network port');
     $a_port = current($a_ports);
     $this->assertEquals('00:21:5a:0b:bb:c4', $a_port['mac'], 'Mac address');
     // check ip
     $a_networknames = $networkName->find("`itemtype`='NetworkPort'\n         AND `items_id`='" . $a_port['id'] . "'");
     $this->assertEquals('1', count($a_networknames), 'May have one networkname');
     $a_networkname = current($a_networknames);
     $a_ipaddresses = $iPAddress->find("`itemtype`='NetworkName'\n         AND `items_id`='" . $a_networkname['id'] . "'");
     $this->assertEquals('1', count($a_ipaddresses), 'May have one IP address');
     $a_ipaddress = current($a_ipaddresses);
     $this->assertEquals('192.168.20.102', $a_ipaddress['name'], 'IP address');
 }
开发者ID:C-Duv,项目名称:fusioninventory-for-glpi,代码行数:42,代码来源:PrinterUpdateTest.php

示例9: while

echo "<th>" . __('Inventory number') . "</th>";
echo "<th>" . __('Model') . "</th>";
echo "<th>" . __('SNMP authentication') . "</th>";
echo "<th>" . __('Status') . "</th>";
echo "</tr>";
if ($result = $DB->query($query)) {
    while ($data = $DB->fetch_array($result)) {
        echo "<tr class='tab_bg_1'>";
        echo "<td>";
        if ($data['network_id'] > 0) {
            $class = new NetworkEquipment();
            $class->getFromDB($data['network_id']);
        } else {
            if ($data['printer_id'] > 0) {
                $class = new Printer();
                $class->getFromDB($data['printer_id']);
            }
        }
        echo $class->getLink(1);
        echo "</td>";
        echo "<td>" . Html::convDateTime($data['last_fusioninventory_update']) . "</td>";
        echo "<td>";
        if ($data['network_id'] > 0) {
            echo __('Networks');
        } else {
            if ($data['printer_id'] > 0) {
                echo __('Printers');
            }
        }
        echo "</td>";
        echo "<td>" . $data['ip'] . "</td>";
开发者ID:korial29,项目名称:fusioninventory-for-glpi,代码行数:31,代码来源:not_queried_recently.php

示例10: testDeleteByCriteria

 /**
  * @covers Printer::deleteByCriteria
  * @covers Printer::restore
  */
 public function testDeleteByCriteria()
 {
     $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());
     $nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     // DeleteByCriteria without history
     $this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 0));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     $nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     $this->assertEquals($nb_before, $nb_after);
     // 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());
     $nb_before = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     // DeleteByCriteria with history
     $this->assertTrue($obj->deleteByCriteria(['name' => __METHOD__], 0, 1));
     $this->assertTrue($obj->getFromDB($id));
     $this->assertEquals(1, $obj->getField('is_deleted'));
     $this->assertEquals(1, $obj->isDeleted());
     $nb_after = countElementsInTable('glpi_logs', "itemtype = 'Printer'\n                                          AND items_id = '{$id}'");
     $this->assertEquals($nb_before + 1, $nb_after);
 }
开发者ID:glpi-project,项目名称:glpi,代码行数:36,代码来源:PrinterTest.php


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