ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilOrgUnitPosition Class Reference

Class ilOrgUnitPosition. More...

+ Inheritance diagram for ilOrgUnitPosition:
+ Collaboration diagram for ilOrgUnitPosition:

Public Member Functions

 delete ()
 
 afterObjectLoad ()
 
 update ()
 
 create ()
 
 getAuthoritiesAsArray ()
 
 __toString ()
 
 getDependentAuthorities ()
 
 deleteWithAllDependencies ()
 This deletes the Position, it's Authorities, dependent Authorities and all User-Assignements! More...
 
 getId ()
 
 setId ($id)
 
 getTitle ()
 
 setTitle ($title)
 
 getDescription ()
 
 setDescription ($description)
 
 isCorePosition ()
 
 setCorePosition ($core_position)
 
 getAuthorities ()
 
 setAuthorities ($authorities)
 
 getCoreIdentifier ()
 
 setCoreIdentifier ($core_identifier)
 
- Public Member Functions inherited from ActiveRecord
 getArConnector ()
 
 getArFieldList ()
 
 getConnectorContainerName ()
 
 setConnectorContainerName ($connector_container_name)
 
 getPrimaryFieldValue ()
 
 setPrimaryFieldValue ($value)
 
 __construct ($primary_key=0, arConnector $connector=null)
 
 storeObjectToCache ()
 
 __getConvertedDateFieldsAsArray ($format=null)
 
 __asCsv ($separator=';', $header=false)
 
 __asArray ()
 
 __asStdClass ()
 
 __asSerializedObject ()
 
 buildFromArray (array $array)
 
 fixDateField ($field_name, $value)
 
 sleep ($field_name)
 
 wakeUp ($field_name, $field_value)
 
 getArrayForDb ()
 
 getArrayForConnector ()
 
 installConnector ()
 
 store ()
 
 save ()
 
 create ()
 
 copy ($new_id=0)
 
 afterObjectLoad ()
 
 read ()
 
 update ()
 
 delete ()
 
 __call ($name, $arguments)
 

Static Public Member Functions

static returnDbTableName ()
 
static get ()
 Override for correct on return value. More...
 
static getCorePosition ($core_identifier)
 
static getCorePositionId ($core_identifier)
 
static getActive ()
 
static getActiveForPosition ($orgu_ref_id)
 
- Static Public Member Functions inherited from ActiveRecord
static returnDbTableName ()
 
static installDB ()
 
static renameDBField ($old_name, $new_name)
 
static tableExists ()
 
static fieldExists ($field_name)
 
static removeDBField ($field_name)
 
static updateDB ()
 
static resetDB ()
 
static truncateDB ()
 
static flushDB ()
 
static preloadObjects ()
 
static additionalParams (array $additional_params)
 
static findOrFail ($primary_key, array $add_constructor_args=array())
 Tries to find the object and throws an Exception if object is not found, instead of returning null. More...
 
static findOrGetInstance ($primary_key, array $add_constructor_args=array())
 
static where ($where, $operator=null)
 
