本文整理汇总了PHP中Printer::can方法的典型用法代码示例。如果您正苦于以下问题:PHP Printer::can方法的具体用法?PHP Printer::can怎么用?PHP Printer::can使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Printer
的用法示例。
在下文中一共展示了Printer::can方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testVisibility
public function testVisibility()
{
$this->Login();
$p = new Printer();
// Visibility from root + tree
$this->setEntity('_test_root_entity', true);
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_all', true), READ));
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_ent0', true), READ));
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_ent1', true), READ));
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_ent2', true), READ));
// Visibility from root only
$this->setEntity('_test_root_entity', false);
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_all', true), READ));
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_ent0', true), READ));
$this->assertFalse($p->can(getItemByTypeName('Printer', '_test_printer_ent1', true), READ));
$this->assertFalse($p->can(getItemByTypeName('Printer', '_test_printer_ent2', true), READ));
// Visibility from child
$this->setEntity('_test_child_1', false);
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_all', true), READ));
$this->assertFalse($p->can(getItemByTypeName('Printer', '_test_printer_ent0', true), READ));
$this->assertTrue($p->can(getItemByTypeName('Printer', '_test_printer_ent1', true), READ));
$this->assertFalse($p->can(getItemByTypeName('Printer', '_test_printer_ent2', true), READ));
}
示例2: testPrinter
/**
* Check right on Recursive object
*/
public function testPrinter()
{
global $DB;
$DB->connect();
$ent0 = $this->sharedFixture['entity'][0];
$ent1 = $this->sharedFixture['entity'][1];
$ent2 = $this->sharedFixture['entity'][2];
$printer = new Printer();
$id[0] = $printer->add(array('name' => "Printer 1", 'entities_id' => $ent0, 'is_recursive' => 0));
$this->assertGreaterThan(0, $id[0], "Fail to create Printer 1");
$id[1] = $printer->add(array('name' => "Printer 2", 'entities_id' => $ent0, 'is_recursive' => 1));
$this->assertGreaterThan(0, $id[1], "Fail to create Printer 2");
$id[2] = $printer->add(array('name' => "Printer 3", 'entities_id' => $ent1, 'is_recursive' => 1));
$this->assertGreaterThan(0, $id[2], "Fail to create Ptiner 3");
$id[3] = $printer->add(array('name' => "Printer 4", 'entities_id' => $ent2));
$this->assertGreaterThan(0, $id[3], "Fail to create Printer 4");
// Super admin
Session::changeProfile(4);
$this->assertEquals(4, $_SESSION['glpiactiveprofile']['id']);
$this->assertEquals(31, $_SESSION['glpiactiveprofile']['printer']);
// See all
$this->assertTrue(Session::changeActiveEntities("all"));
$this->assertTrue($printer->can($id[0], READ), "Fail can read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertTrue($printer->can($id[2], READ), "Fail can read Printer 3");
$this->assertTrue($printer->can($id[3], READ), "Fail can read Printer 4");
$this->assertTrue($printer->canEdit($id[0]), "Fail can write Printer 1");
$this->assertTrue($printer->canEdit($id[1]), "Fail can write Printer 2");
$this->assertTrue($printer->canEdit($id[2]), "Fail can write Printer 3");
$this->assertTrue($printer->canEdit($id[3]), "Fail can write Printer 4");
// See only in main entity
$this->assertTrue(Session::changeActiveEntities($ent0));
$this->assertTrue($printer->can($id[0], READ), "Fail can read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertFalse($printer->can($id[2], READ), "Fail can't read Printer 3");
$this->assertFalse($printer->can($id[3], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->canEdit($id[0]), "Fail can write Printer 1");
$this->assertTrue($printer->canEdit($id[1]), "Fail can write Printer 2");
$this->assertFalse($printer->canEdit($id[2]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[3]), "Fail can't write Printer 1");
// See only in child entity 1 + parent if recursive
$this->assertTrue(Session::changeActiveEntities($ent1));
$this->assertFalse($printer->can($id[0], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertTrue($printer->can($id[2], READ), "Fail can read Printer 3");
$this->assertFalse($printer->can($id[3], READ), "Fail can't read Printer 4");
$this->assertFalse($printer->canEdit($id[0]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[1]), "Fail can't write Printer 2");
$this->assertTrue($printer->canEdit($id[2]), "Fail can write Printer 2");
$this->assertFalse($printer->canEdit($id[3]), "Fail can't write Printer 2");
// See only in child entity 2 + parent if recursive
$this->assertTrue(Session::changeActiveEntities($ent2));
$this->assertFalse($printer->can($id[0], READ), "Fail can't read Printer 1");
$this->assertTrue($printer->can($id[1], READ), "Fail can read Printer 2");
$this->assertFalse($printer->can($id[2], READ), "Fail can't read Printer 3");
$this->assertTrue($printer->can($id[3], READ), "Fail can read Printer 4");
$this->assertFalse($printer->canEdit($id[0]), "Fail can't write Printer 1");
$this->assertFalse($printer->canEdit($id[1]), "Fail can't write Printer 2");
$this->assertFalse($printer->canEdit($id[2]), "Fail can't write Printer 3");
$this->assertTrue($printer->canEdit($id[3]), "Fail can write Printer 4");
}
示例3: Printer
header_nocache();
if (!isset($_POST["id"])) {
$_POST["id"] = "";
}
if (!isset($_POST["sort"])) {
$_POST["sort"] = "";
}
if (!isset($_POST["order"])) {
$_POST["order"] = "";
}
if (!isset($_POST["withtemplate"])) {
$_POST["withtemplate"] = "";
}
checkRight("printer", "r");
$printer = new Printer();
if ($_POST["id"] > 0 && $printer->can($_POST["id"], 'r')) {
if (!empty($_POST["withtemplate"])) {
switch ($_REQUEST['glpi_tab']) {
case 3:
NetworkPort::showForItem('Printer', $_POST["id"], $_POST["withtemplate"]);
break;
case 4:
Infocom::showForItem($printer, $_POST["withtemplate"]);
Contract::showAssociated($printer, $_POST["withtemplate"]);
break;
case 5:
Document::showAssociated($printer, $_POST["withtemplate"]);
break;
default:
Plugin::displayAction($printer, $_REQUEST['glpi_tab'], $_POST["withtemplate"]);
}