ILIAS  trunk Revision v11.0_alpha-1838-g59fc79e306b
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.StyleAccessManager.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
23 use ilRbacSystem;
24 
30 {
31  protected bool $enable_write = false;
32  protected int $ref_id = 0;
33  protected int $user_id = 0;
35 
36  public function __construct(?ilRbacSystem $rbacsystem = null, int $ref_id = 0, int $user_id = 0)
37  {
38  global $DIC;
39 
40  $this->rbacsystem = (!is_null($rbacsystem))
41  ? $rbacsystem
42  : $DIC->rbac()->system();
43  $this->ref_id = $ref_id;
44  $this->user_id = $user_id;
45  }
46 
47  public function enableWrite(bool $write): void
48  {
49  $this->enable_write = $write;
50  }
51 
52  public function checkWrite(): bool
53  {
54  $rbacsystem = $this->rbacsystem;
55  if ($this->ref_id == 0) {
56  return true;
57  }
58 
59  return ($this->enable_write ||
60  $rbacsystem->checkAccessOfUser(
61  $this->user_id,
62  "write",
63  $this->ref_id
64  ) ||
65  $rbacsystem->checkAccessOfUser(
66  $this->user_id,
67  "sty_write_content",
68  $this->ref_id
69  )
70  );
71  }
72 }
checkAccessOfUser(int $a_user_id, string $a_operations, int $a_ref_id, string $a_type="")
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
global $DIC
Definition: shib_login.php:22
Manages access to content style editing.
__construct(?ilRbacSystem $rbacsystem=null, int $ref_id=0, int $user_id=0)