static innerjoinAR (ActiveRecord $ar, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static innerjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static leftjoin ($tablename, $on_this, $on_external, $fields=array(' *'), $operator='=', $both_external=false)
 
static orderBy ($orderBy, $orderDirection='ASC')
 
static dateFormat ($date_format='d.m.Y - H:i:s')
 
static limit ($start, $end)
 
static affectedRows ()
 
static count ()
 
static get ()
 
static debug ()
 
static first ()
 
static getCollection ()
 
static last ()
 
static getFirstFromLastQuery ()
 
static connector (arConnector $connector)
 
static raw ($set_raw=true)
 
static getArray ($key=null, $values=null)
 
static _toCamelCase ($str, $capitalise_first_char=false)
 

Data Fields

const CORE_POSITION_EMPLOYEE = 1
 
const CORE_POSITION_SUPERIOR = 2
 
- Data Fields inherited from ActiveRecord
const ACTIVE_RECORD_VERSION = '2.0.7'
 

Protected Attributes

 $id = 0
 
 $title = ""
 
 $description = ""
 
 $core_position = false
 
 $core_identifier = 0
 
 $authorities = array()
 
- Protected Attributes inherited from ActiveRecord
 $ar_safe_read = true
 
 $connector_container_name = ''
 

Private Member Functions

 storeAuthorities ()
 

Additional Inherited Members

- Protected Member Functions inherited from ActiveRecord
 serializeToCSV ($field)
 This method is called for every field of your instance if you use __asCsv. More...
 
 installDatabase ()
 
- Static Protected Member Functions inherited from ActiveRecord
static getCalledClass ()
 
static fromCamelCase ($str)
 

Detailed Description

Member Function Documentation

◆ __toString()

ilOrgUnitPosition::__toString ( )
Returns
string

Definition at line 212 of file class.ilOrgUnitPosition.php.

213 {
214 return $this->getTitle();
215 }

References getTitle().

+ Here is the call graph for this function:

◆ afterObjectLoad()

ilOrgUnitPosition::afterObjectLoad ( )

Reimplemented from ActiveRecord.

Definition at line 174 of file class.ilOrgUnitPosition.php.

175 {
176 $this->authorities = ilOrgUnitAuthority::where(array( ilOrgUnitAuthority::POSITION_ID => $this->getId() ))
177 ->get();
178 }
static where($where, $operator=null)

References getId(), ilOrgUnitAuthority\POSITION_ID, and ActiveRecord\where().

+ Here is the call graph for this function:

◆ create()

ilOrgUnitPosition::create ( )

Reimplemented from ActiveRecord.

Definition at line 188 of file class.ilOrgUnitPosition.php.

189 {
190 parent::create();
191 $this->storeAuthorities();
192 }

References storeAuthorities().

+ Here is the call graph for this function:

◆ delete()

ilOrgUnitPosition::delete ( )
Exceptions

ilException whenever you try to delete a core-position like employee or superior

Reimplemented from ActiveRecord.

Definition at line 60 of file class.ilOrgUnitPosition.php.

61 {
62 if ($this->isCorePosition()) {
63 throw new ilException('Cannot delete Core-Position');
64 }
65 parent::delete();
66 }
Base class for ILIAS Exception handling.

References isCorePosition().

+ Here is the call graph for this function:

◆ deleteWithAllDependencies()

ilOrgUnitPosition::deleteWithAllDependencies ( )

This deletes the Position, it's Authorities, dependent Authorities and all User-Assignements!

Definition at line 235 of file class.ilOrgUnitPosition.php.

236 {
237 foreach ($this->getDependentAuthorities() as $authority) {
238 $authority->delete();
239 }
240
241 $ilOrgUnitUserAssignmentQueries = ilOrgUnitUserAssignmentQueries::getInstance();
242 foreach ($ilOrgUnitUserAssignmentQueries->getUserAssignmentsOfPosition($this->getId()) as $assignment) {
243 $assignment->delete();
244 }
245 parent::delete();
246 }
$authority

References $authority, getDependentAuthorities(), and ilOrgUnitUserAssignmentQueries\getInstance().

+ Here is the call graph for this function:

◆ get()

static ilOrgUnitPosition::get ( )
static

Override for correct on return value.

Returns
\ilOrgUnitPosition[]

@noinspection PhpIncompatibleReturnTypeInspection

Reimplemented from ActiveRecord.

Definition at line 28 of file class.ilOrgUnitPosition.php.

29 {
31 return parent::get();
32 }

Referenced by ilOrgUnitPermissionTableGUI\collectData().

+ Here is the caller graph for this function:

◆ getActive()

static ilOrgUnitPosition::getActive ( )
static
Returns
\ilOrgUnitPosition[] array of Positions (all core-positions and all positions which have already UserAssignments)

Definition at line 73 of file class.ilOrgUnitPosition.php.

74 {
75 arObjectCache::flush(self::class);
76 $q = "SELECT DISTINCT il_orgu_positions.id, il_orgu_positions.*
77 FROM il_orgu_positions
78 LEFT JOIN il_orgu_ua ON il_orgu_positions.id = il_orgu_ua.position_id
79 WHERE il_orgu_ua.user_id IS NOT NULL
80 OR il_orgu_positions.core_position = 1";
81 $database = $GLOBALS['DIC']->database();
82 $st = $database->query($q);
83
84 $positions = array();
85
86 while ($data = $database->fetchAssoc($st)) {
87 $position = new self();
88 $position->buildFromArray($data);
89 $positions[] = $position;
90 }
91
92 return $positions;
93 }
static flush($class_name)
$GLOBALS['loaded']
Global hash that tracks already loaded includes.

References $data, $GLOBALS, and arObjectCache\flush().

+ Here is the call graph for this function:

◆ getActiveForPosition()

static ilOrgUnitPosition::getActiveForPosition (   $orgu_ref_id)
static
Parameters
int$orgu_ref_id
Returns
\ilOrgUnitPosition[] array of Positions (all core-positions and all positions which have already UserAssignments at this place)

Definition at line 102 of file class.ilOrgUnitPosition.php.

103 {
104 arObjectCache::flush(self::class);
105 $q = "SELECT DISTINCT il_orgu_positions.id, il_orgu_positions.*
106 FROM il_orgu_positions
107 LEFT JOIN il_orgu_ua ON il_orgu_positions.id = il_orgu_ua.position_id AND il_orgu_ua.orgu_id = %s
108 WHERE il_orgu_ua.user_id IS NOT NULL
109 OR core_position = 1";
110 $database = $GLOBALS['DIC']->database();
111 $st = $database->queryF($q, array( 'integer' ), array( $orgu_ref_id ));
112
113 $positions = array();
114
115 while ($data = $database->fetchAssoc($st)) {
116 $position = new self();
117 $position->buildFromArray($data);
118 $positions[] = $position;
119 }
120
121 return $positions;
122 }

References $data, $GLOBALS, and arObjectCache\flush().

Referenced by ilOrgUnitUserAssignmentGUI\index().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthorities()

ilOrgUnitPosition::getAuthorities ( )
Returns
\ilOrgUnitAuthority[]

Definition at line 324 of file class.ilOrgUnitPosition.php.

References $authorities.

Referenced by storeAuthorities().

+ Here is the caller graph for this function:

◆ getAuthoritiesAsArray()

ilOrgUnitPosition::getAuthoritiesAsArray ( )
Returns
array

Definition at line 198 of file class.ilOrgUnitPosition.php.

199 {
200 $return = array();
201 foreach ($this->authorities as $authority) {
202 $return[] = $authority->__toArray();
203 }
204
205 return $return;
206 }

References $authority.

◆ getCoreIdentifier()

ilOrgUnitPosition::getCoreIdentifier ( )
Returns
int

Definition at line 342 of file class.ilOrgUnitPosition.php.

References $core_identifier.

◆ getCorePosition()

static ilOrgUnitPosition::getCorePosition (   $core_identifier)
static
Parameters
$core_identifier
Returns
\ilOrgUnitPosition

@noinspection PhpIncompatibleReturnTypeInspection

Definition at line 40 of file class.ilOrgUnitPosition.php.

41 {
43 return ilOrgUnitPosition::where([ 'core_identifier' => $core_identifier ])->first();
44 }

References $core_identifier, and ActiveRecord\where().

Referenced by ilOrgUnitPositionGUI\assign(), and getCorePositionId().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getCorePositionId()

static ilOrgUnitPosition::getCorePositionId (   $core_identifier)
static
Parameters
$core_identifier
Returns
int

Definition at line 52 of file class.ilOrgUnitPosition.php.

53 {
55 }
static getCorePosition($core_identifier)

References $core_identifier, and getCorePosition().

Referenced by ilObjOrgUnit\assignUsersToEmployeeRole(), ilObjOrgUnit\assignUsersToSuperiorRole(), ilObjOrgUnit\deassignUserFromEmployeeRole(), and ilObjOrgUnit\deassignUserFromSuperiorRole().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDependentAuthorities()

ilOrgUnitPosition::getDependentAuthorities ( )
Returns
array it's own authorities and also all which use this position

Definition at line 221 of file class.ilOrgUnitPosition.php.

222 {
223 $dependent = ilOrgUnitAuthority::where(array( ilOrgUnitAuthority::FIELD_OVER => $this->getId() ))
224 ->get();
225
226 $arr = $dependent + $this->authorities;
227
228 return (array) $arr;
229 }

References $authorities, ilOrgUnitAuthority\FIELD_OVER, getId(), and ActiveRecord\where().

Referenced by deleteWithAllDependencies().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDescription()

ilOrgUnitPosition::getDescription ( )
Returns
string

Definition at line 288 of file class.ilOrgUnitPosition.php.

References $description.

◆ getId()

ilOrgUnitPosition::getId ( )

◆ getTitle()

ilOrgUnitPosition::getTitle ( )
Returns
string

Definition at line 270 of file class.ilOrgUnitPosition.php.

271 {
272 return $this->title;
273 }

References $title.

Referenced by ilOrgUnitUserAssignmentTableGUI\__construct(), and __toString().

+ Here is the caller graph for this function:

◆ isCorePosition()

ilOrgUnitPosition::isCorePosition ( )
Returns
bool

Definition at line 306 of file class.ilOrgUnitPosition.php.

References $core_position.

Referenced by delete().

+ Here is the caller graph for this function:

◆ returnDbTableName()

static ilOrgUnitPosition::returnDbTableName ( )
static
Returns
string

Reimplemented from ActiveRecord.

Definition at line 17 of file class.ilOrgUnitPosition.php.

18 {
19 return "il_orgu_positions";
20 }

◆ setAuthorities()

ilOrgUnitPosition::setAuthorities (   $authorities)
Parameters
\ilOrgUnitAuthority[]$authorities

Definition at line 333 of file class.ilOrgUnitPosition.php.

334 {
335 $this->authorities = $authorities;
336 }

References $authorities.

◆ setCoreIdentifier()

ilOrgUnitPosition::setCoreIdentifier (   $core_identifier)
Parameters
int$core_identifier

Definition at line 351 of file class.ilOrgUnitPosition.php.

352 {
353 $this->core_identifier = $core_identifier;
354 }

References $core_identifier.

◆ setCorePosition()

ilOrgUnitPosition::setCorePosition (   $core_position)
Parameters
bool$core_position

Definition at line 315 of file class.ilOrgUnitPosition.php.

316 {
317 $this->core_position = $core_position;
318 }

References $core_position.

◆ setDescription()

ilOrgUnitPosition::setDescription (   $description)
Parameters
string$description

Definition at line 297 of file class.ilOrgUnitPosition.php.

298 {
299 $this->description = $description;
300 }

References $description.

◆ setId()

ilOrgUnitPosition::setId (   $id)
Parameters
int$id

Definition at line 261 of file class.ilOrgUnitPosition.php.

262 {
263 $this->id = $id;
264 }

References $id.

◆ setTitle()

ilOrgUnitPosition::setTitle (   $title)
Parameters
string$title

Definition at line 279 of file class.ilOrgUnitPosition.php.

280 {
281 $this->title = $title;
282 }

References $title.

◆ storeAuthorities()

ilOrgUnitPosition::storeAuthorities ( )
private

Definition at line 357 of file class.ilOrgUnitPosition.php.

358 {
359 $ids = [];
360 foreach ($this->getAuthorities() as $authority) {
361 $authority->setPositionId($this->getId());
362 if ($authority->getId()) {
363 $authority->update();
364 } else {
365 $authority->create();
366 }
367 $ids[] = $authority->getId();
368 }
369 if (count($ids) > 0) {
370 foreach (ilOrgUnitAuthority::where(array(
371 'id' => $ids,
372 'position_id' => $this->getId(),
373 ), array( 'id' => 'NOT IN', 'position_id' => '=' ))->get() as $authority) {
374 $authority->delete();
375 }
376 }
377
378 if (count($ids) === 0) {
379 foreach (ilOrgUnitAuthority::where(array(
380 'position_id' => $this->getId(),
381 ))->get() as $authority) {
382 $authority->delete();
383 }
384 }
385 }

References $authority, ActiveRecord\count(), getAuthorities(), getId(), and ActiveRecord\where().

Referenced by create(), and update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilOrgUnitPosition::update ( )

Reimplemented from ActiveRecord.

Definition at line 181 of file class.ilOrgUnitPosition.php.

182 {
184 $this->storeAuthorities();
185 }
update($pash, $contents, Config $config)

References storeAuthorities(), and League\Flysystem\Adapter\Polyfill\update().

+ Here is the call graph for this function:

Field Documentation

◆ $authorities

ilOrgUnitPosition::$authorities = array()
protected

◆ $core_identifier

ilOrgUnitPosition::$core_identifier = 0
protected

◆ $core_position

ilOrgUnitPosition::$core_position = false
protected

Definition at line 159 of file class.ilOrgUnitPosition.php.

Referenced by isCorePosition(), and setCorePosition().

◆ $description

ilOrgUnitPosition::$description = ""
protected

Definition at line 151 of file class.ilOrgUnitPosition.php.

Referenced by getDescription(), and setDescription().

◆ $id

ilOrgUnitPosition::$id = 0
protected

Definition at line 135 of file class.ilOrgUnitPosition.php.

Referenced by getId(), and setId().

◆ $title

ilOrgUnitPosition::$title = ""
protected

Definition at line 143 of file class.ilOrgUnitPosition.php.

Referenced by getTitle(), and setTitle().

◆ CORE_POSITION_EMPLOYEE

const ilOrgUnitPosition::CORE_POSITION_EMPLOYEE = 1

◆ CORE_POSITION_SUPERIOR

const ilOrgUnitPosition::CORE_POSITION_SUPERIOR = 2

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