53 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
57 $this->ilDb = $DIC->database();
60 $this->rbacreview = $DIC->rbac()->review();
61 $this->rbacadmin = $DIC->rbac()->admin();
64 $this->positionRepo =
$dic[
"repo.Positions"];
65 $this->assignmentRepo =
$dic[
"repo.UserAssignments"];
70 public function read():
void 74 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
75 $set = $this->ilDb->query($sql);
76 if ($this->ilDb->numRows($set)) {
77 $rec = $this->ilDb->fetchObject($set);
84 $id = parent::create();
85 $this->ilDb->insert(self::TABLE_NAME, array(
87 'orgu_id' => array(
'integer', $this->
getId()),
95 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote(
99 $set = $this->ilDb->query($sql);
100 if ($this->ilDb->numRows($set)) {
101 $this->ilDb->update(self::TABLE_NAME, array(
104 'orgu_id' => array(
'integer', $this->
getId()),
107 $this->ilDb->insert(self::TABLE_NAME, array(
109 'orgu_id' => array(
'integer', $this->
getId()),
139 $this->orgu_type_id = $a_id;
148 public function getAdvancedMDValues(
int $a_record_id = 0): array
154 if (is_array($this->amd_data)) {
156 return $this->amd_data[$a_record_id] ?? array();
165 $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
168 return $this->amd_data[$a_record_id] ?? array();
181 if (is_array(self::$icons_cache)) {
182 return self::$icons_cache;
185 $ilDb = $DIC->database();
186 $sql =
'SELECT orgu_id, ot.id AS type_id FROM orgu_data 187 INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id) 188 WHERE ot.icon IS NOT NULL';
189 $set = $ilDb->
query($sql);
190 $icons_cache = array();
192 $irss = $DIC[
'resource_storage'];
195 if (
$type && $icon_id = $irss->manage()->find(
$type->getIconIdentifier())) {
196 $icons_cache[$row->orgu_id] = $irss->consume()->src($icon_id)->getSrc();
206 self::loadRootOrgRefIdAndId();
208 return self::$root_ref_id;
213 self::loadRootOrgRefIdAndId();
215 return self::$root_id;
220 if (self::$root_ref_id === 0 || self::$root_id === 0) {
222 $ilDb = $DIC[
'ilDB'];
223 $q =
"SELECT o.obj_id, r.ref_id FROM object_data o 224 INNER JOIN object_reference r ON r.obj_id = o.obj_id 225 WHERE title = " . $ilDb->
quote(
'__OrgUnitAdministration',
'text') .
"";
228 self::$root_id = (
int)
$res[
"obj_id"];
229 self::$root_ref_id = (
int)
$res[
"ref_id"];
239 $position_id = $this->positionRepo
244 $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getRefId());
248 'obj_id' => $this->
getId(),
250 'position_id' => $position_id,
251 'user_id' => $user_id
262 $position_id = $this->positionRepo
267 $assignment = $this->assignmentRepo->get($user_id, $position_id, $this->
getRefId());
271 'obj_id' => $this->
getId(),
273 'position_id' => $position_id,
274 'user_id' => $user_id
281 $position_id = $this->positionRepo
285 $assignment = $this->assignmentRepo->find($user_id, $position_id, $this->
getRefId());
287 $this->assignmentRepo->delete($assignment);
292 'obj_id' => $this->
getId(),
294 'position_id' => $position_id,
295 'user_id' => $user_id,
301 $position_id = $this->positionRepo
305 $assignment = $this->assignmentRepo->find($user_id, $position_id, $this->
getRefId());
307 $this->assignmentRepo->delete($assignment);
312 'obj_id' => $this->
getId(),
314 'position_id' => $position_id,
315 'user_id' => $user_id,
324 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
325 if (!in_array($role_id, $arrLocalRoles)) {
329 $return = $this->rbacadmin->assignUser($role_id, $user_id);
333 'obj_id' => $this->
getId(),
335 'role_id' => $role_id,
336 'user_id' => $user_id,
347 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
348 if (!in_array($role_id, $arrLocalRoles)) {
352 $return = $this->rbacadmin->deassignUser($role_id, $user_id);
356 'obj_id' => $this->
getId(),
358 'role_id' => $role_id,
359 'user_id' => $user_id,
365 public static function _exists(
int $id,
bool $isReference =
false, ?
string $type =
"orgu"): bool
367 return parent::_exists($id, $isReference,
"orgu");
375 return $this->
lng->txt(
"objs_orgu");
385 return $this->
lng->txt(
"obj_orgu_description");
387 return parent::getLongDescription();
396 $q =
"SELECT * FROM object_translation WHERE obj_id = " . $this->ilDb->quote(
399 ) .
" ORDER BY lang_default DESC";
400 $r = $this->db->query(
$q);
404 $data[$row->lang_code] = array(
405 "title" => $row->title,
406 "desc" => $row->description,
407 "lang" => $row->lang_code,
408 'default' => $row->lang_default,
412 $translations =
$data;
414 if (!count($translations)) {
416 $translations[$this->
lng->getDefaultLanguage()] = array(
419 "lang" => $this->
lng->getDefaultLanguage(),
423 return $translations;
431 public function delete():
bool 434 if (!parent::delete()) {
441 $query =
"DELETE FROM object_translation WHERE obj_id = " . $this->ilDb->quote($this->
getId(),
'integer');
442 $this->ilDb->manipulate($query);
446 'obj_id' => $this->
getId(),
449 $sql =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
450 $this->ilDb->manipulate($sql);
458 $assignments = $this->assignmentRepo->getByOrgUnit($this->
getRefId());
459 foreach ($assignments as $assignment) {
460 $this->assignmentRepo->delete($assignment);
471 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->ilDb->quote($this->
getId(),
'integer');
472 $res = $this->ilDb->manipulate($query);
481 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->quote(
484 ) .
" AND lang_code = " 485 . $this->quote($a_lang,
'text');
486 $this->ilDb->manipulate($query);
492 public function addTranslation(
string $a_title,
string $a_desc,
string $a_lang,
string $a_lang_default): void
494 if (empty($a_title)) {
495 $a_title =
"NO TITLE";
498 $query =
"INSERT INTO object_translation " .
"(obj_id,title,description,lang_code,lang_default) " .
"VALUES " .
"(" 499 . $this->ilDb->quote($this->
getId(),
'integer') .
"," . $this->ilDb->quote(
502 ) .
"," . $this->ilDb->quote($a_desc,
'text') .
"," 503 . $this->ilDb->quote($a_lang,
'text') .
"," . $this->ilDb->quote($a_lang_default,
'integer') .
")";
504 $this->ilDb->manipulate($query);
513 $a_title =
"NO TITLE";
516 $query =
"UPDATE object_translation SET ";
518 $query .=
" title = " . $this->ilDb->quote($title,
'text');
521 $query .=
", description = " . $this->ilDb->quote($desc,
'text') .
" ";
524 $query .=
", lang_default = " . $this->ilDb->quote($lang_default,
'integer') .
" ";
526 $query .=
" WHERE obj_id = " . $this->ilDb->quote(
529 ) .
" AND lang_code = " . $this->ilDb->quote($lang,
'text');
530 $this->ilDb->manipulate($query);
536 ilOrgUnitPathStorage::writePathByRefId($this->
getRefId());
538 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)
setOrgUnitTypeId(int $a_id)
static getIconsCache()
Returns an array that maps from OrgUnit object IDs to its icon defined by the assigned OrgUnit type...
ilOrgUnitPositionDBRepository $positionRepo
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.
Class ilOrgUnitPathStorage.
__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 loadRootOrgRefIdAndId()
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
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.
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.
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
__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.