ILIAS  trunk Revision v11.0_alpha-1744-gb0451eebef4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 21 of file class.ilOrgUnitAuthorityDBRepository.php.

Constructor & Destructor Documentation

◆ __construct()

ilOrgUnitAuthorityDBRepository::__construct ( ilDBInterface  $db)

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

References $db.

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

Member Function Documentation

◆ create()

ilOrgUnitAuthorityDBRepository::create ( )

Implements OrgUnitAuthorityRepository.

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

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

◆ delete()

ilOrgUnitAuthorityDBRepository::delete ( int  $id)

Implements OrgUnitAuthorityRepository.

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

101  : void
102  {
103  $query = 'DELETE FROM ' . self::TABLE_NAME . PHP_EOL
104  . ' WHERE id = ' . $this->db->quote($id, 'integer');
105 
106  $this->db->manipulate($query);
107  }
$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 112 of file class.ilOrgUnitAuthorityDBRepository.php.

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

◆ deleteLeftoverAuthorities()

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

Deletes orphaned authorities on position save.

Implements OrgUnitAuthorityRepository.

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

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

◆ get()

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

Implements OrgUnitAuthorityRepository.

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

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

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

◆ insert()

ilOrgUnitAuthorityDBRepository::insert ( ilOrgUnitAuthority  $authority)
private

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

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

Referenced by store().

68  {
69  $id = $this->db->nextId(self::TABLE_NAME);
70 
71  $values = [
72  'id' => [ 'integer', $id],
73  'over' => [ 'integer', $authority->getOver() ],
74  'scope' => [ 'integer', $authority->getScope() ],
75  'position_id' => [ 'integer', $authority->getPositionId() ]
76  ];
77 
78  $this->db->insert(self::TABLE_NAME, $values);
79 
80  $ret = (new ilOrgUnitAuthority($id))
81  ->withOver($authority->getOver())
82  ->withScope($authority->getScope())
83  ->withPositionId($authority->getPositionId());
84 
85  return $ret;
86  }
$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 56 of file class.ilOrgUnitAuthorityDBRepository.php.

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

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

◆ update()

ilOrgUnitAuthorityDBRepository::update ( ilOrgUnitAuthority  $authority)
private

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

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

Referenced by store().

88  : void
89  {
90  $where = [ 'id' => [ 'integer', $authority->getId() ] ];
91 
92  $values = [
93  'over' => [ 'integer', $authority->getOver() ],
94  'scope' => [ 'integer', $authority->getScope() ],
95  'position_id' => [ 'integer', $authority->getPositionId() ]
96  ];
97 
98  $this->db->update(self::TABLE_NAME, $values, $where);
99  }
+ 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 24 of file class.ilOrgUnitAuthorityDBRepository.php.

Referenced by __construct().

◆ TABLE_NAME

const ilOrgUnitAuthorityDBRepository::TABLE_NAME = 'il_orgu_authority'

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


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