50 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
54 $this->ilDb = $DIC->database();
57 $this->rbacreview = $DIC->rbac()->review();
58 $this->rbacadmin = $DIC->rbac()->admin();
63 public function read():
void 67 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
68 $set = $this->ilDb->query($sql);
69 if ($this->ilDb->numRows($set)) {
70 $rec = $this->ilDb->fetchObject($set);
77 $id = parent::create();
78 $this->ilDb->insert(self::TABLE_NAME, array(
80 'orgu_id' => array(
'integer', $this->
getId()),
88 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote(
92 $set = $this->ilDb->query($sql);
93 if ($this->ilDb->numRows($set)) {
94 $this->ilDb->update(self::TABLE_NAME, array(
97 'orgu_id' => array(
'integer', $this->
getId()),
100 $this->ilDb->insert(self::TABLE_NAME, array(
102 'orgu_id' => array(
'integer', $this->
getId()),
132 $this->orgu_type_id = $a_id;
141 public function getAdvancedMDValues(
int $a_record_id = 0): array
147 if (is_array($this->amd_data)) {
149 return $this->amd_data[$a_record_id] ?? array();
158 $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
161 return $this->amd_data[$a_record_id] ?? array();
174 if (is_array(self::$icons_cache)) {
175 return self::$icons_cache;
178 $ilDb = $DIC->database();
179 $sql =
'SELECT orgu_id, ot.id AS type_id FROM orgu_data 180 INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) 181 WHERE ot.icon IS NOT NULL';
182 $set = $ilDb->
query($sql);
183 $icons_cache = array();
186 if (
$type && is_file(
$type->getIconPath(
true))) {
187 $icons_cache[$row->orgu_id] =
$type->getIconPath(
true);
197 self::loadRootOrgRefIdAndId();
199 return self::$root_ref_id;
204 self::loadRootOrgRefIdAndId();
206 return self::$root_id;
211 if (self::$root_ref_id === 0 || self::$root_id === 0) {
213 $ilDb = $DIC[
'ilDB'];
214 $q =
"SELECT o.obj_id, r.ref_id FROM object_data o 215 INNER JOIN object_reference r ON r.obj_id = o.obj_id 216 WHERE title = " . $ilDb->
quote(
'__OrgUnitAdministration',
'text') .
"";
217 $set = $ilDb->
query($q);
219 self::$root_id = (
int)
$res[
"obj_id"];
220 self::$root_ref_id = (
int)
$res[
"ref_id"];
232 foreach ($user_ids as $user_id) {
237 'obj_id' => $this->
getId(),
239 'position_id' => $position_id,
240 'user_id' => $user_id,
253 foreach ($user_ids as $user_id) {
258 'obj_id' => $this->
getId(),
260 'position_id' => $position_id,
261 'user_id' => $user_id,
273 'obj_id' => $this->
getId(),
275 'position_id' => $position_id,
276 'user_id' => $user_id,
287 'obj_id' => $this->
getId(),
289 'position_id' => $position_id,
290 'user_id' => $user_id,
299 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
300 if (!in_array($role_id, $arrLocalRoles)) {
304 $return = $this->rbacadmin->assignUser($role_id, $user_id);
308 'obj_id' => $this->
getId(),
310 'role_id' => $role_id,
311 'user_id' => $user_id,
322 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
323 if (!in_array($role_id, $arrLocalRoles)) {
327 $return = $this->rbacadmin->deassignUser($role_id, $user_id);
331 'obj_id' => $this->
getId(),
333 'role_id' => $role_id,
334 'user_id' => $user_id,
340 public static function _exists(
int $id,
bool $isReference =
false, ?
string $type =
"orgu"): bool
342 return parent::_exists($id, $isReference,
"orgu");
347 if (parent::getTitle() !==
"__OrgUnitAdministration") {
348 return parent::getTitle();
350 return $this->
lng->txt(
"objs_orgu");
359 if (parent::getTitle() ===
"__OrgUnitAdministration") {
360 return $this->
lng->txt(
"obj_orgu_description");
362 return parent::getLongDescription();
371 $q =
"SELECT * FROM object_translation WHERE obj_id = " . $this->ilDb->quote(
374 ) .
" ORDER BY lang_default DESC";
375 $r = $this->db->query($q);
379 $data[$row->lang_code] = array(
380 "title" => $row->title,
381 "desc" => $row->description,
382 "lang" => $row->lang_code,
383 'default' => $row->lang_default,
387 $translations =
$data;
389 if (!count($translations)) {
391 $translations[$this->
lng->getDefaultLanguage()] = array(
394 "lang" => $this->
lng->getDefaultLanguage(),
398 return $translations;
406 public function delete():
bool 409 if (!parent::delete()) {
416 $query =
"DELETE FROM object_translation WHERE obj_id = " . $this->ilDb->quote($this->
getId(),
'integer');
417 $this->ilDb->manipulate(
$query);
421 'obj_id' => $this->
getId(),
424 $sql =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
425 $this->ilDb->manipulate($sql);
436 foreach ($assignments as $assignment) {
437 $assignment->delete();
448 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->ilDb->quote($this->
getId(),
'integer');
458 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->quote(
461 ) .
" AND lang_code = " 462 . $this->quote($a_lang,
'text');
463 $this->ilDb->manipulate(
$query);
469 public function addTranslation(
string $a_title,
string $a_desc,
string $a_lang,
string $a_lang_default): void
471 if (empty($a_title)) {
472 $a_title =
"NO TITLE";
475 $query =
"INSERT INTO object_translation " .
"(obj_id,title,description,lang_code,lang_default) " .
"VALUES " .
"(" 476 . $this->ilDb->quote($this->
getId(),
'integer') .
"," . $this->ilDb->quote(
479 ) .
"," . $this->ilDb->quote($a_desc,
'text') .
"," 480 . $this->ilDb->quote($a_lang,
'text') .
"," . $this->ilDb->quote($a_lang_default,
'integer') .
")";
481 $this->ilDb->manipulate(
$query);
490 $a_title =
"NO TITLE";
493 $query =
"UPDATE object_translation SET ";
495 $query .=
" title = " . $this->ilDb->quote($title,
'text');
498 $query .=
", description = " . $this->ilDb->quote($desc,
'text') .
" ";
501 $query .=
", lang_default = " . $this->ilDb->quote($lang_default,
'integer') .
" ";
503 $query .=
" WHERE obj_id = " . $this->ilDb->quote(
506 ) .
" AND lang_code = " . $this->ilDb->quote($lang,
'text');
507 $this->ilDb->manipulate(
$query);
513 ilOrgUnitPathStorage::writePathByRefId($this->
getRefId());
515 throw new \LogicException(
'No ref_id on OrgU with id ' . $this->
getId(), 1);
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
static findOrCreateAssignment(int $user_id, int $position_id, int $orgu_id)
setOrgUnitTypeId(int $a_id)
static getIconsCache()
Returns an array that maps from OrgUnit object IDs to its icon defined by the assigned OrgUnit type...
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
add a new translation to current OrgUnit
removeTranslations()
remove all Translations of current OrgUnit
static array $icons_cache
Cache storing OrgUnit objects that have OrgUnit types with custom icons assigned. ...
assignUsersToSuperiorRole(array $user_ids)
Adds the user ids to the position superior.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _updateUserFolderAssignment(int $a_old_id, int $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts...
fetchAssoc(ilDBStatement $statement)
const CORE_POSITION_EMPLOYEE
updateTranslation(string $title, string $desc, string $lang, string $lang_default)
update a translation to current OrgUnit
array $amd_data
Advanced Metadata Values for this OrgUnit.
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
__construct(int $a_id=0, bool $a_call_by_reference=true)
quote($value, string $type)
ilAppEventHandler $ilAppEventHandler
static _exists(int $id, bool $isReference=false, ?string $type="orgu")
static where($where, $operator=null)
static loadRootOrgRefIdAndId()
getLongDescription()
get object long description (stored in object_description)
deassignUserFromLocalRole(int $role_id, int $user_id)
Deassign a given user to a given local role.
static getCorePositionId(int $core_identifier)
fetchObject(ilDBStatement $query_result)
query(string $query)
Run a (read-only) Query on the database.
deleteTranslation(string $a_lang)
remove translations of current OrgUnit
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
assignUserToLocalRole(int $role_id, int $user_id)
Assign a given user to a given local role.
int $orgu_type_id
ID of assigned OrgUnit type.
__construct(Container $dic, ilPlugin $plugin)
const CORE_POSITION_SUPERIOR
Class ilRbacAdmin Core functions for role based access control.
deassignUserFromEmployeeRole(int $user_id)
deassignUserFromSuperiorRole(int $user_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
assignUsersToEmployeeRole(array $user_ids)
Adds the user ids to the position employee.
static getInstance(int $a_id)
Get instance of an ilOrgUnitType object Returns object from cache or from database, returns null if no object was found.