ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilOrgUnitAuthorityDBRepository Class Reference
+ Inheritance diagram for ilOrgUnitAuthorityDBRepository:
+ Collaboration diagram for ilOrgUnitAuthorityDBRepository:

Public Member Functions

 __construct (ilDBInterface $db)
 
 get (int $id, string $field)
 
 create ()
 
 store (ilOrgUnitAuthority $authority)
 
 delete (int $id)
 
 deleteByPositionId (int $position_id)
 Deletes all authorities for a position. More...
 
 deleteLeftoverAuthorities (array $ids, int $position_id)
 Deletes orphaned authorities on position save. More...
 

Data Fields

const TABLE_NAME = 'il_orgu_authority'
 

Protected Attributes

ilDBInterface $db
 

Private Member Functions

 insert (ilOrgUnitAuthority $authority)
 
 update (ilOrgUnitAuthority $authority)
 

Detailed Description

Definition at line 20 of file class.ilOrgUnitAuthorityDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitAuthorityDBRepository::__construct ( ilDBInterface  $db)

Definition at line 25 of file class.ilOrgUnitAuthorityDBRepository.php.

References $db.

26  {
27  $this->db = $db;
28  }

Member Function Documentation

◆ create()

ilOrgUnitAuthorityDBRepository::create ( )

Implements OrgUnitAuthorityRepository.

Definition at line 50 of file class.ilOrgUnitAuthorityDBRepository.php.

51  {
52  return new ilOrgUnitAuthority();
53  }
Class ilOrguAuthority.

◆ delete()

ilOrgUnitAuthorityDBRepository::delete ( int  $id)

Implements OrgUnitAuthorityRepository.

Definition at line 100 of file class.ilOrgUnitAuthorityDBRepository.php.

100  : void
101  {
102  $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
103  . ' WHERE id = ' . $this->db->quote($id, 'integer');
104 
105  $this->db->manipulate($query);
106  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23

◆ deleteByPositionId()

ilOrgUnitAuthorityDBRepository::deleteByPositionId ( int  $position_id)

Deletes all authorities for a position.

Implements OrgUnitAuthorityRepository.

Definition at line 111 of file class.ilOrgUnitAuthorityDBRepository.php.

111  : void
112  {
113  $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
114  . ' WHERE position_id = ' . $this->db->quote($position_id, 'integer');
115 
116  $this->db->manipulate($query);
117  }

◆ deleteLeftoverAuthorities()

ilOrgUnitAuthorityDBRepository::deleteLeftoverAuthorities ( array  $ids,
int  $position_id 
)

Deletes orphaned authorities on position save.

Implements OrgUnitAuthorityRepository.

Definition at line 122 of file class.ilOrgUnitAuthorityDBRepository.php.

122  : void
123  {
124  $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
125  . ' WHERE position_id = ' . $this->db->quote($position_id, 'integer') . PHP_EOL
126  . ' AND ' . $this->db->in('id', $ids, true, 'integer');
127 
128  $this->db->manipulate($query);
129  }

◆ get()

ilOrgUnitAuthorityDBRepository::get ( int  $id,
string  $field 
)
Returns
ilOrgUnitAuthority[]

Implements OrgUnitAuthorityRepository.

Definition at line 30 of file class.ilOrgUnitAuthorityDBRepository.php.

References $res, ilOrgUnitAuthority\FIELD_OVER, and ilOrgUnitAuthority\POSITION_ID.

30  : array
31  {
32  if (!in_array($field, [ilOrgUnitAuthority::FIELD_OVER, ilOrgUnitAuthority::POSITION_ID, 'id'])) {
33  throw new Exception("Invalid field: " . $field);
34  }
35  $query = 'SELECT id, ' . self::TABLE_NAME . '.over, scope, position_id FROM' . PHP_EOL
36  . self::TABLE_NAME
37  . ' WHERE ' . self::TABLE_NAME . '.' . $field . ' = ' . $this->db->quote($id, 'integer');
38  $res = $this->db->query($query);
39  $ret = [];
40  while ($rec = $this->db->fetchAssoc($res)) {
41  $ret[] = (new ilOrgUnitAuthority((int) $rec['id']))
42  ->withOver((int) $rec['over'])
43  ->withScope((int) $rec['scope'])
44  ->withPositionId((int) $rec['position_id']);
45  }
46 
47  return $ret;
48  }
$res
Definition: ltiservices.php:69
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilOrguAuthority.

◆ insert()

ilOrgUnitAuthorityDBRepository::insert ( ilOrgUnitAuthority  $authority)
private

Definition at line 66 of file class.ilOrgUnitAuthorityDBRepository.php.

References $id, ilOrgUnitAuthority\getOver(), ilOrgUnitAuthority\getPositionId(), and ilOrgUnitAuthority\getScope().

Referenced by store().

67  {
68  $id = $this->db->nextId(self::TABLE_NAME);
69 
70  $values = [
71  'id' => [ 'integer', $id],
72  'over' => [ 'integer', $authority->getOver() ],
73  'scope' => [ 'integer', $authority->getScope() ],
74  'position_id' => [ 'integer', $authority->getPositionId() ]
75  ];
76 
77  $this->db->insert(self::TABLE_NAME, $values);
78 
79  $ret = (new ilOrgUnitAuthority($id))
80  ->withOver($authority->getOver())
81  ->withScope($authority->getScope())
82  ->withPositionId($authority->getPositionId());
83 
84  return $ret;
85  }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilOrguAuthority.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ store()

ilOrgUnitAuthorityDBRepository::store ( ilOrgUnitAuthority  $authority)

Implements OrgUnitAuthorityRepository.

Definition at line 55 of file class.ilOrgUnitAuthorityDBRepository.php.

References ilOrgUnitAuthority\getId(), insert(), and update().

56  {
57  if ($authority->getId() === 0) {
58  $authority = $this->insert($authority);
59  } else {
60  $this->update($authority);
61  }
62 
63  return $authority;
64  }
Class ilOrguAuthority.
+ Here is the call graph for this function:

◆ update()

ilOrgUnitAuthorityDBRepository::update ( ilOrgUnitAuthority  $authority)
private

Definition at line 87 of file class.ilOrgUnitAuthorityDBRepository.php.

References ilOrgUnitAuthority\getId(), ilOrgUnitAuthority\getOver(), ilOrgUnitAuthority\getPositionId(), and ilOrgUnitAuthority\getScope().

Referenced by store().

87  : void
88  {
89  $where = [ 'id' => [ 'integer', $authority->getId() ] ];
90 
91  $values = [
92  'over' => [ 'integer', $authority->getOver() ],
93  'scope' => [ 'integer', $authority->getScope() ],
94  'position_id' => [ 'integer', $authority->getPositionId() ]
95  ];
96 
97  $this->db->update(self::TABLE_NAME, $values, $where);
98  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Field Documentation

◆ $db

ilDBInterface ilOrgUnitAuthorityDBRepository::$db
protected

Definition at line 23 of file class.ilOrgUnitAuthorityDBRepository.php.

Referenced by __construct().

◆ TABLE_NAME

const ilOrgUnitAuthorityDBRepository::TABLE_NAME = 'il_orgu_authority'

Definition at line 22 of file class.ilOrgUnitAuthorityDBRepository.php.


The documentation for this class was generated from the following file: