19 declare(strict_types=1);
    89         protected int $id = 0,
    90         protected bool $referenced = 
true    95         $this->
ilias = $DIC[
"ilias"];
    96         $this->obj_definition = $DIC[
"objDefinition"];
    97         $this->db = $DIC[
"ilDB"];
    98         $this->log = $DIC[
"ilLog"];
   100         $this->error = $DIC[
"ilErr"];
   101         $this->tree = $DIC[
"tree"];
   102         $this->app_event_handler = $DIC[
"ilAppEventHandler"];
   103         $this->lom_services = $DIC->learningObjectMetadata();
   104         $this->object_dic = ilObjectDIC::dic();
   106         $this->call_by_reference = $this->referenced;
   108         if (isset($DIC[
"lng"])) {
   109             $this->
lng = $DIC[
"lng"];
   112         if (isset($DIC[
"ilUser"])) {
   113             $this->
user = $DIC[
"ilUser"];
   116         if (isset($DIC[
"rbacadmin"])) {
   117             $this->rbac_admin = $DIC[
"rbacadmin"];
   120         if (isset($DIC[
"rbacreview"])) {
   121             $this->rbac_review = $DIC[
"rbacreview"];
   125             $this->referenced = 
false;          
   128         if ($this->referenced) {
   141         if ($this->object_properties === null) {
   142             $this->object_properties = $this->object_dic[
'object_properties_agregator']->getFor($this->
id, $this->type);
   152         $this->object_properties = null;
   161         return ($this->call_by_reference) ? true : $this->referenced;
   170         $this->process_auto_reating = 
true;
   177             $ilUser = $DIC[
"ilUser"];
   181         if ($this->referenced) {
   182             if (!isset($this->ref_id)) {
   183                 $message = 
"ilObject::read(): No ref_id given! (" . $this->type . 
")";
   184                 $this->error->raiseError($message, $this->error->WARNING);
   189                 "SELECT od.obj_id, od.type, od.title, od.description, od.owner, od.create_date," . PHP_EOL
   190                 . 
"od.last_update, od.import_id, ore.ref_id, ore.obj_id, ore.deleted, ore.deleted_by" . PHP_EOL
   191                 . 
"FROM " . self::TABLE_OBJECT_DATA . 
" od" . PHP_EOL
   192                 . 
"JOIN object_reference ore ON od.obj_id = ore.obj_id" . PHP_EOL
   193                 . 
"WHERE ore.ref_id = " . $this->db->quote($this->ref_id, 
"integer") . PHP_EOL
   196             $result = $this->db->query($sql);
   199             if ($this->db->numRows($result) === 0) {
   201                     "ilObject::read(): Object with ref_id %s not found! (%s)",
   205                 $this->error->raiseError($message, $this->error->WARNING);
   208             if (!isset($this->
id)) {
   209                 $message = sprintf(
"ilObject::read(): No obj_id given! (%s)", $this->type);
   210                 $this->error->raiseError($message, $this->error->WARNING);
   214                 "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
   215                 . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   216                 . 
"WHERE obj_id = " . $this->db->quote($this->
id, 
"integer") . PHP_EOL
   218             $result = $this->db->query($sql);
   220             if ($this->db->numRows($result) === 0) {
   221                 $message = sprintf(
"ilObject::read(): Object with obj_id: %s (%s) not found!", $this->
id, $this->type);
   225         $obj = $this->db->fetchAssoc($result);
   227         $this->
id = (
int) $obj[
"obj_id"];
   230         if ($this->type != $obj[
"type"] && $obj[
"type"] != 
"xxx") {
   232                 "ilObject::read(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
   238             $this->log->write($message);
   242         $this->type = (string) $obj[
"type"];
   243         $this->title = (string) $obj[
"title"];
   245         $this->untranslatedTitle = (string) $obj[
"title"];
   248         $this->desc = (string) $obj[
"description"];
   249         $this->owner = (
int) $obj[
"owner"];
   250         $this->create_date = (string) $obj[
"create_date"];
   251         $this->last_update = (string) $obj[
"last_update"];
   252         $this->import_id = (string) $obj[
"import_id"];
   254         if ($this->obj_definition->isRBACObject($this->getType())) {
   256                 "SELECT obj_id, description" . PHP_EOL
   257                 . 
"FROM object_description" . PHP_EOL
   258                 . 
"WHERE obj_id = " . $this->db->quote($this->
id, 
'integer') . PHP_EOL
   261             $res = $this->db->query($sql);
   263             $this->long_desc = 
'';
   265                 if (($row->description ?? 
'') !== 
'') {
   272         $translation_type = $this->obj_definition->getTranslationType($this->type);
   274         if ($translation_type == 
"sys") {
   275             $this->title = $this->
lng->txt(
"obj_" . $this->type);
   277         } elseif ($translation_type == 
"db") {
   279                 "SELECT title, description" . PHP_EOL
   280                 . 
"FROM object_translation" . PHP_EOL
   281                 . 
"WHERE obj_id = " . $this->db->quote($this->
id, 
'integer') . PHP_EOL
   282                 . 
"AND lang_code = " . $this->db->quote($ilUser->getCurrentLanguage(), 
'text') . PHP_EOL
   284             $r = $this->db->query($sql);
   287                 $this->title = (string) $row->title;
   288                 $this->setDescription((
string) $row->description);
   292         $this->object_properties = null;
   308         $this->referenced = 
true;
   313         return $this->ref_id ?? 0;
   321     final public function setType(
string $type): void
   350     final public function setTitle(
string $title): void
   356         $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
   358         $this->title = $property->getTitle();
   372             ->getPropertyTitleAndDescription()->withDescription($description);
   374         $this->object_properties = $this->
getObjectProperties()->withPropertyTitleAndDescription($property);
   377         $this->desc = $property->getDescription();
   378         $this->long_desc = $property->getLongDescription();
   386         if ($this->long_desc !== 
'') {
   390         if ($this->desc !== 
'') {
   413         $db = $DIC->database();
   416             "SELECT obj_id" . PHP_EOL
   417             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   418             . 
"WHERE import_id = " . $db->
quote($import_id, 
"text") . PHP_EOL
   419             . 
"ORDER BY create_date DESC" . PHP_EOL
   421         $result = $db->
query($sql);
   423         if ($db->
numRows($result) == 0) {
   429         return (
int) $row->obj_id;
   439             $property_is_online = $property_is_online->withOffline();
   442         $this->object_properties = $this->
getObjectProperties()->withPropertyIsOnline($property_is_online);
   452         return $this->obj_definition->supportsOfflineHandling($this->
getType());
   459         $db = $DIC->database();
   462             "SELECT import_id" . PHP_EOL
   463             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   464             . 
"WHERE obj_id = " . $db->
quote($obj_id, 
"integer") . PHP_EOL
   469             return (
string) $row->import_id;
   493         $lng = $DIC->language();
   496         if ($owner_id != -1) {
   502         $own_name = $lng->
txt(
"unknown");
   503         if (is_object($owner)) {
   504             $own_name = $owner->getFullname();
   512         $this->owner = $usr_id;
   538         $user = $DIC[
"ilUser"];
   540         if (!isset($this->type)) {
   541             $message = sprintf(
"%s::create(): No object type given!", get_class($this));
   542             $this->error->raiseError($message, $this->error->WARNING);
   545         $this->log->write(
"ilObject::create(), start");
   551         } elseif (is_object($user)) {
   552             $owner = $user->
getId();
   555         $this->
id = $this->db->nextId(self::TABLE_OBJECT_DATA);
   557             "obj_id" => [
"integer", $this->
getId()],
   558             "type" => [
"text", $this->
getType()],
   559             "title" => [
"text", $this->
getTitle()],
   561             "owner" => [
"integer", 
$owner],
   562             "create_date" => [
"date", $this->db->now()],
   563             "last_update" => [
"date", $this->db->now()],
   567         $this->db->insert(self::TABLE_OBJECT_DATA, $values);
   568         $this->object_properties = null;
   571         if ($this->obj_definition->isRBACObject($this->getType())) {
   576             $this->db->insert(
'object_description', $values);
   584         if ($this->obj_definition->isOrgUnitPermissionType($this->type)) {
   591             "SELECT last_update, create_date" . PHP_EOL
   592             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   593             . 
"WHERE obj_id = " . $this->db->quote($this->
id, 
"integer") . PHP_EOL
   595         $obj_set = $this->db->query($sql);
   596         $obj_rec = $this->db->fetchAssoc($obj_set);
   597         $this->last_update = $obj_rec[
"last_update"];
   598         $this->create_date = $obj_rec[
"create_date"];
   606                 "ilObject::create(), finished, obj_id: %s, type: %s, title: %s",
   613         $this->app_event_handler->raise(
   614             'components/ILIAS/ILIASObject',
   617                 'obj_id' => $this->
id,
   618                 'obj_type' => $this->type
   629         $this->app_event_handler->raise(
   630             'components/ILIAS/ILIASObject',
   633                 'obj_id' => $this->
getId(),
   634                 'obj_type' => $this->
getType(),
   654             $this->app_event_handler->raise(
   655                 'components/ILIAS/ILIASObject',
   657                 [
'obj_id' => $this->
getId(),
   658                       'obj_type' => $this->
getType(),
   664             if ($element == 
'General') {
   665                 $paths = $this->lom_services->paths();
   666                 $reader = $this->lom_services->read(
   670                     $paths->custom()->withNextStep(
'general')->get()
   673                 $this->
setTitle($reader->firstData($paths->title())->value());
   674                 $this->
setDescription($reader->firstData($paths->descriptions())->value());
   695             $ilUser = $DIC[
"ilUser"];
   697             $this->lom_services->derive()->fromBasicProperties(
   700                 $ilUser->getPref(
'language')
   719             $paths = $this->lom_services->paths();
   721             $manipulator = $this->lom_services->manipulate($this->
getId(), 0, $this->
getType())
   722                 ->prepareCreateOrUpdate($paths->title(), $this->
getTitle());
   725                 $manipulator = $manipulator->prepareCreateOrUpdate(
   726                     $paths->firstDescription(),
   730                 $manipulator = $manipulator->prepareDelete($paths->firstDescription());
   733             $manipulator->execute();
   750             $this->lom_services->deleteAll($this->
getId(), 0, $this->
getType());
   770             "owner" => [
"integer", $this->
getOwner()],
   771             "last_update" => [
"date", $this->db->now()]
   775             "obj_id" => [
"integer", $this->
getId()]
   778         $this->db->update(self::TABLE_OBJECT_DATA, $values, $where);
   787         $db = $DIC->database();
   791             "SELECT obj_id" . PHP_EOL
   792             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   793             . 
"WHERE import_id = " . $db->
quote($import_id, 
"text") . PHP_EOL
   794             . 
"ORDER BY create_date DESC" . PHP_EOL
   797         $result = $db->
query($sql);
   800             return (
int) $row[
"obj_id"];
   813         $db = $DIC->database();
   816             "SELECT ref_id" . PHP_EOL
   817             . 
"FROM object_reference" . PHP_EOL
   818             . 
"WHERE obj_id = " . $db->
quote($id, 
'integer') . PHP_EOL
   821         $result = $db->
query($sql);
   825             $ref[(
int) $row[
"ref_id"]] = (
int) $row[
"ref_id"];
   834         return (
string) $DIC[
"ilObjDataCache"]->lookupTitle($obj_id);
   843         return $DIC[
'ilObjDataCache']->lookupOfflineStatus($obj_id);
   852         return (
int) $DIC[
"ilObjDataCache"]->lookupOwner($obj_id);
   858     final public static function _getIdsForTitle(
string $title, 
string $type = 
'', 
bool $partial_match = 
false): array
   861         $db = $DIC->database();
   863         $where = 
"title = " . $db->
quote($title, 
"text");
   864         if ($partial_match) {
   865             $where = $db->
like(
"title", 
"text", 
'%' . $title . 
'%');
   869             "SELECT obj_id" . PHP_EOL
   870             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   871             . 
"WHERE " . $where . PHP_EOL
   875             $sql .= 
" AND type = " . $db->
quote($type, 
"text");
   878         $result = $db->
query($sql);
   882             $object_ids[] = (
int) $row[
'obj_id'];
   891         return (
string) $DIC[
"ilObjDataCache"]->lookupDescription($obj_id);
   898         $last_update = $DIC[
"ilObjDataCache"]->lookupLastUpdate($obj_id);
   910         $db = $DIC->database();
   913             "SELECT MAX(last_update) as last_update" . PHP_EOL
   914             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
   915             . 
"WHERE " . $db->
in(
"obj_id", $obj_ids, 
false, 
"integer") . PHP_EOL
   918         $result = $db->
query($sql);
   921         return (
string) $row[
"last_update"];
   927         return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
   933         $db = $DIC->database();
   936             "deleted" => [
"date", $db->
now()],
   937             "deleted_by" => [
"integer", $deleted_by]
   941             "ref_id" => [
"integer", 
$ref_id]
   944         $db->
update(
"object_reference", $values, $where);
   953         $db = $DIC->database();
   956             "UPDATE object_reference" . PHP_EOL
   957             . 
"SET deleted = " . $db->
now() . 
", " . PHP_EOL
   958             . 
"deleted_by = " . $db->
quote($user_id, 
"integer") . PHP_EOL
   959             . 
"WHERE " . $db->
in(
"ref_id", $ref_ids, 
false, 
"integer") . PHP_EOL;
   967         $db = $DIC->database();
   970             "deleted" => [
"timestamp", null],
   971             "deleted_by" => [
"integer", 0]
   975             "ref_id" => [
"integer", 
$ref_id]
   978         $db->
update(
"object_reference", $values, $where);
   984         $db = $DIC->database();
   987             "SELECT deleted" . PHP_EOL
   988             . 
"FROM object_reference" . PHP_EOL
   989             . 
"WHERE ref_id = " . $db->
quote($ref_id, 
"integer") . PHP_EOL
   991         $result = $db->
query($sql);
   994         return $row[
"deleted"] ?? null;
  1000     final public static function _writeTitle(
int $obj_id, 
string $title): void
  1003         $db = $DIC->database();
  1006             "title" => [
"text", 
$title],
  1007             "last_update" => [
"date", $db->
now()]
  1011             "obj_id" => [
"integer", $obj_id]
  1014         $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
  1024         $db = $DIC->database();
  1025         $obj_definition = $DIC[
"objDefinition"];
  1030             "description" => [
"text", 
$desc],
  1031             "last_update" => [
"date", $db->
now()]
  1035             "obj_id" => [
"integer", $obj_id]
  1038         $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
  1044                 "SELECT obj_id, description" . PHP_EOL
  1045                 . 
"FROM object_description" . PHP_EOL
  1046                 . 
"WHERE obj_id = " . $db->
quote($obj_id, 
'integer') . PHP_EOL
  1048             $result = $db->
query($sql);
  1050             if ($result->numRows()) {
  1052                     "description" => [
"clob", 
$desc]
  1054                 $db->
update(
"object_description", $values, $where);
  1057                     "description" => [
"clob",
$desc],
  1058                     "obj_id" => [
"integer",$obj_id]
  1060                 $db->
insert(
"object_description", $values);
  1071         $db = $DIC->database();
  1075             "last_update" => [
"date", $db->
now()]
  1079             "obj_id" => [
"integer", $obj_id]
  1082         $db->
update(self::TABLE_OBJECT_DATA, $values, $where);
  1090             return $DIC[
"ilObjDataCache"]->lookupType($DIC[
"ilObjDataCache"]->lookupObjId($id));
  1093         return $DIC[
"ilObjDataCache"]->lookupType($id);
  1099         return $DIC->repositoryTree()->isDeleted($ref_id);
  1108         foreach ($ref_ids as $ref_id) {
  1120         return $DIC[
"ilObjDataCache"]->lookupObjId($ref_id);
  1133         $db = $DIC->database();
  1136             "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
  1137             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  1138             . 
"WHERE type = " . $db->
quote($type, 
"text") . PHP_EOL
  1140         $result = $db->
query($sql);
  1145                 $objects[$row[
"title"] . 
"." . $row[
"obj_id"]] = [
  1146                     "id" => $row[
"obj_id"],
  1147                     "type" => $row[
"type"],
  1148                     "title" => $row[
"title"],
  1149                     "description" => $row[
"description"]
  1165         $this->tree->insertNode($this->
getRefId(), $parent_ref_id);
  1168         $log_entry = sprintf(
  1169             "ilObject::putInTree(), parent_ref: %s, ref_id: %s, obj_id: %s, type: %s, title: %s",
  1177         $this->log->write($log_entry);
  1179         $this->app_event_handler->raise(
  1180             'components/ILIAS/ILIASObject',
  1184                 'obj_type' => $this->
getType(),
  1185                 'obj_id' => $this->
getId(),
  1186                 'parent_ref_id' => $parent_ref_id
  1204         $parent_roles = $this->rbac_review->getParentRoleIds($parent_ref_id);
  1205         foreach ($parent_roles as $parent_role) {
  1209             $operations = $this->rbac_review->getOperationsOfRole(
  1210                 (
int) $parent_role[
'obj_id'],
  1212                 (
int) $parent_role[
'parent']
  1214             $this->rbac_admin->grantPermission(
  1215                 (
int) $parent_role[
'obj_id'],
  1228         if (!isset($this->
id)) {
  1229             $message = 
"ilObject::createNewReference(): No obj_id given!";
  1230             $this->error->raiseError($message, $this->error->WARNING);
  1233         $next_id = $this->db->nextId(
'object_reference');
  1236             "ref_id" => [
"integer", $next_id],
  1237             "obj_id" => [
"integer", $this->
getId()]
  1240         $this->db->insert(
"object_reference", $values);
  1242         $this->ref_id = $next_id;
  1243         $this->referenced = 
true;
  1250         if (!isset($this->
id)) {
  1251             $message = 
"ilObject::countReferences(): No obj_id given!";
  1252             $this->error->raiseError($message, $this->error->WARNING);
  1256             "SELECT COUNT(ref_id) num" . PHP_EOL
  1257             . 
"FROM object_reference" . PHP_EOL
  1258             . 
"WHERE obj_id = " . $this->db->quote($this->
id, 
'integer') . PHP_EOL
  1261         $res = $this->db->query($sql);
  1262         $row = $this->db->fetchObject(
$res);
  1264         return (
int) $row->num;
  1275     public function delete(): 
bool  1278         $rbac_admin = $DIC[
"rbacadmin"];
  1285             if ($this->type != $type) {
  1286                 $log_entry = sprintf(
  1287                     "ilObject::delete(): Type mismatch. Object with obj_id: %s was instantiated by type '%s'. DB type is: %s",
  1293                 $this->log->write($log_entry);
  1294                 $this->error->raiseError(
  1295                     sprintf(
"ilObject::delete(): Type mismatch. (%s/%s)", $this->type, $this->
id),
  1296                     $this->error->WARNING
  1300             $this->app_event_handler->raise(
'components/ILIAS/ILIASObject', 
'beforeDeletion', [
'object' => $this]);
  1303                 "DELETE FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  1304                 . 
"WHERE obj_id = " . $this->db->quote($this->
getId(), 
"integer") . PHP_EOL
  1306             $this->db->manipulate($sql);
  1309                 "DELETE FROM object_description" . PHP_EOL
  1310                 . 
"WHERE obj_id = " . $this->db->quote($this->
getId(), 
"integer") . PHP_EOL
  1312             $this->db->manipulate($sql);
  1316                     "ilObject::delete(), deleted object, obj_id: %s, type: %s, title: %s",
  1328             $news_item->deleteNewsOfContext($this->
getId(), $this->
getType());
  1335                 "DELETE FROM dav_property" . PHP_EOL
  1336                 . 
"WHERE obj_id = " . $this->db->quote($this->
getId(), 
'integer') . PHP_EOL
  1338             $this->db->manipulate($sql);
  1349                     "ilObject::delete(), object not deleted, number of references: %s, obj_id: %s, type: %s, title: %s",
  1359         if ($this->referenced) {
  1362             $this->app_event_handler->raise(
'components/ILIAS/ILIASObject', 
'deleteReference', [
'ref_id' => $this->
getRefId()]);
  1365                 "DELETE FROM object_reference" . PHP_EOL
  1366                 . 
"WHERE ref_id = " . $this->db->quote($this->
getRefId(), 
'integer') . PHP_EOL
  1368             $this->db->manipulate($sql);
  1372                     "ilObject::delete(), reference deleted, ref_id: %s, obj_id: %s, type: %s, title: %s",
  1393         if ($this->referenced) {
  1418                 $action->setRefId($this->
getRefId());
  1434     public static function _exists(
int $id, 
bool $reference = 
false, ?
string $type = null): bool
  1437         $db = $DIC->database();
  1441                 "SELECT object_data.obj_id" . PHP_EOL
  1442                 . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  1443                 . 
"LEFT JOIN object_reference ON object_reference.obj_id = object_data.obj_id " . PHP_EOL
  1444                 . 
"WHERE object_reference.ref_id= " . $db->
quote($id, 
"integer") . PHP_EOL
  1448                 "SELECT object_data.obj_id" . PHP_EOL
  1449                 . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  1450                 . 
"WHERE obj_id = " . $db->
quote($id, 
"integer") . PHP_EOL
  1455             $sql .= 
" AND object_data.type = " . $db->
quote($type, 
"text") . PHP_EOL;
  1458         $result = $db->
query($sql);
  1460         return (
bool) $db->
numRows($result);
  1475         $db = $DIC->database();
  1477         $order = 
" ORDER BY title";
  1481             $where = 
"WHERE type = " . $db->
quote($obj_type, 
"text");
  1483             if (!is_null($owner)) {
  1484                 $where .= 
" AND owner = " . $db->
quote($owner, 
"integer");
  1489             "SELECT obj_id, type, title, description, owner, create_date, last_update, import_id, offline" . PHP_EOL
  1490             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  1494         $result = $db->
query($sql);
  1497         if ($db->
numRows($result) > 0) {
  1499                 $row[
"desc"] = $row[
"description"];
  1500                 $arr[$row[
"obj_id"]] = $row;
  1516         bool $show_path = 
true  1520         $db = $DIC->database();
  1521         $lng = $DIC->language();
  1522         $obj_definition = $DIC[
"objDefinition"];
  1525             "SELECT obj_data.title obj_title, path_data.title path_title, child" . PHP_EOL
  1526             . 
"FROM tree " . PHP_EOL
  1527             . 
"JOIN object_reference obj_ref ON child = obj_ref.ref_id " . PHP_EOL
  1528             . 
"JOIN object_data obj_data ON obj_ref.obj_id = obj_data.obj_id " . PHP_EOL
  1529             . 
"JOIN object_reference path_ref ON parent = path_ref.ref_id " . PHP_EOL
  1530             . 
"JOIN object_data path_data ON path_ref.obj_id = path_data.obj_id " . PHP_EOL
  1531             . 
"WHERE " . $db->
in(
"child", $ref_ids, 
false, 
"integer") . PHP_EOL
  1532             . 
"ORDER BY obj_data.title" . PHP_EOL
  1536         if (!$obj_definition->
isPlugin($new_type)) {
  1537             $options[0] = $lng->
txt(
'obj_' . $new_type . 
'_select');
  1543             if (strlen($title = $row->obj_title) > 40) {
  1544                 $title = substr($title, 0, 40) . 
'...';
  1548                 if (strlen(
$path = $row->path_title) > 40) {
  1552                 $title .= 
' (' . $lng->
txt(
'path') . 
': ' . 
$path . 
')';
  1555             $options[$row->child] = 
$title;
  1557         return $options ?: [];
  1563     public function cloneObject(
int $target_id, 
int $copy_id = 0, 
bool $omit_tree = 
false): ?
ilObject  1568         $ilUser = $DIC[
"ilUser"];
  1569         $rbac_admin = $DIC[
"rbacadmin"];
  1571         $class_name = (
'ilObj' . $this->obj_definition->getClassName($this->
getType()));
  1576         $this->obj_log->debug($title);
  1577         $this->obj_log->debug(
"isTreeCopyDisabled: " . $options->isTreeCopyDisabled());
  1578         $this->obj_log->debug(
"omit_tree: " . $omit_tree);
  1579         if (!$options->isTreeCopyDisabled() && !$omit_tree) {
  1580             $title_with_suffix = $this->
appendCopyInfo($target_id, $copy_id);
  1581             $title = mb_strlen($title_with_suffix) < self::TITLE_LENGTH ? $title_with_suffix : 
$title;
  1582             $this->obj_log->debug(
"title incl. copy info: " . $title);
  1587         $new_obj = 
new $class_name(0, 
false);
  1588         $new_obj->setOwner($ilUser->getId());
  1589         $new_obj->title = 
$title;
  1592         $new_obj->type = $this->
getType();
  1595         $new_obj->create(
true);
  1598             if ($options->isRootNode($this->getRefId())) {
  1599                 $new_obj->getObjectProperties()->storePropertyIsOnline(
  1600                     $new_obj->getObjectProperties()->getPropertyIsOnline()->withOffline()
  1603                 $new_obj->getObjectProperties()->storePropertyIsOnline(
  1609         if (!$options->isTreeCopyDisabled() && !$omit_tree) {
  1611             $new_obj->createReference();
  1612             $new_obj->putInTree($target_id);
  1613             $new_obj->setPermissions($target_id);
  1628             "INSERT INTO dav_property" . PHP_EOL
  1629             . 
"(obj_id, node_id, ns, name, value)" . PHP_EOL
  1630             . 
"SELECT " . $this->db->quote($new_obj->getId(), 
'integer') . 
", node_id, ns, name, value " . PHP_EOL
  1631             . 
"FROM dav_property" . PHP_EOL
  1632             . 
"WHERE obj_id = " . $this->db->quote($this->getId(), 
'integer') . PHP_EOL
  1634         $this->db->manipulate($sql);
  1637         $customIconFactory = $DIC[
'object.customicons.factory'];
  1638         $customIcon = $customIconFactory->getByObjId($this->
getId(), $this->
getType());
  1639         $customIcon->copy($new_obj->getId());
  1641         $new_obj->getObjectProperties()->storePropertyTileImage(
  1642             $new_obj->getObjectProperties()->getPropertyTileImage()->withTileImage(
  1644                     ->getTileImage()->cloneFor($new_obj->getId())
  1648         $this->app_event_handler->raise(
  1649             'components/ILIAS/ILIASObject',
  1652                 'object' => $new_obj,
  1653                 'cloned_from_object' => $this,
  1666         if (!$cp_options->isRootNode($this->getRefId())) {
  1672         $other_children_of_same_type = $this->tree->getChildsByType($target_id, $this->type);
  1674         if ($obj_translations->getLanguages() === []) {
  1676                 fn(array $child): 
string => $child[
'title'],
  1677                 $other_children_of_same_type
  1681                 $this->
lng->txt(
'copy_of_suffix'),
  1682                 $this->
lng->txt(
'copy_n_of_suffix'),
  1693         array $other_children_of_same_type
  1698             $other_children_of_same_type
  1701         $title_translations_per_lang = array_reduce(
  1702             $nodes_translations,
  1707         $new_languages = [];
  1708         $installed_langs = $this->
lng->getInstalledLanguages();
  1709         foreach ($obj_translations->
getLanguages() as $language) {
  1710             $lang_code = $language->getLanguageCode();
  1711             $suffix_lang = $lang_code;
  1712             if (!in_array($suffix_lang, $installed_langs)) {
  1713                 $suffix_lang = $this->
lng->getDefaultLanguage();
  1715             $language->setTitle(
  1717                     $this->
lng->txtlng(
'common', 
'copy_of_suffix', $suffix_lang),
  1718                     $this->
lng->txtlng(
'common', 
'copy_n_of_suffix', $suffix_lang),
  1719                     $language->getTitle(),
  1720                     $title_translations_per_lang[$lang_code] ?? []
  1723             $new_languages[$lang_code] = $language;
  1733             $langs = $nt->getLanguages();
  1734             foreach ($langs as $lang) {
  1735                 if (!array_key_exists($lang->getLanguageCode(), $npl)) {
  1736                     $npl[$lang->getLanguageCode()] = [];
  1738                 $npl[$lang->getLanguageCode()][] = $lang->getTitle();
  1745         string $copy_suffix,
  1746         string $copy_n_suffix,
  1748         array $other_titles_for_lang
  1751         $title_with_suffix = 
"{$title_without_suffix} {$copy_suffix}";
  1752         if ($other_titles_for_lang === []
  1753             || $this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
  1754             return $title_with_suffix;
  1757         for ($i = 2;
true;$i++) {
  1758             $title_with_suffix = $title_without_suffix . 
' ' . sprintf($copy_n_suffix, $i);
  1759             if ($this->
isTitleUnique($title_with_suffix, $other_titles_for_lang)) {
  1760                 return $title_with_suffix;
  1767         foreach ($nodes as $node) {
  1768             if (($title === $node)) {
  1783         $regexp_for_suffix = preg_replace(
  1784             '/([\^$.\[\]|()?*+{}])/',
  1789         $regexp_for_file_name = 
'/' . preg_replace(
'/%1\\\\\$s/', 
'([0-9]+)', $regexp_for_suffix) . 
'$/';
  1791         if (preg_match($regexp_for_file_name, $title, $matches)) {
  1792             return substr($title, 0, -strlen($matches[0]));
  1795         if (str_ends_with($title, 
" {$copy_suffix}")) {
  1822             $obj = $factory->getInstanceByRefId($target_id, 
false);
  1824                 $obj->applyDidacticTemplate($tpl_id);
  1835         $this->lom_services->derive()
  1837                            ->forObject($target_obj->
getId(), 0, $target_obj->
getType());
  1841     public static function getIconForReference(
  1846         bool $offline = 
false  1850         $icon_factory = $DIC[
'ui.factory']->symbol()->icon();
  1851         $irss = $DIC[
'resource_storage'];
  1853         if ($obj_id == 
"" && $type == 
"") {
  1867             $property_icon = ilObjectDIC::dic()[
'additional_properties_repository']->getFor($obj_id)->getPropertyIcon();
  1868             $custom_icon = $property_icon->getCustomIcon();
  1869             if ($custom_icon?->exists()) {
  1870                 return $custom_icon->getFullPath() . 
'?tmp=' . filemtime($custom_icon->getFullPath());
  1873             $file_type_specific_icon = $property_icon->getObjectTypeSpecificIcon($obj_id, $icon_factory, $irss);
  1874             if ($file_type_specific_icon !== null) {
  1875                 return $file_type_specific_icon->getIconPath();
  1880                 $path = $dtpl_icon_factory->getIconPathForReference($ref_id);
  1882                 $path = $dtpl_icon_factory->getIconPathForObject($obj_id);
  1890             return self::getIconForType($type);
  1892         return "./images/standard/icon_{$type}.svg";
  1898         $objDefinition = $DIC[
'objDefinition'];
  1899         if (!$objDefinition->isPluginTypeName($type)) {
  1903         if ($objDefinition->getClassName($type) !== 
'') {
  1904             $class_name = 
"il{$objDefinition->getClassName($type)}Plugin";
  1905             $location = $objDefinition->getLocation($type);
  1906             if (is_file(
$location . 
"/class.{$class_name}.php")) {
  1907                 return call_user_func([$class_name, 
'_getIcon'], $type);
  1923         string $size = 
"big",
  1925         bool $offline = 
false  1927         return self::getIconForReference(0, $obj_id, $size, $type, $offline);
  1932         if ($this->process_auto_reating
  1934             && method_exists($this, 
"setRating")
  1936             $this->setRating(
true);
  1946         if (!$ref_id || !in_array($type, [
"file", 
"lm", 
"wiki"])) {
  1958         if (!$parent_ref_id) {
  1961         if ($parent_ref_id) {
  1984         $objDefinition = $DIC[
"objDefinition"];
  1985         $tree = $DIC->repositoryTree();
  1991         $deps[
"del_ids"][$obj_id] = $obj_id;
  1993         if (!$objDefinition->isPluginTypeName($type)) {
  1994             $class_name = 
"ilObj" . $objDefinition->getClassName($type);
  1995             $odeps = call_user_func([$class_name, 
"getDeletionDependencies"], $obj_id);
  1996             if (is_array($odeps)) {
  1997                 foreach ($odeps as 
$id => $message) {
  1998                     $deps[
"dep"][
$id][$obj_id][] = $message;
  2010             foreach ($deps[
"del_ids"] as $obj_id) {
  2011                 unset($deps[
"dep"][$obj_id]);
  2013             $deps = $deps[
"dep"];
  2028         $db = $DIC->database();
  2031             "SELECT obj_id, description" . PHP_EOL
  2032             . 
"FROM object_description" . PHP_EOL
  2033             . 
"WHERE " . $db->
in(
"obj_id", $obj_ids, 
false, 
"integer") . PHP_EOL
  2035         $result = $db->
query($sql);
  2039             $all[$row[
"obj_id"]] = $row[
"description"];
  2048         $db = $DIC->database();
  2049         $obj_definition = $DIC[
"objDefinition"];
  2055             "SELECT od.obj_id, od.type, od.title" . PHP_EOL
  2056             . 
"FROM object_data od" . PHP_EOL
  2057             . 
"JOIN object_reference oref ON(oref.obj_id = od.obj_id)" . PHP_EOL
  2058             . 
"JOIN tree ON (tree.child = oref.ref_id)" . PHP_EOL
  2062             $sql .= 
"WHERE od.owner = " . $db->
quote($user_id, 
"integer") . PHP_EOL;
  2065                 "LEFT JOIN usr_data ud ON (ud.usr_id = od.owner)" . PHP_EOL
  2066                 . 
"WHERE (od.owner < " . $db->
quote(1, 
"integer") . PHP_EOL
  2067                 . 
"OR od.owner IS NULL OR ud.login IS NULL)" . PHP_EOL
  2068                 . 
"AND od.owner <> " . $db->
quote(-1, 
"integer") . PHP_EOL
  2073             "AND " . $db->
in(
"od.type", $types, 
false, 
"text") . PHP_EOL
  2074             . 
"AND tree.tree > " . $db->
quote(0, 
"integer") . PHP_EOL
  2081             $all[$row[
"type"]][$row[
"obj_id"]] = $row[
"title"];
  2093         $db = $DIC->database();
  2095         if (!in_array($type, [
"catr", 
"crsr", 
"sess", 
"grpr", 
"prgr"])) {
  2100         $missing_obj_ids = [];
  2101         foreach ($obj_title_map as $obj_id => $title) {
  2102             if (!trim($title)) {
  2103                 $missing_obj_ids[] = $obj_id;
  2107         if (!
sizeof($missing_obj_ids)) {
  2117                     "SELECT oref.obj_id, od.type, od.title" . PHP_EOL
  2118                     . 
"FROM object_data od" . PHP_EOL
  2119                     . 
"JOIN container_reference oref ON (od.obj_id = oref.target_obj_id)" . PHP_EOL
  2120                     . 
"AND " . $db->
in(
"oref.obj_id", $missing_obj_ids, 
false, 
"integer") . PHP_EOL
  2122                 $result = $db->
query($sql);
  2125                     $obj_title_map[$row[
"obj_id"]] = $row[
"title"];
  2129                 foreach ($missing_obj_ids as $obj_id) {
  2131                     $obj_title_map[$obj_id] = $sess->getFirstAppointment()->appointmentToString();
  2140         $db = $DIC->database();
  2143             "SELECT create_date" . PHP_EOL
  2144             . 
"FROM " . self::TABLE_OBJECT_DATA . PHP_EOL
  2145             . 
"WHERE obj_id = " . $db->
quote($obj_id, 
"integer") . PHP_EOL
  2147         $result = $db->
query($sql);
  2149         return $rec[
"create_date"];
  2162         return $this->obj_definition->getSubObjects($this->type, $filter);
  2169             $ilDB = $DIC->database();
  2173             "SELECT obj_id FROM object_data" . PHP_EOL
  2174             . 
"WHERE type = 'typ'" . PHP_EOL
  2175             . 
"AND title = " . 
$ilDB->quote($type, 
'text') . PHP_EOL
  2184         return (
int) $row[
'obj_id'] ?? null;
 
beforeMDUpdateListener(string $a_element)
 
static deleteAllEntries(int $ref_id)
Delete all db entries for ref id. 
 
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id. 
 
applyDidacticTemplate(int $tpl_id)
 
static assignTemplate(int $a_ref_id, int $a_obj_id, int $a_tpl_id)
 
static _writeTitle(int $obj_id, string $title)
write title to db (static) 
 
static formatDate(ilDateTime $date, bool $a_skip_day=false, bool $a_include_wd=false, bool $include_seconds=false, ilObjUser $user=null,)
 
static setDeletedDates(array $ref_ids, int $user_id)
 
static _setDeletedDate(int $ref_id, int $deleted_by)
 
supportsOfflineHandling()
 
numRows(ilDBStatement $statement)
 
insert(string $table_name, array $values)
 
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item. 
 
static getLogger(string $a_component_id)
Get component logger. 
 
static _writeImportId(int $obj_id, string $import_id)
write import id to db (static) 
 
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
 
static deleteByObjId(int $a_obj_id)
 
bool $process_auto_reating
 
fetchAssoc(ilDBStatement $statement)
 
like(string $column, string $type, string $value="?", bool $case_insensitive=true)
Generate a like subquery. 
 
$location
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
Interface Observer  Contains several chained tasks and infos about them. 
 
static collectDeletionDependencies(array &$deps, int $ref_id, int $obj_id, string $type, int $depth=0)
Collect deletion dependencies. 
 
getChilds(int $a_node_id, string $a_order="", string $a_direction="ASC")
get child nodes of given node 
 
static cloneDependencies(int $a_src_ref_id, int $a_target_ref_id, int $a_copy_id)
 
static _getAllReferences(int $id)
get all reference ids for object ID 
 
update(string $table_name, array $values, array $where)
$where MUST contain existing columns only. 
 
withReferences()
determines whether objects are referenced or not (got ref ids or not) 
 
static _hasUntrashedReference(int $obj_id)
checks whether an object has at least one reference that is not in trash 
 
setImportId(string $import_id)
 
isRBACObject(string $obj_name)
get RBAC status by type returns true if object type is a RBAC object type 
 
static delete(int $ref_id)
 
static _lookupOwner(int $obj_id)
Lookup owner user ID for object ID. 
 
static _getObjectsDataForType(string $type, bool $omit_trash=false)
get all objects of a certain type 
 
quote($value, string $type)
 
revokePermission(int $a_ref_id, int $a_rol_id=0, bool $a_keep_protected=true)
Revokes permissions of an object of one role. 
 
getCreateDate()
Get create date in YYYY-MM-DD HH-MM-SS format. 
 
getCallbackForTitlesPerLanguageTransformation()
 
static _getObjectsByType(string $obj_type="", int $owner=null)
 
static getDeletionDependencies(int $obj_id)
Get deletion dependencies. 
 
appendNumberOfCopiesToTitle(string $copy_suffix, string $copy_n_suffix, string $title, array $other_titles_for_lang)
 
setPermissions(int $parent_ref_id)
 
isTitleUnique(string $title, array $nodes)
 
setLimit(int $limit, int $offset=0)
 
appendCopyInfoToTranslations(ilObjectTranslation $obj_translations, array $other_children_of_same_type)
 
static _getIdForImportId(string $import_id)
 
static _lookupContainerSetting(int $a_id, string $a_keyword, string $a_default_value=null)
 
static _lookupObjId(int $ref_id)
 
static lookupOfflineStatus(int $obj_id)
Lookup offline status using objectDataCache. 
 
static _resetDeletedDate(int $ref_id)
 
static add(ilObject $object)
 
createReference()
creates reference for object 
 
ilAppEventHandler $app_event_handler
 
static _lookupImportId(int $obj_id)
 
static getInstance()
Get the singleton instance of this ilECSImportManager. 
 
static lookupTemplateId(int $a_ref_id)
 
static getLongDescriptions(array $obj_ids)
 
checkForParentType(int $a_ref_id, string $a_type, bool $a_exclude_source_check=false)
Check for parent type e.g check if a folder (ref_id 3) is in a parent course obj => checkForParentTyp...
 
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data 
 
cloneMetaData(ilObject $target_obj)
Copy meta data. 
 
create()
note: title, description and type should be set when this function is called 
 
static _lookupTitle(int $obj_id)
 
LOMServices $lom_services
 
static _prepareCloneSelection(array $ref_ids, string $new_type, bool $show_path=true)
Prepare copy wizard object selection. 
 
MDUpdateListener(string $element)
Metadata update listener. 
 
static _lookupLastUpdate(int $obj_id, bool $formatted=false)
 
static _isInTrash(int $ref_id)
 
static getInstance(int $obj_id)
 
cloneDependencies(int $target_id, int $copy_id)
Clone object dependencies. 
 
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory) 
 
static _lookupObjectId(int $ref_id)
 
fetchObject(ilDBStatement $query_result)
 
copyLocalRoles(int $a_source_id, int $a_target_id)
Copy local roles This method creates a copy of all local role. 
 
doMDUpdateListener(string $a_element)
 
static _deleteSettingsOfBlock(int $a_block_id, string $a_block_type)
 
updateOwner()
update owner of object in db 
 
selfOrParentWithRatingEnabled()
 
static deleteByRefId(int $a_ref_id)
 
Class ilObjForumAdministration. 
 
query(string $query)
Run a (read-only) Query on the database. 
 
static _deleteByObjId(int $a_obj_id)
Delete by objekt id. 
 
setOfflineStatus(bool $status)
 
initDefaultRoles()
init default roles settings Purpose of this function is to create a local role folder and local roles...
 
static _lookupDescription(int $obj_id)
 
getSubObjectsRecursively(string $obj_type, bool $include_source_obj=true, bool $add_admin_objects=false)
Get all sub objects by type. 
 
static getAllOwnedRepositoryObjects(int $user_id)
 
ilObjectDefinition $obj_definition
 
const AUTO_RATING_NEW_OBJECTS
 
static _getIdsForTitle(string $title, string $type='', bool $partial_match=false)
 
static lookupTxtById(string $plugin_id, string $lang_var)
 
in(string $field, array $values, bool $negate=false, string $type="")
 
static getActionsByTemplateId(int $a_tpl_id)
Get actions of one template. 
 
putInTree(int $parent_ref_id)
maybe this method should be in tree object!? 
 
ilObjectProperties $object_properties
 
static _cloneValues(int $copy_id, int $a_source_id, int $a_target_id, ?string $a_sub_type=null, ?int $a_source_sub_id=null, ?int $a_target_sub_id=null)
Clone Advanced Meta Data. 
 
A news item can be created by different sources. 
 
string $untranslatedTitle
 
static _lookupCreationDate(int $obj_id)
 
setParentRolePermissions(int $parent_ref_id)
Initialize the permissions of parent roles (local roles of categories, global roles...) This method is overwritten in e.g. 
 
appendCopyInfo(int $target_id, int $copy_id)
Prepend Copy info if object with same name exists in that container. 
 
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins 
 
__construct(Container $dic, ilPlugin $plugin)
 
static shortenTextExtended(string $a_str, int $a_len, bool $a_dots=false, bool $a_next_blank=false, bool $a_keep_extension=false)
 
getOwnerName()
get full name of object owner 
 
buildTitleWithoutCopySuffix(string $copy_suffix, string $copy_n_suffix, string $title)
 
getLongDescription()
get object long description (stored in object_description) 
 
static fixMissingTitles($type, array &$obj_title_map)
Try to fix missing object titles. 
 
getPossibleSubObjects(bool $filter=true)
get all possible sub objects of this type the object can decide which types of sub objects are possib...
 
static _getInstance(int $a_copy_id)
 
isPlugin(string $obj_name)
get RBAC status by type returns true if object type is an (activated) plugin type ...
 
static _lookupOwnerName(int $owner_id)
Lookup owner name for owner id. 
 
Class ilRbacAdmin Core functions for role based access control. 
 
getLastUpdateDate()
Get last update date in YYYY-MM-DD HH-MM-SS format. 
 
ilRbacReview $rbac_review
 
getUntranslatedTitle()
Get untranslated object title WebDAV needs to access the untranslated title of an object...
 
manipulate(string $query)
Run a (write) Query on the database. 
 
static _lookupType(int $id, bool $reference=false)
 
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
 
static _getObjectTypeIdByTitle(string $type, \ilDBInterface $ilDB=null)
 
static getIconForType(string $type)
 
setDescription(string $description)
 
static _lookupDeletedDate(int $ref_id)
 
static _getLastUpdateOfObjects(array $obj_ids)
 
static _deleteByObjId(int $a_obj_id)
 
getPresentationTitle()
get presentation title Normally same as title Overwritten for sessions 
 
static _writeDescription(int $obj_id, string $desc)
write description to db (static)