當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Printer::canEdit方法代碼示例

本文整理匯總了PHP中Printer::canEdit方法的典型用法代碼示例。如果您正苦於以下問題:PHP Printer::canEdit方法的具體用法?PHP Printer::canEdit怎麽用?PHP Printer::canEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Printer的用法示例。


在下文中一共展示了Printer::canEdit方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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");
 }
開發者ID:btry,項目名稱:glpi,代碼行數:64,代碼來源:CanCheck.php


注:本文中的Printer::canEdit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。