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.

References getTitle().

213  {
214  return $this->getTitle();
215  }
+ Here is the call graph for this function:

◆ afterObjectLoad()

ilOrgUnitPosition::afterObjectLoad ( )

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

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

175  {
176  $this->authorities = ilOrgUnitAuthority::where(array( ilOrgUnitAuthority::POSITION_ID => $this->getId() ))
177  ->get();
178  }
static where($where, $operator=null)
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ create()

ilOrgUnitPosition::create ( )

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

References storeAuthorities().

189  {
190  parent::create();
191  $this->storeAuthorities();
192  }
+ Here is the call graph for this function:

◆ delete()

ilOrgUnitPosition::delete ( )
Exceptions

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

References isCorePosition().

61  {
62  if ($this->isCorePosition()) {
63  throw new ilException('Cannot delete Core-Position');
64  }
65  parent::delete();
66  }
+ 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.

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

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
+ Here is the call graph for this function:

◆ get()

static ilOrgUnitPosition::get ( )
static

Override for correct on return value.

Returns
[]

PhpIncompatibleReturnTypeInspection

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

Referenced by ilOrgUnitPermissionTableGUI\collectData().

29  {
31  return parent::get();
32  }
+ Here is the caller graph for this function:

◆ getActive()

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

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

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

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  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
static flush($class_name)
+ Here is the call graph for this function:

◆ getActiveForPosition()

static ilOrgUnitPosition::getActiveForPosition (   $orgu_ref_id)
static
Parameters
int$orgu_ref_id
Returns
[] 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.

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

Referenced by ilOrgUnitUserAssignmentGUI\index().

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  }
$GLOBALS['loaded']
Global hash that tracks already loaded includes.
Create styles array
The data for the language used.
static flush($class_name)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAuthorities()

ilOrgUnitPosition::getAuthorities ( )
Returns
[]

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

References $authorities.

Referenced by storeAuthorities().

325  {
326  return $this->authorities;
327  }
+ Here is the caller graph for this function:

◆ getAuthoritiesAsArray()

ilOrgUnitPosition::getAuthoritiesAsArray ( )
Returns
array

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

References $authority, and array.

199  {
200  $return = array();
201  foreach ($this->authorities as $authority) {
202  $return[] = $authority->__toArray();
203  }
204 
205  return $return;
206  }
Create styles array
The data for the language used.
$authority

◆ getCoreIdentifier()

ilOrgUnitPosition::getCoreIdentifier ( )
Returns
int

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

References $core_identifier.

343  {
344  return $this->core_identifier;
345  }

◆ getCorePosition()

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

PhpIncompatibleReturnTypeInspection

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

References $core_identifier, and ActiveRecord\where().

Referenced by ilOrgUnitPositionGUI\assign().

41  {
43  return ilOrgUnitPosition::where([ 'core_identifier' => $core_identifier ])->first();
44  }
static where($where, $operator=null)
+ 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.

References $core_identifier.

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

53  {
54  return self::getCorePosition($core_identifier)->getId();
55  }
+ 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.

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

Referenced by deleteWithAllDependencies().

222  {
224  ->get();
225 
226  $arr = $dependent + $this->authorities;
227 
228  return (array) $arr;
229  }
static where($where, $operator=null)
Create styles array
The data for the language used.
+ 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.

289  {
290  return $this->description;
291  }

◆ getId()

ilOrgUnitPosition::getId ( )

◆ getTitle()

ilOrgUnitPosition::getTitle ( )
Returns
string

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

References $title.

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

271  {
272  return $this->title;
273  }
+ 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().

307  {
308  return $this->core_position;
309  }
+ Here is the caller graph for this function:

◆ returnDbTableName()

static ilOrgUnitPosition::returnDbTableName ( )
static
Returns
string

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

18  {
19  return "il_orgu_positions";
20  }

◆ setAuthorities()

ilOrgUnitPosition::setAuthorities (   $authorities)
Parameters

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

References $authorities.

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

◆ setCoreIdentifier()

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

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

References $core_identifier.

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

◆ setCorePosition()

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

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

References $core_position.

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

◆ setDescription()

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

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

References $description.

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

◆ setId()

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

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

References $id.

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

◆ setTitle()

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

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

References $title.

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

◆ storeAuthorities()

ilOrgUnitPosition::storeAuthorities ( )
private

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

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

Referenced by create(), and update().

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) {
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) {
380  'position_id' => $this->getId(),
381  ))->get() as $authority) {
382  $authority->delete();
383  }
384  }
385  }
static where($where, $operator=null)
Create styles array
The data for the language used.
$authority
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

ilOrgUnitPosition::update ( )

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

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

182  {
183  parent::update();
184  $this->storeAuthorities();
185  }
update($pash, $contents, Config $config)
+ 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: