52 public function __construct(
int $a_id = 0,
bool $a_call_by_reference =
true)
56 $this->ilDb =
$DIC->database();
59 $this->rbacreview =
$DIC->rbac()->review();
60 $this->rbacadmin =
$DIC->rbac()->admin();
63 $this->positionRepo =
$dic[
"repo.Positions"];
64 $this->assignmentRepo =
$dic[
"repo.UserAssignments"];
69 public function read(): void
73 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
74 $set = $this->ilDb->query($sql);
75 if ($this->ilDb->numRows($set)) {
76 $rec = $this->ilDb->fetchObject($set);
83 $id = parent::create();
84 $this->ilDb->insert(self::TABLE_NAME, array(
86 'orgu_id' => array(
'integer', $this->
getId()),
94 $sql =
'SELECT * FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote(
98 $set = $this->ilDb->query($sql);
99 if ($this->ilDb->numRows($set)) {
100 $this->ilDb->update(self::TABLE_NAME, array(
103 'orgu_id' => array(
'integer', $this->
getId()),
106 $this->ilDb->insert(self::TABLE_NAME, array(
108 'orgu_id' => array(
'integer', $this->
getId()),
138 $this->orgu_type_id = $a_id;
147 public function getAdvancedMDValues(
int $a_record_id = 0): array
153 if (is_array($this->amd_data)) {
155 return $this->amd_data[$a_record_id] ?? array();
164 $this->amd_data[$record_id] = $amd_values->getADTGroup()->getElements();
167 return $this->amd_data[$a_record_id] ?? array();
180 if (is_array(self::$icons_cache)) {
185 $sql =
'SELECT orgu_id, ot.id AS type_id FROM orgu_data
186 INNER JOIN orgu_types AS ot ON (ot.id = orgu_data.orgu_type_id)
187 WHERE ot.icon IS NOT NULL';
191 $irss =
$DIC[
'resource_storage'];
194 if (
$type && $icon_id = $irss->manage()->find(
$type->getIconIdentifier())) {
195 $icons_cache[$row->orgu_id] = $irss->consume()->src($icon_id)->getSrc();
219 if (self::$root_ref_id === 0 || self::$root_id === 0) {
222 $q =
"SELECT o.obj_id, r.ref_id FROM object_data o
223 INNER JOIN object_reference r ON r.obj_id = o.obj_id
224 WHERE title = " .
$ilDb->
quote(
'__OrgUnitAdministration',
'text') .
"";
227 self::$root_id = (
int)
$res[
"obj_id"];
228 self::$root_ref_id = (
int)
$res[
"ref_id"];
238 $position_id = $this->positionRepo
243 $assignment = $this->assignmentRepo->get(
$user_id, $position_id, $this->
getRefId());
247 'obj_id' => $this->
getId(),
249 'position_id' => $position_id,
261 $position_id = $this->positionRepo
266 $assignment = $this->assignmentRepo->get(
$user_id, $position_id, $this->
getRefId());
270 'obj_id' => $this->
getId(),
272 'position_id' => $position_id,
280 $position_id = $this->positionRepo
284 $assignment = $this->assignmentRepo->find(
$user_id, $position_id, $this->
getRefId());
286 $this->assignmentRepo->delete($assignment);
291 'obj_id' => $this->
getId(),
293 'position_id' => $position_id,
300 $position_id = $this->positionRepo
304 $assignment = $this->assignmentRepo->find(
$user_id, $position_id, $this->
getRefId());
306 $this->assignmentRepo->delete($assignment);
311 'obj_id' => $this->
getId(),
313 'position_id' => $position_id,
323 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
324 if (!in_array($role_id, $arrLocalRoles)) {
328 $return = $this->rbacadmin->assignUser($role_id,
$user_id);
332 'obj_id' => $this->
getId(),
334 'role_id' => $role_id,
346 $arrLocalRoles = $this->rbacreview->getLocalRoles($this->
getRefId());
347 if (!in_array($role_id, $arrLocalRoles)) {
351 $return = $this->rbacadmin->deassignUser($role_id,
$user_id);
355 'obj_id' => $this->
getId(),
357 'role_id' => $role_id,
364 public static function _exists(
int $id,
bool $isReference =
false, ?
string $type =
"orgu"): bool
366 return parent::_exists(
$id, $isReference,
"orgu");
374 return $this->
lng->txt(
"objs_orgu");
384 return $this->
lng->txt(
"obj_orgu_description");
386 return parent::getLongDescription();
395 $q =
"SELECT * FROM object_translation WHERE obj_id = " . $this->ilDb->quote(
398 ) .
" ORDER BY lang_default DESC";
399 $r = $this->db->query(
$q);
403 $data[$row->lang_code] = array(
404 "title" => $row->title,
405 "desc" => $row->description,
406 "lang" => $row->lang_code,
407 'default' => $row->lang_default,
411 $translations =
$data;
413 if (!count($translations)) {
415 $translations[$this->
lng->getDefaultLanguage()] = array(
418 "lang" => $this->
lng->getDefaultLanguage(),
422 return $translations;
430 public function delete():
bool
433 if (!parent::delete()) {
440 $query =
"DELETE FROM object_translation WHERE obj_id = " . $this->ilDb->quote($this->
getId(),
'integer');
441 $this->ilDb->manipulate($query);
445 'obj_id' => $this->
getId(),
448 $sql =
'DELETE FROM ' . self::TABLE_NAME .
' WHERE orgu_id = ' . $this->ilDb->quote($this->
getId(),
'integer');
449 $this->ilDb->manipulate($sql);
457 $assignments = $this->assignmentRepo->getByOrgUnit($this->
getRefId());
458 foreach ($assignments as $assignment) {
459 $this->assignmentRepo->delete($assignment);
470 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->ilDb->quote($this->
getId(),
'integer');
471 $res = $this->ilDb->manipulate($query);
480 $query =
"DELETE FROM object_translation WHERE obj_id= " . $this->quote(
483 ) .
" AND lang_code = "
484 . $this->quote($a_lang,
'text');
485 $this->ilDb->manipulate($query);
491 public function addTranslation(
string $a_title,
string $a_desc,
string $a_lang,
string $a_lang_default): void
493 if (empty($a_title)) {
494 $a_title =
"NO TITLE";
497 $query =
"INSERT INTO object_translation " .
"(obj_id,title,description,lang_code,lang_default) " .
"VALUES " .
"("
498 . $this->ilDb->quote($this->
getId(),
'integer') .
"," . $this->ilDb->quote(
501 ) .
"," . $this->ilDb->quote($a_desc,
'text') .
","
502 . $this->ilDb->quote($a_lang,
'text') .
"," . $this->ilDb->quote($a_lang_default,
'integer') .
")";
503 $this->ilDb->manipulate($query);
512 $a_title =
"NO TITLE";
515 $query =
"UPDATE object_translation SET ";
517 $query .=
" title = " . $this->ilDb->quote(
$title,
'text');
520 $query .=
", description = " . $this->ilDb->quote(
$desc,
'text') .
" ";
523 $query .=
", lang_default = " . $this->ilDb->quote($lang_default,
'integer') .
" ";
525 $query .=
" WHERE obj_id = " . $this->ilDb->quote(
528 ) .
" AND lang_code = " . $this->ilDb->quote(
$lang,
'text');
529 $this->ilDb->manipulate($query);
535 ilOrgUnitPathStorage::writePathByRefId($this->
getRefId());
537 throw new \LogicException(
'No ref_id on OrgU with id ' . $this->
getId(), 1);
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static saveObjRecSelection(int $a_obj_id, string $a_sub_type="", ?array $a_records=null, bool $a_delete_before=true)
Save repository object record selection.
static getInstancesForObjectId(int $a_obj_id, ?string $a_obj_type=null, string $a_sub_type="-", int $a_sub_id=0)
raise(string $a_component, string $a_event, array $a_parameter=[])
Raise an event.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array $icons_cache
Cache storing OrgUnit objects that have OrgUnit types with custom icons assigned.
assignUserToLocalRole(int $role_id, int $user_id)
Assign a given user to a given local role.
array $amd_data
Advanced Metadata Values for this OrgUnit.
static loadRootOrgRefIdAndId()
addTranslation(string $a_title, string $a_desc, string $a_lang, string $a_lang_default)
add a new translation to current OrgUnit
ilAppEventHandler $ilAppEventHandler
ilOrgUnitPositionDBRepository $positionRepo
deassignUserFromLocalRole(int $role_id, int $user_id)
Deassign a given user to a given local role.
deleteTranslation(string $a_lang)
remove translations of current OrgUnit
removeTranslations()
remove all Translations of current OrgUnit
create()
note: title, description and type should be set when this function is called
deassignUserFromEmployeeRole(int $user_id)
static getIconsCache()
Returns an array that maps from OrgUnit object IDs to its icon defined by the assigned OrgUnit type.
__construct(int $a_id=0, bool $a_call_by_reference=true)
getLongDescription()
get object long description (stored in object_description)
ilOrgUnitUserAssignmentDBRepository $assignmentRepo
deassignUserFromSuperiorRole(int $user_id)
static _exists(int $id, bool $isReference=false, ?string $type="orgu")
checks if an object exists in object_data
setOrgUnitTypeId(int $a_id)
updateTranslation(string $title, string $desc, string $lang, string $lang_default)
update a translation to current OrgUnit
int $orgu_type_id
ID of assigned OrgUnit type.
assignUsersToSuperiorRole(array $user_ids)
Adds the user ids to the position superior.
assignUsersToEmployeeRole(array $user_ids)
Adds the user ids to the position employee.
static _updateUserFolderAssignment(int $a_old_id, int $a_new_id)
Update user folder assignment Typically called after deleting a category with local user accounts.
Class ilOrgUnitPathStorage.
const CORE_POSITION_EMPLOYEE
const CORE_POSITION_SUPERIOR
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(int $a_id)
Get instance of an ilOrgUnitType object Returns object from cache or from database,...
Class ilRbacAdmin Core functions for role based access control.
class ilRbacReview Contains Review functions of core Rbac.
fetchObject(ilDBStatement $query_result)
quote($value, string $type)
query(string $query)
Run a (read-only) Query on the database.
fetchAssoc(ilDBStatement $statement)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc